16 — Event scripts: events and actions¶
Every built-in event a script can wait for and every action it can take. The language around them is in chapter 15.
Contents
- Events
- Relations between factions: GlobalWar · NuclearAttack · War_Started · Ceasefire · Alliance_Formed · Surrendered
- Technology and the build queue: Researched · Tech_Available · Queued_Tech · Queued_Unit · Queued_Missile
- Combat: Attacked / Damaged · Destroyed … OF · Destroyed · Destroyed INACTIVE · Casualties · Visible · Launched · Exploded
- Hosting, orders and deployment: Launched Hosted · Boarded · Orders Completed · Inactive · Deployed
- Occupation, regions and population: Besieged · Occupied · Deoccupied · Region_Occupied · Region_Invaded · Region_Liberated · Region_Destroyed · Population
- Missions and the end of the game: Mission · Game_Finished
- Timers: TICK · TIME
- Custom events
- Other event keywords
- Actions
- Flow and blocks: Dummy · Block call · Execute · Throw · Assignments and function calls
- AI and attack control: Suspend / Resume · AutoAttack · AttackFaction · LimitedAttack · AttackUnit · StopAttack · GlobalAttack · BlockAttack / AllowAttack · BlockInvasion / AllowInvasion · BlockHomelandAttack / AllowHomelandAttack · Invasion · Defend
- Unit orders: Move · Attack · Launch · Board · Follow · Weapon_Use · Weapon_Switch · Delete Orders · Make Visible
- Missions and UI: Mission · Show / Hide Population · Message · SetGameSpeed
- Diplomacy and war: Declare War · Create Alliance · Ceasefire With · Peace Treaty With · Leave Alliance · Surrender
- Production and weapons: Build · Enable / Disable Missiles
- Sets: Select · Clear
Events¶
The game throws the built-in events below. Some are faction-specific: only one faction's script receives them. Others are common: every active faction's script receives them. Parameters link to their descriptions in Event parameters; events combine as described in Event combination.
Relations between factions¶
Deals reach the scripts through these events only: a deal that starts a war, ends one or forms an alliance throws the event below. Other deal items (a peace treaty between factions not at war, contributions, aid, technology, intelligence, promises, sanctions, threats) throw no event.
GlobalWar¶
Syntax: GlobalWar
Sent to: faction-specific.
Thrown when the AI playing the faction decides on an all-out nuclear attack. It is thrown again whenever the AI reaches that decision anew, so with ON EACH it repeats. The shipped scripts also use a custom event named "Global War", which is a different thing.
on GlobalWar throw "Global War" globally
NuclearAttack¶
Syntax: NuclearAttack [ON race_or_region_parm] [BY race_parm]
Sent to: common.
Thrown when a faction's land is attacked by a weapon whose explosion has TriggerResponse = Yes. It happens after the explosion, or when a missile with a non-zero production cost first becomes visible coming at that land. ON is the land's owner or the region, BY the attacker. A strike whose author stays hidden from the victim doesn't throw it.
Thrown once per attacker and victim: later attacks by the same faction don't throw it again while the two are at war. To react to every nuclear explosion, use Exploded.
on NuclearAttack ON ANYONE ELSE BY ME throw "We struck first" globally
War_Started¶
Syntax: War_Started [(BETWEEN | FOR) race_parm [AND race_parm]]
Sent to: common.
Thrown when a war starts between two factions, also when an alliance's mutual defence pulls a faction in. Only one event is thrown per war. If "US" and "USSR" start a war, a trigger on War_Started BETWEEN "US" AND "USSR" and one on War_Started BETWEEN "USSR" AND "US" both fire, so the order of the names doesn't matter and ON EACH is safe. FOR "US" is any war of that faction.
An AND right after the first faction always belongs to the event. To combine with another event, use parentheses: (War_Started FOR ME) AND "Phase 2".
ON War_Started BETWEEN ME AND "Neutral" Mission "No War" fail
Ceasefire¶
Syntax: Ceasefire [(BETWEEN | FOR) race_parm [AND race_parm]]
Sent to: common.
Thrown when a war between two factions ends. A peace treaty between factions not at war doesn't throw it. As with War_Started, one event is thrown per pair and matches either order.
on Ceasefire BETWEEN ME AND PlayerID Mission "Truce" success
Alliance_Formed¶
Syntax: Alliance_Formed [(BETWEEN | FOR) race_parm [AND race_parm]]
Sent to: common.
Thrown when two factions form an alliance or partnership. One event per pair; it matches either order.
on Alliance_Formed BETWEEN "China" AND "North Korea" throw "Bloc formed" globally
Surrendered¶
Syntax: Surrendered race_parm
Sent to: common.
Thrown when a faction surrenders.
ON Surrendered "United States" Mission "United States" Success
on surrendered "Revolutionary Communists" AND surrendered "Neutral Communists" MISSION "KeepTerritories" FAIL
Technology and the build queue¶
Researched¶
Syntax: Researched (string_expression | ANYTHING) [BY race_parm]
Sent to: common.
Thrown when a faction gets the technology given by string_expression, or any technology with ANYTHING. Without BY, only our own faction's research matches; use BY ANYONE for every faction. A name given by an expression must match the technology's ID in exact letter case. For what a faction has learned about others, use Tech_Available.
On the game's first tick, scripts of factions the AI plays also receive it for every technology already available to any active faction, so on Researched "X" BY ANYONE fires at once there if someone starts with X.
ON Researched "Weapon_Modernization" BY "Soviet Union" SovietsModernized()
Tech_Available¶
Syntax: Tech_Available (string_expression | ANYTHING) [BY race_parm]
Sent to: faction-specific (the faction that learns about it).
Thrown when the faction gets a technology itself, and when it gets reliable information that another faction has one. As with Researched, without BY only our own faction matches: use BY ANYONE ELSE to hear about the others.
On the game's first tick, scripts of factions the AI plays also receive it for what they already know about other factions.
on Tech_Available "Tactical_nukes" BY ANYONE ELSE throw "Enemy has tactical nukes" globally
Queued_Tech¶
Syntax: Queued_Tech (string_expression | ANYTHING) [BY race_parm]
Sent to: faction-specific (the faction that queues the technology).
Thrown when a human player adds a technology that wasn't in the research queue. AI factions never throw it. Without BY, our own faction is assumed.
on Queued_Tech "Chemical_Weapons" StdMessage(7710)
Queued_Unit¶
Syntax: Queued_Unit (ANYTHING | ANY {class [, class]+} | [ANY] "unit_type" | [ANY] expression) [BY race_parm]
Sent to: faction-specific (the faction that queues the unit).
Thrown when a human player adds a unit to the construction queue in the Build screen, once for every unit added: adding five at once throws five events. Units queued automatically (refilling hangars, AI production) don't throw it. Missiles have their own event, Queued_Missile.
"unit_type": a unit type ID. A missile's ID here stops the loading.ANY {class [, class]+}: unit classes, as in unit_parm.- expression: a string, or a set of strings, compared with the unit type ID.
- An embedded variable after the unit gives the unit type ID (
string).
on Queued_Unit "Army_Base" StdMessage(7712)
on each Queued_Unit ANY {Naval, Subwater} ->(string T) CheckNavalBuild(T)
Queued_Missile¶
Syntax: Queued_Missile missile_type_parm [BY race_parm]
Sent to: faction-specific (the faction that queues the missile).
Thrown when a human player adds a missile to the construction queue in the Build screen, once for every missile added. All missile_type_parm forms work: ANYTHING, NUKE, ANY {CHEM, BIO}, GENEVA "name", AI_CATEGORY "name", a missile type ID or an expression. Missiles queued automatically (re-arming after a launch, refilling storage, building missiles for a selected unit, AI production) don't throw it.
on Queued_Missile NUKE throw "Player builds nukes" globally
on each Queued_Missile GENEVA "Chemical" ->(string M) WarnAboutChemicals(M)
Combat¶
Attacked / Damaged¶
Syntax: Attacked unit_parm [BY missile_type_parm] [ATTACKER race_parm], or the same with Damaged
Sent to: the unit's owner only (my unit was attacked).
The two names are the same event: a unit was damaged by an explosion. To get the attacking unit, convert the missile parameter to a unit:
on attacked anything ->(unit Victim) by {"Small Arms", "Demolition Charge"} ->(unit Attacker) CheckPair(Victim, Attacker)
Destroyed … OF (their unit, destroyed by us)¶
Syntax: Destroyed unit_parm OF race_parm [BY missile_type_parm]
Sent to: the faction that destroyed the unit.
Thrown when a unit of another faction is destroyed by our faction. OF names the victim's owner; the word turns this into the other event, so Destroyed X OF ME means we destroyed our own unit. The attacking unit is available by converting the missile parameter to a unit.
In both Destroyed events, BY takes every missile_type_parm form, the classes (NUKE, CHEM and so on) too. A unit destroyed with no weapon involved matches only BY ANYTHING or no BY at all.
on Destroyed any "Spec_Ops_Team" OF Enemy CountKill()
Destroyed (our unit)¶
Syntax: Destroyed unit_parm [BY missile_type_parm] [ATTACKER race_parm]
Sent to: the unit's owner only.
Thrown when one of our units is destroyed. The attacking unit is available by converting the missile parameter to a unit.
on Destroyed any "Spec_Ops_Team" SpawnNew()
Destroyed INACTIVE¶
Syntax: Destroyed INACTIVE unit_parm [BY missile_type_parm] [ATTACKER race_parm]
Sent to: the unit's owner only.
The same as Destroyed, but for our non-active units, that is, units hosted inside a unit that is destroyed. A plain Destroyed doesn't fire for them. The OF form isn't allowed here.
on Destroyed inactive any "Spec_Ops_Team" SpawnNew()
Casualties¶
Syntax: Casualties unit_parm [KILLED] [ATTACKER race_parm]
Sent to: the city's owner only.
Thrown when our city takes casualties (more than 0 killed). KILLED gives the number killed through an int embedded variable:
on casualties anything ->(unit ThisCity) KILLED ->(int NumKilled) CheckCity(ThisCity, NumKilled)
Visible¶
Syntax: Visible unit_parm [OF race_parm] [BY unit_parm]
Sent to: the faction that detected the unit, when the AI plays it.
Thrown when a unit becomes visible to the faction, and when a launcher gives itself away by its shot. OF is the unit's owner, BY the unit that saw it. A faction played by a human never receives it, so keep these triggers under FOR AI.
on each visible any {Ground, Naval} ->(unit Check) of PlayerID CheckIfCrossedBorder(Check)
Launched¶
Syntax: Launched missile_type_parm [AT unit_parm] [TARGET race_or_region_parm]
Sent to: the launcher's owner.
Thrown when one of our units launches a missile. AT is the target unit; TARGET is the owner of the target or of the target point, or the region it stands in. Warheads released by a missile don't throw it.
on Launched geneva "Chemical" throw "Authorise chem" globally
Exploded¶
Syntax: Exploded missile_type_parm [IN race_or_region_parm] [BY race_parm]
Sent to: every faction that can see the explosion.
Thrown when a missile explodes. IN is the owner of the land under it, or the region; BY is the faction that fired.
ON EXPLODED NUKE IN ME BY ENEMY StartGlobalWar()
ON each exploded nuke ->(string MType) by anyone ->(int WRace) CheckForGlobalWar(MType, WRace)
Hosting, orders and deployment¶
Launched Hosted¶
Syntax: Launched Hosted unit_parm [BY unit_parm] [OF race_parm]. Launched_Hosted is the same event.
Sent to: the host's owner.
Thrown when one of our units launches a hosted unit. The first parameter is the launched unit, BY the host, OF the host's owner.
on each Launched Hosted ANY "Spec_Ops_Team" ->(unit ThisSpecOps) OF ME RouteSpecOps(ThisSpecOps)
Boarded¶
Syntax: Boarded unit_parm [BY unit_parm] [OF race_parm]
Sent to: the host's owner.
Thrown when a unit boards one of our units. The first parameter is the unit that boards, BY the host, OF the host's owner.
on each Boarded ANY "Army_Division" ->(unit A) CountLoaded(A)
Orders Completed¶
Syntax: Orders Completed unit_parm
Sent to: the unit's owner only.
Thrown when one of our units completes all its orders. An aircraft throws it when its real order is done and only the automatic return remains. Missiles don't throw it.
on each Orders Completed ANY "Spec_Ops_Team" ->(unit ThisSpecOps) RouteSpecOps(ThisSpecOps)
Inactive¶
Syntax: Inactive unit_parm
Sent to: the unit's owner only.
Thrown when one of our units enters a host and so becomes inactive.
on each Inactive ANY "Spy_Plane" ->(unit ThisSpyPlane) TryRerouteSpyPlane(ThisSpyPlane)
Deployed¶
Syntax: Deployed unit_parm
Sent to: the unit's owner only.
Thrown when the faction deploys a unit on the map, and for each unit deployed along with it as a follower.
ON Deployed ANY "Army_Division" StdMessage(6769)
Occupation, regions and population¶
In Besieged, Occupied and Deoccupied, the first parameter takes every unit_parm form. Cities are ANY "VirtualCity" or ANY {City}.
Besieged¶
Syntax: Besieged unit_parm [OF race_or_region_parm] [BY race_parm]
Sent to: common if unit_parm is a city; the unit's owner if it is a unit.
Thrown when the occupation timer starts, and again when the occupier changes while it runs. OF is the owner or the region, BY the occupier.
ON (BESIEGED ANY "VirtualCity" OF REGION "North Korea" BY ANYONE BUT ALLY) OR (DAMAGED ANY {Ground, Naval, City}) ProtectOrInvade()
Occupied¶
Syntax: Occupied unit_parm [OF race_or_region_parm] [BY race_parm]
Sent to: common if unit_parm is a city; the old and the new owner if it is a unit.
Thrown when a city or unit is completely occupied.
on each Occupied any "VirtualCity" ->(unit ThisCity) OF ME by enemy CheckCityOccupied(ThisCity)
Deoccupied¶
Syntax: Deoccupied unit_parm [OF race_or_region_parm] [BY race_parm]
Sent to: as Besieged.
Thrown when a previously besieged or occupied city or unit is no longer besieged. BY here is the unit's own owner, not the occupier that left.
on Deoccupied "Pyongyang" BuildArmyBase()
Region_Occupied¶
Syntax: Region_Occupied region_parm [BY race_parm], or Region_Occupied ANY [OF race_parm] [BY race_parm]
Sent to: common.
Thrown when a region passes to another faction, unless the transfer is a friendly one. OF is the previous owner, BY the new one. OF is allowed only after ANY: the ANY form fires for any region of the faction without naming it.
on each Region_Occupied ANY ->(string RegionName) BY ME TransferRegionToAllies(RegionName, AlliedFaction)
ON REGION_OCCUPIED "North Korea" BY ALLY PLUS ME MISSION "NorthKorea" SUCCESS
Region_Invaded¶
Syntax: Region_Invaded region_parm [BY race_parm], or Region_Invaded ANY [OF race_parm] [BY race_parm]
Sent to: the region's owner, the invader, and every other faction that can see the invading unit.
Thrown when a faction that isn't the owner's ally first brings occupying units into a region.
ON REGION_INVADED ANY ->(string RegionName) OF ME DoSomething(RegionName)
Region_Liberated¶
Syntax: Region_Liberated region_parm, or Region_Liberated ANY [OF race_parm]
Sent to: the region owner only.
Thrown when a region is freed from enemy armies. It is not thrown when the region is freed by a ceasefire or a transfer.
on Region_Liberated "South Korea" throw "South Korea Liberated" globally
Region_Destroyed¶
Syntax: Region_Destroyed region_parm, or Region_Destroyed ANY [OF race_parm]
Sent to: common.
Thrown when a region is totally destroyed and removed from the game.
on each Region_Destroyed ANY of "Japan" JapanRegionDestroyed()
Population¶
Syntax: Population [OF race_parm] LESS int_expression
Sent to: common.
Checked every time a faction's remaining population, as a whole percentage of its initial one, changes. It fires when that is below int_expression percent. Without OF, our own faction.
on Population less 20 Surrender
Missions and the end of the game¶
Mission¶
Syntax: Mission mission_name [SUCCESS | FAIL [TYPE n] | ANYTHING]
Sent to: common.
Thrown when a mission succeeds or fails. mission_name is a mission ID string or a set of them, in any letter case, or ANY (also ANYTHING), ANY PRIMARY or ANY SECONDARY. Without a state word, Mission "name" is the same as Mission "name" ANYTHING: it fires on either outcome. SUCCEED and SUCCEEDED are synonyms of SUCCESS; FAILURE and FAILED of FAIL.
n is a literal 0, 1 or 2, set by the Mission action. FAIL without TYPE is FAIL TYPE 0: it doesn't match the other two. To catch every failure, combine the three types with OR, or use ANYTHING and read MISSION_STATE.
The MISSION keyword is required. Without it, "name" is a custom event.
DELETE WHEN Mission ANY Primary FAIL
ON Mission "Casualties" SUCCESS StdMessage(7531)
Game_Finished¶
Syntax: Game_Finished
Sent to: common.
Thrown when the game ends by its own rules: pollution reaches 100%, the end-game countdown runs out, only one permanent alliance is left, or in single player the player's faction has surrendered.
ON Game_Finished CheckMissionComplete()
Timers¶
TICK¶
Syntax: TICK [+] int_expression
Sent to: common.
A relative timer: it fires n ticks after the trigger is set. It is converted automatically into an absolute TIME event when the statement is reached, or, on the right of THEN, when the left part has triggered. Use SECONDS(), MINUTES() and HOURS() to convert game time into ticks. With EACH, it repeats every n ticks.
on each tick +SECONDS(30) SpawnMRBM()
TIME¶
Syntax: TIME [+] int_expression
Sent to: common.
An absolute timer: it fires when the game time reaches int_expression ticks (compare with CURRENT_TICK). The + changes nothing here. TICK +n is the usual way to write timers.
on TIME MINUTES(45) throw "Reinforcements" globally // 45 game minutes after the game's start
Custom events¶
Syntax: any expression that gives a string, or a set of strings (any of them)
Sent to: depends on how it is thrown.
Scripts throw custom events with THROW to signal each other, including between different factions' scripts. Letter case doesn't matter in the name. Up to two values can travel with the event: see embedded variables.
throw "Phase 2" globally
...
on "Phase 2" StartPhase2()
on "Stop Airstrikes " + SelfID Dummy
Other event keywords¶
| Keyword | Meaning |
|---|---|
Custom string_expression |
The same as the string alone. |
Custom_Bool condition |
The same as the condition alone. |
Dummy |
Always true. |
Built unit_parm, Blocked |
Accepted, have no effect: such a trigger never fires. |
on Custom "Phase " + NextPhase StartNextPhase()
Actions¶
An action is a statement that does something. It can be the action of an ON trigger, or it can stand alone in a body, in which case it runs immediately. Parameters in italics link to Event parameters or Action expressions.
Flow and blocks¶
Dummy¶
Syntax: Dummy
Does nothing. Use it as a placeholder where an action is required.
on "Stop Airstrikes " + SelfID Dummy
Block call¶
Syntax: block_name(param [, param]+)
The simplified execute: calls a previously declared block. This is the usual way to run code, and the only way to do several things in one ON trigger.
on "Phase 2" StartPhase2()
on each destroyed any "Army_Base" ->(unit B) Rebuild(B)
Execute¶
Syntax: Execute [FILE] "name" [(param [, param]+)] [FOR race_parm]
Starts executing a block, looked up by name when the action runs. The parameters are passed to the block.
- "name": the name of a block. It must be a literal string, not an expression.
FILE: "name" is the path of a file with plain statements up to anEND, read when the action runs. It takes no parameters.FOR: the block is executed in the script of the listed faction(s) instead of our own. Each of those scripts must have the block: a block of ours is not found there.
on launched nuke execute "AuthoriseNukes" for "China"
execute "ReviveFaction" for FactionToCheck
Throw¶
Syntax: Throw string_expression [PARM expression]+ [GLOBALLY | TO race_parm]
Throws a custom event.
- Without
GLOBALLY/TO, only the throwing faction's own script sees it. GLOBALLYsends it to every faction's script, ours included. Phase changes need this:throw "Phase 2" globally.TOrace_parm sends it to specific factions.PARMattaches up to two values, calculated at the throw; a third is an error. See embedded variables.
throw "Phase 2" globally
throw "CheckAttackedCity" PARM ThisCity PARM NumKilled globally
throw "Cancel SecureMoveUnit " + This
Assignments and function calls¶
- Assignments:
variable = expression,+=,-=,*=,/=,%=,++,--. See Operators. The wordAssignis no statement: writing it is a loading error. - Control flow:
If … [Else …] End,While … End,ForEach … End,Break,Return expression. See Control flow. - Function calls: a built-in function used as a statement, for its side effect:
CREATE_UNIT("Coastal", pt),GRANT_TECH(SelfID, "Chemical_Weapons").
Counter++
Targets += CITY("Busan")
GRANT_TECH(SelfID, "Chemical_Weapons")
AI and attack control¶
Suspend / Resume¶
Syntax: (Suspend | Resume) (AI [FOR unit_parm] | PRODUCTION | CONSTRUCTION | SCIENCE | RESEARCH | ESPIONAGE | DIPLOMACY | TRANSPORT) [OF race_parm]
Suspend switches off part of a faction's activity and Resume switches it back on. OF applies it to the listed factions instead of our own.
AI: stops the whole faction AI and the AI of each of its units, including its diplomacy, untilRESUME AI, which resumes all its units, also those suspended one by one.AI FORunits stops it for those units only, so the script can move them itself.AI FOR "Faction name"is the same asAI OF "Faction name". Units created byCREATE_UNIT,CREATE_GROUPorTRANSFER_UNITstart with AI on.PRODUCTION(same asCONSTRUCTION),SCIENCE(same asRESEARCH),ESPIONAGE,DIPLOMACY: stop those activities.TRANSPORT: the AI won't use transport units to airdrop or carry other units, so every unit must reach its destination on its own.
For a human player, suspending PRODUCTION, SCIENCE or DIPLOMACY blocks access to those screens in the game UI.
SUSPEND AI
SUSPEND AI FOR InvasionGroup
on "Allow AI" OR Attacked ANYTHING RESUME AI
SUSPEND DIPLOMACY
AutoAttack¶
Syntax: AutoAttack [DISABLE] [FOR unit_parm] [OF race_parm]
Lets units, or all units of the faction, attack targets of opportunity automatically. DISABLE stops it. OF applies it to the listed factions instead of our own.
AutoAttack For Group
AttackFaction¶
Syntax: AttackFaction race_parm
Declares war on the given factions (except permanent allies), lifts our attack block on them, and forces a full-scale attack on them.
on "Phase 2" AttackFaction "Soviet Union"
LimitedAttack¶
Syntax: LimitedAttack race_parm
Declares war on the given factions (except permanent allies) and marks them as limited-war targets: the AI lifts its attack and homeland-attack blocks on them and attacks them, but without the full forced attack of AttackFaction.
LimitedAttack PlayerID
AttackUnit¶
Syntax: AttackUnit unit_parm [BY race_parm]
Makes the AI attack a specific unit: the unit is revealed to our faction on the next turn and added to the AI's priority targets. It works even on allied units and our own.
It takes one unit. With an ANY form, one visible unit of the type is picked at random among those owned by the BY factions: give BY there, since without it only the aggressor faction counts. A set isn't accepted: use ForEach.
on each visible any "Mobile_SRBM" ->(unit Launcher) of PlayerID AttackUnit Launcher
StopAttack¶
Syntax: StopAttack race_parm
Revokes the full-scale attack permission. It doesn't block attacks completely; it only stops a premature attack ordered by AttackFaction or GlobalAttack. To block attacks, use BlockAttack.
on Ceasefire BETWEEN ME AND PlayerID StopAttack PlayerID
GlobalAttack¶
Syntax: GlobalAttack
Declares war on every faction except our permanent allies, lifts our attack blocks, and forces an all-out attack on them.
on "Global War" GlobalAttack
BlockAttack / AllowAttack¶
Syntax: (BlockAttack | AllowAttack) race_parm
Disables, or re-enables, any attack on the given factions. Permanent allies and our own faction stay out of the list. Unit … Attack respects the block.
BlockAttack "China"
on "Phase 2" AllowAttack "United States"
BlockInvasion / AllowInvasion¶
Syntax: (BlockInvasion | AllowInvasion) race_parm
Disables, or re-enables, invading the given factions.
BlockInvasion "United States"
on "Phase 3" AllowInvasion "United States"
BlockHomelandAttack / AllowHomelandAttack¶
Syntax: (BlockHomelandAttack | AllowHomelandAttack) race_parm
Disables, or re-enables, attacks on the factions' ground units inside their homeland. Attackers of unknown ownership, such as enemy spec-ops, aren't affected.
BlockHomelandAttack PlayerID
on "Phase 2" AllowHomelandAttack PlayerID
Invasion¶
Syntax: Invasion (CANCEL | race_or_region_parm [STOP])
Orders the AI to invade a region. The AI keeps a list of such regions; each INVASION adds one.
- With a faction instead of a region, our attack block on it is lifted, and one region of that faction that borders us or a permanent ally is picked at random. A literal string is taken as a faction first, then as a region. With no such region to pick, or a region name that doesn't exist, the list stays as it is.
- target
STOP(orCANCEL): removes that region from the list. INVASION CANCEL: clears the whole list.
INVASION "South Korea"
Invasion REGION TargetRegion
INVASION CANCEL
Defend¶
Syntax: Defend (CANCEL | [CITIES [OF]] region [FROM race_parm] [BORDER region] [STOP | CANCEL])
Orders the AI to defend a region. The AI keeps a list of such regions; each DEFEND adds one.
- region: a region name, or a string expression.
- region
STOP(orCANCEL): removes that region from the list. DEFEND CANCEL: clears the whole list.CITIES OF,FROMandBORDERare accepted and have no effect:DEFEND CITIES OF "Dongbei"andDEFEND "Dongbei" BORDER "North Korea"both defend the region Dongbei.
DEFEND "Dongbei" BORDER "North Korea"
DEFEND CITIES OF "Thailand"
DEFEND CANCEL
Unit orders¶
Unit can also be written Units. In all unit orders, unit_expression is a unit, a unit UID, or a set of them (see Action expressions); parameter forms like ANY "type" aren't accepted here, so collect the units with SELECT first. The order is given to every unit in it, except that Move orders only one. Units of any faction can be commanded. An order written without Unit reaches no unit.
Unit … Move¶
Syntax: Unit unit_expression Move [RANDOM] [LOOPED | LOOP] coordinates_expression
Moves one unit to a point: the unit given, or the first unit of a set. To move a group, give the leader the order and have the others follow, or loop over the set.
- coordinates_expression can be a single point or a set of points. A set is a route, visited in order.
LOOPED(also writtenLOOP) keeps patrolling a route of two points or more.RANDOMpicks one point at random. WithLOOPEDa new point is picked each time the unit arrives, until the trigger'sDELETE WHEN. The shipped scripts usemove random loop {…}for random patrols andMove looped Routeto patrol a route.- Units and city names convert to their positions automatically.
unit Leader move Destination
unit 2930952 move random loop {@(0.80, 0.40), @(0.82, 0.40)}
Unit … Attack¶
Syntax: Unit unit_expression Attack unit_parm [OF race_parm] [BY (missile_type_parm | BEST [class | {class [, class]+}])]
Attacks targets. Targets must be at least ghost-visible to the attacker. Targets of a faction under a ceasefire with the attacker's, or under its attack block or homeland block, are skipped. A unit that can't move takes only targets within its range.
Each attacker gets one target. The nearest pairs go first, cities by largest population, and each target gets an attacker before any target gets a second one.
- To attack cities, write
ANY "VirtualCity"orANY {City}. OF: only targets owned by those factions.BYmissile_type_parm: only targets those weapons can reach and hit are chosen. The order itself doesn't limit the weapons.BY BEST: the unit automatically selects the best available weapon config for each chosen target. A class afterBESTlimits the choice:BY BEST NUKE,BY BEST {CONVENTIONAL, CHEM}.BESTis valid only here; it isn't a general missile type.
unit Airbases attack any {Ground, Naval} of ENEMY BY BEST
unit SRBMs attack any "Army_Base" of "China"
Unit … Launch¶
Syntax: Unit unit_expression Launch unit_parm AT unit_parm [ATTACK] [WITH (missile_type_parm | BEST)]
Launches hosted units from the given hosts.
- The first unit_parm selects which hosted units to launch, for example
any "Air_Transport",any TransportUToranything. ATunit_parm: the destination, a point, a set of points, or units. Always give it. The shipped scripts pass a single point, a set of points from GET_VICINITY_POINTS, or a target unit.- One hosted unit goes to each destination, in order, until they run out, so a single point launches a single unit. With more hosts than destinations, each host launches one unit and the destinations repeat.
- A launched unit sent at a unit has that unit as its target: it attacks a unit of a faction we aren't allied with, unless it can occupy it, and lands on a host that can take it.
ATTACK: with a target unit, the launched unit attacks it if it can, also a unit it could occupy and a unit of an ally. Our own and permanent allies' units stay out of this: the launched unit goes to them as it would withoutATTACK, so an airbase of ours is where it lands. With points as the destination,ATTACKhas no effect.WITHis accepted and has no effect.
unit Base launch any "Air_Transport" at DestinationPoints
UNIT This Launch anything AT Dest
Unit … Board¶
Syntax: Unit unit_expression Board unit_parm
Boards another unit, such as a transport. Each unit goes to the nearest of the given hosts that still has room, counting those already on their way to it.
unit AllArmies board AllTransports
Unit … Follow¶
Syntax: Unit unit_expression Follow unit_parm
Follows another unit and joins its follow group: the nearest active one of those given, in place of any unit it followed. See also MAKE_GROUP.
unit NewSupport follow This
Unit … Weapon_Use¶
Syntax: Unit unit_expression Weapon_Use missile_type_parm (Never | Always | WhenAttacked | WhenAttackedAIOnly | WhenAttackedByNuke | WhenAttackedByNukeAIOnly)
Sets the weapon-use policy of the units for that weapon.
Unit AllArmies WEAPON_USE "Nuclear Artillery" Always
Unit … Weapon_Switch¶
Syntax: Unit unit_expression Weapon_Switch missile_type_parm (ON | OFF) (also TRUE / FALSE)
Unit unit_type_expression Weapon_Switch missile_type_parm (ON | OFF) BY DEFAULT
Switches a weapon on or off for the given units. It acts only on weapons declared Switchable, and only in a faction played by a human. With BY DEFAULT the first argument is a unit type (or a set of types), and the setting applies to all future units of those types of our faction, whoever plays it.
Unit AllArmies WEAPON_SWITCH "Chemical Artillery" OFF
Unit {"Army_Division", "Army_Base"} WEAPON_SWITCH "Chemical Artillery" OFF BY DEFAULT
Unit … Delete Orders¶
Syntax: Unit unit_expression Delete Orders
Clears all orders of the units.
unit Stalin delete orders
Unit … Make Visible¶
Syntax: Unit unit_expression Make Visible [FOR race_parm]
Reveals the units on the next turn, to everyone or to the listed factions.
unit Targets make visible for SelfID
unit This make visible
Missions and UI¶
Mission (action)¶
Syntax: Mission mission_name_expression operation
mission_name_expression is a string naming a mission defined in the map file, in any letter case. The action does nothing outside a scenario, or for a name the map doesn't define. The scripts see the change at once. The operations are:
[ADD]int_expression: adds progress.Mission "Indian airports" add 1.SETint_expression: sets progress or target.Mission "Arab royal families" SET SIZE_OF(VIPs).POINTSint_expression: sets the number of points for the mission, overriding the value defined in the map.txtfile that references the scripts.FAIL [TYPEn]: fails the mission. n is a literal 0, 1 or 2; default 0.SUCCESS: completes the mission.FINAL_SUCCESS: completes it and finishes the scenario.UNHIDE: shows a hidden mission.TIMERint_expression: attaches a countdown in ticks.MISSION "Mission Timer" TIMER MINUTES(30).
FAIL, SUCCESS and FINAL_SUCCESS act only on a mission still in progress.
To react to a mission's outcome, use the Mission event; to read its state, use MISSION_STATE.
Mission "Airports" add 1
Mission "Arab royal families" SET SIZE_OF(VIPs)
MISSION "Mission Timer" TIMER MINUTES(30)
on Destroyed ANY "Army_Base" Mission "Hold" FAIL TYPE 1
Show / Hide Population¶
Syntax: (Show | Hide) Population [For] race_parm
Shows or hides the remaining-population percentage of the factions under the mission objectives. Does nothing outside a scenario.
Show Population for Anyone
on "Phase 2" Hide Population for "China"
Message¶
Syntax: Message (CLEAR | expression [DIM] [NoOK] [Portrait string_expression] [Position (Center | TopLeft | BottomLeft | TopRight | BottomRight | CenterLeft | CenterRight)] [Justify (Left | Center | Right)])
Shows an advisor message, or clears the current one with CLEAR. A message reaches every player's screen, whichever faction's script runs it. While a message is open, a new one is added to its text.
- expression: the text. Any value converts to a string, which makes
Messagehandy for debugging:Message "Targets: " + Targets. DIM: dims the screen behind the message.NoOK: the message has no OK button.Portrait: path of the portrait image, usuallyADVISOR_PORTRAIT.Position: where the message box appears. Default:Center.Justify: text alignment. Default:Leftwith a portrait,Centerwithout.- The options can come in any order.
Put player-facing text in the localisation table and show it with UI_STRING. The house style is:
Message UI_STRING(7328) Position TopLeft Portrait ADVISOR_PORTRAIT
SetGameSpeed¶
Syntax: SetGameSpeed int_expression
SetGameSpeed 0 pauses, which is used for end-of-mission messages; 1 is normal speed, up to 4. Other values do nothing.
BLOCK EndMessage()
SetGameSpeed 0
Message UI_STRING(7531) Position Center
END
Diplomacy and war¶
Declare War¶
Syntax: Declare War race_parm
Declares war on the factions, except our permanent allies, and lifts our attack block on them.
Declare War "Soviet Union"
Declare War GET_ALLIES("United States")
Create Alliance¶
Syntax: Create Alliance [With] race_parm
Forms an alliance with the factions. Those already allied are skipped.
Create Alliance With "American Mutineers"
Ceasefire With¶
Syntax: Ceasefire With race_parm [DURATION int_expression]
Stops the war with those of the factions we are at war with, and starts a ceasefire. DURATION (also FOR) sets its length in ticks; default: the map's ceasefire timeout, which is also the shortest ceasefire.
Ceasefire with "India"
Ceasefire With PlayerID DURATION MINUTES(20)
Peace Treaty With¶
Syntax: Peace Treaty With race_parm [DURATION int_expression]
Starts a ceasefire if the factions are at war; otherwise signs a peace treaty. Permanent allies are skipped. DURATION (also FOR) sets the length of the ceasefire in ticks, and of the peace treaty when it is longer than the map's peace-treaty timeout.
Peace Treaty with "United States"
Leave Alliance¶
Syntax: Leave Alliance
Leaves the current alliance. It does nothing in a permanent alliance, which can't be broken.
on "Coup" Leave Alliance
Surrender¶
Syntax: Surrender
The faction surrenders. The map's NoSurrender setting holds here too: with NoSurrender manual the action does nothing, and with NoSurrender Yes nothing happens while the faction has a unit left.
on Population less 20 Surrender
Production and weapons¶
Build¶
Syntax: Build [ANY] unit_type_or_missile_type_expression [x int_expression]
Adds units or missiles to the faction's stockpile, ready to deploy. A set gives that number of each.
Build "250kt_MRBM" x 250
Enable / Disable Missiles¶
Syntax: (Enable | Disable) Missiles missile_type_parm [FOR race_parm]
Forbids, or allows again, the use of a weapon class, for our faction or for the listed factions. Disable affects AI factions only: human players keep their weapons. Enable works for every faction.
DISABLE Missiles geneva "Chemical"
DISABLE Missiles NUKE
ENABLE Missiles geneva "High-Yield Nukes" FOR Ally plus me
Sets¶
Select¶
See SELECT.
Clear¶
Syntax: Clear set_variable
Empties the set. It takes a set variable, not an expression.
clear EnemyIDs