Flags
From CoDWWModWiki
Contents |
Overview
Call of Duty World at War has a nice flag system to help you with various control and check tasks in your missions. You can use flags in your level to control when parts of your script can get executed or if at all, you can set/clear flags in Radiant or script and check their status to decide what to do, or you can use flags for whatever other tasks you see fit.
Think of flags as variables or notifies with true or false states, but can be changed/checked at any time in script or in Radiant really easily. Flags are more convenient and less likely to result in errors compared to Notifys because flags maintain their status whereas notifies are set off and automatically perish.
Listed below are some common operations and use of flags, you can find more functions in the _utility.GSC script found in raw\maps.
Initiating Flags
You can initialize flags where ever you want in your script, but they must be initialized before you actually try to set/clear/check them in script or in-game.
You initialize them by passing a string into flag_init function:
flag_init( "bunkers_destroyed" );
Setting Flags
Setting flags will switch their value to True.
Script
flag_set( "bunkers_destroyed" );
Trigger
Give a trigger the following Key Value Pairs:
"targetname" "flag_set" "script_flag" "bunkers_destroyed"
When triggered, the flag will be set.
Clearing Flags
Clearing flags will switch their value to False.
Script
flag_clear( "bunkers_destroyed" );
Trigger
Give a trigger the following Key Value Pairs:
"targetname" "flag_clear" "script_flag" "bunkers_destroyed"
When triggered, the flag will be clear.
Waiting For Flags
Now that you understand how flags work, you can now use them to control or do checks in your script. Below are some examples.
Looping
while( !flag( "bunkers_destroyed" ) )
{
// Keep looping while flag is cleared / False
wait( RandomIntRange( 15,30 ) );
}
Wait Till Flag
// Do stuff // Wait for flag to be set / True flag_wait( "bunkers_destroyed" ); // Do more stuff
Wait Till Either Flags
// Do stuff // Wait for either flag to be set / True flag_wait_either( "bunkers_destroyed", "bunkers_on_fire" ); // Do more stuff
Wait Till Any Flags
// Do stuff // Wait for any of the flags to be set / True flag_wait_any( "bunkers_destroyed", "bunkers_on_fire", "bunkers_leveled", "bunkers_artillery_hit") // Do more stuff
Wait Till All Flags
// Do stuff // Wait for all flags to be set / True flag_wait_any( "bunkers_destroyed", "bunkers_on_fire", "bunkers_leveled", "bunkers_artillery_hit") // Do more stuff
Wait Till Flag Or Timer
// Do stuff // Wait for flag to be set or timer to run out flag_wait_or_timeout( "bunkers_destroyed", 60 ) // Do more stuff

