Fixed
Revived stack doesn't trigger Regeneration phase (00446B50)
As the title, if a stack is killed and revived (with Resurrection spell) in the same turn, this will completely skip its regeneration phase (00446B50), which potentially leads to an infinite loop for AI player if the killed stack has defended last turn and not yet acted this turn.
This can be a bug of the original H3. But I haven't got a chance to test yet.
Download save game and video for testing
Tested with only ERA.
game bug fixes extended.dll is not related.
Steps to reproduce with this save game:
- pretty much just do the same as the video shows
- The key point is, must kill a stack that has been defended last turn and not acted this turn. When AI revives the killed stack, it would try to defend (because the stack can do nothing else due to the gate getting blocked), and this leads to an infinite loop due to the stack is already defending (inherited from the last turn, meaning 00446B50 is not executed).
Quick script to fix:
- !?FU(OnBattleStackObtainsTurn);
- !!BMi^battle_current_stack^:F?(flags:y);
- !!VR(isDefending:y):S(flags) &(MON_FLAG_DEFENDING);
- !!if&(isDefending);
- !!BMi^battle_current_stack^:Z?(stackStruct:y);
- !!UN:C(stackStruct)/1244/4/?(bonusDefense:y);
- !!UN:C(stackStruct)/204/4/d-(bonusDefense:y);
- !!VR(flags):&4160749567;
- !!UN:C(stackStruct)/132/4/(flags);
- !!en;
Just ensure whenever it's on a stack's turn, the defending status is correctly removed.