2.2 Start of battle ATB initial values - jmcx532/FFX-2-TurnBased GitHub Wiki
BtlATBInitHandler.cs
This module handles start of battle triggers and manages cases where 2 or more characters may end up with a turn due to Pre-emptive / First Strike.
h_MsCalcFirstAttack - start of battle triggers
At the start of battle, the game will always run MsCalcFirstAttack(). This function checks the Initial Battle State field - Normal / Preemptive / Ambush - and proceeds accordingly.
This function is hooked in order to:
- Set YRP's number of targets hit by last attack flag to 1. [see note 1]
- Update YRP's Chr Poison Damage percentage. [see note 2]
- Re-enable Time Trip [see note 3]
h_MsChrAtbInit - First Strike handling
This function normally checks a character's First Strike auto-ability flag, and sets their ATB remaining to 0.
Instead, I set the value to be their Character ID:
- Yuna: 0
- Rikku: 1
- Paine: 2
This stops them from all being ready to act at once, which stops the player from being able to switch between their battle windows and choose who to attack with.
h_MsChrAtbReset - update ATB values based on Ambush vs Pre-emptive strike
On Ambush or Pre-emptive strike, character's ATB time remaining values are set to (Character ID + 3). This again stops YRP from all being ready to act at once, which stops the player from being able to switch between their battle windows and choose who to attack with. This also accounts for First Strike, which is given priority over Pre-emptive Strikes.
Notes
1. This flag is monitored by the Wait Flag Writer for counterattack handling - it needs to be initialized here to prevent a softlock.
2. It can't be done in kernel/rom.bin as it would also apply to enemies.
3. Time Trip can only be used once per battle in this mod.