Download "CasterEXP6B.zip" to try it.
If you intend to participate in the "Earth Lore Sprite Analysis", I suggest using this version as it will be in the next update (unless someone finds a serious flaw).
So...what does this actually do?
-There are no numerical limits on primary or secondary monsters anymore. If you see "many cockatrices" and don't scout, you risk losing all your sprites because there might be 7-9 of them which is likely too much to handle. Note that this was already the case for secondary monsters, and having this outcome appear without a secondary monster is fairly uncommon. 80%+ of the encounter zones still have two types of monsters, albeit it might be a 7-2 or 8-1 setup.
-The monster type is picked randomly with an equal chance for each in both slots. So the chance no longer depends on costs and pre-rolled "intended number of monsters" values, nor the leftover fractional points after the first monster placed. Of course if the target budget is impossible to meet using the selected two monster types, it gets rerolled so the actual chances are not equal, but it won't depend on something as unrelated as the cost of other monsters not being picked. The greatest difference here is that having two expensive monsters appear together will be more likely (albeit places with enough budget for that are uncommon so don't expect it often -still having it with mid cost monsters will be a thing, the old code didn't generate things like 4 gorgons+5 stone giants ever).
-Always the more expensive monster is in the first slot - there is no such outcome when the primary monster is weaker but more numerous like 6 Unicorns with a single Archangel.
-Except for invisible monsters : These always go to the secondary slot even if they are the stronger one. Don't expect to go into a node with "Phantom Warriors" safely without properly scouting it first - Air Elementals might be lurking inside.
-As monster costs no longer have an unwanted influence on placing other monsters, they can be adjusted freely to match their actually difficulty - all costs have been revised and changed, some significantly (Phantom Beast for example is down to 100 points each). You can run "magicedt.exe" to see the numbers.
-If the primary monster is Great Wyrm, the secondary monster cannot be an Earth Elemental, Cockatrice, Great Lizard or War Bears.
-If there is only one type of monster, it cannot be Great Wyrm or Earth Elemental. Wyrms are very high value and too easy to defeat with flying ranged units (not just sprites, but anything and their value is relevant even in the midgame), while Earth Elementals are so ridiculously slow that any ranged unit can kill them easily while they still provide fairly good treasure.
If you intend to participate in the "Earth Lore Sprite Analysis", I suggest using this version as it will be in the next update (unless someone finds a serious flaw).
So...what does this actually do?
-There are no numerical limits on primary or secondary monsters anymore. If you see "many cockatrices" and don't scout, you risk losing all your sprites because there might be 7-9 of them which is likely too much to handle. Note that this was already the case for secondary monsters, and having this outcome appear without a secondary monster is fairly uncommon. 80%+ of the encounter zones still have two types of monsters, albeit it might be a 7-2 or 8-1 setup.
-The monster type is picked randomly with an equal chance for each in both slots. So the chance no longer depends on costs and pre-rolled "intended number of monsters" values, nor the leftover fractional points after the first monster placed. Of course if the target budget is impossible to meet using the selected two monster types, it gets rerolled so the actual chances are not equal, but it won't depend on something as unrelated as the cost of other monsters not being picked. The greatest difference here is that having two expensive monsters appear together will be more likely (albeit places with enough budget for that are uncommon so don't expect it often -still having it with mid cost monsters will be a thing, the old code didn't generate things like 4 gorgons+5 stone giants ever).
-Always the more expensive monster is in the first slot - there is no such outcome when the primary monster is weaker but more numerous like 6 Unicorns with a single Archangel.
-Except for invisible monsters : These always go to the secondary slot even if they are the stronger one. Don't expect to go into a node with "Phantom Warriors" safely without properly scouting it first - Air Elementals might be lurking inside.
-As monster costs no longer have an unwanted influence on placing other monsters, they can be adjusted freely to match their actually difficulty - all costs have been revised and changed, some significantly (Phantom Beast for example is down to 100 points each). You can run "magicedt.exe" to see the numbers.
-If the primary monster is Great Wyrm, the secondary monster cannot be an Earth Elemental, Cockatrice, Great Lizard or War Bears.
-If there is only one type of monster, it cannot be Great Wyrm or Earth Elemental. Wyrms are very high value and too easy to defeat with flying ranged units (not just sprites, but anything and their value is relevant even in the midgame), while Earth Elementals are so ridiculously slow that any ranged unit can kill them easily while they still provide fairly good treasure.
Code:
jmp start
RND:
push ax
db 9Ah, 0D4h,00,0B0h,00
pop dx
retn
getunit:
push ax
mov bx, 24h
imul bx
mov bx,ax
pop ax
retn
getrandommonster:
invalid:
mov ax,42
call rnd
add ax,154
; Random fantastic unit
call getunit
cmp byte ptr [bx+220h], 0 ; Floating Islands cannot be added
jnz invalid
push ax
mov al, [bx+219h]
cbw
cmp ax,[bp-4] ; Check for the correct realm
pop ax
jnz invalid
retn
swap:
mov ax,[bp-8]
mov dx,[bp-0Ah]
mov [bp-8],dx
mov [bp-0Ah],ax
retn;
start:
push di
push si
mov word ptr [bp-2],2 ; allowed difference 2%
mov word ptr [bp-0Eh],0
reroll:
call getrandommonster
mov [bp-8],ax
rerollsec:
call getrandommonster
cmp ax,[bp-8] ; Primary and secondary must be different
jz reroll
mov [bp-0Ah],ax
call getunit
mov di,bx
mov ax,[bp-8]
call getunit
cmp [bp-8],167 ; Primary monster invisible? Always secondary!
jz invisible
cmp [bp-8],194 ; Primary monster invisible? Always secondary!
jz invisible
mov ax,[bx+216h] ; Primary monster cost
cmp ax,[di+216h] ; Secondary monster cost
jge safe
invisible:
call swap
safe:
; Selected primary and secondary monster
cmp word ptr [bp-8],189
jnz notwyrm
; Primary monster is great wyrm
mov ax,[bp-0Ah]
cmp ax,179 ; War Bears -> Reroll
jz rerollsec
cmp ax,187 ; Earth Elemental
jz rerollsec
cmp ax,181 ; Cockactirces
jz rerollsec
cmp ax,182 ; Great Lizard
jz rerollsec
notwyrm:
mov word ptr [bp-0Ch],0
rerollamount:
mov ax,10
call RND
dec ax ; 0-9 primary monsters
mov di,ax ; Nof primary monsters
mov ax,9
sub ax,di
inc ax
call RND
dec ax ; Can have 0 of these
mov si,ax ; Nof secondary monsters
mov ax,[bp-8]
call getunit
mov ax,[bx+216h]
imul di
push ax
mov ax,[bp-0Ah]
call getunit
mov ax,[bx+216h]
imul si
pop cx
add cx,ax ; Total cost of rolled monsters
mov ax,[bp+12h]
mov bx,100
add bx,[bp-2]
imul bx
mov bx,100
idiv bx
cmp ax,cx
jl bad
mov ax,[bp+12h]
mov bx,100
sub bx,[bp-2]
imul bx
mov bx,100
idiv bx
cmp ax,cx
jg bad
jmp done
bad:
inc word ptr [bp-0Ch]
cmp word ptr [bp-0Ch],50
jle rerollamount
inc word ptr [bp-0Eh]
cmp word ptr [bp-0Eh],50
jle reroll
add word ptr [bp-2],2
jmp reroll
done:
mov cx,si
pop si
or di,di
jnz ok1
mov di,cx ; Zero primary monster : move up secondary to primary slot
mov ax,[bp-0Ah]
mov [bp-8],ax
xor cx,cx
ok1:
or cx,cx ; no secondary monster and Earth Elemental or Wyrm? Reroll
jnz ok3
cmp word ptr [bp-8],187
jz redo
cmp word ptr [bp-8],189
jz redo
jmp ok3
redo:
push si
jmp bad
ok3:
mov ax,si
mov dx, 18h
imul dx
les bx, [089D6h] ; Dungeons
add bx, ax
or di,di
jnz ok2
; zero of both monsters
mov byte ptr es:[bx+5],0
mov byte ptr es:[bx+6],0
jmp nosecond
ok2:
mov al,[bp-8]
mov es:[bx+5], al
mov ax,di
mov es:[bx+6],al
or cx,cx
jnz secondaryexists
nosecond:
mov byte ptr es:[bx+7],0
mov byte ptr es:[bx+8],0
jmp over
secondaryexists:
mov al,[bp-0Ah]
mov es:[bx+7],al
mov es:[bx+8],cl
over:
pop di