As you may or may not know, I've been working on remastering of the AI scripts in FF7 using PrC and an assembler that I coded myself. Normal enemies only get redone if they're too stupid/easy/pointless, or if they're glitchy, and bosses get anything from a minor tweak to a complete overhaul depending on their initial in-game difficulties (I want to make the game harder, but not IMPOSSIBLY hard--I'm trying to make it just barely doable on a lowish level playthrough).
So far everything's been smooth, until I tried to start using new concepts...
What I'm stuck on is Rude's main script for the Gelnika battle. This is what I've got (what PrC disassembly gives me):
LocalVar:0020 <- RandomBit(AllyMask)
If ( ( ( (LocalVar:0020.HP < LocalVar:0020.MHP / 2) And Random MOD 2) And (Self.MP >= 64) ) )
{
TargetMask <- LocalVar:0020
Perform("Curaga"[0002], EnemyAttack)
}
ElseIf (Random MOD 2)
{
LocalVar:0000 <- RandomBit(AllActiveOpponentMask)
// EDEF(LocalVar:0000, 8 )
If ( (TargetMask.GreatestElementalDamage <= 4) Or (TargetMask.GreatestElementalDamage == 255) )
{
Perform("Ground Punch 2"[0102], EnemyAttack)
}
// EDEF(LocalVar:0000, 1 )
ElseIf ( ( (TargetMask.GreatestElementalDamage < 4) Or (TargetMask.GreatestElementalDamage == 255) ) And (Self.MP >= 52) )
{
Perform("Firaga"[001D], EnemyAttack)
}
// EDEF(LocalVar:0000, 2 )
ElseIf ( ( (TargetMask.GreatestElementalDamage < 4) Or (TargetMask.GreatestElementalDamage == 255) ) And (Self.MP >= 52) )
{
Perform("Blizzaga"[0020], EnemyAttack)
}
// EDEF(LocalVar:0000, 4 )
ElseIf ( ( (TargetMask.GreatestElementalDamage < 4) Or (TargetMask.GreatestElementalDamage == 255) ) And (Self.MP >= 52) )
{
Perform("Thundaga"[0023], EnemyAttack)
}
Else
{
Perform("Shoulder Attack"[0374], EnemyAttack)
}
}
Else
{
TargetMask <- AllActiveOpponentMask
Perform("Grand Punch 2"[0165], EnemyAttack)
}
SCRIPT END
This is the assembly code, which is more informative
;Rude Main Script
PUSH11 0020
PSHA01 ALLYMASK
RBYT ; Check whether to heal either yourself or Reno
STRA
PSHA01 0020
PSHA02 HP
MASK
PSHA01 0020
PSHA02 MHP
MASK
PUSH 02
DIV
LSTN
RWRD
PUSH 2
MOD
AND
PSHA01 SELF
PSHA02 MP
MASK
PUSH #64
GEQU
AND
JMP0 SINGATK
PUSH11 TARGETMASK
PSHA01 0020
STRA
PUSH 20
PUSH 02 ; Curaga
ATTK
JUMP FIN
SINGATK RWRD
PUSH 02
MOD
JMP0 ALLATK
PUSH11 0000
PSHA01 ALLACTIVEOPPONENTMASK
RBYT
STRA
PSHA01 0000
PUSH 8 ; Earth bit
EDEF ; Load GreatestElementalDamage(Earth)
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH 4 ; 1/2 damage
LEQU ; or better
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH FF ; gotta check nothing, too
EQU
OR
JMP0 TRYFIRE
PUSH 20
PUSH 102 ; Ground Punch 2, earth damage on one opponent
ATTK
JUMP FIN
TRYFIRE PSHA01 0000
PUSH 1 ; Fire bit
EDEF ; Load GreatestElementalDamage(Fire)
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH 4 ; 1/2 damage
LSTN ; ...isn't good enough
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH FF ; gotta check nothing, too
EQU
OR
PSHA01 SELF
PSHA02 MP
MASK
PUSH #52
GEQU
AND
JMP0 TRYICE
PUSH 20
PUSH 1D ; Firaga
ATTK
JUMP FIN
TRYICE PSHA01 0000
PUSH 2 ; Ice bit
EDEF ; Load GreatestElementalDamage(Ice)
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH 4 ; 1/2 damage
LSTN ; ...isn't good enough
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH FF ; gotta check nothing, too
EQU
OR
PSHA01 SELF
PSHA02 MP
MASK
PUSH #52
GEQU
AND
JMP0 TRYBOLT
PUSH 20
PUSH 20 ; Blizzaga
ATTK
JUMP FIN
TRYBOLT PSHA01 0000
PUSH 4 ; Bolt bit
EDEF ; Load GreatestElementalDamage(Bolt)
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH 4 ; 1/2 damage
LSTN ; ...isn't good enough
PSHA01 TARGETMASK
PSHA02 GREATESTELEMENTALDAMAGE
MASK
PUSH FF ; gotta check nothing, too
EQU
OR
PSHA01 SELF
PSHA02 MP
MASK
PUSH #52
GEQU
AND
JMP0 SHOULDER
PUSH 20
PUSH 23 ; Thundaga
ATTK
JUMP FIN
SHOULDER PUSH 20
PUSH 0374 ; Shoulder Attack, non-elemental phys damage
ATTK
JUMP FIN
ALLATK PUSH11 TARGETMASK
PSHA01 ALLACTIVEOPPONENTMASK
STRA
PUSH 20
PUSH 0165 ; Grand Punch 2, hits everyone
ATTK
FIN END
What this SHOULD do is determine if earth type magic is effective against a chosen opponent, then if it isn't, move on to other elements and finally, default to a physical attack if all elements are a no-go. Instead, Rude constantly defaults to the PHYSICAL attack regardless of elemental immunity (meaning it thinks every one is resistant to every element, which they're not).
Any input/inquiries would be gladly appreciated. Thanks.
Edit: I've switched my code over to using GreatestElementalDamage in conjunction with EDEF, and I got my values straight from the wiki, something's not right here...