Battles involving Ghosts don't show correct casualties
When Ghosts drain life from their victims, both the initial amount (BM:B) and current amount (BM:N) are updated. This leads to the problem that the casualties number can be wrong/confusing.
For example:
- before battle, there are 111 ghosts
- During the battle, 3 ghosts were killed, 11 ghosts were revived after killing some gremlins, and then 3 more ghosts were killed
- After this, I ended the battle with my commander killing all the remaining enemies.
- Here we see the problem. The battle result shows 3 ghosts were killed, while the total number is now 116 (5 more than its initial 111).
This is because BM:B for ghosts weren't updated when they were killed (BM:B updates only when Ghosts attack). Thus the final BM:N minus BM:B value is 3, and then the baltte results show 3 casualties.
My suggestion:
BM:B value should be saved before battle and restored right before the battle result is shown. For example, I would do this.
- !!SN:E(setHook)/1/4681149/(arch_OnBeforeBattleResult);
- !?FU(OnSetupBattlefield)&(ERM_FLAG_IS_HUMAN);
- !!SN:Mi^arch_soulAttractersList^;
- !!FU(NewIntArray):P42/?i^arch_soulAttractersList^/(M_TEMP);
- !!re i/(BATTLE_STACK_FIRST)/(BATTLE_STACK_LAST);
- !!BMi:N?(num:y);
- !!if&(num)>0;
- !!BMi:T?(type:y);
- !!FU(arch_CheckIfMonAttractsDeadSouls):P(type)/?(result:y);
- !!SN&(result):Mi^arch_soulAttractersList^/i/(num);
- !!en;
- !!en;
- !!SN:Mi^arch_soulAttractersList^/?(size:y);
- !!if&(size)=0;
- !!SN:Mi^arch_soulAttractersList^;
- !!VRi^arch_soulAttractersList^:S0;
- !!en;
- !?FU(arch_OnBeforeBattleResult)&i^arch_soulAttractersList^/(ERM_FLAG_IS_HUMAN);
- !!re i/(BATTLE_STACK_FIRST)/(BATTLE_STACK_LAST);
- !!BMi:N?(num:y);
- !!if&(num)>0;
- !!BMi:T?(type:y);
- ;
- !!FU(arch_CheckIfMonAttractsDeadSouls):P(type)/?(result:y);
- !!if&(result);
- !!SN:Mi^arch_soulAttractersList^/i/?(initNum:y);
- ;
- !!BMi:B(initNum);
- !!en;
- !!en;
- !!en;
- !!SN:Mi^arch_soulAttractersList^;
- !!VRi^arch_soulAttractersList^:S0;
- !?FU(arch_CheckIfMonAttractsDeadSouls);
- !#VA(mon:x) (result:x);
- !!VR(result):S(FALSE);
- !!VR(result)&(mon)=(MON_GHOST):S(TRUE);