Yep, it sets its physical immune flag based on the performed actions action index (turns it off for 3, which is limit) which tells me that global variables like 2120, 2050, etc are set prior to pre-turn scripts.
My issue is that in order to half/double (or otherwise scale) damage taken based on the element of the previous action, I actually need to double or half the attackers level instead of the targets, diamond mutates his own flags.
So I need some way to get the index of the actor who used the attack during pre-turn which is being executed, if that was the case I could just do:
Pre-Turn
If self.soaked_bit_on{
If 2120 bitAnd 8192 { ## was bolt attack check
If not already halved (will store this var in my global clock actor so its the same for all actors, and keep multiple actors from messing with it){
temp = self.previous_attacker.level
self.previous_attacker.level = temp/2
}
}
}
I can then unset the already_halved far and re-assign the attackers correct level in the counter script to achieve the desired effect.
EDIT: Actually, that will cause damage to be doubled for all targets if even one target is soaked, in the event that an attack hits more than one target =(
Is there a pointer table in the exe to the various formulas with actor/target stats in specific registers/fixed addresses for the jump, so that one could find an empty block and create a wrapper around base damage calculation which still performed the calculation according to the pointer, but did something like...
If target level = 255, bit-shift right the base_damage
if target level = 254, bit-shift left the base_damage.
EDIT: I've disassembled the exe, and with help from NFTC1, found the relevant routine. I have successful redirected the function in the exe to a (non functioning) custom function at run-time, so The damage formulas reference a context pointer for most stats/checks, so they have more or less global access to battle state making this much easier. I'm now confident I can implement this as described above with a bit more work tracing the formula calls to make sure my custom functions are referencing the arguments correctly.