# Get Flag
Grammar — Gets the current value of the flag at index index for player player
Flags —Native
|Function
Gets the current value of the specified flag index for a player. The flag is a per player boolean array that can be useful to AI scripting.
# Arguments
int
— Playerint
— Index
Returns — bool
native bool AIGetFlag(int player, int index);
# Related
Category: AI Advanced / Utility / Functions
- Is Point In Shrub —
bool
— InShrub - Is Campaign AI —
bool
— AIIsCampaign - Grab Unit —
unit
— AIGrabUnit - Get State —
int
— AIState - Get Flag —
bool
— AIGetFlag - Get Coop Flag —
bool
— AIGetCoopFlag - Unit Has AI Option —
bool
— UnitGetAIOption - Wants To Surrender —
bool
— AIGivingUp - AI Pathing Cost Map —
int
— AIPathingCostMap - AI Pathing Cost Unit —
int
— AIPathingCostUnit - AI Self Reinforce Point —
point
— AISelfReinforceDropPoint
# Examples
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:81
"max", AIGetMaxPeonCount(player, c_townMax)
);
DebugVarBool("e_flagsScouting", AIGetFlag(player, e_flagsScouting));
DebugVarBool("e_flagsTimeout", AIGetFlag(player, e_flagsTimeout));
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:82
);
DebugVarBool("e_flagsScouting", AIGetFlag(player, e_flagsScouting));
DebugVarBool("e_flagsTimeout", AIGetFlag(player, e_flagsTimeout));
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:177
}
if (count >= 6 && AIGetFlag(player, e_flagsTimeout)) {
if (attackState != e_attackState_DropAttack && attackState != e_attackState_DropRetreat) {
AIWaveMerge(player, c_waveMain, c_waveAttack);
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:225
}
if (!AIGetFlag(player, e_flagsDiversion)) {
if (AIWaveUnitCount(w) != 0) {
if (type == c_waveDivert1) {
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:332
// Check global option
if (AIGetFlag(player, e_flagsClearObs) == false) {
return false;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:464
int numMobileTransports;
if (!AIGetFlag(player, e_flagsAllowDropAttack)) {
return false;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:579
AISetAttackState(player, e_attackState_Attack);
}
else if (count >= 15 && AIGetFlag(player, e_flagsTimeout) && AIWaveGetTimeSinceCombat(w) >= 150) {
AISetAttackState(player, e_attackState_Attack);
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:589
AISetAttackState(player, e_attackState_Attack);
}
else if (count >= 20 && AIGetFlag(player, e_flagsTimeout) && AIWaveGetTimeSinceCombat(w) >= 300 - 4*count) {
AISetAttackState(player, e_attackState_Attack);
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:668
if (state == e_attackState_Attack) {
if (AIGetFlag(player, e_flagsAllowRetreat) && !AIGetCoopFlag(player, c_coopWaveAttacker)) {
// retreat logic
time = AIWaveGetTimeInCombat(w);
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:673
eval = AIWaveEvalRatio(w, c_evalRange);
if (eval >= 75 && eval <= 85 && time <= 3) { // when not fighting and only a little weak
if (AIGetFlag(player, e_flagsRunScared)) { // need to add check for ranges & max eval
AISetAttackState(player, e_attackState_Scared);
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:779
AISetAttackState(player, e_attackState_Attack);
}
else if (AIGetFlag(player, e_flagsTimeout) && AIWaveGetTimeSinceCombat(w) >= 600 - 2*count) {
AISetAttackState(player, e_attackState_Attack);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:134
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:177
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:116
// diversion units
if (AIGetFlag(player, e_flagsDiversion)) {
if (type == c_TU_Reaper) {
AIMergeUnit(player, u, AIWaveGet(player, c_waveDivert1));
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:153
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:202
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:162
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:212
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:81
"max", AIGetMaxPeonCount(player, c_townMax)
);
DebugVarBool("e_flagsScouting", AIGetFlag(player, e_flagsScouting));
DebugVarBool("e_flagsTimeout", AIGetFlag(player, e_flagsTimeout));
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:82
);
DebugVarBool("e_flagsScouting", AIGetFlag(player, e_flagsScouting));
DebugVarBool("e_flagsTimeout", AIGetFlag(player, e_flagsTimeout));
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:159
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:202
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:122
// diversion units
if (AIGetFlag(player, e_flagsDiversion)) {
if (type == c_TU_Reaper) {
AIMergeUnit(player, u, AIWaveGet(player, c_waveDivert1));
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:159
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:208
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:168
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:218
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:168
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:211
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:128
// diversion units
if (AIGetFlag(player, e_flagsDiversion)) {
if (type == c_TU_Reaper) {
AIMergeUnit(player, u, AIWaveGet(player, c_waveDivert1));
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:165
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:214
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:174
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:224
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:122
// diversion units
if (AIGetFlag(player, e_flagsDiversion)) {
if (type == c_TU_Reaper) {
AIMergeUnit(player, u, AIWaveGet(player, c_waveDivert1));
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:159
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:208
string prevType;
if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
return c_nullUnit;
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:270
}
if (count >= 6 && AIGetFlag(player, e_flagsTimeout)) {
if (attackState != e_attackState_DropAttack && attackState != e_attackState_DropRetreat) {
AIWaveMerge(player, c_waveMain, c_waveAttack);
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:314
}
if (!AIGetFlag(player, e_flagsDiversion)) {
if (AIWaveUnitCount(w) != 0) {
if (type == c_waveDivert1) {
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:415
// Check global option
if (AIGetFlag(player, e_flagsClearObs) == false) {
return false;
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:554
int numMobileTransports;
if (!AIGetFlag(player, e_flagsAllowDropAttack)) {
return false;
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:668
AISetAttackState(player, e_attackState_Attack);
}
else if (count >= 10 && AIGetFlag(player, e_flagsTimeout) && AIWaveGetTimeSinceCombat(w) >= 120) {
AISetAttackState(player, e_attackState_Attack);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:678
AISetAttackState(player, e_attackState_Attack);
}
else if (count >= 15 && AIGetFlag(player, e_flagsTimeout) && AIWaveGetTimeSinceCombat(w) >= 300 - 5*count) {
AISetAttackState(player, e_attackState_Attack);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:754
if (state == e_attackState_Attack) {
if (AIGetFlag(player, e_flagsAllowRetreat) && !AIGetCoopFlag(player, c_coopWaveAttacker)) {
// retreat logic
time = AIWaveGetTimeInCombat(w);
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:760
if (eval >= 75 && eval <= 85 && time <= 3) { // when not fighting and only a little weak
DebugAI("case1");
if (AIGetFlag(player, e_flagsRunScared)) { // need to add check for ranges & max eval
AISetAttackState(player, e_attackState_Scared);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:875
AISetAttackState(player, e_attackState_Attack);
}
else if (AIGetFlag(player, e_flagsTimeout) && AIWaveGetTimeSinceCombat(w) >= 300-10*count) {
AISetAttackState(player, e_attackState_Attack);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/Orc/Orc.galaxy:557
if (!PlayerBeaconIsSet(player, c_beaconScout) &&
!AIGetFlag(player, e_flagsScouting)) {
// if no scouting beacons are set and we're not ready to scout, don't return a unit
return c_nullUnit;