Well yes, Ozma has some checkings in his "loop" function, but that's a bit different. The "loop" function really often serves as a secondary "Init" function that only init things that needs player's and enemy's datas to be loaded.
The game can't check party's level too soon in the fight, because the party is not loaded yet ("SV_PlayerTeam" and "SV_EnemyTeam" are 0 before they are loaded). Hence the checks for party's level is delayed until everything is loaded.
However, besides the fact you can't check for party's level or status or whatever too soon, you can decide to put those checks wherever you want. Here are some possibilities :
1) Put the check in the ATB function : I'd say that's the default choice. When Kuja's ATB bar is full, he checks if it is relevant to cast Reflect on himself. Devs tended to use an additionnal variables here, like "CuragaTarget" (see one of Necron's dummy for this example, but there are a lot of them, starting with Ozma's LV spells target which use a slight variation of that system).
However, nothing prevents you to do the check in the "set SV_Target" line :
Code: [Select]
Code:
case +2: if (#(SV_PlayerTeam[MODEL_TYPE] ==$ 2)) { set #( SV_Target = SV_PlayerTeam ) } else { set #( SV_Target = 0 ) } break
2) Put it in the "loop" function, in the initializing part of the function. That's what Ozma does for the checks of the party's level. Since those lvls won't change during the fight, you can perform the check once and keep the result all over the fight. That's a good way to do it for things like lvl, model type or auto-status, but that's kinda irrelevant for current statuses, HP and such. Note that you always need at least an additionnal variable here for storing the result, and maybe another one if there is no "initializing part" of the function (that's not so common though). It could look like this :
Code: [Select]
Code:
if ( !initflag ) { set initflag = 1 while ( !( GetBattleLoadState & 16 ) ) { Wait( 1 ) set VAR_GenUInt8_206 = GetRandom } // you can do it with a boolean like this : set myreflectflag = (#(SV_PlayerTeam[MODEL_TYPE] ==$ 2)) // or, more like what devs usually did : if (#(SV_PlayerTeam[MODEL_TYPE] ==$ 2)) { set myreflecttarget = SV_FunctionEnemy } else { set myreflecttarget = 0 } while ( GetBattleState != 4 ) { Wait( 1 ) } }
Then, in the ATB function (or Counter function if you want to use Reflect as a counter), you use "myreflecttarget" as your target when casting Reflect, or check the "myreflectflag".
3) Put it at the top-level of the "loop" function (out of any "if" block). This way you can perform the check every frame and add the ability to cancel the casting if it's not relevant anymore at that point. That's more complicated and I won't give an example here, but that's a system used by Black Waltz 2 or Steiner, for instance : if their target dies before the attack is performed, they cancel it and choose another valid (non-Dagger) target. That way they don't take the risk to redirect their attack on Dagger.
I'll make a small update soon. I'll fix that bug with the World Map and improve a bit script readability. I'll also join a file for the naming of variables in all the AI scripts.