List of all IES script commands for scenarios in EE2 and EE2X

Modding, Map Editor, IES Scripting and Other Tutorials
Post Reply
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

List of all IES script commands for scenarios in EE2 and EE2X

Post by Loewenherz »

Image

Please do not reply to the thread here! Disscussion and feedback have a place here:
viewtopic.php?f=54&t=5592

Overview

------------------------------------------------------

To jump to a specific location, simply search for one of these terms in your browser by pressing Ctrl + F.

Game Actions
Effects
Strategic AI
Airport & Airplane manipulations
Economy Parameter Manipulation
Cinematics
UI/Visual Actions
Mission Objectives
Selection Manipulation
Group Manipulation
Actions on Selections
Script access to UI Elements
Mission Timer
Audio
Diplomacy Functions
Weather
Conditions / Value Functions
Crowns
Player Statistics

THINGS YOU MIGHT WANT TO DO, AND HOW TO DO THEM
GOOD PRACTICES TO FOLLOW
ENUM LISTS
LIST OF ALL IES SCRIPT COMMANDS

C Arithmetic Operators


------------------------------------------------------

This list will be updated every now and then when I have time. It contains all script commands that can be used to create scenarios. In addition, there will be some tips and tricks on how to add interessting features for you scenarios. For example, how to change unit values or the time of day.

GLOSSARY OF SCRIPTING TERMS


STEP-delaying Actions

DoDelay
Spoiler
// void DoDelay(float in_fSeconds)
// Wait for fSeconds before STEPping the script.
// example usage:
// Execute Something(), wait 3.5 seconds, then
// execute SomethingElse()
...
Something();
DoDelay(3.5);
STEP
SomethingElse();
...

Game Actions


DoDisplayDialog
SetUnitDisplayName
Spoiler
// void SetUnitDisplayName(const char *in_szUnitNameInScript,
// const char *in_szTextDatabaseEntry);

// set (localized) display name for a named unit
// in_szUnitNameInScript must be a valid named unit (script name)
// in_szTextDatabaseEntry must be a valid text database entry
// (the contents of which will become the displayed name)
example usage:
if you have a unit named "Jesus" in the scripting unit name
table and a text database entry named "tx_scenUnitName_Jesus"
exists, then you could do this:
SetUnitDisplayName("Jesus", "tx_scenUnitName_Jesus");
CreateUnitAtLocation
Spoiler
// void CreateUnitAtLocation((int in_iPlayerID,
// const char *in_szTypeName,
// bool in_bSpecialForces, float in_fXLoc, float in_fYLoc,
// float in_fAngle)
CreateNamedUnitAtLocation
Spoiler
// void CreateNamedUnitAtLocation(int in_iPlayerID,
// const char *in_szTypeName, const char *in_szUnitName,
// bool in_bSpecialForces, float in_fXLoc, float in_fYLoc,
// float in_fAngle)
CreateGroupedUnitAtLocation
Spoiler
// void CreateGroupedUnitAtLocation(int in_iPlayerID,
// const char *in_szTypeName, const char *in_szUnitName,
// bool in_bSpecialForces, float in_fXLoc, float in_fYLoc,
// float in_fAngle)

// Creates a in_iPlayerID-owned unit of type in_szTypeName as close as
// possible to (in_fXLoc, in_fYLoc), facing direction in_fAngle. If
// in_bSpecialForces is true, it will mark this unit as special forces.
// The CreateNamedUnitAtLocation variant will additionally name the
// unit in_szUnitName, and the CreateGroupedUnitAtLocation variant will
// add the unit to the in_szGroupName group.
// example usage:


//Give AI player 3 a few light infantry guys and stick
//them in the "Disposable" group. Just let the AI use
//them as it wishes - don't make them special forces.

CreateGroupedUnitAtLocation(3, "LightInfantry",
"Disposable", false, 96, 96, 0);
CreateGroupedUnitAtLocation(3, "LightInfantry",
"Disposable", false, 96, 96, 0);
CreateGroupedUnitAtLocation(3, "LightInfantry",
"Disposable", false, 96, 96, 0);
//Give AI player 2 a male citizen named "JamesBond".
//Make him special forces so the AI won't touch him.
CreateNamedUnitAtLocation(2, "CitizenM", "JamesBond",
true, 32, 32, 0);

//Give the human player an anonymous bomber.
CreateUnitAtLocation(1, "Bomber", false, 64, 64, 0);
SetUnitPlacementAngle
Spoiler
// void SetUnitPlacementAngle(float in_fAngle)
// Sets the unit placement angle for the following 'Create*InArea'
// calls. Maintains the same angle for the entire STEP, at which
// point, the default angle (0, or east) comes back.
CreateUnitInArea
Spoiler
// void CreateUnitInArea(int in_iPlayerID,
// const char *in_szTypeName,
// bool in_bSpecialForces, const char *in_szAreaName)
CreateNamedUnitInArea
Spoiler
// void CreateNamedUnitInArea(int in_iPlayerID,
// const char *in_szTypeName, const char *in_szUnitName,
// bool in_bSpecialForces, const char *in_szAreaName)
CreateGroupedUnitInArea
Spoiler
// void CreateGroupedUnitInArea(int in_iPlayerID,
// const char *in_szTypeName, const char *in_szUnitName,
// bool in_bSpecialForces, const char *in_szAreaName)
// These work exactly the same as the Create*UnitAtLocation commands
// above, except they take the name of an area instead of a pair of
// coordinates and an angle. Right now it just places them as close
// to the center as possible, and search out in a 'ring' pattern
// like the AtLocation commands do.
// example usage:
SetUnitPlacementAngle(1.57f); // face north, buddy
CreateNamedUnitInArea(2, "CitizenM", "Gatekeeper",
true, "OutsideCityGate");

CreateUnitInTerritory
Spoiler
// void CreateUnitInTerritory(int in_iPlayerID,
// const char* in_szTypeName, bool in_bSpecialForces,
// const char* in_szTerritoryName)
CreateNamedUnitInTerritory
Spoiler
// void CreateNamedUnitInTerritory(int in_iPlayerID,
// const char *in_szTypeName, const char *in_szUnitName,
// bool in_bSpecialForces, const char *in_szTerritoryName)
CreateGroupedUnitInTerritory
Spoiler
// void CreateGroupedUnitInTerritory(int in_iPlayerID,
// const char *in_szTypeName, const char *in_szUnitName,
// bool in_bSpecialForces, const char *in_szTerritoryName)
// These commands are similar to the above area commands. Instead
// of using an area name, however, they take a name of a territory,
// and use the approximate center of the territory as the location
// when creating the unit.
// NOTE: Test these commands to make sure the location used matches
// your expectations. The center of the territory may not be where
// you think it is, and it might be better for you to create an area
// or use an X,Y coordinate instead of using the territory.
CreateUnitInUnit
Spoiler
// CreateUnitInUnit(int in_iPlayerID, const char* in_szTypeName,
// bool in_bSpecialForces, const char* in_szTargetUnit)
CreateNamedUnitInUnit
Spoiler
// CreateNamedUnitInUnit(int in_iPlayerID, const char* in_szTypeName,
// const char* in_szUnitName, bool in_bSpecialForces,
// const char* in_szTargetUnit)
CreateGroupedUnitInUnit
Spoiler
// CreateGroupedUnitInUnit(int in_iPlayerID, const char* in_szTypeName,
// const char* in_szGroupName, bool in_bSpecialForces,
// const char* in_szTargetUnit)
// These work like CreateUnitAtLocation and the related commands,
// except for the last parameter in each command. The last parameter
// is the name of an existing unit that can garrison other units. The
// new uits will be garrisoned in the specified unit when they are
// created.
CreateNamedUnitInUnit(2, "CitizenM", "Gatekeeper",
true, "Transport01");
GenerateAIBuildManagers
Spoiler
// void GenerateAIBuildManagers(const char* in_szCapitolName)
// tell the AI to auto-generate build managers for all city centers on // the map, the specified capitol will use the default build list,
// all others will use the buildlists from buildListRegistry_NewCity
PausePlayerAI
Spoiler
// void PausePlayerAI(int in_iPlayerID, bool bPaused)
// Disable/enable strategic AI of computer player
// example usage:
//Pause AI player 2 until some condition is met.
PausePlayerAI(2, true);
...
//Unpause player 2, now that the human player's ready.
PausePlayerAI(2, false);
SetAIInstantRallying
Spoiler
// void SetAIInstantRallying(int in_iPlayerID, bool
in_bShouldInstantRally)
// set instant rallying for this AI - this makes it NOT try to pull its
// troops together before attacking really just a hack for if you're
// giving it way too many units that it can't rally them
AI_ChangePersonality
Spoiler
// void AI_ChangePersonality(int in_iPlayerID,
// const char *in_szFileName)
// Load the specified Aip file for the given playerID
// example usage:
AI_ChangePersonality(playerID, "bully.aip");
AI_LoadCivSpecificPersonality

AI_SetAttackFactor
Spoiler
// void AI_SetAttackFactor(int in_iPlayerID, float in_fFactor)
// Set a multiplier on how much damage this player does,
// this is after all global game and difficulty settings
// are applied. Set to less than 1 to do less damage than normal,
// greater than 1 to do more damage than normal.
AI_SetBuildTimeFactor
Spoiler
// void AI_SetBuildTimeFactor(int in_iPlayerID, float in_fFactor)
// A multiplier on how long it takes to build units and buildings,
// applied after global and difficulty settings, set to less than
// 1.0 to take LESS time to build than normal.
AI_SetBuildCostFactor
Spoiler
// void AI_SetBuildCostFactor(int in_iPlayerID, float in_fFactor)
// A multiplier on how much things cost, applied after global and
// difficulty settings, set to < 1.0 to make things cost LESS than
// normal, or greater to cost more (and handicap the player)
AI_CreateBattalion
Spoiler
// create a specific battalion to do stuff
void AI_CreateBattalion(int in_iPlayerID,
const char* in_szMyUnitGroupName,
const char *in_szEnemyUnitGroupName,
const char* in_szTerritoryName,
eTaskType in_eTaskType)

// in_szMyUnitGroupName is the name of the group of units that will be
performing the task.
// in_szEnemyUnitGroupName is the name of the target
units, so if you are attacking an army or base, these are those
units, though if you are defending a base, these will be your
buildings
// in_szTerritoryName is used INSTEAD of in_szEnemyUnitGroupName for
capture territory tasks
// Valid task types are:
// kTaskType_AttackArmy, kTaskType_AttackBase, kTaskType_DefendBase
// or kTaskType_CaptureTerritory
// One other option is kTaskType_StartCity, which is the only
// NON-MILITARY action possible, give it citizens ONLY or
// badness will follow

// Note: for capture territory, you CAN give it citizens in the selection, and it'll use them right. If you don't, it'll look for any citizens not on special forces and snag some of them.
SetPlayerToCinematicOnly
Spoiler
// void SetPlayerToCinematicOnly(int in_PlayerID,
// bool in_bCinematicOnly)
// Change a player to be cinematic only or not. Cinematic only players
// do not show up in the Diplomacy screen, end game stats, and other
// in-game UI elements that normally list players.
// NOTE: You can set a player to be cinematic-only in the scenario
// editor. You can even make a cinematic-only player, and use that
// player for scripted events during the game. It is probably
// better to use the scenario editor, and make the player
// cinematic-only or not for the entire game.
// example:
// Player 5 was used for some barbarian hordes which
// did not represent a cohesive civilization and shouldn't show
// up in the end game stats. So make them disappear.
SetPlayerToCinematicOnly(5, true);
SetPlayerResource
Spoiler
// void SetPlayerResource(int in_iPlayerID, eResourceType in_eResType,
// int in_iAmount)
// Change player's resource amount to x
// Set the amount of resource for the specified type. NB: If you have
// a rule testing GetAmountOfResourcesCollected(), it will NOT keep
// track of resources added by this call! It only keeps track of
// resources actually gathered by the player.
// example usage:
//Thieves have broken into your treasury!
SetPlayerResource(1, kResourceType_Gold, 0);
AddPlayerResource
Spoiler
// void AddPlayerResource(int in_iPlayerID, eResourceType in_eResType,
// int in_iAmountToAdd)
// add extra amount of the specified resource type. NB: If you have
// a rule testing GetAmountOfResourcesCollected(), it will NOT keep
// track of resources added by this call! It only keeps track of
// resources actually gathered by the player.
// example usage:
//After the player completes a game event that establishes
//positive diplomatic relations with Nigeria, we have the
//Nigerian ambassador send him/her a gift of uranium.
AddPlayerResource(1, kResourceType_Uranium, 500);
RemovePlayerResource
Spoiler
// void RemovePlayerResource(int in_iPlayerID,
// eResourceType in_eResType, int in_iAmountToRemove)
// remove some amount of the specified resource type
// If the player has less than in_iAmountToRemove, it will only
// take away as much as he has, so if the script is doing a thing where
// it needs to know whether he has enough to pay for something, you'll
// have to check with GetPlayerResource() first!
// example usage:
//The termites are horrible this time of year..
RemovePlayerResource(1, kResourceType_Wood, 250);
LiftShroudForPlayer
Spoiler
// void Script_LiftShroudForPlayer(int in_iPlayerID)
// Lifts the shroud for player in_iPlayerID. This is irreversible so
// only do it if you mean it. This function call is a stopgap measure
// until we get shroud-painting into the scenario editor.
// example usage:
//You'd want to put this in the INITIALIZATION section of
//a script for a scenario where you want the player to
//be able to see the entire terrain.
LiftShroudForPlayer(1);
ToggleFogOfWar
Spoiler
// void ToggleFogOfWar(bool in_bFogOn)
// Turns the fog of war on and off for a map. Pass in true if you want
// fog of war on, and false if you want it off.
// Example:
// To turn the fog off for a map right at the beginning, stick
// this in the INITIALIZATION section of the script.
ToggleFogOfWar(false);
ResetFogOfWar
Spoiler
// void ResetFogOfWar(int in_iPlayerID)
// Resets the fog of war for the specified player. It will set the
// shroud to be as if they player has not explored beyond what his
// units let him see right now
// Example:
// After the cinematic, make this call to clean up anything that
// might have been revealed.
ResetFogOfWar(1);
CarveShroudCircle
Spoiler
// void CarveShroudCircle(int in_iPlayerID, float in_fX, float in_fY,
// int in_iRadius)
// carve a circular hole in in_iPlayerID's shroud. If in_iPlayerID is
// 0, will carve for all players.
// example usage:
// Let player 1 see a circle of radius 5 at 32, 32.
CarveShroudCircle(1, 32, 32, 5);
CarveShroudOverTerritory
Spoiler
// void CarveShroudOverTerritory(int in_iPlayerID,
// const char* in_szTerritoryName)
// Carve out a hole in in_iPlayerID's shroud. The hole will be over
// the entirety of the named territory.
// example usage:
// Let player 1 see Kansas.
CarveShroudOverTerritory(1, "Kansas");

CarveShroudArea
Spoiler
// void CarveShroudArea(int in_iPlayerID, const char *in_szAreaName)
// carve a named-area-shaped hole in in_iPlayerID's shroud. If
// in_iPlayerID is 0, will carve for all players.
// example usage:
// Let player 1 see the whole field
CarveShroudArea(1, "BattleField");
PlaceFlare
Spoiler
// void PlaceFlare(float in_fX, float in_fY, int in_iRadius,
// int in_iPlayerID, float in_fDuration)
// Puts a flare of radius in_iRadius down at location (in_fX, in_fY)
// for player in_iPlayerID. If in_fDuration is > 0, the flare will
// automatically terminate after in_fDuration seconds. If in_fDuration
// is <= 0, the flare will last until you call FlushFlares() on the
// same player ID.
// example usage:
// Let player 1 see (units included) a circle of radius 5 at
// 32, 32 for 30 seconds.
PlaceFlare(32, 32, 5, 1, 30);
FlushFlares
Spoiler
// void FlushFlares(int in_iPlayerID)
// Flushes all flares created by PlaceFlare() that had a permanent
// duration (i.e. the ones that were given a finite duration will still
// burn).
// example usage:
FlushFlares();
FlareMiniMap
Spoiler
// void FlareMiniMap(int in_iPlayerID, float in_fX, float in_fY)
// Play a flare on the mini map and full-screen map at the specified
// X, Y location. The flare is shown to in_iPlayerID. Flares
// started at the same time will actually start with five-second delays
// between them. (This is built into the flare system to prevent too
// many flares from happening at once.)
// example usage:
// Show the player where he needs to attack, assuming the enemy
// fortress is located at 125,60
FlareMiniMap(1, 125, 60);
FlareMiniMapForDuration
Spoiler
// void FlareMiniMapForDuration(int in_iPlayerID, float in_fX,
// float in_fY, float in_fDuration)
// Play a flare on the mini map and full-screen map at the specified
// X, Y location. The flare is shown to in_iPlayerID. The flare will
// last for the designated duration.
// example usage:
// There's a KMart at location 125, 60, and they have a blue
// light special on tanks for the next 60 seconds. Get them
// before they're gone!
FlareMiniMapForDuration(1, 125, 60, 60);
AlertPlayer
Spoiler
// void AlertPlayer()
// Just plays a sound to tell the player to pay attention. Can be
// coupled with a minimap flare for an audio and visual cue.
// example:
// Just bring the player's attention to this location.
FlareMiniMap(1, 20, 43);
AlertPlayer();
SetPopCapPerCityCenterForPlayer
Spoiler
// void SetPopCapPerCityCenterForPlayer(int in_iPlayerID,
// int in_iPopCap)
// Set the amount of population that player in_iPlayerID is allowed
// for each city center to be in_iPopCap.
// Human player has 2 city centers, let's let him have a max of
// 40 population:
SetPopCapPerCityCenterForPlayer(1, 20);
SetMaxPopCapacity
Spoiler
// void SetMaxPopCapacity(int in_iPlayerID, int in_iNewMaxPopCap)
// Set the max pop capacity for the specified player. City centers and
// houses grant so much population capacity to a player. This sets
// the maximum capacity that the player can get from those buildings
// and similar bonuses. You can use this to place a hard limit on the
// number of units that a player can have in a scenario.
// For performance and balance reasons, limit the computer
// player to 500 pop capacity
SetMaxPopCapacity(3, 500);
SetTechEnabled
Spoiler
// void SetTechEnabled(int in_iPlayerID, const char *in_szTechName,
// bool in_bEnabled)
// Enable or disable a player's ability to research a given tech.
// example usage:
//Use this in some crazy atheist campaign, I guess
SetTechEnabled(1, "Priest", false);
AdvancePlayerEpoch
Spoiler
// void AdvancePlayerEpoch(int in_iPlayerID, int in_iEpoch)
// Advance player in_iPlayerID to epoch in_iEpoch. This will fail
// (and assert) if you attempt to advance a player backwards.
// example usage:
// player 1 found the crashed alien spacecraft
// and stole its technology, so advance him up
// to the atomic epoch
AdvancePlayerEpoch(1, 12);
AwardTech
Spoiler
// void AwardTech(int in_iPlayerID, const char* in_szTechName)
// Award the named tech to the specified player. The tech name
// comes from run\db\techtree\dbtechtreenode.csv. Each row of
// this file lists a different node. The leftmost column contains
// the name of each node.
// example usage:
// Grant player 1 the third military tech in epoch 1
AwardTech(1, "Military1_3");
SetMaxEpochUI
Spoiler
void SetMaxEpochUI(int in_iMaxEpoch)
This command sets a max epoch number for UI purposes. There's a tooltip on the main screen for the widget that displays the player's current epoch. It has a tooltip that reads something like "Epoch 4 out of 9". This command lets you specify which number is used for the high epoch in that tooltip.
You can specify a max epoch less than one if you want to force the game to revert to the default value.
NOTE: This command has no Sim effect. That is, calling this command by itself will not restrict any player from epoching beyond the specified epoch.
Example:
// You want to restrict the player to a max epoch of 7.
// Make these calls in the Initialization portion of the
// script to do so.
// Call SetTechEnabled to disable the first node in epoch 8,
// which prevents the player from epoching up.
SetTechEnabled(1, "Main8", false);
// And call SetMaxEpochUI to make sure the UI reflects this
// limitation.
SetMaxEpochUI(7);
CallNamedEventHandler
Spoiler
// void CallNamedEventHandler(const char *in_szEventHandlerName,
// const char *in_szArgument)
// Manually call a registered NAMED_EVENT_HANDLER with argument.
// NAMED_EVENT_HANDLERS are the things that you bind keys to in
// your hotkeys.cfg.
// example usage:
//Pretend this is the tutorial and I'm showing you how
//to use the pip.
CallNamedEventHandler("PipSwap", "");
HasPlayerResearchedTech
Spoiler
// bool HasPlayerResearchedTech(int in_iPlayerID,
// const char* in_szTechName)
// Checks to see if the specified player has researched
// the named technology. The technology name comes from
// dbtechtreenode.csv.
// example usage:
// Has the player researched fire, yet?
RULE HasPlayerDiscoveredFire
If(HasPlayerResearchedTech(1, "Main1_1"))
Then TellPlayerToBuildNewBuildings
END_RULE
SetPlayerWinner

WinScenario
Spoiler
// void WinScenario()
// End scenario (with victory/failure message)
// Sets the local player as having won the scenario. This will trigger
// the end of the scenario, but only if there's a 'Script Says So'
// victory condition set up for the scenario!
// example usage:
//You win!
WinScenario();

Hint: Remember that in the scenario edition, there is a "Victory Conditions" option. For .ies you need to set to "Script Says So", otherwise the Scenario has "normal" conditions, like "no units more in game" and this effect will not work.

LoseScenario
Spoiler
// void LoseScenario()
// End scenario (with victory/failure message)
// Sets the local player as having lost the scenario. This will
// trigger the end of the scenario, but only if there's a 'Script Says
// So' victory condition set up for the scenario!
// example usage:
//You lose, man.
LoseScenario();


Hint: Remember that in the scenario edition, there is a "Victory Conditions" option. For .ies you need to set to "Script Says So", otherwise the Scenario has "normal" conditions, like "no units more in game" and this effect will not work.
Last edited by Loewenherz on 22 May 2022, 10:03, edited 5 times in total.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160

User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: List of all IES script commands for scenarios in EE2 and EE2X

Post by Loewenherz »

Effects

All the effects that can be attached to units and players are
located in the ddfs in $/run/db/AreaEffects/. The special per-scenario
effects can be added to dbareaeffects_scenario.ddf, and there is some helpful documentation in there as to how to craft them.

AttachEffectToUnit
Spoiler
// int AttachEffectToUnit(const char *in_szUnitName,
// const char *in_szEffectName)
// Attaches the effect named in_szEffectName to the named
// unit in_szUnitName. You can hold on to the effect ID
// returned for later cancellation.

// Give this guy the loyalty effect that is usually
// a leader power
AttachEffectToUnit("JimJones", "Loyalty");
AttachEffectToGroup
Spoiler
// int AttachEffectToGroup(const char *in_szGroupName,
// const char *in_szEffectName)
// Attaches the effect named in_szEffectName to EACH unit
// in the group in_szGroupName. You can hold on to the
// effect ID returned for later cancellation.
DEFINITIONS
int iFatID;
...

// Make everyone in this group a little slow
iFatID = AttachEffectToGroup("BrunosCustomers", "Fatness");
...

// Until the winter's over
CancelEffect(iFatID);
AttachEffectToPlayer
Spoiler
// int AttachEffectToPlayer(int in_iPlayerID,
// const char *in_szEffectName)
// Attaches the effect named in_szEffectName to player
// in_iPlayerID. You can hold on to the effect ID
// returned for later cancellation.
// Make all player's units immune to conversion
// for the rest of the scenario.
AttachEffectToPlayer(1, "Fanaticism");
AttachEffectToPlayerAtLocation
Spoiler
// int AttachEffectToPlayerAtLocation(int in_iPlayerID,
// const char *in_szEffectName,
// float in_fX,
// float in_fY)
// Attaches the effect named in_szEffectName to player
// in_iPlayerID, and sets it to be located at the
// specified X,Y location. This allows you to create
// certain area effects that are not on a particular unit,
// but will only affect a certain area. These effects, when
// created, will effect a certain radius around their location.
// Damage all units that get to close to the Devil's playpen.
// Note that you need to create the appropriate area effect
// to do this.
AttachEffectToPlayerAtLocation(1, "DamageUnitsWithin5Tiles",
666, 666);
CancelEffect
Spoiler
// void CancelEffect(int in_iEffectID)
// Cancels an effect previously started with one of the AttachEffect
// calls. See AttachEffectToGroup for an example.
GetOwningPlayerForTerritory
Spoiler
// int GetOwningPlayerForTerritory(const char* in_szTerritoryName)
// Get the player ID of the specified territory.
// Returns -1 if the territory is unclaimed.
If(GetOwningPlayerForTerritory("France") == 1)
Then CongratulationsYouTookOverFrance
ChangeTerritoryOwner
Spoiler
// void ChangeTerritoryOwner(const char* in_szTerritoryName,
// int in_iNewPlayer)
// Change the ownership of a territory to a new player.
//Let's go conquer Mexico.
ChangeTerritoryOwner("Mexico", 1);
ChangeTerritoryCityName
Spoiler
void ChangeTerritoryCityName(const char* in_szTerritoryName,
const char* in_szCityName)
Change the city name for a particular territory. The city name is the name assigned to any city center that gets built in this territory after this command is called. This command does not rename any city centers already in the territory. in_szCityName may be NULL or an empty string. In this case, any city centers built in the territory will get their name randomly from an appropriate list of city names. (Depending on civilization.) If in_szCityName is not NULL or an empty string, then it must be the name of a text db entry. This is to help enforce localization and to prevent typos.
Example:
// Why would anybody in their right mind want to name any city
// in our glorious state anything other than Cambridge?
// NOTE: tx_ms_cityname_Cambridge may not be a real text db
// entry. :)
ChangeTerritoryCityName("Massachusetts",
"tx_ms_cityname_Cambridge");
GetNumTerritoriesForPlayer
Spoiler
// int GetNumTerritoriesForPlayer(int in_PlayerID)
// Find out how many territories the specified player controls.
// If a player needs to conquer three territories as a
// victory condition, use this check.
If(GetNumTerritoriesForPlayer(1) >= 3)
Then MarkTerritoryObjectiveComplete
GetNumberTerritoriesTributed
DidPlayerTributeTerritoryToOwner
Spoiler
bool DidPlayerTributeTerritoryToOwner(const char* in_szTerritoryName,
int in_iPreviousOwner)
Query to find out if the named territory was tributed to the current owner by the specified player. Returns true if it was, and false otherwise.

Strategic AI


GiveAttackBasePreference
Spoiler
// void GiveAttackBasePreference(int in_iPlayerID,
// const char *in_szAreaName, float in_priorityBoost)
// When playing with the strategic AI turned on, pass in
// the name of an area and a priority boost to make the player
// with id in_iPlayerID prefer attack targets in that area. The
// priority boost should be in the same scale as the
// AttackBase task priority from the AIP, so if that priority
// is 10, the priorityboost should be passed in as maybe 3
// or 4 to give a slight preference to that area
// example usage:
GiveAttackBasePreference(2, "DangerousArea", 3.0);
GiveDefendBasePreference
Spoiler
// void GiveDefendBasePreference(int in_iPlayerID,
// const char *in_szAreaName, float in_priorityBoost)
// When playing with the strategic AI turned on, pass in
// the name of an area and a priority boost to make the player
// with id in_iPlayerID prefer to defend in that area. The
// priority boost should be in the same scale as the
// DefendBase task priority from the AIP, so if that priority
// is 10, the priorityboost should be passed in as maybe 3
// or 4 to give a slight preference to that area
// example usage:
GiveDefendBasePreference(2, "HomeArea", 3.0);
GiveCaptureTerritoryPreference
Spoiler
// void GiveCaptureTerritoryPreference (int in_iPlayerID,
// const char *in_szTerritoryName, float in_priorityBoost)
// When playing with the strategic AI turned on, pass in
// the name of a territory and a priority boost to make the player
// with id in_iPlayerID prefer to capture that territory. The
// priority boost should be in the same scale as the
// DefendBase task priority from the AIP, so if that priority
// is 10, the priorityboost should be passed in as maybe 3
// or 4 to give a slight preference to that area
// example usage:
GiveCaptureTerritoryPreference (2, "Lawrence", 3.0);
GiveAttackArmyPreference
Spoiler
// void GiveAttackArmyPreference(int in_iPlayerID,
// const char* in_szTypeName, float in_priorityBoost)
// Gives the Strategic AI a preference to attack armies with units of
// this type in them. The priority boost should be in the same scale
// as the AttackArmy task priority from the AIP, so if that priority
// is 10, the priorityboost should be passed in as maybe 3
// or 4 to give a slight preference to that area
// example usage:
GiveAttackArmyPreference(2, "TradeCart", 3.0);

Airport & Airplane manipulations


AddAirMissionWayPoint
Spoiler
// add a way point to the specified airport mission, if the mission
// does not exist yet, this will
// create it; if the mission already exists, this will add to the way // point list
// note that in_missionNumber's range is 0-1
// void AddAirMissionWayPoint(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber, float in_waypointX, float in_waypointY;
example: AddAirMissionWayPoint("airport1", kAirMission_Strike, 0, 20, 30)
AddAirMissionWayPointArea
Spoiler
// add a way point (through area name) to the specified airport
// mission, if the mission does not exist yet, this will
// create it; if the mission already exists, this will add to the way
// point list
// note that in_missionNumber's range is 0-1
// void AddAirMissionWayPointArea(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber, const char *in_szAreaName;
example: AddAirMissionWayPoint("airport1", kAirMission_Strike, 0, "bombingArea")
CancelAirMission
Spoiler
// cancel the specified air mission (and remove all waypoints
// associated with it)
// void CancelAirMission(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber);
example: CancelAirMission ("airport1", kAirMission_Strike, 0)
AssignAirplaneToMission
Spoiler
// assign the specified airplanes to this mission (it is assumed that
// the airplanes is already garrisoned in the airport and the mission
// is active; otherwise it will do nothing)
// void AssignAirplaneToMission(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber, const char *in_szAirplaneUnitName) = 0;
example: AssignAirplaneToMission ("airport1", kAirMission_Strike, 0, "bomber2")

Economy Parameter Manipulation


The commands in this section can be used to query or manipulate the economy parameters for a player. All of these commands require a player and a resource type. Do not use gold as a resource type for any of these commands. It will result in an assert. Gold is never traded, all other resources are traded, and gold is used as the currency.

GetCurrentBuyPrice
Spoiler
int GetCurrentBuyPrice(int in_iPlayer, eResourceType in_eType)
GetCurrentSellPrice
Spoiler
int GetCurrentSellPrice(int in_iPlayer, eResourceType in_eType)
For a player, get the current price to buy or sell a particular resource type.
GetCurrentInflationRate
Spoiler
int GetCurrentInflationRate(int in_iPlayer, eResourceType in_eType)
GetCurrentDeflationRate
Spoiler
int GetCurrentDeflationRate(int in_iPlayer, eResourceType in_eType)
For a player, get the current inflation or deflation rate of a particular resource. When a player buys a resource, the buy and sell price for that resource increases by the inflation rate. When a player sells a resource, the buy and sell price decrease by the inflation rate.
GetCurrentMaxBuyPrice
Spoiler
int GetCurrentMaxBuyPrice(int in_iPlayer, eResourceType in_eType)
GetCurrentMinSellPrice
Spoiler
int GetCurrentMinSellPrice(int in_iPlayer, eResourceType in_eType)
For a player, get the current maximum buy price or minimum sell price for a particular resource. When buying a resource, the buy and sell price of the resource increase by the inflation rate once for each purchase. There is a maximum buy price that cannot be exceeded, however, and it is found via GetCurrentMaxBuyPrice. Similarly, prices decrease when selling a resource. You can find the minimum selling price with GetCurrentMinSellPrice.
SetBuyPrice
Spoiler
void SetBuyPrice(int in_iPlayer, eResourceType in_eType, int in_iValue)
SetSellPrice
Spoiler
void SetSellPrice(int in_iPlayer, eResourceType in_eType, int in_iValue)
For a player, set the buy or sell price of a particular resource to the specified value. This sets the price right now. The price will still increase or decrease with each sale according to the inflation or deflation rate.
NOTE: If you adjust either the buy price, or the sale price, you probably also want to adjust the other. Otherwise, you might inadvertently create a situation in which the sell price is higher than the buy price.
Example:
// Call this during the initialization phase of a script to make
// food cheap to buy to begin with for the player.
// This will make food cost 40 gold to buy, and allow the player
// to sell for 20.
SetBuyPrice(1, kResourceType_Food, 40);
SetSellPrice(1, kResourceType_Food, 20);
SetInflationRate
Spoiler
void SetInflationRate(int in_iPlayer, eResourceType in_eType,
int in_iValue)
SetDeflationRate
Spoiler
void SetDeflationRate(int in_iPlayer, eResourceType in_eType, int in_iValue)
For a player, set the inflation or deflation rate for a particular resource type. Inflation controls the amount that the buy and sell price go up when the player buys. Deflation controls the amount that the buy and sell price go down when the player sells. These should both be greater than or equal to zero. (Just for reference, the current default inflation and deflation rates are five.)
NOTE: The inflation and deflation rates should probably be the same value so that the buy and sell prices go up and down at the same rate. It could potentially lead to problems (like the sell price getting higher than the buy price) if you don't keep these the same for a particular resource for a particular player.
Example:
// Make the economy in wood very stable. A value of 1 will mean
// little change when buying or selling.
SetInflationRate(1, kResourceType_Wood, 1);
SetDeflationRate(1, kResourceType_Wood, 1);
SetMaxBuyPrice
Spoiler
void SetMaxBuyPrice(int in_iPlayer, eResourceType in_eType,
int in_iValue)
SetMinSellPrice
Spoiler
void SetMinSellPrice(int in_iPlayer, eResourceType in_eType,
int in_iValue)
For a player, set the max buy price, or the min sell price for a particular resource type. Inflation and deflation cause the prices to rise and fall as a player buys and sells. There are caps, though, and this lets you set those caps. I think the current default is something like a max buy price of 900, and a min sell price of 20.
NOTE: These can be set independently, but the max buy price should always be higher than the min sell price.
Example:
// Set a low ceiling for the price of stone. This will mean
// stone will get a little more expensive than the start value
// of 100, but it won't keep climbing forever.
SetMaxBuyPrice(1, kResourceType_Stone, 150);

Cinematics


StartPlayingCinematic
Spoiler
// void StartPlayingCinematic(const char *in_szCinematicName)
// Starts playing a cinematic.
// example usage:
StartPlayingCinematic("OpeningCredits");
DoDelayUntilCinematicTime
Spoiler
// void DoDelayUntilCinematicTime(float in_fMark, cIEScript *pIEScript)
// Delays the STEPping of the script until the currently playing
// cinematic has reached in_fMark seconds.
// example usage:
DoDelayUntilCinematicTime(5.0);
STEP
PrintSubtitle("Lead Programmer: Rex Bradford");
DoDelayUntilCinematicTime(7.5);
STEP
PrintSubtitle("Script Interface Programmer: Ben Morse");
DoDelayUntilCinematicFinished
Spoiler
// void DoDelayUntilCinematicFinished(cIEScript *pIEScript)
// Delays the STEPping of the script until the currently playing
// cinematic has finished.
// example usage:
DoDelayUntilCinematicFinished();
STEP
// Clean up
ClearSubtitle();
SetCinematicTime
Spoiler
// void SetCinematicTime(float in_fTime)
// Sets the cinematic time to in_fTime. You can use this to skip
// backwards in a cinematic or ffw towards the end. Be careful! Only
// use this when a cinematic is actually playing!
// example usage:
DEFINITIONS
bool bStartLoopingCinematic
bool bStopLoopingCinematic
END_DEFINITIONS

RULE StartLoopingCinematic
if (bStartLoopingCinematic && ALWAYS_EVALUATE)
then StartLoopingCinematic
END_RULE

ACTION StartLoopingCinematic
SCRIPT WORLD
// Don't start twice
bStartLoopingCinematic = false;
// Assume that someone else started the cinematic, and set
// bStartLoopingCinematic to true. We would put all the
// cinematic control code in here -

...

// Then, when we're about to hit the end of the cinematic:
// If nothing has set bStopLoopingCinematic, just jump back
// to the beginning!
SetCinematicTime(0);
if (!bStopLoopingCinematic) bStartLoopingCinematic = true;
END_SCRIPT
END_ACTION
PrintSubtitle
Spoiler
// void PrintSubtitle(const char *in_szMessage)
// Show a subtitle message during a cutscene. If there's already a
// message in the subtitle bar, clears it first.
// example usage:
PrintSubtitle("A long time ago, in a galaxy far, far away...");
ClearSubtitle
Spoiler
// void ClearSubtitle()
// Clears the subtitle bar.
// example usage:
// They've read that line long enough, let's leave it blank for a
// while
ClearSubtitle();
PrintFormattedSubtitle
Spoiler
// void PrintFormattedSubtitle()
// Prints the formatted message started with StartFormat() to the
// subtitle bar.
// example usage:
StartFormat("tx_t1_grocerylist");
// remember, I hate menthols
FormatString("ITEM", "tx_t1_cigarettes");
PrintFormattedSubtitle();
PlayBink
Spoiler
// void PlayBink(const char *in_szBinkVideoName)
// Plays back a .bik movie. Just drop it in the "Movies" folder.
// example usage:
// Once upon a time in Egypt...
PlayBink(CinematicEgypt3_Opening_1.bik)

UI/Visual Actions


Internationalized Message Formatting

StartFormat
Spoiler
// void StartFormat(const char *in_szTextDBEntry)
// Starts a formatted message. You must either PrintFormattedMessage()
// or PrintFormattedSubtitle() by the end of the STEP.
// example usage:
// use this particular token for the message we're about to send.
// in the DB, it looks like:
// "%PNAME%, the %CIV% king, demands %AMT% %RES% from you,
// on penalty of %PENALTY!%!"
StartFormat("tx_ex_kingdemands");
FormatPlayerName
Spoiler
// void FormatPlayerName(const char *in_szArgument, int in_iPlayerID)
// Formats in_szArgument to the name of player in_iPlayerID.
// example usage:
// The player name of player 2:
FormatPlayerName("PNAME", 2);
FormatPlayerCiv
Spoiler
// void FormatPlayerCiv(const char *in_szArgument, int in_iPlayerID)
// Formats in_szArgument to the civilization of player in_iPlayerID.
// example usage:
// His civilization:
FormatPlayerCiv("CIV", 2);
FormatInt
Spoiler
// void FormatInt(const char *in_szArgument, int in_iValue)
// Formats in_szArgument to a given integer value.
// example usage:
// Let's say he wants 100 gold
FormatInt("AMT", 100);
FormatFloat
Spoiler
// void FormatFloat(const char *in_szArgument, float in_fValue)
// Formats in_szArgument to a given floating-point value.
// example usage:
// We could also say he wants 100.0 gold, I guess:
FormatFloat("AMT", 100);
FormatEnum
Spoiler
// void FormatEnum(const char *in_szArgument,
// const char *in_szEnumName, int in_iValue)
// Formats in_szArgument to the descriptive name of a given
// enumeration. For instance, for 'Gold', you'd pass in "eResourceType"
// and kResourceType_Gold. For 'Military', you'd pass in "eCrownType"
// and kCrownType_Military.
// example usage:
// But he definitely wants gold, yeah.
FormatEnum("RES", "eResourceType", kResourceType_Gold);
FormatString
Spoiler
// void FormatString(const char *in_szArgument,
// const char *in_szTextDBEntry)
// Format in_szArgument to another string from the text DB.
// example usage:
// Let's be nice for the little kids in the audience
if (iDifficultyLevel > 1)
FormatString("PENALTY", "death");
else
FormatString("PENALTY", "tickling");
PrintFormattedMessage
Spoiler
void PrintFormattedMessage()
// Prints the formatted message started with StartFormat() to the
// main message window.
// example usage:
StartFormat("tx_t1_grocerylist");
// don't forget these
FormatString("ITEM", "tx_t1_nicotinepatch");
PrintFormattedMessage();
PrintMessage
Spoiler
void PrintMessage(const char *in_szMessage)
// prints a message to the screen. Currently just using the network
// chat widget. in_szMessage is the lookup for an internationalized
// message in the text DB.
// example usage:
PrintMessage("tx_k1_castleunderattack");
PrintFormattedMissionStatusString
Spoiler
void PrintFormattedMissionStatusString (int in_iStringID)
// Prints the formatted message into a status string which may be shown
// and hidden at a later time. This command otherwise behaves like
// PrintFormattedMessage, and must follow a call to StartFormat.
// When shown, the string is persistent and will remain on screen
// until hidden. This is unline messages, which disappear after a
// time. See the section "Create and update a status string" below
// for an example of use.
PrintMessageFromPlayer
Spoiler
void PrintMessageFromPlayer(const char* in_szMessage, int in_iPlayerID)
// Prints a chat message to the screen, and makes it appear as if it were a chat sent by the specified player.
// Send a custom taunt to the player.
PrintMessageFromPlayer( "tx_somecustomtaunt", PLAYER_ID );
ClearMessage
Spoiler
void ClearMessage()
// Clears the message window.
// example usage:
// All that stuff I printed about how every civilization in
// history is attacking us simultaneously is probably obscuring
// the battlefield a bit, so why don't I -
ClearMessage();
PIPSetBookmarkLocation
Spoiler
void PIPSetBookmarkLocation(int in_iPlayerID, int in_iBookmark,
// float in_fX, float in_fY, float in_fDistance)
// set the specified bookmark of the specified player to a location
// requirements:
// in_iPlayerID must specify a valid player
// in_iBookmark must be a valid bookmark number (1-6)
// in_fX, in_fY must specify a valid map location
// in_fDistance is the camera distance (0.0 to 1.0;
// 0.0 is most zoomed in, 1.0 is most zoomed out)
// example usage:
// set player 1's first bookmark to be the SW corner,
// at the closest-to-the-ground camera angle
PIPSetBookmarkLocation(1, 1, 0, 0, 0.0);
PIPSetBookmarkUnit
Spoiler
void PIPSetBookmarkUnit(int in_iPlayerID, int in_iBookmark, const char *in_szUnitName, float in_fDistance)
// set the specified bookmark of the specified player to a unit
// requirements:
// in_iPlayerID must specify a valid player
// in_iBookmark must be a valid bookmark number (1-6)
// in_szUnitName must refer to a valid named unit
// in_fDistance is the camera distance (0.0 to 1.0;
// 0.0 is most zoomed in, 1.0 is most zoomed out)
// example usage:
// Or we could look at this guy. max zoom out, please.
PIPSetBookmarkUnit(1, 1, "Fabio", 1.0);
PIPViewBookmark
Spoiler
// void PIPViewBookmark(int in_iBookmark)
// view the specified bookmark of the current player
// will have no effect if the bookmark is not set
// @NOTE viewing a specific bookmark will turn off cycling mode, so
// you should call PIPViewBookmark() BEFORE you call PIPCycleMode()
// requirements:
// in_iBookmark must be a valid bookmark number (1-6)
// example usage:
// So what's Fabio up to today?
PIPViewBookmark(1);
PIPCycleMode
Spoiler
// void PIPCycleMode(bool in_bCycle)
// turn on/off PIP cycle mode
// @NOTE viewing a specific bookmark will turn off cycling mode, so
// you should call PIPViewBookmark() BEFORE you call PIPCycleMode()
// example usage:
// you want the PIP to cycle:
PIPCycleMode(true);
// you don't want the PIP to cycle:
PIPCycleMode(false);
// rock on!
PIPEnable
Spoiler
// void PIPEnable(bool in_bEnable)
// turn PIP window on/off
// @NOTE current implementation changes the actual game setting for
// PIP on/off; this may not be desirable...
// example usage:
// turn PIP window on:
PIPEnable(true);
// turn PIP window off:
PIPEnable(false);
SetVisualStateOnUnit
Spoiler
virtual void Script_SetVisualStateOnUnit(const char *in_szUnitName, const char *in_szVisualStateName, float in_fStateLoopTime, EVisualLoopType in_eLoopType)
// Set state(visual) on a unit.
// example usage:
//Look busy, even if you're not
SetVisualStateOnUnit("OverworkedPeasant", "Harvesting",
0, eVISUAL_LOOP);
SetCameraLookAt
Spoiler
void SetCameraLookAt(float in_fX, float in_fY, bool in_bPIP)
// Move the game camera to look at location in_fX, in_fY.
// if in_bPIP is true, sets the pip camera instead of the main camera.
// Make the main camera look at the settlers in the southwest
SetCameraLookAt(10, 10, false);
SetCameraLookAtArea
Spoiler
void SetCameraLookAtArea(const char *in_szAreaName, bool in_bPIP)
// Move the game camera to look at area in_szAreaName.
// if in_bPIP is true, sets the pip camera instead of the main camera.
// Show the settlement area in the PIP
SetCameraLookAtArea("Settlement", true);
SetCameraHeading
Spoiler
void SetCameraHeading(float in_fAngle, bool in_bPIP)
// Set the camera's heading to in_fAngle (where in_fAngle is between
// 0 and 360). 0 is facing east, 90 is facing north, 180 is facing
// west, and 270 is facing south.
// if in_bPIP is true, sets the pip camera instead of the main camera.
// Show the settlement from the west facing east so we
// can see the sunrise or something
SetCameraHeading(0, true);
SetCameraDistanceFraction
Spoiler
void SetCameraDistanceFraction(float in_fFraction, bool in_bPIP)
// set the camera distance fraction. 0 is the minimum distance, 1 is
// the maximum zoom-out.
// if in_bPIP is true, sets the pip camera instead of the main camera.
// example usage:
// zoom all the way out to start
SetCameraDistanceFraction(1, false);
DebugOutputString
Spoiler
void DebugOutputString(const char *in_szDebugString)
// Place a string in the debug buffer.
// example usage:
DebugOutputString("At the DebugOutputString() call");
ClearDebugBuffer
Spoiler
void ClearDebugBuffer()
// Clear the debug buffer.
// example usage:
ClearDebugBuffer();
IsUnitBookMarked
Spoiler
// bool IsUnitBookMarked(const char* in_szUnitName)
// See if the specified unit is bookmarked by the PIP.
// example:
// Smile! You're on our hidden camera. Although, this
// might give the wrong idea. This function will return
// true if the unit is bookmarked on any pip button,
// even if the pip is currently viewing something else.
RULE
If(IsUnitBookMarked("Exhibitionist"))
Then DoSomethingNaughty
END_RULE
IsBookmarkSet

IsUnitSelectedUI
IsGroupSelectedUI
Spoiler
// bool IsUnitSelectedUI(const char* in_szUnitName)
// bool IsGroupSelectedUI(const char* in_szGroupName)
// Check if a particular unit or group is in the current UI
// selection. For the group function, all units in the
// group must be selected for it to return true.
// example:
// You could be really, really mean to the player:
RULE
If(IsUnitSelectedByPlayer("Bob"));
Then RemoveBobFromGame
END_RULE
IsWidgetVisible
Spoiler
// bool IsWidgetVisible(const char* in_szWidgetName)
// Check to see if a particular UI element is visible.
// Can be used to see which parts of the UI are in use.
// Speak to a programmer to determine the appropriate
// widget name for your purposes.
// Example:
// See if the player is looking at the citizen manager:
if(IsWidgetVisible("fullmap_citizenmanager"))
then DoSomething
SetWarPlanDeleteEnabled
SetWarPlanCopyEnabled
SetWarPlanSendToAlliesEnabled
Spoiler
void SetWarPlanDeleteEnabled(bool in_bEnabled)
void SetWarPlanCopyEnabled(bool in_bEnabled)
void SetWarPlanSendToAlliesEnabled(bool in_bEnabled)
These commands enable or disable specific widgets on the warplan manager. When the widget is disabled, it will be grayed out. The player will not be able to click on it, nor will the hotkey function. The widgets may still be flashed when disabled.
ShowMonthWidget
Spoiler
// bool ShowMonthWidget(bool in_bShow)
// Show or hide the widget that displays the current month
// in text form.
// Example:
// Show the widget that displays the current month
ShowMonthWidget(true)
// Hide the widget that displays the current month
ShowMonthWidget(false)
IsUserPlacingType
Spoiler
// bool IsUserPlacingType(const char* in_szUnitTypeName)
// Is the user presently using the mouse to place a unit of the
// specified type name. Returns true if she is, false if
// she isn't.
// Example:
// For a tutorial, play some VO when the user starts to place a
// city center.
RULE isPlacingCityCenter
if(IsUserPlacingType("CityCenter"))
then PlayTutorialVO
END_RULE
HasTextBeenTyped
Spoiler
// bool HasTextBeenTyped( const char *in_szText)
// Check and see if the specified text has been typed into
// the chat box during the current game. Note that this check
// is case insensitive. Therefore if you are checking for "BAR"
// and "bar" had been typed into the chat box, true would be
// returned.
// Example:
// is steve rocking?
if( HasTextBeenTyped("steve is rocking") )
then playSomeRockingMusic

PS: Since this command does not work as described here, Dr. Mona Lisa has described here a solution how this script command can still work.

viewtopic.php?t=5421
SuppressTerritoryMessages
Spoiler
// void SuppressTerritoryMessages(bool in_bSuppressMessages)
// Call this function and pass true to stop all messages normally
// generated when territories change ownership. Call it and pass
// false to allow messages to happen again.
// Call this in the initialization section of a script
// to disable territory messages for the whole game.
SuppressTerritoryMessages(true);


Mission Objectives


============ .ddf SETUP ===========

Each objective is now defined in its own block outside of the scenario definition for each scenario in a .ddf file. The objective definitions must come before the scenario definition, and must have unique names across all scenarios (hence, a suggested naming convention of "American1_Objective1" or "American1_ObjPrimary1" etc.) In the scenario definition, in the objectives = [ ... part, all objectives you wish to include must be referenced by name. These objectives will be read in as is when the scenario first starts.

A typical objective definition will look something like this:

Code: Select all

	Objective Tutorial1_Objective1 {
		name		= text_scen_tut1_explanation
		description	= text_scen_tut1_explanation
		type		= Primary
		startHidden	= 0
	}
Note that there are separate name and description fields; the name should be pretty short, whereas the description can be as long as you want. the type file can be Primary, Secondary, or Lose startHidden can be 0 (to start unlocked) or 1 (to start hidden)

Optionally, you can specify target locations, named target units, named target areas, and named target territories from the .ddf, inside the objective definition for a particular objective target locations look like this:

Code: Select all

	Objective Tutorial1_Objective1 {
		... 
		targetLocations = [ 	{ x = 10 y = 10 }
					{ x = 20 y = 10 }
					{ x = 10 y = 20 }
		]
	}
Target named units look like this:

Code: Select all

	Objective Tutorial1_Objective1 {
		... 
		targetUnits = [ 	"Jesus" "Jesus2000"	]
	}
Target areas and target territories are predictably similar, only using the field names targetAreas and targetTerritories.

@IMPORTANT target locations must specify valid locations on the map

@IMPORTANT target named units, areas, etc. must specify valid
named entities which have been named at load, ie you set the names in the editor rather than in the script. If you wish to target named entities which you name in script, you will have to use one of the lovely script functions for that purpose.


============ OVERVIEW ===========

When a scenario starts, all the objectives for that scenario will be loaded, and all that aren't supposed to start hidden are unlocked. The first not-hidden primary objective will appear in the scenario objective dialog box, which is the best thing ever and shows you the description of the objective, and if the objective has any target locations, units, etc. allows you to cycle through those locations in the world, and also allows you to jump to the objectives pane on the fullmap and hilite
the objective which is in the dialog.

Each objective is always in exactly one of four states:
1.) hidden (aka locked, aka inactive)
2.) unlocked (aka active, aka shown)
3.) completed
4.) failed

The allowable transitions are depicted below:

PRIMARY/SECONDARY:
<==> completed
hidden <==> unlocked
==> failed

LOSE CONDITIONS:

hidden <==> unlocked ==> failed

@NOTE please note that currently, you are not allowed to mark an objective as hidden once you have completed or failed it.

All state transitions are specified by the designer in the script when an objective becomes unlocked, the scenario objective dialog will automatically open (or, if open, its current contents will be overridden by) the newly unlocked objective. When an objective is completed or failed, it will be marked thusly on the fullmap objectives screen, but currently there are no other automatic notifications in the UI.


============ DIALOG BOX ===========

It is also worth noting that the tutorial dialog box has gone away, and the scenario objective dialog box has replaced it. There is a separate script function CreateDialogBox() which will open the scenario objective dialog to display text of your choosing, rather than the text for an objective

@NOTE if the dialog is already open (eg displaying a newly unlocked objective) opening the dialog will overwite the contents of the dialog

@NOTE you must specify a title for the dialog box (if you leave it as NULL, a default will be used, but it is something stupid like "Script Update!")

Dialog box

CreateDialogBox
Spoiler
// void CreateDialogBox(const char *in_szTitle,
// const char* in_szDisplayText,
// bool in_bPauseGame)
// show text in the scenario objective dialog box
// @NOTE this uses the scenario objective dialog box, so it will
// overwrite the current contents of the dialog box
// in_szTitle is title text entry in the text database
// (or NULL for default title)
// in_szDisplayText is text entry in the text database
// if in_bPauseGame is specified, this will pause the game
// example usage:
CreateDialogBox("tx_mydialog_title", "tx_mydialog_description"
true);
CreateObjectiveDialogBox
Spoiler
// void CreateObjectiveDialogBox(const char *in_szObjectiveName,
// bool in_bPauseGame)
// open scenario objective dialog box for the specified objective
// (or, if the scenario objective dialog box is already open, either
// for displaying text ala CreateDialogBox() or for displaying another
// objective, it will overwrite the current contents of the dialog)
// in_szObjectiveName must specify a valid objective
// if in_bPauseGame is specified, this will pause the game
// example usage:
CreateObjectiveDialogBox ("Tutorial1_Objective1", false);
IsObjectiveDialogBoxOpen
Spoiler
// bool IsObjectiveDialogBoxOpen()
// query whether or not the objective dialog box is open
// @NOTE because the same dialog box is used for both CreateDialogBox()
// and CreateObjectiveDialogBox(), this will return true if the dialog
// box is open for either of those purposes
// example usage:
RULE Example ONESHOT
if (IsObjectiveDialogBoxOpen()
)
then
...
END_RULE
SetAllowObjectiveDialogInEncyclopedia
Spoiler
// void SetAllowObjectiveDialogInEncyclopedia(bool in_bAllow)
// set to allow/disallow objective dialog box in the encyclopedia
// @HACK HACK this is just a tutorial hack, please don't use this if
// you don't have to. You should call this before opening the
// objective dialog box on the encyclopedia screen

// example usage:
SetAllowObjectiveDialogInEncyclopedia(true);
Query the state of individual objectives

IsObjectiveCompleted
Spoiler
// bool IsObjectiveCompleted(const char *in_szObjectiveName)
// returns true if objective in_iObjectiveIndex has been completed.
// in_szObjectiveName must specify a valid objective
IsObjectiveFailed
Spoiler
// bool IsObjectiveFailed(const char *in_szObjectiveName)
// Returns true if the objective has been failed.
// in_szObjectiveName must specify a valid objective
IsObjectiveUnlocked
Spoiler
// bool IsObjectiveUnlocked(const char *in_szObjectiveName)
// returns true if objective in_iObjectiveIndex has been unlocked.
// in_szObjectiveName must specify a valid objective
// example usage:
RULE Example ONESHOT
if (IsObjectiveCompleted("Tutorial1_Objective1") &&
!IsObjectiveUnlocked("Tutorial1_Objective2")
)
then
...
END_RULE
Query the state all objectives

AllPrimaryObjectivesCompleted
Spoiler
// bool AllPrimaryObjectivesCompleted()
// returns true if ALL primary objectives have been completed
AllSecondaryObjectivesCompleted
Spoiler
// bool Script_AllSecondaryObjectivesCompleted()
// returns true if ALL secondary objectives have been completed
AnyPrimaryObjectivesFailed
Spoiler
// bool Script_AnyPrimaryObjectivesFailed()
// returns true if ANY primary objectives have been failed
AnyLoseConditionsFailed
Spoiler
// bool Script_AnyLoseConditionsFailed()
// returns true if ANY lose conditions have been failed
// example usage:
RULE Example ONESHOT
if (AllPrimaryObjectivesCompleted()
)
then
...
END_RULE
Change objective state

SetObjectiveUnlocked
Spoiler
// void SetObjectiveUnlocked(const char *in_szObjectiveName)
// unlock (ie. activate, un-hide, show, whatever) this objective
// in_szObjectiveName must specify a valid objective
// @NOTE you can only unlock hidden objectives
SetObjectiveLocked
Spoiler
// void SetObjectiveLocked(const char *in_szObjectiveName)
// lock (ie. inactivate, hide, whatever) this objective
// in_szObjectiveName must specify a valid objective
// @NOTE you can only lock unlocked (not completed or failed)
// objectives
SetObjectiveCompleted
Spoiler
// void SetObjectiveCompleted(const char *in_szObjectiveName)
// Mark the objective in_iObjectiveIndex as completed.
// in_szObjectiveName must specify a valid objective
// @NOTE you can only mark unlocked, unfailed objectives as completed
SetObjectiveNotCompleted
Spoiler
// void SetObjectiveNotCompleted(const char *in_szObjectiveName)
// Mark the objective in_iObjectiveIndex as NOT completed, after having
// in_szObjectiveName must specify a valid objective
// @NOTE you can only mark completed objectives as not completed
// @NOTE you cannot mark lose conditions as completed
SetObjectiveFailed
Spoiler
// void SetObjectiveFailed(const char *in_szObjectiveName)
// Mark the objective as failed
// in_szObjectiveName must specify a valid objective
// @NOTE you can only mark unlocked, not completed objectives as failed

// example usage:
SetObjectiveCompleted("Tutorial1_Objective1");
Misc changes to objectives

ChangeObjectiveDescription
Spoiler
// void ChangeObjectiveDescription(const char *in_szObjectiveName,
// const char *in_szDescriptionText)
// change the objective description text
// in_szObjectiveName must specify a valid objective
// in_szDescriptionText must specify a valid text database entry

// example usage:
ChangeObjectiveDescription ("Tutorial1_Objective1",
"text_scen_tut1_explanation2");
ObjectiveClearAllTargets
Spoiler
// void ObjectiveClearAllTargets(const char *in_szObjectiveName)
// clear all targets (locations, units, areas, and territories) for
// this objective
// in_szObjectiveName must specify a valid objective

// example usage:
ObjectiveClearAllTargets ("Tutorial1_Objective1");
Edit target locations for an objective

ObjectiveSetTargetLocation
Spoiler
// void ObjectiveSetTargetLocation(const char *in_szObjectiveName,
// float in_fX, float in_fY)
// set to target a single location
// in_szObjectiveName must specify a valid objective
// (in_fY, in_fX) must specify a valid map location
// example usage:
ObjectiveSetTargetLocation ("Tutorial1_Objective1", 10, 15);
ObjectiveAddTargetLocation
Spoiler
// void ObjectiveAddTargetLocation(const char *in_szObjectiveName,
// float in_fX, float in_fY)
// add a target location
// in_szObjectiveName must specify a valid objective
// (in_fY, in_fX) must specify a valid map location
// example usage:
ObjectiveSetTargetLocation ("Tutorial1_Objective1", 10, 15);
ObjectiveRemoveTargetLocation
Spoiler
// bool ObjectiveRemoveTargetLocation(const char *in_szObjectiveName,
// float in_fX, float in_fY)
// remove a target location
// in_szObjectiveName must specify a valid objective
// (in_fY, in_fX) must specify a valid map location
// returns true if the location was removed, false if not found
// example usage:
ObjectiveRemoveTargetLocation ("Tutorial1_Objective1", 10, 15);
ObjectiveClearTargetLocations
Spoiler
// void ObjectiveClearTargetLocations(const char *in_szObjectiveName)
// remove all target locations
// in_szObjectiveName must specify a valid objective
// example usage:
ObjectiveClearTargetLocations ("Tutorial1_Objective1");
Edit target units for an objective

ObjectiveSetTargetUnit
Spoiler
// void ObjectiveSetTargetUnit(const char *in_szObjectiveName,
// const char *in_szUnitName)
// set to target a single named unit
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named unit
// example usage:
ObjectiveSetTargetUnit ("Tutorial1_Objective1", "Jesus");
ObjectiveAddTargetUnit
Spoiler
// void ObjectiveAddTargetUnit(const char *in_szObjectiveName,
// const char *in_szUnitName)
// add a target named unit
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named unit
// example usage:
ObjectiveAddTargetUnit ("Tutorial1_Objective1", "Jesus");
ObjectiveRemoveTargetUnit
Spoiler
// bool ObjectiveRemoveTargetUnit(const char *in_szObjectiveName,
// const char *in_szUnitName)
// remove a target named unit
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named unit
// returns true if the unit was removed, false if not found
// example usage:
ObjectiveRemoveTargetUnit ("Tutorial1_Objective1", "Jesus");
ObjectiveClearTargetUnits
Spoiler
// void ObjectiveClearTargetUnits(const char *in_szObjectiveName)
// remove all target named units
// in_szObjectiveName must specify a valid objective
// example usage:
ObjectiveClearTargetUnits ("Tutorial1_Objective1");
Edit target areas for an objective

ObjectiveSetTargetArea
Spoiler
// void ObjectiveSetTargetArea(const char *in_szObjectiveName,
// const char *in_szAreaName)
// set to target a single named area
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named area
// example usage:
ObjectiveSetTargetArea ("Tutorial1_Objective1", "Bethlehem");
ObjectiveAddTargetArea
Spoiler
// void ObjectiveAddTargetArea(const char *in_szObjectiveName,
// const char *in_szAreaName)
// add a target named area
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named area
// example usage:
ObjectiveAddTargetArea ("Tutorial1_Objective1", "Bethlehem");
ObjectiveRemoveTargetArea
Spoiler
// bool ObjectiveRemoveTargetArea(const char *in_szObjectiveName,
// const char *in_szAreaName)
// remove a target named area
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named area
// returns true if the area was removed, false if not found
// example usage:
ObjectiveRemoveTargetArea ("Tutorial1_Objective1", "Bethlehem");
ObjectiveClearTargetAreas
Spoiler
// void ObjectiveClearTargetAreas(const char *in_szObjectiveName)
// remove all target named areas
// in_szObjectiveName must specify a valid objective
// example usage:
ObjectiveClearTargetAreas ("Tutorial1_Objective1");
Edit target territories for an objective

ObjectiveSetTargetTerritory
Spoiler
// void ObjectiveSetTargetTerritory(const char *in_szObjectiveName,
// const char *in_szTerritoryName)
// set to target a single named territory
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named territory
// example usage:
ObjectiveSetTargetTerritory ("Tutorial1_Objective1",
"FieryInferno");
ObjectiveAddTargetTerritory
Spoiler
// void ObjectiveAddTargetTerritory(const char *in_szObjectiveName,
// const char *in_szTerritoryName)
// add a target named territory
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named territory
// example usage:
ObjectiveAddTargetTerritory ("Tutorial1_Objective1",
"FieryInferno");
ObjectiveRemoveTargetTerritory
Spoiler
// bool ObjectiveRemoveTargetTerritory(const char *in_szObjectiveName,
// const char *in_szTerritoryName)
// remove a target named territory
// in_szObjectiveName must specify a valid objective
// in_szUnitName must specify a valid named territory
// returns true if the territory was removed, false if not found
// example usage:
ObjectiveRemoveTargetTerritory ("Tutorial1_Objective1",
"FieryInferno");
ObjectiveClearTargetTerritories
Spoiler
// void ObjectiveClearTargetTerritories(const char *in_szObjectiveName)
// remove all target named territories
// in_szObjectiveName must specify a valid objective
// example usage:
ObjectiveClearTargetAreas ("Tutorial1_Objective1");
Last edited by Loewenherz on 22 May 2022, 11:30, edited 11 times in total.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: List of all IES script commands for scenarios in EE2 and EE2X

Post by Loewenherz »

Selection Manipulation

SelectUnit
Spoiler
// bool SelectUnit(const char *in_szUnitName)
// Adds a unit to the current selection for giving an order to.
// Returns true so it can be used in Rules.
// example usage:
//Select the unit that I created in the
//CreateUnitAtLocation example above
SelectUnit("JamesBond");
SelectGroup
Spoiler
// bool SelectGroup(const char *in_szGroupName)
// Adds the units in the group in_szGroupName to the current selection
// for giving an order to.
// Returns true so it can be used in Rules.
// example usage:
//Pretend I created a group of all my available citizens,
//and now I'm going to select them and tell them to
//kill JamesBond!
SelectGroup("AvailableCitizens");
AttackWithSelection("JamesBond");
SelectGroupForPlayer
Spoiler
// bool SelectGroupForPlayer(const char* in_szGroupName,
// int in_iPlayerID)
// Select all units in the group that belong to the specified player.
// This is good if you have a group that will be around for a while
// and some of the units in the group might be converted by another
// player. Converting a unit does not remove it from a group, and if
// you try to select a group that has units belonging to multiple
// players, it will cause a crash.
// This command will work fine for a group with units that all
// belong to the same player, so you can just always use this command
// if you want to be safe.
// Returns true so it can be used in Rules.
// Select units that may have been converted by the human player.
SelectGroupForPlayer("WeakMindedFools", 2);
ClearSelection
Spoiler
// bool ClearSelection()
// Clears the current selection manually. There really isn't a reason
// you should need to use this, as all the operations that work on
// selections clear the selection when they're done, but it's provided
// in case something weird pops up.
// Returns true so it can be used in Rules.
// example usage:
ClearSelection();
Group Manipulation

You will notice that all the group manipulation functions are boolean. They always return true, for ease of insertion into a rule. Obviously, this is computationally expensive, and you should mitigate it by having a PERIODICITY parameter and bool variable that you check first.

This is what the whole deal would look like:

Code: Select all

DEFINITIONS
     bool bWhatever
END_DEFINITIONS

INITIALIZATION
     bwhatever = FALSE
END_INITIALIZATION

RULE ONESHOT PERIODICITY 3
if (!bWhatever &&
    CreateNamedGroup("DudesOnMyLawn") &&
    AddUnitsByAttributeToGroup("DudesOnMyLawn", "MobileUnits", 2,
        kPlayerMode_Enemies, "MyLawn") &&
    (NumUnitsInGroup("DudesOnMyLawn") > 0) )
then CallTheCops
END_RULE

CreateNamedGroup
Spoiler
// bool CreateNamedGroup(const char *in_szGroupName)
// Define objects as a group
// Creates a group named in_szGroupName. If one already exists, this
// clears it out.
// example usage:
CreateNamedGroup("DudesOnMyLawn");
AddUnitToGroup
RemoveUnitFromGroup
Spoiler
// bool AddUnitToGroup(const char *in_szGroupName,
// const char *in_szUnitName)
// bool RemoveUnitFromGroup(const char *in_szGroupName,
// const char *in_szUnitName)
// Adds/Removes the unit named in_szUnitName to the group
// in_szGroupName.
// example usage:
AddUnitToGroup("Spies", "JamesBond");
AddGroupToGroup
RemoveGroupFromGroup
Spoiler
// bool AddGroupToGroup(const char *in_szGroupTo,
// const char *in_szGroupFrom)
// bool RemoveGroupFromGroup(const char *in_szGroupTo,
// const char *in_szGroupFrom)
// Adds/Removes all the units in in_szGroupFrom to the group
// in_szGroupTo.
// example usage:
//copy the units from the three special battalions into
//the 'final strike' wave
AddGroupToGroup("FinalStrike", "SpecialBattalion1");
AddGroupToGroup("FinalStrike", "SpecialBattalion2");
AddGroupToGroup("FinalStrike", "SpecialBattalion3");
//but remove the wounded guys that we selected earlier
//because they can't come along, or something
RemoveGroupFromGroup("FinalStrike", "Wounded");
RemoveGarrisonedUnitsFromGroup
Spoiler
RemoveGarrisonedUnitsFromGroup("TroopsToMove");
// Removes all units which are garrisoned from the group. Use this before any kind of SelectGroup(); a script error comes up if you try to Select() a garrisoned unit.
AddUnitsByAttributeToGroup
RemoveUnitsByAttributeFromGroup
Spoiler
// bool AddUnitsByAttributeToGroup(const char *in_szGroupName,
// const char *in_szAttributeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// bool RemoveUnitsByAttributeFromGroup(const char *in_szGroupName,
// const char *in_szAttributeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// Adds all units that meet the criteria specified in
// in_szAttributeName to in_szGroupName. If in_szAreaName is not NULL,
// this further constrains the added units to ones that are in the
// specified area only.
// example usage:
//This will add all mobile units that belong to players that are
//enemies of player 2 to the group "DudesOnMyLawn".
AddUnitsByAttributeToGroup("DudesOnMyLawn",
"MobileUnits", 2, kPlayerMode_Enemies, "MyLawn");
//But pretend for some reason we want to allow animals from
//player 5 in. Note that since DudesOnMyLawn already only has
//units in the MyLawn area in it right now, we don't need to
//specify an area for this remove step.
RemoveUnitsByAttributeFromGroup("DudesOnMyLawn",
"Animals", 5, kPlayerMode_Self, NULL);
AddUnitsByTypeToGroup
RemoveUnitsByTypeFromGroup
Spoiler
// bool AddUnitsByTypeToGroup(const char *in_szGroupName,
// const char *in_szUnitTypeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// bool RemoveUnitsByTypeFromGroup(const char *in_szGroupName,
// const char * in_szUnitTypeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// Adds all units OF THE SPECIFIC UNIT TYPE (not UnitTypeAttribute!)
// in_szUnitTypeName that match the in_iPlayerID and in_iPlayerMode to
// in_szGroupName. If in_szAreaName is not NULL, this further
// constrains the added units to ones that are in the specified area
// only.
// example usage:
//This will add all MALE citizens that belong to player 1
//to the group "Homies".
AddUnitsByTypeToGroup("Homies", "CitizenM",
1, kPlayerMode_Self, NULL);
AddDeadUnitsByAttributeToGroup
AddDeadUnitsByTypeToGroup
Spoiler
// bool AddDeadUnitsByAttributeToGroup(const char *in_szGroupName,
// const char *in_szAttributeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// bool AddDeadUnitsByTypeToGroup(const char *in_szGroupName,
// const char *in_szUnitTypeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// Same as the above but for dead units. Note that rules checking for
// dead units should be evaluated at every 2-3 seconds,
// otherwise there's a chance that the dead unit might be removed from
// the world before the rule gets a chance to fire.
// example usage:
// This fires when any unit from player 1 matching the attribute
// "NavalUnits" dies in the area named "InternationalWaters".
RULE ShipDiesInInternationalWaters ONESHOT
if (CreateNamedGroup("DeadInternationalShips") &&
AddDeadUnitsByTypeToGroup("DeadInternationalShips", "NavalUnits",
1, kPlayerMode_Self,
"InternationalWaters") &&
NumUnitsInGroup("DeadInternationalShips") > 0)
then AShipWasKilledInInternationalWaters
END_RULE
AddUnitsInCityToGroup
RemoveUnitsInCityFromGroup
Spoiler
// bool AddUnitsInCityToGroup(const char* in_szGroupName,
// const char* in_szAttributeName,
// int in_iPlayerID,
// ePlayerMode in_ePlayerMode,
// const char* in_szCityName)
// Add units within the city to the specified group. It examines all
// units within the area of the city. Any that match the criteria
// of in_szAttributeName and the player information are added to the
// specified group. in_szCityName is the name of a CityCenter unit
// that is the center of the city that you'd like to select.
// RemoveUnitsInCityFromGroup() works the same way, but removes those
// units from the group.
// This adds all mobile units in Boston that belong to Player
// 1 to the group "Urbanites".
AddUnitsInCityToGroup("Urbanites",
"Mobile", 1, kPlayerMode_Self, "Boston");
// But we don't want any civilians in our group, so remove them
// from the group.
RemoveUnitsInCityFromGroup("Urbanites ",
"Citizens", 1, kPlayerMode_Self, NULL);
AddUnitsByAttributeToGroupFromTerritory
RemoveUnitsByAttributeFromGroupFromTerr
Spoiler
// bool AddUnitsByAttributeToGroupFromTerritory(
// const char *in_szGroupName, const char *in_szAttributeName,
// int in_iPlayerID, ePlayerMode in_ePlayerMode,
// const char *in_szTerritoryName)
// bool RemoveUnitsByAttributeFromGroupFromTerritory(
// const char *in_szGroupName, const char *in_szAttributeName,
// int in_iPlayerID, ePlayerMode in_ePlayerMode,
// const char *in_ szTerritoryName)
// Adds or removes all units that meet the criteria specified in
// in_szAttributeName to in_szGroupName as long as they are in the
// specified territory.
// example usage:
//This will add all mobile units that belong to players that are
//enemies of player 2 to the group "DudesOnMyLawn".
AddUnitsByAttributeToGroupFromTerritory ("DudesOnMyLawn",
"MobileUnits", 2, kPlayerMode_Enemies, "MyLawn");
//But pretend for some reason we want to allow animals from
//player 5 in.
RemoveUnitsByAttributeFromGroupFromTerritory ("DudesOnMyLawn",
"Animals", 5, kPlayerMode_Self, "MyLawn");
AddUnitsByTypeToGroupFromTerritory
RemoveUnitsByTypeFromGroupFromTerritory
Spoiler
// bool AddUnitsByTypeToGroupFromTerritory(const char *in_szGroupName,
// const char *in_szUnitTypeName, int in_iPlayerID,
// ePlayerMode in_ePlayerMode, const char *in_szAreaName)
// bool RemoveUnitsByTypeFromGroupFromTerritory (
// const char *in_szGroupName, const char * in_szUnitTypeName,
// int in_iPlayerID, ePlayerMode in_ePlayerMode,
// const char *in_szAreaName)
// Adds all units OF THE SPECIFIC UNIT TYPE (not UnitTypeAttribute!)
// in_szUnitTypeName that match the in_iPlayerID and in_iPlayerMode to
// in_szGroupName as long as they are in the specified territory.
// example usage:
//This will add all MALE citizens that belong to player 1
//to the group "Homies", if they are in the territory "ThaHood".
AddUnitsByTypeToGroupFromTerritory ("Homies", "CitizenM",
1, kPlayerMode_Self, "ThaHood");
AddUnitsByAttributeInLOSToGroup
RemoveUnitsByAttributeInLOSFromGroup
AddUnitsByTypeInLOSToGroup
RemoveUnitsByTypeInLOSFromGroup
Spoiler
// bool AddUnitsByAttributeInLOSToGroup(int in_iPlayerWhoSeesID,
// const char* in_szGroupName, const char* in_AttributeName,
// int in_iPlayerWhoControlsID)
// bool AddUnitsByTypeInLOSToGroup(int in_iPlayerWhoSeesID,
// const char* in_szGroupName, const char* in_AttributeName,
// int in_iPlayerWhoControlsID)
// bool RemoveUnitsByAttributeInLOSFromGroup(int in_iPlayerWhoSeesID,
// const char* in_szGroupName, const char* in_AttributeName,
// int in_iPlayerWhoControlsID)
// bool RemoveUnitsByTypeInLOSFromGroup(int in_iPlayerWhoSeesID,
// const char* in_szGroupName, const char* in_AttributeName,
// int in_iPlayerWhoControlsID)
// These functions are all similar. They all either add or remove
// units to a group depending on whether they can be seen by a
// specified player.
// in_iPlayerWhoSeesID is the ID of the player whose LOS we care
// about. Units will only be added to or subtracted from a group
// if in_iPlayerWhoSeesID can see them.
// in_iPlayerWhoControlsID is the ID of the player that owns the units
// to be added or removed. Only units belonging to
// in_iPlayerWhoControlsID will be added to or removed from the group.
// The other two parameters are pretty straightforward. One is the
// the name of the group in question. The other is the name of the
// attribute or type that will be used to get a more fine selection of
// units.
// example:
// This is something I know some of you are waiting for. You
// want to count the total number of units seen by an AI player,
// and do something when there are too many. Player 1 is the
// human player, player 2 is the AI that the human is trying to
// hide his army from. The computer attacks when it knows the
// human has an army of size 10 or more.
RULE ruleLookForMilitary ONESHOT
if(iEverySecond
&& AddUnitsByAttributeInLOSToGroup(2, "HumanArmy",
"MilitaryUnits", 1)
&& NumUnitsInGroup("HumanArmy") >= 10)
then actionLookForMilitary
END_RULE
PlayerHasLOSToAnyoneInGroup
Spoiler
// bool PlayerHasLOSToAnyoneInGroup(int in_iPlayerID,
// const char *in_szGroupName)
// returns true if player in_iPlayerID can see anyone
// in the group in_szGroupName.
// example usage:
// If player(x) has LOS to group(y) - anybody
if (PlayerHasLOSToAnyoneInGroup(x, "y") )
// If player(x) has LOS to any unit owned by player(y)
if (CreateGroup("dudes") &&
AddUnitsByAttributeToGroup("dudes", "Anything", y,
kPlayerMode_Self, NULL) &&
PlayerHasLOSToAnyoneInGroup(x, "dudes") )
// If player(x) has LOS to named building\unit
if (CreateGroup("dudes") &&
AddUnitToGroup("dudes", "named_unit") &&
PlayerHasLOSToAnyoneInGroup(x, "dudes") )
UnitHasLOSToAnyoneInGroup
Spoiler
// bool UnitHasLOSToAnyoneInGroup(const char *in_szUnitName,
// const char *in_szGroupName)
// returns true if unit in_szUnitName can see anyone in the
// group in_szGroupName.
// example usage:
// If named building\unit has LOS to player(x)
if (CreateGroup("dudes") &&
AddUnitsByAttributeToGroup("dudes", "Anything", x,
kPlayerMode_Self, NULL) &&
UnitHasLOSToAnyoneInGroup("named_unit", "dudes") )
GroupHasLOSToAnyoneInGroup
Spoiler
// bool GroupHasLOSToAnyoneInGroup(const char *in_szWatchers,
// const char *in_szTargets)
// returns true iff anyone in the group in_szWatchers can see anyone in
// in_szTargets. This is crazy slow. You don't want to do this that
// often.
// This fires when any unit from player 1 matching the attribute
// "NavalUnits" dies in the LOS of any "Dock"-type unit from
// player 2.
RULE DocksSeeDeadPeople ONESHOT
if (CreateNamedGroup("MyDeadShips") &&
AddDeadUnitsByTypeToGroup("MyDeadShips", "NavalUnits", 1, kPlayerMode_Self, NULL) &&
CreateNamedGroup("EnemyDocks") &&
AddUnitsByTypeToGroup("EnemyDocks", "Dock", 2, kPlayerMode_Self, NULL) &&
GroupHasLOSToAnyoneInGroup("EnemyDocks", "MyDeadShips"))
then TheySawYourShipDie
END_RULE
NamedUnitIsInArea
NamedUnitIsInTerritory
Spoiler
// bool NamedUnitIsInArea(const char *in_szUnitName,
// const char *in_szAreaName)
// bool NamedUnitIsInTerritory(const char *in_szUnitName,
// const char *in_szTerritoryName)
// Returns true iff the unit named in_szUnitName is in in_szAreaName,
// or in in_szTerritoryName, depending on the command used.
// example usage:
//trigger when bond walks into the trap
if (NamedUnitIsInArea("JamesBond", "HiddenSpikePit") ...
AnyoneFromGroupIsInArea
AnyoneFromGroupIsInTerritory
Spoiler
// bool AnyoneFromGroupIsInArea(const char *in_szGroupName,
// const char *in_szAreaName)
// bool AnyoneFromGroupIsInTerritory(const char *in_szGroupName,
// const char *in_szTerritoryName)
// Returns true iff ONE OR MORE units from in_szGroupName are in
// in_szTerritoryName. Will return false if in_szGroupName is empty, // or doesn't exist!
// example usage:
//If any of the recon droids get on your lawn, you're toast
if (AnyoneFromGroupIsInArea("ReconDroids", "SecretBase") ...
EveryoneFromGroupIsInArea
EveryoneFromGroupIsInTerritory
Spoiler
// bool EveryoneFromGroupIsInArea(const char *in_szGroupName,
// const char *in_szAreaName)
// bool EveryoneFromGroupIsInTerritory(const char *in_szGroupName,
// const char *in_szTerritoryName)
// Returns true iff EVERY SINGLE unit from in_szGroupName is in
// in_szTerritoryName. Will return false if in_szGroupName is empty, // or doesn't exist!
// example usage:
//If you can fight the enemy dudes back to the border, you win
if (EveryoneFromGroupIsInArea("BadDudes", "BehindBorder") ...
AddToControlGroupFromGroup
Spoiler
// void AddToControlGroupFromGroup(const char *in_szGroupName,
// int in_iPlayerID, int in_iControlGroupNumber)
// Adds the group named in_szGroupName to one of in_iPlayerID's control
// groups. in_iControlGroupNumber must be between 0 and 9 inclusive.
// example usage:
// Actually, put all the female citizens in there too
CreateNamedGroup("CitzF");
AddUnitsByTypeToGroup("CitzF", "CitizenF", 1,
kPlayerMode_Self, NULL);
AddToControlGroupFromGroup("CitzF", 1, 0);
SetControlGroupFromGroup
Spoiler
// void SetControlGroupFromGroup(const char *in_szGroupName,
// int in_iPlayerID, int in_iControlGroupNumber)
// Adds the group named in_szGroupName to one of in_iPlayerID's control
// groups. in_iControlGroupNumber must be between 0 and 9 inclusive.
// example usage:
// Put all my male citizens in control group zero
CreateNamedGroup("CitzM");
AddUnitsByTypeToGroup("CitzM", "CitizenM", 1,
kPlayerMode_Self, NULL);
SetControlGroupFromGroup("CitzM", 1, 0);
ClearControlGroup
Spoiler
// void ClearControlGroup(int in_iPlayerID, int in_iControlGroupNumber)
// Clears one of in_iPlayerID's control groups.
// in_iControlGroupNumber must be between 0 and 9 inclusive.
// example usage:
// Okay I'm bored with all you citizens
ClearControlGroup(1, 0);
AddToGroupFromControlGroup
Spoiler
// void AddToGroupFromControlGroup(int in_iControlGroupNumber,
// int in_iPlayerID, const char *in_szGroupName)
// Adds the contents of one of in_iPlayerID's control groups to the
// group in_szGroupName. in_iControlGroupNumber must be between 0 and
// 9 inclusive.
// example usage:
// Make the player pay for using control groups!
AddToGroupFromControlGroup(0, 1, "Player1ControlGroup0");
SelectGroup("Player1ControlGroup0");
KillSelection();
LookAtControlGroup
Spoiler
// void LookAtControlGroup(int in_iPlayerID,
// int in_iControlGroupNumber)
// Move the camera to look at the centroid of in_iPlayerID's control
// group. in_iControlGroupNumber must be between 0 and 9 inclusive.
// example usage:
PrintMessage("Check out what control group zero is doing!");
LookAtControlGroup(1, 0);
ControlGroupHasUnits
Spoiler
// bool ControlGroupHasUnits(int in_iPlayerID,
// int in_iControlGroupNumber)
// See if the specified player currently has any units assigned to the
// specified control group.
// example
// If the player one has assigned units to control group one…
if(ControlGroupHasUnits(1, 1))
then DoSomething

Actions on Selections


MoveSelection
Spoiler
// void MoveSelection(float fX, float fY)
// Give a move goal to the units in the current selection. After
// giving the move goal, this flushes the current selection.
// example usage:
SelectUnit("AmbassadorToPlayer1");
//Send the ambassador to the city gates
MoveSelection(10, 10);
MoveSelectionToArea
MoveSelectionToTerritory
Spoiler
// void MoveSelectionToArea(const char *in_szAreaName)
// void MoveSelectionToTerritory(const char *in_szTerritoryName)
// Give a move goal to the units in the current selection to move to
// the center of the given area or territory. After giving the move
// goal, this flushes the current selection.
// NOTE: Test the territory command to make sure the location used
// matches your expectations. The center of the territory may not be
// where you think it is, and it might be better for you to create an
// area or use an X,Y coordinate instead of using the territory.
// example usage:
SelectUnit("Ben");
//It's 6:00 and guess where I'm going
MoveSelectionToArea("Sligo");
MoveSelectionToAreaWithAttack
MoveSelectionToTerritoryWithAttack
Spoiler
// void MoveSelectionWithAttack(float fX, float fY,
// bool in_bGroupAttack)
// void MoveSelectionToAreaWithAttack(const char *in_szAreaName,
// bool in_bGroupAttack)
// void MoveSelectionToTerritoryWithAttack(
// const char *in_szTerritoryName, bool in_bGroupAttack)
// These do the same as the "MoveSelection" commands, but they will
// attack enemy units on the way there. If in_bGroupAttack is true,
// they will attack in formation. If in_bGroupAttack is false, then
// only dudes who are set to agressive stance will peel off and attack
// individually while the rest continue on.
// example usage:
SelectUnit("JackieChan");
MoveSelectionToAreaWithAttack("TheBronx", false);
InstantMoveSelectionToArea
Spoiler
// void InstantMoveSelectionToArea(const char* in_szAreaName,
// int iMaxDistance)
// Instantly move the current selection to the center of the specified // area. Units are placed one at a time as close as possible to the
// desired location, but no further than iMaxDistance away. Units
// that cannot be moved because there is no valid place for them will
// not be moved. A warning will be displayed when a unit cannot be
// moved.
SelectGroup("BobAndFriends");
// Party at Bob's! Better leave a large iMaxDistance because
// Bob has a lot of friends, and we want them all to fit.
InstantMoveSelectionToArea("BobsHouse", 3);
InstantMoveSelection
Spoiler
// void InstantMoveSelection(float fX, float fY, int iMaxDistance)
// Instantly move the current selection to the specified coordinates.
// Units are placed one at a time as close as possible to the
// desired location, but no further than iMaxDistance away. Units
// that cannot be moved because there is no valid place for them will
// not be moved. A warning will be displayed when a unit cannot be
// moved.
SelectUnit("Bob");
// Warp Bob instantly to this spot. But leave a little bit of
// flexibility by setting the iMaxDistance to 1, in case
// there's a tree or other unit already in that location.
InstantMoveSelection(20, 20, 1);
ReloadSelection

PatrolWithSelection
Spoiler
// void PatrolWithSelection(const char *in_szPoint1,
// const char *in_szPoint2, const char *in_szPoint3,
// const char *in_szPoint4, const char *in_szPoint5,
// const char *in_szPoint6, const char *in_szPoint7,
// const char *in_szPoint8)
// Set the selected units on patrol to eight areas in order. If you
// want less patrol points, simply put in NULL for the later areas.
// Clears the selection.
// example usage:
SelectUnit("PatrolGuy");
PatrolWithSelection("PatrolArea1", "PatrolArea2",
"BreakRoom", "PatrolArea3", "BreakRoom",
NULL, NULL, NULL);
AttackAreaWithSelection
Spoiler
// void AttackAreaWithSelection(const char *in_szAreaName)
// Give an attack area goal to the currently selected units, targeted
// at the area named in_szAttackee. This is only for units with area
// attacks (projectiles, etc.), not for telling the selection to kill
// everyone in a given area. After giving the goal, this flushes the
// current selection.
// example usage:
SelectGroup("Bombers");
AttackAreaWithSelection("Guernica");
SetSelectionFormation
Spoiler
// void SetSelectionFormation(const char *in_szFormationName)
// Puts the selection in the formation named in_szFormationName.
SelectGroup("CosbyKids");
SelectUnit("FatAlbert");
SetSelectionFormation("Wedge");
// Note that SetSelectionFormation() doesn't clear the selection,
// so I can immediately follow it with:
MoveSelectionToArea("Wherever");
// if I didn't move them, I'd have to do a ClearSelection().
AttackWithSelection
Spoiler
// void AttackWithSelection(const char *in_szAttackee)
// Give an attack goal to the currently selected units, targeted at the
// unit/group named in_szAttackee. After giving the goal, this flushes
// the current selection.
// example usage:
//If we've detected someone coming in, shoot them!
SelectUnit("FrontGateCannon");
AttackWithSelection("DudesOnMyLawn");
AttackGroupWithSelection
Spoiler
// void AttackGroupWithSelection(const char *in_szTargetGroupName)
// force the currently selected units to attack the group named
// in_szAttackee.
// This flushes the current selection.
// example usage:
SelectUnit("Grandma");
AttackGroupWithSelection("Ruffians");
CaptureWithSelection
Spoiler
// void CaptureWithSelection(const char *in_szTarget)
//force the currently selected units to capture the unit/group named
//in_szTarget. This flushes the current selection.
// example usage:
SelectUnit("ChechenRebels");
// I am obviously running out of examples here
CaptureWithSelection("RussianOperaHouse");
SetSelectionStance
Spoiler
// void SetSelectionStance(eStanceType in_eStance)
// set the stance of units in the current selection to in_eStance.
// This flushes the current selection.
// example usage:
// Set my dudes agressive, so if they see someone, they'll
// kill him
SetSelectionStance(kStanceType_Aggressive);
SearchAndDestroyWithSelection
Spoiler
// void SearchAndDestroyWithSelection()
// Assign a search-and-destroy tactical goal to the current selection.
// This flushes the current selection.
// example usage:
SelectUnit("HansBlix");
SearchAndDestroyWithSelection();
SearchAndDestroyWallsWithSelection
Spoiler
// void SearchAndDestroyWallsWithSelection()
// Assign a search-and-destroy tactical goal to the current selection.
// The units will ONLY target walls. WALLS ONLY NO MATTER WHAT
// This flushes the current selection.
// example usage:
SelectUnit("HansBlixen");
SearchAndDestroyWallsWithSelection();
GatherFromNamedUnitWithSelection
Spoiler
// void GatherFromNamedUnitWithSelection(const char *in_szUnitName)
// make the selected units gather from the NAMED resource pile,
// in_szUnitName.
// I don't know what the hell this means but hey
SelectUnit("BrerRabbit");
GatherFromNamedUnitWithSelection("BramblePatch");
GatherResourceWithSelection

GuardWithSelection
Spoiler
// void GuardWithSelection(const char* in_szUnitToGuard)
// Instruct the current selection to guard the named unit. It's the
// same as giving a guard command in the game.
// Guard the president from those evil terrists.
SelectGroup("SecretService");
GuardWithSelection("ThePresident");
StopSelection
Spoiler
// void StopSelection()
// Just send a stop command to the selection. This clears the
// selection.
// Just stop.
StopSelection();
ExploreWithSelection
Spoiler
// void ExploreWithSelection()
// Assign an exploration tactical goal to the current selection.
// This flushes the current selection.
// example usage:
SelectUnit("Lewis");
SelectUnit("Clark");
ExploreWithSelection();
IsUnitExploring
Spoiler
// bool IsUnitExploring(const char* in_szUnitName)
// Checks to see if the named unit currently has an explore goal.
// Example usage:
RULE
If(IsUnitExploring("Magellan"))
Then CrewMutinies
END_RULE
IsAnyoneInGroupExploring
Spoiler
// bool IsAnyoneInGroupExploring(const char* in_szGroupName)
// Checks to see any unit in the named group currently has an
// explore goal.
// Example usage:
RULE
If(IsAnyoneInGroupExploring ("Vikings"))
Then Pillage
END_RULE
IsUnitPatrolling
IsAnyoneInGroupPatrolling
Spoiler
bool IsUnitPatrolling(const char* in_szUnitName)
bool IsAnyoneInGroupPatrolling(const char* in_szGroupName)
Check to see if a particular unit, or if any unit in a group, currently has a patrol goal.
GarrisonSelection
Spoiler
// void Script_GarrisonSelection(const char *in_szContainerName)
// Garrison selection into in_szContainerName.
// example usage:
//hide...
SelectUnit("DickCheney");
GarrisonSelection("UndisclosedLocation");
UngarrisonSelection
Spoiler
// void Script_UngarrisonSelection()
// Ungarrison selected container.
//...and unhide.
SelectUnit("UndisclosedLocation");
UngarrisonSelection();
UngarrisonSelectionAtLocation
Spoiler
// bool IsUnitGarrisoned(const char* in_szUnitName)
// Check if the specified unit is garrisoned in anything at all.
// Move Bob to the battlefield, so long as he's not hiding
// somewhere.
If(!IsUnitGarrisoned("Bob"))
{
SelectUnit("Bob");
MoveSelectionToArea("Battlefield");
}
IsUnitGarrisoned
IsUnitSabotaged

GetNumGarrisoned
Spoiler
// int GetNumGarrisoned(const char *in_szGroupName)
// Count the number of units in the group named in_szGroupName
// that are garrisoned.
RULE
// if more than 5 citizens belonging to player 1 are garrisoned,
// do something. NOTE!! This DOES NOT WORK if you try to add units
// in an area. Garrisoned units do NOT SHOW UP in areas.
if( CreateNamedGroup("CitizenGroup") &&
AddUnitsByTypeToGroup("CitizenGroup", "Citizen", 1,
kPlayerMode_Self, NULL) &&
GetNumGarrisoned("CitizenGroup") > 5 )
then HouseParty
END_RULE
CountUnitsGarrisonedInUnit
Spoiler
// int CountUnitsGarrisonedInUnit(const char* in_szUnitName)
// Given the name of a unit that can hold other units
// (transport, fortress, etc), count the number of units that are
// garrisoned in that unit.
// Example:
// If the transport has enough people, then it's time to
// sail to the new world
RULE
if(CountUnitsGarrisonedInUnit("TheMayflower"))
then SailToTheNewWorld
END_RULE
CountUnitsGarrisonedInGroup
Spoiler
// int CountUnitsGarrisonedInGroup(const char* in_szGroup)
// Counts all of the units garrisoned in the group. It examines each
// unit in the group. If the unit has the garrison ability, it adds
// the amount of units it presently contains to the total. The command
// ignores any units in the group that do not have the garrison ability.
// example:
// See if the player has garrisoned any citizens in his
// wearhouses
RULE
If(CountUnitsGarrisonedInGroup("Warehouses"))
Then PatPlayerOnTheBack
END_RULE
KillSelection
Spoiler
// void KillSelection()
// Kill/remove object/group
// example usage:
SelectGroup("DudesOnMyLawn");
// Pretend they died instantaneously of my poisonous lawn
// treatment chemicals..?
KillSelection();
RemoveSelection
Spoiler
// void RemoveSelection()
// Kill/remove object/group
// example usage:
SelectGroup("GuysOnEdgeOfMap");
// Pretend they got away from the feds and are effectively
// out-of-the-world, now.
RemoveSelection();
HealUnit
HealGroup
Spoiler
// void HealUnit(const char *in_szUnitName)
// void HealGroup(const char *in_szGroupName)
// Restore object/group's health
// example usage:
HealGroup("SuperSoldiers");
DamageUnit
DamageGroup
Spoiler
// void DamageUnit(const char *in_szUnitName, float in_fAmount)
// void DamageGroup(const char *in_szGroupName, float in_fAmount)
// Instantly cause in_fAmount damage to the specified unit or group.
// This CAN kill a unit.
// example usage:
// Cause damage to a particular city center.
DamageUnit("ComputerCityCenter", 500);
SetUnitOwnedBy
SetGroupOwnedBy
Spoiler
// void SetUnitOwnedBy(const char *in_szUnitName,
// int in_iPlayerID)
// void SetGroupOwnedBy(const char *in_szGroupName,
// int in_iPlayerID)
// Change ownership of object/group to player x
// example usage:
//He's defecting to the human player's side!
SetUnitOwnedBy("DoubleAgent", 1);
PauseUnitAI
PauseGroupAI

SetUnitSpecialForces
SetGroupSpecialForces
Spoiler
// void SetUnitSpecialForces(const char *in_szUnitName,
// bool in_bSpecial)
// void SetGroupSpecialForces(const char *in_szGroupName,
// bool in_bSpecial)
// Set Scripted Unit - "Special Forces"
// Marks/Clears the selected units as 'special forces', so that
// the strategic AI won't touch them.
// example usage:
//For a while, keep him out of the eyes of the strategic AI so
//it doesn't accidentally send him to gather firewood while we're
//trying to get him to infiltrate the enemy city
SetUnitSpecialForces("JamesBond", true);
SetResourcesGatheredTypeAndAmount
Spoiler
// void SetResourcesGatheredTypeAndAmount(eResourceType in_resourceType
// int in_iAmount)
// For the selected unit(s), this function forces the unit to carry
// the type and amount of resources specified. The amount is
// restricted by the unit's carry limit, so if a citizen can only
// carry 15 pieces of food, and you try to tell it to carry 200
// pieces of food, it will only end up carrying 15 pieces of food.
// The list of resources that you can specify for this function can
// be found in DbResourceDefs.h. Look for eResourceType.
// This function does NOT change the goal of the affected units.
// This forces Bob to carry lots of gold.
SelectUnit("Bob");
SetResourcesGatheredTypeAndAmount(kResourceType_Gold, 15);
SetResourcesGatheredAmount
Spoiler
// void SetResourcesGatheredAmount(int in_iAmount)
// For the selected unit(s), this function forces the unit to carry
// the amount of resources specified. This does not change they type
// of resources that the unit is carrying. The amount is
// restricted by the unit's carry limit, so if a citizen can only
// carry 15 pieces of food, and you try to tell it to carry 200
// pieces of food, it will only end up carrying 15 pieces of food.
// If the unit was not previously carrying any resources, the
// unit will end up carrying food in the amount specified.
// This function does NOT change the goal of the affected units.
// This forces Bob to drop whatever he's carrying.
SelectUnit("Bob");
SetResourcesGatheredAmount(0);
IsSelectionInsideCity
Spoiler
// bool IsSelectionInsideCity(const char* in_szCityName, bool in_bAll)
// Check the current selection, and determine if it is within the
// specified city. in_szCityName is the name of the CityCenter unit
// that the city is built around. in_bAll determines whether the
// entire selection is required to be in the city, or if only part of
// the selection needs to be in the city. If in_bAll is true, then
// the command only returns true if all of the units in the selection
// are within the area of the city. If in_bAll is false, then the
// command will return true if one or more of the units in the
// selection are within the area of the city.
// Make sure everyone is at Bob's city before we start the
// party.
SelectGroup("BobsFriends");
if(IsSelectionInsideCity("BobsCityCenter", true))
{
PartyInTheStreets();
}
// NOTE there is no PartyInTheStreets() command. Really.
// Don't try it, it won't work.
UseSpecialPowerSelf
UseSpecialPowerTarget
UseSpecialPowerLocation
Spoiler
// void UseSpecialPowerSelf(const char* in_szSpecialPower)
// void UseSpecialPowerTarget(const char* in_szSpecialPower,
// const char* in_szTargetUnitName)
// void UseSpecialPowerLocation(const char* in_szSpecialPower,
// float in_fX, float in_fY)
// These commands instruct the current selection to use the specified
// special power. The commands look at each unit in the selection, and
// see if the unit is capable of using the special power. If it is,
// it be instructed to use the special power. Using these commands is
// essentially the same as using a special power button on the
// UnitStats panel in the game. As such, it only makes sense to use
// powers that show up there.
//
// in_szSpecialPower is the name of the AreaEffect that coordinates the
// power. AreaEffects can be found in run\db\AreaEffects, but in order
// to be used in this command, they must also be attached to units
// through the SpecialPower ability. (Leaders have these powers, for
// example)
//
// Some powers instantly affect the unit that has the power, or an area
// around the unit. For these powers, use UseSpecialPowerSelf.
// Some powers affect a specific target unit. For these powers, use
// UseSpecialPowerTarget.
// Some powers affect the area around a location. For those powers,
// use UseSpecialPowerLocation.
// You will receive a warning if you use the wrong command to activate
// an effect.
// Make the military leader Napoleon hustle his troops to battle.
// But first, ensure that he is at full power.
SelectUnit("Napoleon");
RechargePowerReserve();
SelectUnit("Napoleon");
UseSpecialPowerSelf("FireAndManeuver");
UseSpecialPowerOnTargetInArea
Spoiler
// void UseSpecialPowerOnTargetInArea(const char* in_szPowerName,
// const char* in_szAreaName)
// Chooses a random, valid target from all units in the area named
// in_szAreaName. All units in the current selection are then ordered
// to use the named special power on the chosen target.
// NOTE: The power specified should be one that expects a single unit
// as a target.
// Make James Bond poison a building in Berlin
SelectUnit("JamesFreakinBond");
RechargePowerReserve();
SelectUnit("JamesFreakinBond");
UseSpecialPowerOnTargetInArea("TozicSpill", "Berlin");
UseSpecialPowerOnTargetInGroup
Spoiler
// void UseSpecialPowerOnTargetInGroup(const char* in_szPowerName,
// const char* in_szGroupName)
// Chooses a random, valid target from all units in the group named
// in_ szGroupName. All units in the current selection are then
// ordered to use the named special power on the chosen target.
// NOTE: The power specified should be one that expects a single unit
// as a target.
// Make James Bond poison a warehouse in Berlin
SelectUnit("JamesFreakinBond");
RechargePowerReserve();
SelectUnit("JamesFreakinBond");
UseSpecialPowerOnTargetInGroup("TozicSpill",
"WarehousesInBerlin");
RechargePowerReserve
Spoiler
// void RechargePowerReserve()
// Forces all units in the current selection to regain all power in
// their power reserves.
// Force a priest to regain his power so he can convert more
// units.
SelectUnit("FatherBob");
RechargePowerReserve();
HasPlayerUsedSpecialPowerRecently
Spoiler
// bool HasPlayerUsedSpecialPowerRecently(int in_iWhichPlayer,
// eEffectType in_whichEffect, float in_fTimePeriod)
// See if any unit belonging to the specified player has used a power
// of the specified effect type within the time period prior to when
// the command was called. If a unit has used the power, then the
// command returns true, otherwise it returns false. See the enum
// section below for an abbreviated list of the effect types that
// might be used. I'm not including the comprehensive list of effect // types because it is quite long, and I haven't tested them all. And // most of them probably won't even be used for this command anyway.

// Example:
// This sees if an AI has sabotaged something recently. If the
// AI succeeds, then the player loses the scenario.
RULE ONESHOT
if (HasPlayerUsedSpecialPowerRecently(1, kEffectType_Sabotage, 1)
&& iEverySecond)
then OhNoTerroristsGotInYouLose
END_RULE
NumTimesPlayerUsedRegionPower
Spoiler
// int NumTimesPlayerUsedRegionPower(int in_iPlayerID)
// Get the number of times that the player has used his region power.
// example usage:
RULE ONESHOT
If(NumTimesPlayerUsedRegionPower(1) >=1)
Then PatPlayerOnTheBack
END_RULE
IsEffectOfTypeOnSelection
Spoiler
bool IsEffectOfTypeOnSelection(eEffectType in_whichEffect,
bool in_bAll)
Query to find out if a subeffect of the specified type is affecting one or more unit in the selection. Call this after selecting one or more units. This command will clear the selection. If in_bAll is true, all selected units must have the effect for the command to return true. If in_bAll is false, only one unit in the selection must have the effect for the command to return true.
Example:
// Check to see if any Player 1 cities have been sabotaged.
// Assume that the group "Player1Cities" is up to date.
RULE CheckForSabotage ONESHOT
if (SelectGroup("Player1Citites")
&& IsEffectOfTypeOnSelection(kEffectType_Sabotage, false)
)
then FixSabotagedCities
END_RULE
StartBuildWall
StartBuildRoad
AddConnectableWaypoint
SelectionBuildConnectable
Spoiler
// The following commands are used for using the script to order units
// in the game to construct walls or roads at predetermined locations.
// There is a specific sequence of steps that needs to be followed when
// doing this construction, as laid out in the example.
// CAUTION: Check your walls and roads in game! There might be gaps
// or irregularities that you don't like, so make sure the command
// is doing exactly what you expect it to.

// void StartBuildWall(int in_iPlayerID, float in_fX, float in_fY,
// const char* in_szWallBaseType);
// void StartBuildRoad(int in_iPlayerID, float in_fX, float in_fY,
// const char* in_szRoadBaseType);
// These commands are used to start building a wall or road. The
// player ID is the player to whom the roads or walls will belong. X
// and Y are the coordinates of the start location. The string is the
// name of a basetype. For walls, it should be "Palisade" or "Wall".
// For roads, it should presently be "Road1_Piece".
// You must call SelectionBuildConnectable after StartBuildWall or
// StartBuildRoad and in the same step, or you will get an error.

// void AddConnectableWaypoint(float in_fX, float in_fY)
// This adds a waypoint to a road or wall that you have already started
// with one of the above commands. Use this command for each corner in
// your road/wall and for the final end position. The waypoint is
// added at the specified X,Y location.
// This command may produce errors if you try to add a waypoint that
// is not valid. Invalid waypoints are those that would create
// segments at bad angles.
// Do not call AddConnectableWayPoint without calling StartBuildWall
// or StartBuildRoad first in the same step, or you will get an error.

// void SelectionBuildConnectable()
// Order the current selection to build the wall/road most recently
// started by the above functions. The selected units should probably
// belong to the same player that you specified in the start function.
// Do not call SelectionBuildConnectable without calling StartBuildWall
// or StartBuildRoad first in the same step, or you will get an error.

// Example of building a wall:
// This is how you would go about building a wall. This wall will have
// three main segments and stretch from position 10,10 to 15,15 to
// 20,15 to 25,10. It would essentially look like this:
// ______
// / \
// / \

// Aggregate the information about the wall that we want to build
StartBuildWall(1, 10, 10);
AddConnectableWaypoint(15, 15);
AddConnectableWaypoint(20, 15);
AddConnectableWaypoint(25, 10);

// Select the some citizens to build the wall.
SelectGroup("Masons");

// And order the citizens to build the above wall.
SelectionBuildConnectable();

// When the last call executes, foundations will be placed for
// wall that was laid out, and the selected citizens will go and
// start to build it.
BlinkSelectionCircles
Spoiler
// void BlinkSelectionCircles(float in_fDuration)
// Blink the selection circles (or squares for buildings) for the
// specified duration. The selection circle will blink on and off
// regardless of whether the unit is selected or not.
// example usage:
// Blink napoleon for ten seconds so the player knows who he is:
SelectUnit("Napoleon");
BlinkSelectionCircles(10);



Script access to UI Elements


@NOTE all of these work with widget names. Generally speaking, widget names in the game are not always unique (although they usually are). Furthermore, all of these assume that not only are the names unique on a particular screen, they must be unique across both the game and fullmap screens (and options screen, for that matter, not that you should try to access widgets in the options screens, but the names of the ones in game you access must not also be names in the options screen)
You will probably encounter occasional cases where your script does not run correctly when trying to access a particular widget, in which case it may be that the widget does not have a unique name.
The only real way to solve this problem is to involve a programmer and get the names reworked. Also, because the widget you want to access may not even exist when
you invoke the script call, there is currently no great way of debugging this stuff if you enter an incorrect widget name if this becomes a persistent problem, we can probably work something out.

@HINT an easy way to determine the name of a widget: hit Ctrl+TAB to open the debug console, then type in ToggleWidgetUnderMouse this puts the UI into a widget debugging mode that lets you inspect the widget under the mouse, among other things, telling you its name. Enter the command again to turn the mode back off

widget flashing

FlashWidgetUntilClicked
Spoiler
// void FlashWidgetUntilClicked(const char *in_szWidgetName,
// bool in_bStopFlashingIfHotkeyActivated)
// flash the specified widget until it gets clicked
// in_szWidgetName must specify a valid sprite widget on either the
// main game screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens
// if in_bStopFlashingIfHotkeyActivated is true, the widget will also
// stop flashing if its hotkey is triggered

// example usage:
// this flashes the widget named "game_bestWidgetEver" until it is
// clicked or until its hotkey is activated
FlashWidgetUntilClicked("game_bestWidgetEver", true);
FlashWidgetForTime
Spoiler
// void FlashWidgetForTime(const char *in_szWidgetName,
// float in_fTimeInSeconds)
// flash the specified widget for a period of time
// in_szWidgetName must specify a valid sprite widget on either the
// main game screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens
// in_fTimeInSeconds must be a time value greater than zero

// example usage:
// this flashes the widget named "game_bestWidgetEver" for 3 seconds
FlashWidgetForTime("game_bestWidgetEver", 3);
FlashWidgetUntilStopped
Spoiler
// void FlashWidgetUntilStopped(const char *in_szWidgetName)
// flash the specified widget until the script stops it again
// in_szWidgetName must specify a valid sprite widget on either the
// main game screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens
StopFlashingWidget
Spoiler
// void StopFlashingWidget(const char *in_szWidgetName)
// stop a widget from flashing
// in_szWidgetName must specify a valid sprite widget on either the
// main game screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens

// example usage:
// this flashes the widget named "game_bestWidgetEver" until the
// script event which stops it from flashing
FlashWidgetUntilStopped("game_bestWidgetEver");
...
StopFlashingWidget("game_bestWidgetEver");
HackMakeWidgetFlashable

widget selection tracking

AddWidgetListenForSelection
Spoiler
// void AddWidgetListenForSelection(const char *in_szWidgetName,
// bool in_bCountHotkeyActivationAsSelection)
// add the specified widget to the list of those for which we log
// selection activity
// in_szWidgetName must specify a valid widget on either the main game
// screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens
// if in_bCountHotkeyActivationAsSelection is true, when the hotkey for
// the widget is triggered that will also increment the selection count
AddWidgetListenForSelectionWithEventAnd
Spoiler
// void AddWidgetListenForSelectionWithEventAndArg(
// const char *in_szWidgetName,
// const char *in_szEventName,
// const char *in_szEventArg)
// add the specified widget to the list of those for which we log
// selection activity
// in_szWidgetName must specify a valid widget on either the main game
// screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens
// you must also specify both an event name and an argument for the
// event. the arg need not be the entire argument string, but rather
// the arg specified must be contained in the arg string of the desired
// event in order to count as a selection
RemoveWidgetListenForSelection
Spoiler
// void RemoveWidgetListenForSelection(const char *in_szWidgetName)
// remove the specified widget from the list of those for which we log
// selection activity
// in_szWidgetName must specify a valid widget on either the main game
// screen or the fullmap
// for this to function correctly, the widget name must be unique
// across both screens
// @NOTE this will fail silently if the widget was not in the list
// already
HasWidgetBeenSelected
Spoiler
// bool HasWidgetBeenSelected(const char *in_szWidgetName)
// query the selection activity of the specified widget
// returns true if the widget has been selected since it was added to
// the selection logging list (see AddWidgetListenForSelection()),
// otherwise returns false
// in_szWidgetName must specify a valid widget on either the main game
// screen or the fullmap, and it must be one we are listening for
// selection activity for

// example usage:
// this adds the widget named "game_bestWidgetEver" to the selection
// list, then at some other script event queries if it has been
// selected (including hotkey selection), and if so stops listening for
// selection
AddWidgetListenForSelection("game_bestWidgetEver", true);
...
RULE BestRuleEver ONESHOT
if (HasWidgetBeenSelected("game_bestWidgetEver")
)
then
RemoveWidgetListenForSelection("game_bestWidgetEver'');
// do some other stuff too...
END_RULE
GetWidgetSelectionCount
Spoiler
// int GetWidgetSelectionCount(const char *in_szWidgetName)
// query the selection activity of the specified widget
// returns the number of times the widget has been selected since it
// was added to the selection logging list (see
// AddWidgetListenForSelection())
// in_szWidgetName must specify a valid widget on either the main game
// screen or the fullmap, and it must be one we are listening for

// example usage:
// this adds the widget named "game_bestWidgetEver" to the selection
// list, then at some other script event queries if it has been
// selected at least 3 times (excluding hotkey selection), and if so
// stops listening for selection
AddWidgetListenForSelection("game_bestWidgetEver", true);
...
RULE BestRuleEver ONESHOT
if (GetWidgetSelectionCount("game_bestWidgetEver") >= 3
)
then
RemoveWidgetListenForSelection("game_bestWidgetEver'');
// do some other stuff too...
END_RULE
SetDontPauseDuringEncyclopedia
SetDontPauseDuringDiplomacy
SetDontPauseDuringScenarioBriefing
Spoiler
// Don't pause in these menus so script will run:
// SetDontPauseDuringEncyclopedia(true);
DisableCitizenManager
Spoiler
// Disables the Citizen Manager UI, primarily for turning points.

Mission Timer


NewMissionTimer
Spoiler
// Void NewMissionTimer(const char *in_szTextDBEntry, bool in_bMissionTimer);
// Creates a new MissionTimer that is displayed
// together with a text when it is called up.
// Example:
Ship1RepairTimer = NewMissionTimer(Ship1RepairTEXT, bShipRepair1A);
NewMissionTimerWithFormattedName
Spoiler
// void NewMissionTimerWithFormattedName(bool in_bMissionTimer);
// Creates a new MissionTimer that is
// displayed with a formatted name when called.
// Example:

iWaveinfo = NewMissionStatusString();
StartFormat("tx_futuretext97");
iTimeuntilfirstwave = NewMissionTimerWithFormattedName(bTimeuntilfirstwave);
SetMissionTimer
Spoiler
// void StartMissionTimer(int in_iTimerID)
// Sets the time for the specified countdown.
// Example:

SetMissionTimer(iTimeuntilfirstwave, 600);
StartMissionTimer
Spoiler
// void StartMissionTimer(int in_iTimerID)
// Starts the countdown.
// Example:

StartMissionTimer(iTimeuntilfirstwave);
PauseMissionTimer
Spoiler
// void PauseMissionTimer(int in_iTimerID)
// Pause the countdown.
// Example:

PauseMissionTimer(iTimeuntilfirstwave);
IsMissionTimerExpired
Spoiler
// bool IsMissionTimerExpired(int in_iTimerID)
// Becomes true as soon as the Couddown has expired.
// Example:

RULE Example ONESHOT
if (IsMissionTimerExpired(iTimeuntilfirstwave)
)
then
...
END_RULE
GetMissionTimer
Spoiler
// int GetMissionTimer(int in_iTimerID)
// Returns the current time of the countdown.
// Example:

GetMissionTimer(iTimeuntilfirstwave);
ShowMissionTimerWidget
Spoiler
// void ShowMissionTimerWidget(int in_iTimerID, bool in_bShow)
// Shows or hides the MissionTimer specified by the ID.
// Example:

ShowMissionTimerWidget(iTimeuntilnextwave, true);
-----------------------------------------

ShowMissionStatusString
Spoiler
void ShowMissionStatusString(int in_iStringID, bool in_bShow)
Shows or hides the string specified by the ID. Does not change the contents of the string, which you need to set with PrintFormattedMissionStatusString. See the section "Create and update a status string" below for an example.
NewMissionStatusString
Spoiler
This creates a new mission status string, and returns an integer ID for the string. This can be called during the initialization portion of the script, once for each status string that you intend to use. See the section "Create and update a status string" below for an example of how to use this.
Audio

//Play any sound file called by name. This function loads and unloads the file upon start and completion.
//Should only be used for sounds used a few times, like a voice over. Returns a sound handle so the
//sound can be stopped pre-maturely.
Int PlayVoiceOver("American1_VO.wav");

StartPlayingSound
Spoiler
// Plays the sound named in_szSoundSampleName in the audio DB, and returns a handle to it in case you want to stop it later.
int StartPlayingSound(const char *in_szSoundSampleName);
StopSound
Spoiler
// Stops a sounds previously started reference via file handle.
Void StopSound(int in_handle);
StopAllScriptSounds
Spoiler
// Stops all sounds that were started within the script
void StopAllScriptSounds();
PlayVoiceOver
Spoiler
//Play a voice over, or any one time use sound accessed by real
//filename. This sound is loaded when this function is called
// and unloaded when it finishes. If you will be using a given
//sound multiple times, you should make a audio DB entry.
//Function returns the sound handle of the sound, which can be used
//to stop the sound. These sounds can also be stopped with stop all
//script sounds
int PlayVoiceOver(const char *in_filename);
PlayUnpausableVoiceOver
Spoiler
//int PlayUnpausableVoiceOver(const char *in_filename);
//Play a voice over, that not become stopped from user interface menus.
// Example:

hCurrVoiceOverHandle = PlayUnpausableVoiceOver("tut_1_03_place_cursor.mp3");
PlayLoopingVoiceOver
Spoiler
//Same as PlayVoiceOver, but makes the sound loop indefinitely.
//You definitely want to save the sound handle for this one so you can
//stop it. These sounds can also be stopped with stop all script
//sounds
int PlayLoopingVoiceOver(const char *in_filename);
FadeOutSound
Spoiler
//Begins fading out the sound. The fade will last the given length of
//time. After the fade is complete the sound is stopped
void FadeOutSound(int in_handle, float in_length);
IsSoundPlaying
Spoiler
// bool IsSoundPlaying(int in_iNonce) = 0;
// Check and see if the sound indicated by the specified nonce is
// currently playing. (The nonce is the number that gets returned
// by script commands like PlayVoiceOver.)
ToggleStreamingMusic
Spoiler
//Turns on and off the streaming background music so voice overs and
// other sounds can be heard. True to turn on, false for off.
void ToggleStreamingMusic(bool in_enable);
PlayLoopingMusic
Spoiler
//Plays the specified music file as background music from the Music folder by real filename.
//Always repeats itself.
int PlayLoopingMusic(const char *in_filename);
PlayOneShotMusic
Spoiler
//Plays the specified music file as background music from the Music folder by real filename.
//Always repeats itself.
int PlayOneShotMusic(const char *in_filename);
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: List of all IES script commands for scenarios in EE2 and EE2X

Post by Loewenherz »

Diplomacy Functions

GetDiplomaticState
Spoiler
// eDiplomaticState GetDiplomaticState(int in_iFromPlayer,
// int in_iToPlayer)
// Get the diplomatic stance of in_iFromPlayer towards in_iToPlayer.
// It will be either kDiplomaticState_Hostile,
// kDiplomaticState_Neutral, or kDiplomaticState_Allied.
// example usage:
//If you're gonna be a dork about it...
if (GetDiplomaticState(1, 2) == kDiplomaticState_Hostile ...
SetDiplomaticState
Spoiler
// void SetDiplomaticState(int in_iFromPlayer, int in_iToPlayer,
// eDiplomaticState in_eState)
// Set the diplomatic stance of in_iFromPlayer towards in_iToPlayer.
// It MUST be either kDiplomaticState_Hostile or
// kDiplomaticState_Neutral - to create alliances, you need to call
// EnterAllianceProposal/AcceptWaitingProposal or ForceAlliance.
// For those calls, you don't need a SetDiplomaticState call, just
// the alliance call.
// example usage:
//... then _I'M_ gonna be a dork about it too!
SetDiplomaticState(2, 1, kDiplomaticState_Hostile);
IsDiplomaticStateLocked
Spoiler
// bool IsDiplomaticStateLocked(int in_iPlayer1ID, int in_iPlayer2ID)
// Query whether the diplomatic state between in_iPlayer1ID and
// in_iPlayer2ID is locked.
// example usage:
//have we locked the state?
if (IsDiplomaticStateLocked(1, 2) ...
LockDiplomaticState
UnlockDiplomaticState
Spoiler
// void LockDiplomaticState(int in_iPlayer1ID, int in_iPlayer2ID)
// void UnlockDiplomaticState(int in_iPlayer1ID, int in_iPlayer2ID)
// Lock or unlock the diplomatic state between in_iPlayer1ID and
// in_iPlayer2ID. This locks/unlocks in BOTH directions - you
// can't lock the way player 1 feels about player 2 but leave
// player 2 unlocked in the way he feels about player 1.
// example usage:
//Keep these guys fighting
SetDiplomaticState(2, 3, kDiplomaticState_Hostile);
SetDiplomaticState(3, 2, kDiplomaticState_Hostile);
LockDiplomaticState(2, 3);
EnterAllianceProposal
Spoiler
// void ForceAlliance(int in_iPlayer1ID, int in_iPlayer2ID,
// eAllianceDuration in_eDuration, float in_fLength,
// eAllianceLOSState in_eLOS,
// eAllianceBorderPerm in_eBorderPermission,
// eAllianceResRight in_eResourceRight)
// Forces in_iFromPlayer into an alliance with in_iToPlayer with the
// specified parameters. If in_eDuration is kAllianceDuration_Timed,
// then in_fLength is the length (in seconds) of the alliance.
// Otherwise, just send in a 0 or whatever, it doesn't matter.
// For this calls, you don't need a SetDiplomaticState call, just
// the alliance call.
// example usage:
//behind the scenes, have 2 and 3 ally so it's harder for the
//player to take them down
ForceAlliance (2, 3, kAllianceDuration_UntilWar, 0,
kAllianceLOSState_Full, kAllianceBorderPerm_Full,
kAllianceResRight_Full);
IsAllianceProposalWaiting
GetWaitingProposalDurationType
GetWaitingProposalTimeElapsed
GetWaitingProposalDuration
GetWaitingProposalLOSState
GetWaitingProposalBorderPermission
WaitingProposalAllowsMiningOf
WaitingProposalTariffPercentage
GetWaitingProposalTribute
RejectWaitingProposal
AcceptWaitingProposal
Spoiler
// bool IsAllianceProposalWaiting(int in_iPlayer1ID, int in_iPlayer2ID)
// float GetWaitingProposalTimeElapsed (int in_iFromPlayer,
// int in_iToPlayer)
// ---===And===---
// eAllianceDuration GetWaitingProposalDurationType(int in_iFromPlayer,
// int in_iToPlayer)
// float GetWaitingProposalDuration (int in_iFromPlayer,
// int in_iToPlayer)
// eAllianceLOSState Script_GetWaitingProposalLOSState
// (int in_iFromPlayer, int in_iToPlayer)
// eAllianceBorderPerm GetWaitingProposalBorderPermission
// (int in_iFromPlayer, int in_iToPlayer)
// bool WaitingProposalAllowsMiningOf(int in_iFromPlayer,
// int in_iToPlayer, eResourceType in_eResourceType)
// int WaitingProposalTariffPercentage(int in_iFromPlayer,
// int in_iToPlayer, eResourceType in_eResourceType)
// int GetWaitingProposalTribute(int in_iPlayerFromID,
// int in_iPlayerToID, eResourceType in_eResourceType)
// ---===And===---
// void AcceptWaitingProposal(int in_iFromPlayer, int in_iToPlayer)
// void RejectWaitingProposal(int in_iFromPlayer, int in_iToPlayer)
//
// These functions all work together to allow you to script whether the
// AI will accept or reject an alliance that the player is proposing.
// What you'll generally want is a structure consisting of a rule
// that checks whether a proposal is waiting from another player,
// whether it's been waiting an appropriate length of time, then fires
// an action that contains an if statement that will either
// accept or reject the proposal. The whole thing looks like this:
RULE HumanPlayerOffers
//Every second, check to see if there's a proposal waiting from 1 to 2,
//and whether it's been waiting at least 15 seconds (so we don't look
//like a robot).

if (IsAllianceProposalWaiting(1, 2) &&
GetWaitingProposalTimeElapsed(1,2) >= 15)
then CheckProposal
END_RULE

ACTION CheckProposal
SCRIPT WORLD
// Only accept an until-war (or at least 30-sec) proposal
// that has full LOS, civilian or full border permission,
// and allows tariff-free mining of gold. Also, the sum
// of all tribute offered in the proposal must be at least
// zero (which means they can't offer a proposal in which
// they take something from us).
if (
(
GetWaitingProposalDurationType(1,2) ==
kAllianceDuration_UntilWar ||
(
GetWaitingProposalDurationType(1,2) ==
kAllianceDuration_Timed &&
GetWaitingProposalDuration(1,2) >= 30
)
) &&
GetWaitingProposalLOSState(1, 2) ==
kAllianceLOSState_Full &&
(
GetWaitingProposalBorderPermission(1,2) ==
kAllianceBorderPerm_Full ||
GetWaitingProposalBorderPermission(1,2) ==
kAllianceBorderPerm_Civilian
) &&
WaitingProposalAllowsMiningOf(1, 2,
kResourceType_Gold) &&
WaitingProposalTariffPercentage(1, 2,
kResourceType_Gold) == 0 &&
GetWaitingProposalTribute(1, 2,
kResourceType_AllNaturalResource) >= 0
)
AcceptWaitingProposal(1, 2);
else
RejectWaitingProposal(1, 2);
END_SCRIPT
END_ACTION


// void EnterAllianceProposal(int in_iPlayer1ID, int in_iPlayer2ID,
// eAllianceDuration in_eDuration, float in_fLength,
// eAllianceLOSState in_eLOS,
// eAllianceBorderPerm in_eBorderPermission,
// eAllianceResRight in_eResourceRight)
// Makes in_iFromPlayer propose an alliance to in_iToPlayer with the
// specified parameters. If in_eDuration is kAllianceDuration_Timed,
// then in_fLength is the length (in seconds) of the alliance.
// Otherwise, just send in a 0 or whatever, it doesn't matter.
// example usage:
//friends 4-ever (well, actually, for 45 seconds)
EnterAllianceProposal (2, 3, kAllianceDuration_Timed, 45,
kAllianceLOSState_Full, kAllianceBorderPerm_Full,
kAllianceResRight_Full);
ALLIANCE PROPOSAL COUNTER-OFFERS

Alliance proposal counter-offers combine the functionality of checking the settings of an existing alliance proposal and setting new values for a possible counter-proposal at the same time.

If you want to examine a proposal that the player has sent to an AI, and you want the AI to send a counter-proposal if it does not meet certain standards, here's what to do:

StartAllianceProposal
SendAllianceProposal
SetAllianceProposalDurationUntilWarIsDe
SetAllianceProposalDurationTimed
SetAllianceProposalLOSState
SetAllianceProposalBorderPermission
SetAllianceProposalResourceRight
AddAllianceProposalTributeResource
AddAllianceProposalTributeUnits
AddAllianceProposalTributeTerritory
StartVerifyAllianceProposal
VerifyProposalDurationNotLongerThan
VerifyProposalDurationNotShorterThan
VerifyProposalLOS
VerifyProposalBorderPermissions
VerifyProposalResourceRightsNotMoreThan
VerifyProposalResourceRightsNotLessThan
VerifyProposalTributeResource
VerifyProposalTributeTerritory
FinishVerifyAllianceProposal
Spoiler
ALLIANCE PROPOSAL COUNTER-OFFERS

Alliance proposal counter-offers combine the functionality of checking the settings of an existing alliance proposal and setting new values for a possible counter-proposal at the same time.

If you want to examine a proposal that the player has sent to an AI, and you want the AI to send a counter-proposal if it does not meet certain standards, here's what to do:

RULE HumanPlayerOffers
//Every second, check to see if there's a proposal waiting from 1 to 2,
//and whether it's been waiting at least 15 seconds (so we don't look
//like a robot).
if (IsAllianceProposalWaiting(1, 2) &&
GetWaitingProposalTimeElapsed(1,2) >= 15)
then CheckProposal
END_RULE

ACTION CheckProposal
SCRIPT WORLD
// This starts to verify the proposal. It also starts
// working on a possible counter-offer.
if(StartVerifyAllianceProposal(1,2)

// These check various propertied of the player's
// proposal:
// Alliance cannot last more than 30 seconds
&& VerifyProposalDurationNotLongerThan(
kAllianceDuration_Timed, 30)

// Alliance must have full LOS
&& VerifyProposalLOS(kAllianceLOSState_Full)

// Alliance must have full border perms
&& VerifyProposalBorderPermissions(
kAllianceBorderPerm_Full)

// Alliance must have resource rights of 15% or
// less
&& VerifyProposalResourceRightsNotMoreThan(15)

// Player must be willing to tribute at least 400
// gold
&& VerifyProposalTributeResource(
kResourceType_Gold, 400)

// Finish verifying the proposal. If any of the
// above conditions were not met, then this command
// will return false, and it will automatically send
// a counter-proposal to the first player.
&& FinishVerifyAllianceProposal())

// If all of the above commands returned true, then the
// proposal sent by player 1 meets the requirements of
// player 2, and it's OK to accept the proposal.
{
AcceptWaitingProposal(1,2);
}
END_SCRIPT
END_ACTION

// void ForceAlliance(int in_iPlayer1ID, int in_iPlayer2ID,
// eAllianceDuration in_eDuration, float in_fLength,
// eAllianceLOSState in_eLOS,
// eAllianceBorderPerm in_eBorderPermission,
// eAllianceResRight in_eResourceRight)
// Forces in_iFromPlayer into an alliance with in_iToPlayer with the
// specified parameters. If in_eDuration is kAllianceDuration_Timed,
// then in_fLength is the length (in seconds) of the alliance.
// Otherwise, just send in a 0 or whatever, it doesn't matter.
// For this calls, you don't need a SetDiplomaticState call, just
// the alliance call.
// example usage:
//behind the scenes, have 2 and 3 ally so it's harder for the
//player to take them down
ForceAlliance (2, 3, kAllianceDuration_UntilWar, 0,
kAllianceLOSState_Full, kAllianceBorderPerm_Full,
kAllianceResRight_Full);

Here are the detailed command descriptions:

bool StartVerifyAllianceProposal(int in_iPlayer1ID, int in_iPlayer2ID)
Starts verifying the contents of a proposal sent from player 1 to player 2. If there is no such pending proposal, it returns false. Otherwise, it returns true. This command starts the verification process, and starts to put together a possible counter-offer that player 2 may wish to send to player 1.

The following verify commands share similar properties. They all must be called after StartVerifyAllianceProposal and before FinishVerifyAllianceProposal. Each command checks an aspect of the proposal that you started to examine with StartVerifyAllianceProposal. If the proposal does not meet the parameters in one of these commands, then the command will cause for a counter-proposal to be sent when FinishVerifyAllianceProposal is called. Each command returns false if there was an operational problem. (ie: if they are called before StartVerifyAllianceProposal) Normally, each command should return true, even if the proposal does not meet the specified parameters.

bool VerifyProposalDurationNotLongerThan(
eAllianceDuration in_eDurationType, float in_fDuration)
This command checks to make sure that a proposed alliance will not last longer than a specified duration. Pass in the type of duration (kAllianceDuration_UntilWar or kAllianceDuration_Timed) and the duration in seconds. The duration in seconds is ignored for UntilWarIsDeclared. UntilWarIsDeclared alliances are considered to last longer than Timed alliances for the purposes of this command.

bool VerifyProposalDurationNotShorterThan(
eAllianceDuration in_eDurationType, float in_fDuration)
This command checks to make sure that a proposed alliance will last at least a specified duration. Pass in the type of duration (kAllianceDuration_UntilWar or kAllianceDuration_Timed) and the duration in seconds. The duration in seconds is ignored for UntilWarIsDeclared. UntilWarIsDeclared alliances are considered to last longer than Timed alliances for the purposes of this command.

bool VerifyProposalLOS(eAllianceLOSState in_eLOS)
Checks to make sure that the proposed alliance will have a particular LOS state.

bool VerifyProposalBorderPermissions(
eAllianceBorderPermissions in_eBorderPermissions)
Checks to make sure that the proposed alliance will have a particular border permission.

bool VerifyProposalResourceRightsNotMoreThan(
int in_iPercent)
Check to make sure that the resource rights are less than or equal to the specified value.

bool VerifyProposalResourceRightsNotLessThan(
int in_iPercent)
Check to make sure that the resource rights are greater than or equal to the specified value.

bool VerifyProposalTributeResource( eResourceType in_eType,
int in_iAmount)
Check to make sure that the player who proposed the alliance is tributing at least a certain amount of a specified resource.

bool VerifyProposalTributeTerritory(
const char* in_szTerritoryName)
Check to make sure that the player who proposed the alliance is tributing the specified territory. This command will generate an error if the player does not currently control the territory.

bool FinishVerifyAllianceProposal()
This command should be called after StartVerifyAllianceProposal, and after an optional number of the VerifyProposal… commands. When this command is sent, if any of the conditions set forth in the VerifyProposal commands were not met in this initial proposal, then this command will automatically send a counter-proposal to the originating player. Also, this command will return false in that case. If all conditions were properly met, then this command will return true.
ForceAlliance
Spoiler
// void ForceAlliance(int in_iPlayer1ID, int in_iPlayer2ID,
// eAllianceDuration in_eDuration, float in_fLength,
// eAllianceLOSState in_eLOS,
// eAllianceBorderPerm in_eBorderPermission,
// eAllianceResRight in_eResourceRight)
// Forces in_iFromPlayer into an alliance with in_iToPlayer with the
// specified parameters. If in_eDuration is kAllianceDuration_Timed,
// then in_fLength is the length (in seconds) of the alliance.
// Otherwise, just send in a 0 or whatever, it doesn't matter.
// For this calls, you don't need a SetDiplomaticState call, just
// the alliance call.
// example usage:
//behind the scenes, have 2 and 3 ally so it's harder for the
//player to take them down
ForceAlliance (2, 3, kAllianceDuration_UntilWar, 0,
kAllianceLOSState_Full, kAllianceBorderPerm_Full,
kAllianceResRight_Full);
TributeResource
Spoiler
// void TributeResource(int in_iPlayerFromID, int in_iPlayerToID,
// eResourceType in_eResourceType, int in_iAmount)
// Make in_iPlayerFromID give in_iAmount of in_eResourceType to
// in_iPlayerToID in tribute.
// example usage:
//hey, watch me give 10 gold to the human player
TributeResource(2, 1, kResourceType_Gold, 10);
TributeTerritory
TributeUnits

SetAIDiplomacyEnabled
Spoiler
// void SetAIDiplomacyEnabled(int in_iPlayerID, bool bEnabled)
// Toggles on/off AI diplomacy, if shut off, AI will never send/accept
// alliances on its own, everything must be scripted. If on, it'll use
// its own ideas about what to accept. When using the UNDOCUMENTED script command StartAllianceProposal, you need to disable diplomacy of the AI with this command.
// example usage:
// let AI 2 deal with the player, we don't want to script him
SetAIDiplomacyEnabled(2, true);
SetAIWarplansEnabled
Spoiler
// void SetAIWarplansEnabled (int in_iPlayerID, bool in_bEnabled)
// Toggles on/off AI warplan responsiveness, if shut off, AI will never // respond to warplans on its own, everything must be scripted. If on,
// it'll use its own ideas about what to accept
// example usage:
// let AI 2 deal with the player, we don't want to script him
SetAIWarplansEnabled (2, true);
SetAITauntsEnabled
Spoiler
// void SetAITauntsEnabled(bool bEnabled)
// Toggle on/off AI taunting - this is global, NOT on a per AI basis
// the system defaults to OFF
// turn on taunt system for all AIs
SetAITauntsEnabled(true);
ForceSurrenderOffer
Spoiler
// void ForceSurrenderOffer(int in_iPlayerAI, int in_iPlayerHuman)
// force the AI in_iPlayerAI to surrender to in_iPlayerHuman
// YOU HAVE TO ENABLE STRATEGIC LEVEL DIPLOMACY FOR THIS PLAYER, OR YOU
// WILL GET A WEIRD CRASH WITH A NON OBVIOUS ERROR MESSAGE:
// DO THIS FIRST: SetAIDiplomacyEnabled()

ForceSurrenderOffer(2, 1);
/***************************** War Plans **************************/

IsAnyWarplanSentFromPlayerToPlayer
Spoiler
// bool IsAnyWarplanSentFromPlayerToPlayer(int in_iPlayerSendID,
// int in_iPlayerReceiveID)
// returns true if sending player has sent a warplan to receiving
// player, otherwise will return false
// requirements:
// the player Ids must be distinct, valid, non-world player Ids
// bugs:
// 1.) if a plan has been deleted, it will not cause this function
// to return true
// 2.) if, at the time of sending a warplan, the current player
// was not involved in the warplan (sender or receiver),
// that warplan will not cause this function to return true
// example usage:
RULE PlanSent ONESHOT
if( IsAnyWarplanSentFromPlayerToPlayer(1, 2) ...
AcceptPendingPlanFromPlayer
Spoiler
bool AcceptPendingPlanFromPlayer(int in_iSendingPlayer,
int in_iReceivingPlayer)
Forces the receiving player to accept a pending warplan that was sent by the sending player. If there is any pending warplan that was sent by the sending player, then the receiving player will accept it. Returns true if it accepts a warplan, and false otherwise. Note that the receiving player needs to have an AI, or the command will throw an error.

// Set up a rule so that Player 2 will accept a war plan sent by player
// 1. But only check every thirty seconds. You can do whatever you
// want when this rule fires, but the AI should already be acting on
// the warplan as soon as the command returns true.
RULE AcceptPlan ONESHOT
If(AcceptPendingPlanFromPlayer(1, 2)
)
then Whatever
END_RULE

Weather


GetCurrentMonth
Spoiler
// int GetCurrentMonth()
// Returns the current month in the range 1 (January) to 12 (December).
// example usage:
RULE MerryChristmas ONESHOT
if (GetCurrentMonth() == 12 ...
GetCurrentSeason
Spoiler
// int GetCurrentSeason()
// Returns the current season in the range 0-3:
// 0 = Summer
// 1 = Fall
// 2 = Winter
// 3 = Spring
SetCurrentMonth
Spoiler
// void SetCurrentMonth(int in_iMonth)
// Sets the current month. 1=January, 12=December.
// example usage:
//can't really wait for christmas (i like the snow)
SetCurrentMonth(12);
SetCurrentTimeOfDay
Spoiler
// void SetCurrentTimeOfDay(int in_iHour)
// Sets the current time of day. 0 = 12:00 (midnight),
// 23 = 11:00 PM. (changes lighting settings).
// example usage:
//all slanty lighting
SetCurrentTimeOfDay(19);
SetSecondsPerYear
Spoiler
// void SetSecondsPerYear(float in_fSecPerYear)
// Sets the 'relative time' speed of the calendar. It will
// take in_fSecPerYear seconds for a year to elapse, so if you
// set it to 12, it will take 1 seconds for a month to pass by.
// Lower numbers make time go faster.
// example usage:
SetSecondsPerYear(1200); //default
PauseCalendar
Spoiler
// void PauseCalendar(bool in_bPause)
// PauseCalendar(true) causes the calendar to stop advancing.
// PauseCalendar(false) causes the calendar to start advancing again.
// example usage:
//having set up the scenario weather we don't want it
//changing until they advance to the 'summer' part of
//the script
PauseCalendar(true);
PauseCalendarAtMonth
Spoiler
// void PauseCalendarAtMonth(int in_iWhichMonth)
// This command tells the calendar to pause when it next gets to the
// start of the specified month. The range of months is 1 (January)
// to 12 (December). If you are in the middle of month 5, for example,
// and you call PauseCalendarAtMonth(5), it will pause the NEXT time
// you get to the start of month 5.
// We've started some rain in a temperate map, and we want
// the calendar to stop before it gets to the snowy season
// and starts changing the terrain texture to be snow. So
// tell the calendar to pause once we get to September.
PauseCalendarAtMonth(9);
PauseWeatherSystem
Spoiler
// void PauseWeatherSystem(bool in_bPause)
// Pause and unpause the automatic weather system. This is independent
// of the calendar. Pausing the automatic weather system stops the
// game engine from generating new weather events and changing the
// weather. You must pause the automatic system before changing the
// weather state with script calls. Passing true for in_bPause
// pauses the system, and passing false unpauses the system.
// When you unpause the system, the game will automatically revert
// to the state it had before you paused it.
// See ChangeToWeather for an example
ChangeToWeather
Spoiler
// void ChangeToWeather(enum eWeatherState in_whichWeather,
// float in_fTransitionTime)
// Change to the specified weather state. eWeatherState is an
// enumeration of the different possible weather conditions. (See
// enums below.) These conditions include normal, light rain, heavy
// rain, light snow, heavy snow, light dust and heavy dust. When this
// command is called, it causes the game to change to the specified
// state. This can change lighting, the skybox, the fog and
// atmospheric particle effects. It may also have gameplay effects,
// like limiting line of sight and damaging units. Certain elements
// can take time to transition to the new state, light lighting and
// fog. These will gradually change over the number of seconds
// specified by in_fTransitionTime. I recommend about 2-3 seconds.
// Please feel free to bug Matt Corthell for assistance with this.
// NOTE: Make sure you call PauseWeatherSystem before changing the
// weather state.
// In this example, we decide to start a rain storm. We will
// transition to the storm over two seconds.
PauseWeatherSystem(true);
ChangeToWeather(kWeatherState_RainHv, 2);
StartLightningBolt
Spoiler
// void StartLightningBolt()
// Starts an ambient lightning flash and thunderbolt. This is
// pretty straightforward. It fires a single bolt when you want it to.
StartLightningBoltAtLocation
Spoiler
// void StartLightningBoltAtLocation(float in_fX, float in_fY)
// Starts a lightning bolt that will strike the ground at the specified
// x,y location.
StartLightningBoltAtLocation(5, 10);
StartLightningBoltHitUnit
Spoiler
// void StartLightningBoltHitUnit(const char* in_szTargetUnitName,
// float in_fDamageAmount)
// Starts a lightning bolt that will strike the specified unit, and
// deal the specified damage to the unit.
// Don't golf in the rain.
StartLightningBoltHitUnit("TigerWoods", 100);
ChangeToSkybox
Spoiler
// Changes to the specified skybox. This causes the current skybox to
// fade to the specified skybox over the specified period of seconds.
// The weather system should be paused before using this command.
// ( PauseWeatherSystem(true) )
// Skyboxes are defined in db\terrain\climate.ddf.
void ChangeToSkybox(const char* in_szSkyboxName,
float in_fTransitionTime);
Conditions / Value Functions

RandomIntBetween
Spoiler
// int RandomIntBetween(int in_iLow, int in_iHigh)
// Get a random integer number between in_iLow and in_iHigh, inclusive.
// i.e.: RandomIntBetween(3,5) will give you either 3, 4, or 5.
// example usage:
//Send one of the AIs randomly after the player.
SetDiplomaticState(RandomIntBetween(2, 4), 1,
kDiplomaticState_Hostile);
RandomFloatBetween
Spoiler
// float RandomFloatBetween(float in_fLow, float in_fHigh)
// Get a random floating-point number between in_fLow and in_fHigh,
// inclusive. i.e.: RandomFloatBetween(3,5) can give you 3, 3.2, 4.96,
// or 5.
//Wait between 9 and 15 seconds to respond to the invasion..
DoDelay(RandomFloatBetween(9, 15));
STEP
...
GetDistanceFromUnitToPoint
Spoiler
// float GetDistanceFromUnitToPoint(const char *in_szUnitName,
// float in_fX, float in_fY)
// Get the distance between a unit and a point.
// example usage:
//trigger when he gets near the southwest corner of the map
if ((GetDistanceFromUnitToPoint("JamesBond", 0, 0) < 3) ...
GetDistanceFromUnitToUnit
Spoiler
// float GetDistanceFromUnitToUnit(const char *in_szUnit1Name,
// const char *in_szUnit2Name)
// Get the distance between two named units.
// example usage:
if ((GetDistanceFromUnitToUnit("GuyA", "GuyB") < 2) ...
GetMinDistanceFromUnitToGroup
Spoiler
// float GetMinDistanceFromUnitToGroup(const char *in_szUnitName,
// const char *in_szGroupName)
// Get the distance between a unit and the _closest_ member of a group.
// example usage:
//trigger as soon as JB is close enough for ANY of the
//scouts to spot him.
if ((GetMinDistanceFromUnitToGroup("JamesBond", "Scouts") < 5) ...
GetMaxDistanceFromUnitToGroup
Spoiler
// float GetMaxDistanceFromUnitToGroup(const char *in_szUnitName,
// const char *in_szGroupName)
// Get the distance between a unit and the _furthest_ member of a
// group.
// example usage:
//trigger once ALL the scouts are close enough
//to be affected by the sleeping gas in the cufflink
//or whatever
if ((GetMaxDistanceFromUnitToGroup("JamesBond", "Scouts") < 5) ...
DoesWallCoverGap
Spoiler
// bool DoesWallCoverGap(int in_iPlayerID, const char* in_szAreaA,
// const char* in_szAreaB, int in_iMaxUnits)
// Given two areas, this function will check to see if the specified
// player has a continuous wall that exists in both areas. By making
// two very small areas, you can use this to check if a player has
// built a wall to span from one point to another. (The center points
// of the two areas.)
// in_iMaxUnits is a limiter that restricts the size of the wall. A
// player could construct a wall that technically connects the two
// areas, but it could be long and windy. If you give in_iMaxUnits a
// positive value, then it will reject all walls that are longer than
// the specified value. Note that the number is the count of units,
// not tiles. You may need to experiment to find the appropriate value
// for each case. If you don't care about the length of the wall, set
// in_iMaxUnits to –1, and the function will return true for any
// wall, regardless of length.
// NOTE: This could be a kind of expensive command. I'd recommend
// doing this no more frequently than once per second. If you can do
// it less than that, it's probably better.
// Example:
// See if the player has constructed a (mostly) straight wall
// between two points.
If(DoesWallCoverGap(1, "WallEndA", "WallEndB", -1)). . .
DoesRoadCoverGap
Spoiler
// bool DoesRoadCoverGap(int in_iPlayerID, const char* in_szAreaA,
// const char* in_szAreaB, int in_iMaxUnits)
// This works just like the wall function above, but checks for road
// connectivity instead.
// NOTE: This might not work for bridges. Yell at me (Matt) if you
// need this to work for bridges.
DoesUnitExist
Spoiler
// bool DoesUnitExist(const char *in_szUnitName)
// If object exists
// If in_szUnitName does not exist (was never named) or is dead, this
// will return false. Otherwise it returns true.
// example usage:
RULE ONESHOT
if (!DoesUnitExist("JamesBond")
)
then JBHasBeenAssassinated
END_RULE
NameRandomUnitInGroup
Spoiler
// void NameRandomUnitInGroup(const char *in_szGroupName,
// const char *in_szUnitName)
// Picks a random unit in in_szGroupName and names it in_szUnitName.
// Does nothing if const char *in_szGroupName doesn't exist or is
// empty.
// example usage:
NameRandomUnitInGroup("Barbarians", "FocusBarbarian");
// now we can start the cinematic that focuses on FocusBarbarian
GetUnitGoalType
Spoiler
// eUnitGoalType GetUnitGoalType(const char *in_szUnitName)
// If object has state: attacking/moving/harvesting
// example usage:
RULE ONESHOT
if ((GetUnitGoalType("JoeBob") != kGoalType_GatherResource)
)
then GetBackToWork
END_RULE
GetUnitHealth
Spoiler
// float GetUnitHealth(const char *in_szUnitName)
// If object's health = %x
// example usage:
RULE ONESHOT
if ((GetUnitHealth("JamesBond") < 0.50)
)
then SendInReinforcements
END_RULE
GetPlayerResource
Spoiler
// int GetPlayerResource(int in_iPlayerID, eResourceType in_eResType)
// Get the amount of resource of the specified type. This returns
// the CURRENT amount of resources that the player has. If you want
// to know how much resources the player has collected in total, see
// GetAmountOfResourcesCollected().
// example usage:
RULE ONESHOT
if ((GetPlayerResource(1, kResourceType_Food) < 25)
)
then OfferFoodForPeace
END_RULE

Crowns


GetPlayerCrownScore
Spoiler
// float GetPlayerCrownScore(int in_iPlayerID,
// eCrownType in_eCrownType)
// Get a player's current score for a particular crown.
GetPlayerCrownThreshold
Spoiler
// float GetPlayerCrownThreshold(int in_iPlayerID,
// eCrownType in_eCrownType)
// Get the threshold score a player needs to achieve
// to win the crown
RULE ONESHOT
If(GetPlayerCrownScore(1, kCrownType_Economic) /
GetPlayerCrownThreshold(1, kCrownType_Economic) > 0.5)
Then TellPlayerOneHesHalfwayToTheEconomicCrown
END_RULE
AdjustPlayerCrownScore
Spoiler
// void AdjustPlayerCrownScore(int in_iPlayerID,
// eCrownType in_eCrownType, float in_fAdjustment)
// Add or subtract a number to the players score for a particular
// crown.
// Give the player 100 more points in the economic crown
void AdjustPlayerCrownScore(1, kCrownType_Economic, 100);
AwardCrown
Spoiler
// void AwardCrown(int in_iPlayerID, eCrownType whichCrown)
// this will award the crown in_eCrownType to player in_iPlayerID.
// example usage:
// the player just did something that earns him the
// economic crown
AwardCrown(1, kCrownType_Economic);
AddCrownPowerForAllPlayers
RemoveCrownPowerForAllPlayers
AddCrownPowerForOnePlayer
RemoveCrownPowerForOnePlayer
Spoiler
// void AddCrownPowerForAllPlayers(eCrownType in_eCrownType,
// const char* in_szPowerName)
// void RemoveCrownPowerForAllPlayers(eCrownType in_eCrownType,
// const char* in_szPowerName)
// void AddCrownPowerForOnePlayer(int in_iPlayerID,
// eCrownType in_eCrownType, const char* in_szPowerName)
// void RemoveCrownPowerForOnePlayer(int in_iPlayerID,
// eCrownType in_eCrownType, const char* in_szPowerName)
// These all modify the powers that are available to players when
// they win a particular crown. In each case, you specify the
// crown type that is to be changed, and the name of the power
// that is to be added or removed. (For single player modifications
// you also need the ID of the player to be affected.) These
// changes affect both human players and AI players.
//
// For reference, the default powers available for each crown are
// listed in run/db/Simulation/dbcrowns.ddf. In each crown
// definition, there is an EffectList, with the names of the area
// effects. The area effects, themselves, are defined in
// run/db/AreaEffects/dbareaeffects_crown.ddf. You could create your
// own specialized effects for scenarios. I'd recommend using the
// existing crown effects as templates.
//
// Example:
// If for some reason you wanted everyone to have the Infantry
// Doctrine power when they won the economic crown instead
// of the military crown, here's what you'd do:
RemoveCrownPowerForAllPlayers(kCrownType_Military,
"InfantryDoctrine");
AddCrownPowerForAllPlayers(kCrownType_Economic,
"InfantryDoctrine");
LimitPlayerToOneCrownPower
Spoiler
// void LimitPlayerToOneCrownPower(int in_iPlayerID,
// eCrownType in_eCrownType, const char* in_szPowerName)
// This command is very similar to the above crown power commands.
// This command adjusts the available powers for a particular player
// so that only one power is available when they win the crown. This
// can be used to force an AI player to use a particular power.
// Example:
// Force a computer player to use the Infantry Doctrine power.
LimitPlayerToOneCrownPower(2, kCrownType_Military,
"InfantryDoctrine");
AwardCrown(2, kCrownType_Military);
PlayerWhoHasCrown
Spoiler
// int PlayerWhoHasCrown(eCrownType in_eCrownType)
// returns the ID of the player who has the crown in_eCrownType. If
// nobody has the crown yet, returns -1.
// example usage:
RULE ONESHOT
if (PlayerWhoHasCrown(kCrownType_Military) == 1)
then WooHooWeAreNumberOne
END_RULE
HasPlayerEarnedCrown
Spoiler
// bool HasPlayerEarnedCrown(int in_iPlayerID,
// eCrownType in_eCrownType)
// Returns true if the specified player has ever owned the specified
// crown.
RULE ONESHOT
if (HasPlayerEarnedCrown (1, kCrownType_Military))
then IAmAStrategistGod
END_RULE
SetAllowLeaderForCrown
Spoiler
void SetAllowLeaderForCrown(int in_iPlayerID, eCrownType in_eCrownType,
bool m_bMayBuild)
Set whether a particular player may be awarded a leader when he wins a particular type of crown. This does not remove or affect existing leader units. This does not prevent the script from creating leaders.
Example:
// Put this in the initialization portion of your script
// if you want to prevent the player from getting any leaders
// when a crown is won over the course of a scenario.
SetAllowLeaderForCrown(1, kCrownType_Military, false);
SetAllowLeaderForCrown(1, kCrownType_Imperial, false);
SetAllowLeaderForCrown(1, kCrownType_Economic, false);

Player Statistics


GetAmountOfResourcesCollected
Spoiler
// int GetAmountOfResourcesCollected(int in_iPlayerID,
// eResourceType in_eType)
// Get the total amount of resource of the specified type
// that in_iPlayerID has collected over the course of the game.
// Note that this does NOT count resources given to the player
// by the script AddPlayerResource command, and it also does not
// count starting resources.
// example usage:
// As soon as Player 1 has collected 350 wood, complain about
// deforestation or something
if ((GetAmountOfResourcesCollected(1, kResourceType_Wood) >= 350) ...
GetAmountOfGoldFromTrade
Spoiler
// int GetAmountOfGoldFromTrade(int in_iPlayerID)
// Determine how much gold the specified player has earned through
// trade. It counts gold earned when your trade carts visit your
// markets and also from when other players' trade carts visit your
// markets.
RULE ONESHOT
if ((GetAmountOfGoldFromTrade (1) > 100)
)
then YouAreATradingMagnate
END_RULE
GetNumCitizensGatheringResource
Spoiler
// int GetNumCitizensGatheringResource(int in_iPlayerID,
// eResourceType in_eType)
// Find out how many citizens belonging to the specified player are
// harvesting a particular resource
// Give the player some bonus for being such a basass
// lumber gatherer.
RULE
If(GetNumCitizensGatheringResource(1, kResourceTypeWood) > 50)
Then GivePlayerLumberjackCrown
END_RULE
// If number of player's units killed = x
// example usage:

GetNumDeadUnits
GetNumDeadUnitsOfType
GetNumDeadUnitsByAttribute
Spoiler
// int GetNumDeadUnits(int in_iFromPlayerID)
// int GetNumDeadUnitsOfType(int in_iFromPlayerID,
// const char *in_szUnitTypeName)
// int GetNumDeadUnitsByAttribute(int in_iFromPlayerID,
// const char *in_szAttributeName)
// If number of player's units of a specific type killed = x
// example usage:
// This will fire when 15 units of any type from player 1 have died.
if ((GetNumDeadUnits(1) >= 15) ...
// This will fire when 4 male citizens from player 3 have died.
if ((GetNumDeadUnitsOfType(3, ("CitizenM")) >= 4) ...
// This will fire when 15 units with building ability from player
// 2 have died.
if ((GetNumDeadUnitsByAttribute(2, ("Builders")) >= 15) ...
GetNumConvertedUnitsOfType
GetNumConvertedUnitsByAttribute
GetNumConvertedAwayUnitsOfType
GetNumConvertedAwayUnitsByAttribute
GetNumConvertedUnitsFromPlayerOfType
GetNumConvertedUnitsFromPlayerByAttribute
Spoiler
// int GetNumConvertedAwayUnitsOfType(int in_iFromPlayerID,
// const char *in_szUnitTypeName)
// int GetNumConvertedAwayUnitsByAttribute(int in_iFromPlayerID,
// const char *in_szAttributeName)
// Gets the number of units of a type/attribute that in_iToPlayerID has
// lost to conversion.
// example usage:
// This will fire as soon as player 3 loses a mobile unit.
if ((GetNumConvertedAwayUnitsByAttribute(3, "MobileUnits") > 0)
...
// This will fire as soon as player 1 loses a female citizen.
if ((GetNumConvertedAwayUnitsOfType(1, "CitizenF") > 0) ...

// int GetNumConvertedUnitsOfType(int in_iToPlayerID,
// const char *in_szUnitTypeName)
// int GetNumConvertedUnitsByAttribute(int in_iToPlayerID,
// const char *in_szAttributeName)
// Gets the number of units of a type/attribute that in_iToPlayerID has
// converted, from all sources.
// example usage:
// This will fire as soon as player 3 converts a mobile unit.
if ((GetNumConvertedUnitsByAttribute(3, "MobileUnits") > 0)
...
// This will fire as soon as player 1 converts a female citizen.
if ((GetNumConvertedUnitsOfType(1, "CitizenF") > 0) ...

// int GetNumConvertedUnitsFromPlayerOfType(int in_iFromPlayerID,
// int in_iToPlayerID, const char *in_szUnitTypeName)
// int GetNumConvertedUnitsFromPlayerByAttribute(int in_iFromPlayerID,
// int in_iToPlayerID, const char *in_szAttributeName)
// example usage:
// This will fire as soon as player 3 converts one of player 1's mobile
// units.
if ((GetNumConvertedUnitsFromPlayerByAttribute(1, 3, "MobileUnits")
> 0) ...
// This will fire as soon as player 1 converts one of player 2's
// female citizens.
if ((GetNumConvertedUnitsFromPlayerOfType(2, 1, "CitizenF") > 0) ...
GetNumKilledUnitsOfType
GetNumKilledUnitsByAttribute
GetNumKilledUnitsFromPlayerOfType
GetNumKilledUnitsFromPlayerByAttribute
Spoiler
/ int GetNumKilledUnitsOfType(int in_iToPlayerID,
// const char *in_szUnitTypeName)
// int GetNumKilledUnitsByAttribute(int in_iToPlayerID,
// const char *in_szAttributeName)
// int GetNumKilledUnitsFromPlayerOfType(int in_iFromPlayerID,
// int in_iKillingPlayerID, const char *in_szUnitTypeName)
// int GetNumKilledUnitsFromPlayerByAttribute(int in_iFromPlayerID,
// int in_iKillingPlayerID, const char *in_szAttributeName)
// example usage:
// This will fire when player 1 kills a female citizen for the first
// time.
if ((GetNumKilledUnitsOfType(1, "CitizenF") > 0) ...
// This will fire when player 1 kills a mobile unit for the first
// time.
if ((GetNumKilledUnitsByAttribute(1, "MobileUnits") > 0) ...
// This will fire as soon as player 3 sinks 2 of player 1's fishing
// ships.
if ((GetNumKilledUnitsFromPlayerOfType(1, 3, "FishingShip") >= 2) ...
// This will fire when player 2 kills 8 units with land RPS from
// player 4.
if ((GetNumKilledUnitsFromPlayerByAttribute(4, 2, "LandRPS")
>= 8) ...
GetNumProducedUnitsOfType
GetNumProducedUnitsByAttribute
Spoiler
// int GetNumProducedUnitsOfType(int in_iPlayerID,
// const char *in_szUnitTypeName)
// int GetNumProducedUnitsByAttribute(int in_iPlayerID,
// const char *in_szAttributeName)
// example usage:
// This will fire as soon as player 3 builds his first Temple.
if ((GetNumProducedUnitsOfType(3, "Temple") > 0) ...
// This will fire as soon as player 1 produces 20 naval units
// (units with either NavalDeep or NavalShallow movement types).
if ((GetNumProducedUnitsByAttribute(1, "Naval") >= 20) ...
GetAmountOfTribute
Spoiler
// int GetAmountOfTribute(int in_iPlayerFromID, int in_iPlayerToID,
// eResourceType in_eResourceType)
// Get amount of resource type in_eResourceType that in_iPlayerFromID
// has tributed to player in_iPlayerToID. Asking for
// kResourceType_AllNaturalResource gets the total amount of all
// resources tributed.
// example usage:
RULE PayUp
if (GetAmountOfTribute(2, 1, kResourceType_Gold) >= 200)
then ThatsAboutRightSeeYouNextWeekPunk
END_RULE
GetOwningPlayerID
Spoiler
// int GetOwningPlayerID(const char *in_szUnitName)
// If player owns object(s)
// Get the ID of the player that owns unit in_szUnitName. If
// in_szUnitName does not exist or is dead, this will return -1.
// example usage:
RULE ONESHOT
if (((GetOwningPlayerID("Rocky") == GetOwningPlayerID("Bullwinkle"))
)
then TogetherAtLast
END_RULE
IsGroupOwnedBy
Spoiler
// bool IsGroupOwnedBy(const char *in_szGroupName, int in_iPlayerID)
// Returns true if and only if in_szGroupName exists, is non-empty,
// and everyone in it is owned by in_iPlayerID. If it hasn't been
// created or if it's empty, it'll return false.
// example usage:
if (IsGroupOwnedBy("Escapees", 1) ...
GetGroupOwnerID
Spoiler
// int GetGroupOwnerID(const char *in_szGroupName)
// If EVERY unit in in_szGroupName is owned by a single player, will
// return that player's ID. If in_szGroupName is empty or has mixed
// ownership, will return -1.
// example usage:
RULE PlayerConquers ONESHOT
if ( (GetGroupOwnerID("BuildingsToCapture") == 1))
then YouCapturedAllTheBuildingsFromThatGroupThatAreStillAlive
END_RULE
GetElapsedGameTime
Spoiler
// float GetElapsedGameTime()
// If time elapsed = x
// example usage:
RULE ONESHOT
if ((GetElapsedGameTime() > 30 * 60))
then InformPlayerAboutTheDangersOfEyeStrain
END_RULE
PlayerInGame
Spoiler
// bool PlayerInGame(int in_iPlayerID)
// If player is alive/dead A player is "dead" if he has no more
// important units. Important units include units that can attack,
// build, or produce, and specifically exclude ammo and construction
// sites.
// This is supposed to allow designers to approximate Conquest
// victories through scripting.
// example usage:
RULE ONESHOT
if (!PlayerInGame(3))
then MournTheLossOfOurBelovedPlayer3
END_RULE
PlayerHasResearchedTech
Spoiler
// bool PlayerHasResearchedTech(int in_iPlayerID,
// const char *in_szTechName)
// Check whether a player has researched a specific technology or not.
// Returns true after the player has FINISHED researching the tech.
// example usage:
RULE ONESHOT
//NB: Main1_1 is fire
if (PlayerHasResearchedTech(1, "Main1_1")
)
then InvitePlayer1OverForABarbecue
END_RULE
GetPlayerEpoch
Spoiler
// int GetPlayerEpoch(int in_iPlayerID)
// Check what epoch a player is currently in.
// example usage:
RULE ONESHOT
if ((GetPlayerEpoch(1) > GetPlayerEpoch(2)
)
then SuckUpToPlayer1
END_RULE
DoesPlayerHaveEnoughTechsToAdvance
Spoiler
bool DoesPlayerHaveEnoughTechsToAdvance(int in_iPlayerID)
Returns true if the specified player has researched enough techs in the current epoch to allow advancement to the next epoch. Returns false otherwise.
Example:
// In the tutorial, after telling the player to research a few
// techs, give him a new goal to advance to the next epoch, or
// something.
RULE ONESHOT
if(DoesPlayerHaveEnoughTechsToAdvance(1))
then GiveGoalToAdvance
END_RULE
NumUnitsInGroup
Spoiler
// int NumUnitsInGroup(const char *in_szGroupName)
// Returns the number of units in the group named in_szGroupName.
// Useful for, say, periodically building up a group of enemy units in
// some area, then checking to see if that group is empty or not.
// NOTE: This number will include dead units that are still "rotting".
// Use NumUnitsInGroupNotDead to ensure that you only get live units.
// example usage:
RULE ONESHOT
if (NumUnitsInGroup("DudesOnMyLawn") > 0)
then CallTheCops
END_RULE
NumUnitsInGroupNotDead
Spoiler
// int NumUnitsInGroupNotDead(const char* in_szGroupName)
// Returns the number of units in the group that are not dead.
// Units that are in a group that are dead and rotting are normally
// included in the count of that group. That is not the case when
// using this function, however.
RULE ONESHOT
if (NumUnitsInGroup("MyEnemies") == 0)
then ICanStopFighting
END_RULE
GetNumPlayers
Spoiler
// int GetNumPlayers()
// Get the number of players in the game.
// example usage:
RULE ONESHOT
if ((GetNumPlayers() == 2))
then SwitchToSeriouslyAgressiveAIP
END_RULE
IsPlayerAttackingInArea
Spoiler
// bool IsPlayerAttackingInArea( int in_iAttackerID,
// int in_iTargetID,
// const char* in_szArea)
// in_iAttackerID is the ID of a player. (The attacker.)
// in_iTargetID is the ID of a player. (The target.)
// in_szArea is the name of an area. (The area.)
// The function checks to see if the attacker has any units that are
// attacking units that belong to the target, where both the attacking
// unit and target unit are in the area. If this condition is true,
// then the function returns true. If the attacking unit is in the
// area, and the target unit is not in the area, then the function
// returns false. Similarly, if the defender is in the area, and the
// attacker is not, the function returns true.
// The function does not care if any units belonging to the target
// are attacking units belonging to the attacker. The function only
// checks aggression in one direction.
// The function takes into account conversions and captures in
// progress.
// If the human player starts to attack player 2 near Bob's home,
// then the computer wants to produce a lot of defenders.
RULE ONESHOT
if (IsPlayerAttackingInArea(1, 2, "BobsHome")
)
then ProduceLotsOfDefendingUnits
END_RULE
GetLandTradeRoutesBetweenPlayers
GetSeaTradeRoutesBetweenPlayers
GetAllTradeRoutesBetweenPlayers
Spoiler
// int GetLandTradeRoutesBetweenPlayers(int in_iPlayerA, int
// in_iPlayerB)
// int GetSeaTradeRoutesBetweenPlayers(int in_iPlayerA, int
// in_iPlayerB)
// int GetAllTradeRoutesBetweenPlayers(int in_iPlayerA, int
// in_iPlayerB)
// These functions count and return the number of active trade routes
// that Player A has with Player B. For the purposes of this function,
// a trade route is defined as a trading unit (trade card, merchant
// ship, etc.) that belongs to Player A, and is currently engaged in
// trading with a building belonging to Player B. Units belonging to
// Player B do not count toward this number, even if they are trading
// with Player A.
// This does not count past trade routes. So if Player A had 5 trade
// carts that were trading, and they all get killed, then he has no
// active routes.
// The variations on the functions restrict the search to land or sea
// trade routes, or allow for a general search that includes all trade
// routes.
// If the player establishes ten trade routes, then give him a
// bonus.
RULE ONESHOT
if (GetLandTradeRoutesBetweenPlayers(1, 2) >= 10
)
then GivePlayer1LotsOfMoney
END_RULE
GetAllTradeRoutesForPlayer
Spoiler
// int GetAllTradeRoutesForPlayer(int in_iPlayer)
// Count the total number of active trade routes that the specified
// player currently has. A trade route is a single trade unit (trade
// cart, merchant ship, etc.) that is actively trading with another
// player.
// If the player establishes a hundred total trade routes, then
// they must have a frickin' monopoly. Sue them.
RULE ONESHOT
if (GetAllTradeRoutesForPlayer (1) >= 100
)
then BringAnAntiTrustSuit
END_RULE
HavePlayersTradedRecently
Spoiler
// bool HavePlayersTradedRecently(int in_iPlayerA,
// int in_iPlayerB,
// float in_fTimePeriod)
// Checks to see if Player A has traded with Player B within the
// specified time period. Returns true if a trade unit from A
// has visited and completed a trade transaction with a building
// belonging to B within the given time.
// This rule can be used to watch for when the human player
// first completes a trade with AI player 2. iEverySecond
// is a cPeriodicInt set to evaluate every second. This
// rule will evaluate every second, and check to see if
// Player 1 has traded with Player 2 within the past second.
RULE ONESHOT
if (HavePlayersTradedRecently (1, 2, 1)
)
then RewardPlayer
END_RULE
IsWeakestPlayer
Spoiler
// Is this player weaker than every other player in the game –
// requiredRatio specifies how many times weaker
// this player needs to be, to be considered weakest
bool IsWeakestPlayer(int in_iPlayer, float in_fRequiredRatio);
IsStrongestPlayer
Spoiler
// is this player stronger than every other player in the game –
// requiredRatio specifies how many times stronger
// this player needs to be, to be considered strongest
bool IsStrongestPlayer(int in_iPlayer, float in_fRequiredRatio);
HasLeastResources
Spoiler
// does this player have less resources than everyone else –
// requiredRatio specifies how many times less
// this player needs have, to be considered having the least
bool HasLeastResources(int in_iPlayer, float in_fRequiredRatio);
EnemiesArePlaneHappy
EnemiesHaveForsakenPlanes
Spoiler
// These next 2 are for switching aips in skirmish games
// we're in a late epoch game, is our enemy using tons of planes?
bool EnemiesArePlaneHappy(int in_iPlayer)
// has our enemy stopped with the planes?
bool EnemiesHaveForsakenPlanes(int in_iPlayer)
GetPlayerPopulation
Spoiler
// Get the population count for the specified player. This is not
// necessarily the number of units that the player has, as some units
// may count as two or more in the population, and others might not
// count at all. This should be the number that is displayed in
// the UI, however.
int GetPlayerPopulation(int in_iPlayer);
OnIslandsMap
IsDeathmatchGame
HaveLowResources

GetPercentOfMapExploredByPlayer
Spoiler
// float GetPercentOfMapExploredByPlayer(int in_iPlayerID)
// Get the percent of map explored by the specified player. Returns
// the percent as a floating value between 0 and 1. 0.0 = 0%,
// 0.5 = 50%, 1.0 = 100%, etc.
// example:
// See how much the player has explored. If the player has
// been adventurous and seen half the map, reward her.
RULE ONESHOT
if (GetPercentOfMapExploredByPlayer(1) >= 0.5
)
then RewardPlayer
END_RULE
IsPlayerHumanControlled
Spoiler
bool IsPlayerHumanControlled(int in_iPlayerID)
Test to see if the specified player is human-controlled. Returns true if she is. Note that observer players are not human controlled, and will return false if this command is called on them.
SetRollCreditsAfterScenario
Spoiler
void SetRollCreditsAfterScenario(bool in_bRollCredits)
Set whether or not the game should jump to the EE2 credits after the player has finished viewing the end-game statistics.
WasHotKeyPressedRecently
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: List of all IES script commands for scenarios in EE2 and EE2X

Post by Loewenherz »

THINGS YOU MIGHT WANT TO DO, AND HOW TO DO THEM:

* Set up a trigger that fires only once, right when the game starts

You'd have a rule like this:

Code: Select all

RULE ONESHOT
if (true)
then <whatever>
END_RULE
* Increment counter(x), If counter(x) equals (y)

Counters are represented by cHotInts, in the scripting system. You create a counter named <name> by putting the following in your DEFINITIONS section:

cHotInt <name>

Then, you can set the counter in the INITIALIZATION section like so:

<name> = 0;

You can initialize it to any number you want. Then, you can perform mathematical operations on it inside ACTION sections. To increment it, you would do:

<name> = <name> + 1;

To decrement it:

<name> = <name> - 1;

You can copy the values of other counter variables as well:

<name> = <othername>;

Then, when you want to make a rule that depends on the value of a counter, it will look like this:

// Example: fire Bonk when counter Foo reaches 23

Code: Select all

RULE
if (23 == Foo)
then Bonk
END_RULE
Note the TWO equals signs! = means assignment, == means test for equality.

* If player's unit count (specific unit type or total) = x
* If player(x) has total unit count of (x)


You do this, and most things of this form (unit counts of a type) by using Groups. In this case, you want to make up a group, put all the units of the type you're interested in into that group, and then test the group's size.

To fire a rule when a player 1's unit count of all types is EXACTLY x:

Code: Select all

RULE ONESHOT
if (CreateNamedGroup("UCount") &&
    AddUnitsByAttributeToGroup("UCount", "Anything", 1,
                               kPlayerMode_Self, NULL) &&
    NumUnitsInGroup("Ucount") == x	//doing == for EXACTLY x
    )
then Whatever
END_RULE
In the above example, the "UCount" name is something I just made up for this rule. The only thing that matters is that it's not going to collide with something else. You could, if you wanted to, do something in the ACTION section that this rule fires, like SelectGroup("UCount") and then AttackWithSelection(), but for this example we're just counting the units.

"Anything" is the name of the attribute that we're using to select units to add to the group. The full set of named attributes is in $/run/db/dbunittypeattribute.uta. I could have chosen MobileUnits, or Citizens, to limit it to the count of units that matched those attributes.

The 1 is the player that we're talking about, and kPlayerMode_Self means that we're only considering units that belong to that player. These are the different player modes you can use:

kPlayerMode_Anybody, //all players (including the world player)
kPlayerMode_Self, //only units that belong to me.
kPlayerMode_Allies, //only units that belong to my allies
kPlayerMode_SelfAndAllies, //units that belong to me OR my allies
kPlayerMode_Enemies, //units that belong to my declared enemies
kPlayerMode_NonSelf, //enemies and allies, just not me
kPlayerMode_World, //the world player only (resources, animals)
kPlayerMode_NotTheWorld, //anybody who is not the world player

(For future reference, they're located in $/src/EE2/DbHdrs/DbUnitTypeAttributeDefs.h.)

* If quantity(x) units from player(x) enters trigger area(y)
* If player(x) has type of unit(y) in trigger area(z)


This is very much the same as the above, but theA ddUnitsByAttributeToGroup call needs an additional parameter, the name of the area. If you named an area "NearMyBase", and you wanted to trigger as soon as AT LEAST five citizens from player 2 were near your base:

Code: Select all

RULE ONESHOT
if (CreateNamedGroup("Trespassers") &&
    AddUnitsByAttributeToGroup("Trespassers", "Citizens", 2,
                               kPlayerMode_Self, "NearMyBase") &&
    NumUnitsInGroup("Ucount") >= 5	//doing >= for AT LEAST five
    )
then Whatever
END_RULE
To show off player modes, maybe you don't care about which specific player they're from, as long as they're enemies of player 1. Then you'd do this:

...
AddUnitsByAttributeToGroup("Trespassers", "Citizens", 1,
kPlayerMode_Enemies, "NearMyBase") &&
...

* An alternate way to see if named unit enters trigger area(x)


First, create a group, then add your named unit to it. Then, REMOVE all the units in the group that are in the trigger area. Then, if the group is empty, you know that the guy's in the area you're looking for. Make sense?

Here's an example:

Code: Select all

RULE ONESHOT
if (CreateNamedGroup("JustJames") &&
    AddUnitToGroup("JustJames", "JamesBond") &&
    RemoveUnitsByAttributeFromGroup("JustJames", "Anything", 0,
                                   kPlayerMode_Anyone, "NearMyBase") &&
    NumUnitsInGroup("JustJames") == 0 
    )
then JamesBondIsNearMyBase
END_RULE
[color=#BF0000]
* If player(x) has killed count(y) units owned by player(z)[/color]
This case is handled by:

Code: Select all

RULE ONESHOT
if (GetNumKilledUnitsFromPlayerByAttribute(z, x, "Anything") >= y 
    )
then HoorayForUs
END_RULE
* If player(x) destroys quantity(y) of unit type(z) owned by player(z1)

But note that you can be more selective by changing "Anything" to the name of another UnitTypeAttribute, such as MobileUnits (if you don't want to count building destruction):

Code: Select all

RULE ONESHOT
if (GetNumKilledUnitsFromPlayerOfType(z1, x, "z") >= y 
    )
then WeAreTotallyTheBest
END_RULE
Also note that we do ">= y" rather than "== y", which would trigger when the killed count was exactly y. The reason why we do this is because in the super-rare occurrence that player x kills multiple units at the same time (or, maybe in the nuclear epoch, not so super-rare occurence), the kill count might jump past y without ever equalling it exactly. Therefore it's a lot more pragmatic to test with a > or a < in there somewhere.


* Find the name of a particular unit type for AddUnitsByTypeToGroup


There is no authoritative/centralized list of types, but if you search
for 'UnitType' at the start of the line in $/run/db/Units/*.ddf,
you'll find them. A handy way to do this in VC++ is:

1. go to "Find in Files" under the "Edit" menu
2. Make sure 'Regular Expression' is checked and 'Look in subfolders'
is _not_ checked
3. type '^UnitType' (make sure the ^ is there) into 'Find what:'
4. type '*.ddf' into 'In files/file types:'
5. type C:\EE2\run\db\Units into 'In folder:' (or wherever your
run/db/units directory is
6. hit enter

Of course, without VC++ this can be a little tricky, but the Unit Type names are actually quite easy to figure out. You can usually just use a unit's RPS class name (Frigate, Bomber, HeavyInfantry, LightInfantry, etc.) as it's type. Buildings are always their base type (barracks, workshops – even if its in an epoch with factories, warehouse, etc.) Note that some RPS families have some extra members. If you want Macemen through Objective Force Warriors, it's HeavyInfantry1. If you want Spearmen through Mini-Gunners, it's HeavyInfantry2. Heavy and Light Mounted2 are Helicopters and Heavy and Light Mounted3 are HERCs. Tanks are LightTank and HeavyTank. Finally, LightArtillery2 is the mobile AA unit.

* Use certain 'area' commands relative to the locations of units/groups


So, say you want to move the selection to a named unit called 'TargetUnit'. Instead of placing an area down in the editor where you think TargetUnit is going to be and giving a move order to that area, you can do:

MoveSelectionToArea("Unit:TargetUnit");

Likewise, if there's a group named TargetGroup that you want to move towards the middle of, do this:

MoveSelectionToArea("Group:TargetGroup");

The script interface sees the Unit: and Group: prefixes and does the right thing. This syntax works for the commands:

Create[Named,Grouped]UnitInArea (maybe good for group)
MoveSelectionToArea[WithAttack]
InstantMoveSelectionToArea
AttackAreaWithSelection
SetCameraLookArea

* Make a unit invincible

Do this:
AttachEffectToUnit("<unitname>", "Invincibility");

There used to be a SetUnitInvincible call, but it didn't work, and since this -does- work, it's much more preferable.

* Clean up after a cinematic before the objectives panel pops up

If you want to have some cleanup functions called before the initial cinematic ends, you can put them in a special ACTION called "PreScenInfoPanelHook". This ACTION section should only have one step, and can't use any delay functions (like DoDelay, or DoWaitUntilCinematicTime), since it all takes place at once. It should look like this:

Code: Select all

ACTION PreScenInfoPanelHook
SCRIPT WORLD
  SelectGroup("UnitsUsedOnlyForCinematic");
  RemoveGroup();
END_SCRIPT
END_ACTION
This will be called immediately after the cinematic ends, but before the objectives panel comes up, so you can do it to remove things you don't want visible during that time.

* All text must use localized strings


A localized string is simply a call to a text database where your text lives. Having all text in an outside database makes it easier to troubleshoot and translate, should the mood strike you. All text that you wish to display in your scenario, either through messages you display through your script or custom display names you set in the editor, must be in the form of a string that can be found and edited in an external file in the text database.

To add an entry to the text db, you need to download and use an editing program like BabelPad™ and make sure you save the file with the prefix "usertext" as in usertext_myscenario.utf8. Next, make a folder called "db" in your "EE2\Run" directory and drop the .utf8 file in a "Text" folder within the "db" folder. Next, start making up strings:

usertext_myscenario_beginning,"""In the beginning…"""
usertext_myscenario_cornchips,"""there were plenty of corn chips…"""
etc…

Make sure you end the file with a hard return, or else you'll likely get some kind of error.

Then, in your script, anytime you want to show some text, you call a the appropriate string:

PrintMessage("usertext_myscenario_beginning");
Or…
CreateDialogBox("usertext_myscenario_beginning", true);

Or you can create a custom display name in the editor by opening up the object properties panel and entering a string:

Display Name: usertext_unitname_BobTheMighty


Now that we've gotten past the simple example, I'm going to give you a
very complex one. This is for strings that have formatting commands in
them, when you want to print a message where the content depends on
values that aren't known until runtime. In this situation, we want to
print a message that depends on the name of a player, an amount
(ostensibly extracted from an alliance proposal), the name of a
particular enum (in this case, a resource), and another
designer-specified string that lives elsewhere in the text DB. We can
do this with a text DB entry that has argument strings in it.

Argument strings are basically small chunks of a message that you want
to substitute something else in for. They're represented by single
words, preferably in all caps, surrounded by % signs. (If you want to
use a % sign by itself in your string, use '\%', and if you want to
use a \ sign by itself, use '\\'.) The following example has four
formatting strings in it, each of which is replaced by a different
piece of data.

// in $/run/db/Text/dbtext_scenario_tutorial1.csv:
usertext_scenario_tutorial1_14 "%PLAYER% has offered you %AMOUNT% %RESOURCE% in exchange for
%AREA%!"
usertext_scenario_tutorial1_15 "Lawrence"
usertext_scenario_tutorial1_16 "North Andover"

// in your script:
StartFormat("usertext_scenario_tutorial1_14");
FormatPlayerName("PLAYER", 2);
FormatInt("AMOUNT", 100);
FormatEnum("RESOURCE", "eResourceType", kResourceType_Gold);
FormatString("AREA", "usertext_scenario_tutorial1_15");
PrintFormattedMessage();

In the end, it will come out looking like:
"King George has offered you 100 Gold in exchange for Lawrence!"
This assumes that player 2's name is King George, but you get the point.

* Create and update a status string

You can make persistent strings that remain on screen. The intent is so that players will have information about their progress toward a particular goal. An example of a good use would be if a player needed to capture three territories, you can display a string on screen that says something like "Captured 0 of 3 territories." When the player captured another territory, you can update it again to say 1 of 3, and so forth. Use of these strings builds upon localized strings as described above. You'll need to know how to do that in order to format these status strings.

I'll describe an example based on the capturing territories idea. First, you need to make sure you have a localized string defined in one of the .utf8 files. This is the only thing that needs to be done outside of the script. This is, of course, a template. And you will be able to, in script, replace the %CAPTUREDNUM% and %CAPTUREDREQ% portions of the string with data in the script.

text_G3_objectiveCapture_status,
"""Captured %CAPTUREDNUM% of %CAPTUREDREQ% territories"""

In the script, for each status string you need an integer which is used to hold an identifier for the string. The integer can be declared in the DEFINITIONS portion of the script, like so.
int statusObjectiveCapture

You need to create a new status string. This can be done in the INITIALIZATION portion of the script.

int statusObjectiveCapture = NewMissionStatusString();

The following section is the action in which the objective is given to the player. The script that I'm including will build the formatted string and put it into our status string. Afterward, we'll make another call to show the string. The command to show the string will make sure the string is automatically displayed on the screen.

Code: Select all

ACTION GivePlayerCaptureObjective
	    SCRIPT_WORLD		

		// Include other script to enable the objective
		. . .
		//

		// Start formatting the status string.
		StartFormat("text_G3_objectiveCapture_status");

		// Add the number of captured territories.  I'm assuming
		// you define this integer elsewhere, and that you are
		// updating it.  Note that the value of the integer RIGHT
		// NOW is the value that gets inserted into the string.
		// If the value of the integer changes later, the string
		// will NOT be automatically updated.
		FormatInt("CAPTUREDNUM", numTerritoriesCaptured);

		// Add one more int for the number of required territoried
		FormatInt("CAPTUREDREQ", numTerritoriedRequired);

		// Finally, we 'print' the text specified in the
		// StartFormat command into the status string that we
		// created with NewMissionStatusString during
		// initialization, including the variables we added with
		// the format calls.  Note that this does not cause the
		// string to be displayed on string.
		PrintFormattedMissionStatusString(statusObjectiveCapture);

		// Now that we have initially formatted the string, we can
		// show it to the user.
		ShowMissionStatusString(statusObjectiveCapture, true);
	    END_SCRIPT
	END_ACTION
Here's another action that gets called whenever the player captures a new territory. This action updates the string to reflect the progress of the player. Note that we can format and print a string without having to show the string again, because we already showed the string when the previous action ran.

Code: Select all

ACTION UpdateCaptureObjective
	    SCRIPT_WORLD		

		// Include other script to do whatever
		. . .
		//

		// Start formatting the status string.
		StartFormat("text_G3_objectiveCapture_status");

		// Again, the number of captured territories and
		// and required territories are added.  We assume that
		// numTerritoriesCaptured has been updated already.
		FormatInt("CAPTUREDNUM", numTerritoriesCaptured);
		FormatInt("CAPTUREDREQ", numTerritoriedRequired);

		// And print once again.  This will update and change the
		// displayed string, assuming that the string is already
		// shown.
		PrintFormattedMissionStatusString(statusObjectiveCapture);

	    END_SCRIPT
	END_ACTION

And, finally, you should hide the string once it's no longer relevant to the player. When he's completed the objective, for example.

ShowMissionStatusString(statusObjectiveCapture, false);


GOOD PRACTICES TO FOLLOW:


* Use constants instead of strings in place


This is a good practice to follow to reduce the occurence of 'typo errors' (e.g., accidentally mistyping the name of a unit, group, or area). Instead of referring to areas/groups/units by name strings, make a constant out of that name string, and use that instead:

Code: Select all

        // old way:
        RULE IsHirohitoDead ONESHOT
        if (!DoesUnitExist("Hirohito")
)
        then OhManHeDied
        END_RULE

        // new, slightly annoying way:
        DEFINITIONS
                   constant HIROHITO "Hirohito"
        END_DEFINITIONS

        RULE IsHirohitoDead ONESHOT
        if (!DoesUnitExist(HIROHITO)
)
        then OhManHeDied
        END_RULE
This has one major benefit: if you misspell the name of a constant,
you will get a compile error, instead of it mysteriously not working during testing.

Code: Select all

        // old way, no error (though you will get a message about
        // Hirohito dying earlier than you would expect):
        RULE IsHirohitoDead ONESHOT
        if (!DoesUnitExist("Hirhito")
)
        then OhManHeDied
        END_RULE

        // new way, now with compile-time error:
        DEFINITIONS
                   constant HIROHITO "Hirohito"
        END_DEFINITIONS

        RULE IsHirohitoDead ONESHOT
        if (!DoesUnitExist(HIOHITO)
)
        then OhManHeDied
        END_RULE
Of course, you are obligated to spell the name correctly in the DEFINITIONS section, but if you're using the same constant everywhere, it will be more likely to show up earlier if you misspell it there.


ENUM LISTS:

Some arguments to script commands are 'enums', which are enumerated values. They have very long descriptive names and are usually used to select one of a set of possibilities. You can tell an enum argument to a script command by the fact that its type starts with an 'e' (like ePlayerMode). Here are the list of possible enums that script interface calls take, and their possible values:

// the basic move type each terrain type can be classified into
ENUM eResourceType {
// special enum to signify all natural resources
kResourceType_AllNaturalResource,
kResourceType_Food,
kResourceType_Wood,
kResourceType_Stone,
kResourceType_Gold,
kResourceType_Tin,
kResourceType_Iron,
kResourceType_Saltpeter,
kResourceType_Oil,
kResourceType_Uranium,
};

// Player mode enumeration - each UnitTypeAttribute has a player mode,
// which is used to determine whether units are contained in the set
// described by a UnitTypeAttribute depending on their ownership. For
// a unit, its mode will be kPlayerMode_Self, which is the default for
// all UnitTypeAttributes.
ENUM ePlayerMode {
kPlayerMode_Anybody, //all players (including the world player)
kPlayerMode_Self, //only units that belong to me.
kPlayerMode_Allies, //only units that belong to my allies
kPlayerMode_SelfAndAllies,//units that belong to me OR my allies
kPlayerMode_Enemies, //units that belong to my declared enemies
kPlayerMode_NonSelf, //enemies and allies, just not me
kPlayerMode_World, //the world player only (resources, animals)
kPlayerMode_NotTheWorld, //anybody who is not the world player
};

//These are the four crown types.
ENUM eCrownType {
kCrownType_Military,
kCrownType_Economic,
kCrownType_Cultural,
kCrownType_Imperial,
};

// determine how out of range time is handled by an animator
enum EVisualLoopType
{
// anim will loop until changed
eVISUAL_LOOP,
// anim will play once then stay at the last pose
eVISUAL_CLAMP,
// anim will play forward then backward etc ...
eVISUAL_PINGPONG
};

enum eDiplomaticState
{
//If player X is hostile toward player Y, player X automatically
//gets the 'attack' cursor when mousing over Y's units. These
//enemy units will also be considered valid targets of
//opportunity (based on the players unit AI settings). This is a
//nonreflexive state - X's hostility toward Y doesn't necessarily
//imply Y's hostility toward X.
kDiplomaticState_Hostile,

//Players who have a neutral diplomatic stance don't get the
//attack cursor by default, but can use a keyboard modifier key
//to initiate attack. Trading is allowed between neutral
//players.
kDiplomaticState_Neutral,

//When two players are allied, all kinds of stuff can happen
//depending on the scope of their alliance. This is a reflexive
//relationship - 'X allied with Y' implies 'Y allied with X' in
//the exactly symmetric fashion.
kDiplomaticState_Allied,
};

enum eAllianceDuration
{
//The alliance will only last until war is declared by either
//party.
kAllianceDuration_UntilWar,

//The alliance has a specific time duration and cannot be broken
//until then.
kAllianceDuration_Timed,
};

enum eAllianceLOSState
{
//Each party gets full shared LOS from the other's units.
kAllianceLOSState_Full,

//Each party only gets shared LOS from the other's buildings.
kAllianceLOSState_Buildings,

//Each party only gets shared LOS from the other's mobile units
kAllianceLOSState_MobileUnits,

//Neither party gets any LOS from the other.
kAllianceLOSState_None,
};


enum eAllianceBorderPerm
{
//Each player has full access to the other player's empire,
//regardless of borders.
kAllianceBorderPerm_Full,

//Only civilian units may pass through the other player's
//borders.
kAllianceBorderPerm_Civilian,

//No units may pass through the other player's borders.
kAllianceBorderPerm_None,
};

enum eAllianceResRight
{
//Other player may freely harvest from any resource located
//within the other player's borders.
kAllianceResRight_Full,

//The player individually specifies the resources that can be
//harvested by the other player. The player also specifies a
//'Tariff' associated with the resource rights. This is a
//percentage that the player harvesting pays in the resource
//being harvested. Valid percentages range from 0 to 99%.
kAllianceResRight_Specified,

//Other player may not harvest any resource located within the
//other player's borders.
kAllianceResRight_None,
};

enum eStanceType {
kStanceType_Aggressive,
kStanceType_Defensive,
kStanceType_HoldPosition,
kStanceType_Cautious,
};

// Enumeration of the different weather states. Normal is the default.
ENUM eWeatherState {
kWeatherState_Normal,
kWeatherState_RainLt,
kWeatherState_SnowLt,
kWeatherState_DustLt,
kWeatherState_RainHv,
kWeatherState_SnowHv,
kWeatherState_DustHv,
kNumWeatherStates,
};

// This is an enumeration of the different area effect types. Many
// special unit powers directly correspond to an effect type. You can // use this enum to see if a player has used a particular unit power.
// The enum shown here is not comprehensive. There are many more
// effect types. If you're looking for one and you don't see it here, // it most likely exists and is ready to use, but it might
// require a little bit of programming support first.
ENUM eEffectType {
kEffectType_GatherIntel,
kEffectType_Extraction,
kEffectType_Contaminate,
kEffectType_Sabotage,
kEffectType_Cloak //this is what the Pyramids do, amongst other things



-------------------------------------------

LIST OF ALL IES SCRIPT COMMANDS

Again, an overview of all commands that the compiler knows in the editor.

DoDisplayDialog
void SetUnitDisplayName(const char *in_szUnitNameInScript, const char *in_szTextDatabaseEntry);
void CreateUnitAtLocation(int in_iPlayerID,const char *in_szTypeName,bool in_bSpecialForces, float in_fXLoc, float in_fYLoc,float in_fAngle)
void CreateNamedUnitAtLocation(int in_iPlayerID,const char *in_szTypeName, const char *in_szUnitName,bool in_bSpecialForces, float in_fXLoc, float in_fYLoc,float in_fAngle)
void CreateGroupedUnitAtLocation(int in_iPlayerID,const char *in_szTypeName, const char *in_szUnitName,bool in_bSpecialForces, float in_fXLoc, float in_fYLoc,float in_fAngle)
void SetUnitPlacementAngle(float in_fAngle)
void CreateUnitInArea(int in_iPlayerID,const char *in_szTypeName,bool in_bSpecialForces, const char *in_szAreaName)
void CreateNamedUnitInArea(int in_iPlayerID,const char *in_szTypeName, const char *in_szUnitName,bool in_bSpecialForces, const char *in_szAreaName)
void CreateGroupedUnitInArea(int in_iPlayerID,const char *in_szTypeName, const char *in_szUnitName,bool in_bSpecialForces, const char *in_szAreaName)
void CreateUnitInTerritory(int in_iPlayerID, const char* in_szTypeName, bool in_bSpecialForces,const char* in_szTerritoryName)
void CreateNamedUnitInTerritory(int in_iPlayerID,const char *in_szTypeName, const char *in_szUnitName,bool in_bSpecialForces, const char *in_szTerritoryName)
void CreateGroupedUnitInTerritory(int in_iPlayerID,const char *in_szTypeName, const char *in_szUnitName,bool in_bSpecialForces, const char *in_szTerritoryName)
void CreateUnitInUnit(int in_iPlayerID, const char* in_szTypeName,bool in_bSpecialForces, const char* in_szTargetUnit)
void CreateNamedUnitInUnit(int in_iPlayerID, const char* in_szTypeName,const char* in_szUnitName, bool in_bSpecialForces, const char* in_szTargetUnit)
void CreateGroupedUnitInUnit(int in_iPlayerID, const char* in_szTypeName,const char* in_szGroupName, bool in_bSpecialForces, const char* in_szTargetUnit)

void GenerateAIBuildManagers(const char* in_szCapitolName)
void PausePlayerAI(int in_iPlayerID, bool bPaused)
void SetAIInstantRallying(int in_iPlayerID, bool in_bShouldInstantRally)
void AI_ChangePersonality(int in_iPlayerID, const char *in_szFileName)
AI_LoadCivSpecificPersonality
void AI_SetAttackFactor(int in_iPlayerID, float in_fFactor)
void AI_SetBuildTimeFactor(int in_iPlayerID, float in_fFactor)
void AI_SetBuildCostFactor(int in_iPlayerID, float in_fFactor)
void AI_CreateBattalion(int in_iPlayerID, const char* in_szMyUnitGroupName, const char *in_szEnemyUnitGroupName, const char* in_szTerritoryName, eTaskType in_eTaskType)

void SetPlayerToCinematicOnly(int in_PlayerID, bool in_bCinematicOnly)
void SetPlayerResource(int in_iPlayerID, eResourceType in_eResType,int in_iAmount)
void AddPlayerResource(int in_iPlayerID, eResourceType in_eResType,int in_iAmountToAdd)
void RemovePlayerResource(int in_iPlayerID,eResourceType in_eResType, int in_iAmountToRemove)
void LiftShroudForPlayer(int in_iPlayerID)
void ToggleFogOfWar(bool in_bFogOn)
void ResetFogOfWar(int in_iPlayerID)
void CarveShroudCircle(int in_iPlayerID, float in_fX, float in_fY, int in_iRadius)
void CarveShroudOverTerritory(int in_iPlayerID, const char* in_szTerritoryName)
void PlaceFlare(float in_fX, float in_fY, int in_iRadius, int in_iPlayerID, float in_fDuration)
void FlushFlares(int in_iPlayerID)
void FlareMiniMap(int in_iPlayerID, float in_fX, float in_fY)
void FlareMiniMapForDuration(int in_iPlayerID, float in_fX, float in_fY, float in_fDuration)
void AlertPlayer()
void CarveShroudArea(int in_iPlayerID, const char *in_szAreaName)

void SetPopCapPerCityCenterForPlayer(int in_iPlayerID,
void SetMaxPopCapacity(int in_iPlayerID, int in_iNewMaxPopCap)
Void NewMissionTimer(const char *in_szTextDBEntry, int in_iTimerID);
void NewMissionTimerWithFormattedName(bool in_bMissionTimer);
void SetMissionTimer(int in_iTimerID, int in_iTimeInSeconds);
void StartMissionTimer(int in_iTimerID)
void PauseMissionTimer(int in_iTimerID)
int NewMissionStatusString()
void SetTechEnabled(int in_iPlayerID, const char *in_szTechName, bool in_bEnabled)
void AdvancePlayerEpoch(int in_iPlayerID, int in_iEpoch)
void AwardTech(int in_iPlayerID, const char* in_szTechName)
void SetMaxEpochUI(int in_iMaxEpoch)
void CallNamedEventHandler(const char *in_szEventHandlerName, const char *in_szArgument)
int AttachEffectToUnit(const char *in_szUnitName, const char *in_szEffectName)
int AttachEffectToGroup(const char *in_szGroupName, const char *in_szEffectName)
int AttachEffectToPlayer(int in_iPlayerID, const char *in_szEffectName)
int AttachEffectToPlayerAtLocation(int in_iPlayerID,const char *in_szEffectName,float in_fX,float in_fY)
void CancelEffect(int in_iEffectID)
SetPlayerWinner
void WinScenario()
void LoseScenario()
bool HasPlayerResearchedTech(int in_iPlayerID, const char* in_szTechName)
int GetOwningPlayerForTerritory(const char* in_szTerritoryName)
void ChangeTerritoryOwner(const char* in_szTerritoryName, int in_iNewPlayer)
void ChangeTerritoryCityName(const char* in_szTerritoryName, const char* in_szCityName)
int GetNumTerritoriesForPlayer(int in_PlayerID)
GetNumberTerritoriesTributed
bool DidPlayerTributeTerritoryToOwner(const char* in_szTerritoryName, int in_iPreviousOwner)

void AddAirMissionWayPoint(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber, float in_waypointX, float in_waypointY);
void AddAirMissionWayPointArea(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber, const char *in_szAreaName);
void CancelAirMission(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber);
void AssignAirplaneToMission(const char *in_szAirportUnitName, eAirMissionType in_missionType, int in_missionNumber, const char *in_szAirplaneUnitName) = 0;

int GetCurrentBuyPrice(int in_iPlayer, eResourceType in_eType)
int GetCurrentSellPrice(int in_iPlayer, eResourceType in_eType)
int GetCurrentInflationRate(int in_iPlayer, eResourceType in_eType)
int GetCurrentDeflationRate(int in_iPlayer, eResourceType in_eType)
int GetCurrentMaxBuyPrice(int in_iPlayer, eResourceType in_eType)
int GetCurrentMinSellPrice(int in_iPlayer, eResourceType in_eType)
void SetBuyPrice(int in_iPlayer, eResourceType in_eType, int in_iValue)
void SetSellPrice(int in_iPlayer, eResourceType in_eType, int in_iValue)
void SetInflationRate(int in_iPlayer, eResourceType in_eType, int in_iValue)
void SetDeflationRate(int in_iPlayer, eResourceType in_eType, int in_iValue)
void SetMaxBuyPrice(int in_iPlayer, eResourceType in_eType,int in_iValue)
void SetMinSellPrice(int in_iPlayer, eResourceType in_eType,int in_iValue)

void StartPlayingCinematic(const char *in_szCinematicName)
void DoDelayUntilCinematicTime(float in_fMark, cIEScript *pIEScript)
void DoDelayUntilCinematicFinished(cIEScript *pIEScript)
void SetCinematicTime(float in_fTime)
void PlayBink(const char *in_Binkfilename)

void StartFormat(const char *in_szTextDBEntry)
void FormatPlayerName(const char *in_szArgument, int in_iPlayerID)
void FormatPlayerCiv(const char *in_szArgument, int in_iPlayerID)
void FormatInt(const char *in_szArgument, int in_iValue)
void FormatFloat(const char *in_szArgument, float in_fValue)
void FormatEnum(const char *in_szArgument, const char *in_szEnumName, int in_iValue)
void FormatString(const char *in_szArgument, const char *in_szTextDBEntry)
void PrintFormattedMessage()
void PrintFormattedSubtitle()
void PrintFormattedMissionStatusString (int in_iStringID)
void PIPSetBookmarkLocation(int in_iPlayerID, int in_iBookmark, float in_fX, float in_fY, float in_fDistance)
void PIPSetBookmarkUnit(int in_iPlayerID, int in_iBookmark, const char *in_szUnitName, float in_fDistance)
void PIPViewBookmark(int in_iBookmark)
void PIPCycleMode(bool in_bCycle)
void PIPEnable(bool in_bEnable)

void CreateDialogBox(const char *in_szTitle,const char* in_szDisplayText,bool in_bPauseGame)
void CreateObjectiveDialogBox(const char *in_szObjectiveName,bool in_bPauseGame)
bool IsObjectiveDialogBoxOpen()
void SetAllowObjectiveDialogInEncyclopedia(bool in_bAllow)
bool IsObjectiveCompleted(const char *in_szObjectiveName)
bool IsObjectiveFailed(const char *in_szObjectiveName)
bool IsObjectiveUnlocked(const char *in_szObjectiveName)
bool AllPrimaryObjectivesCompleted()
bool AllSecondaryObjectivesCompleted()
bool AnyPrimaryObjectivesFailed()
bool AnyLoseConditionsFailed()
void SetObjectiveUnlocked(const char *in_szObjectiveName)
void SetObjectiveLocked(const char *in_szObjectiveName)
void SetObjectiveCompleted(const char *in_szObjectiveName)
void SetObjectiveNotCompleted(const char *in_szObjectiveName)
void SetObjectiveFailed(const char *in_szObjectiveName)
void ChangeObjectiveDescription(const char *in_szObjectiveName,const char *in_szDescriptionText)
void ObjectiveClearAllTargets(const char *in_szObjectiveName)
void ObjectiveSetTargetLocation(const char *in_szObjectiveName,float in_fX, float in_fY)
void ObjectiveAddTargetLocation(const char *in_szObjectiveName,float in_fX, float in_fY)
bool ObjectiveRemoveTargetLocation(const char *in_szObjectiveName,float in_fX, float in_fY)
void ObjectiveClearTargetLocations(const char *in_szObjectiveName)
void ObjectiveSetTargetUnit(const char *in_szObjectiveName,const char *in_szUnitName)
void ObjectiveAddTargetUnit(const char *in_szObjectiveName,const char *in_szUnitName)
bool ObjectiveRemoveTargetUnit(const char *in_szObjectiveName,const char *in_szUnitName)
void ObjectiveClearTargetUnits(const char *in_szObjectiveName)
void ObjectiveSetTargetArea(const char *in_szObjectiveName,const char *in_szAreaName)
void ObjectiveAddTargetArea(const char *in_szObjectiveName,const char *in_szAreaName)
bool ObjectiveRemoveTargetArea(const char *in_szObjectiveName,const char *in_szAreaName)
void ObjectiveClearTargetAreas(const char *in_szObjectiveName)
void ObjectiveSetTargetTerritory(const char *in_szObjectiveName,const char *in_szTerritoryName)
void ObjectiveAddTargetTerritory(const char *in_szObjectiveName,const char *in_szTerritoryName)
bool ObjectiveRemoveTargetTerritory(const char *in_szObjectiveName,const char *in_szTerritoryName)
void ObjectiveClearTargetTerritories(const char *in_szObjectiveName)

bool SelectUnit(const char *in_szUnitName)
bool SelectGroup(const char *in_szGroupName)
bool SelectGroupForPlayer(const char* in_szGroupName,int in_iPlayerID)
bool ClearSelection()
bool CreateNamedGroup(const char *in_szGroupName)
bool AddUnitToGroup(const char *in_szGroupName,const char *in_szUnitName)
bool RemoveUnitFromGroup(const char *in_szGroupName,const char *in_szUnitName)
bool AddGroupToGroup(const char *in_szGroupTo,const char *in_szGroupFrom)
bool RemoveGroupFromGroup(const char *in_szGroupTo,const char *in_szGroupFrom)
bool AddUnitsByAttributeToGroup(const char *in_szGroupName,const char *in_szAttributeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool RemoveUnitsByAttributeFromGroup(const char *in_szGroupName,const char *in_szAttributeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool AddUnitsByTypeToGroup(const char *in_szGroupName,const char *in_szUnitTypeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool RemoveUnitsByTypeFromGroup(const char *in_szGroupName,const char * in_szUnitTypeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool AddDeadUnitsByAttributeToGroup(const char *in_szGroupName,const char *in_szAttributeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool AddDeadUnitsByTypeToGroup(const char *in_szGroupName,const char *in_szUnitTypeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool AddUnitsInCityToGroup(const char* in_szGroupName,const char* in_szAttributeName,int in_iPlayerID,ePlayerMode in_ePlayerMode,const char* in_szCityName)
bool RemoveUnitsInCityFromGroup(const char* in_szGroupName,const char* in_szAttributeName,int in_iPlayerID,ePlayerMode in_ePlayerMode,const char* in_szCityName)
bool AddUnitsByAttributeToGroupFromTerritory(const char *in_szGroupName, const char *in_szAttributeName, int in_iPlayerID, ePlayerMode in_ePlayerMode, const char *in_szTerritoryName)
bool RemoveUnitsByAttributeFromGroupFromTerritory(const char *in_szGroupName, const char *in_szAttributeName, int in_iPlayerID, ePlayerMode in_ePlayerMode, const char *in_ szTerritoryName)
bool AddUnitsByTypeToGroupFromTerritory(const char *in_szGroupName,const char *in_szUnitTypeName, int in_iPlayerID,ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool RemoveUnitsByTypeFromGroupFromTerritory (const char *in_szGroupName, const char * in_szUnitTypeName, int in_iPlayerID, ePlayerMode in_ePlayerMode, const char *in_szAreaName)
bool AddUnitsByAttributeInLOSToGroup(int in_iPlayerWhoSeesID,const char* in_szGroupName, const char* in_AttributeName,int in_iPlayerWhoControlsID)
bool RemoveUnitsByAttributeInLOSFromGroup(int in_iPlayerWhoSeesID,const char* in_szGroupName, const char* in_AttributeName,int in_iPlayerWhoControlsID)
bool AddUnitsByTypeInLOSToGroup(int in_iPlayerWhoSeesID,const char* in_szGroupName, const char* in_AttributeName,int in_iPlayerWhoControlsID)
bool RemoveUnitsByTypeInLOSFromGroup(int in_iPlayerWhoSeesID,const char* in_szGroupName, const char* in_AttributeName,int in_iPlayerWhoControlsID)
bool PlayerHasLOSToAnyoneInGroup(int in_iPlayerID,const char *in_szGroupName)
bool UnitHasLOSToAnyoneInGroup(const char *in_szUnitName,const char *in_szGroupName)
bool GroupHasLOSToAnyoneInGroup(const char *in_szWatchers,const char *in_szTargets)
bool NamedUnitIsInArea(const char *in_szUnitName,const char *in_szAreaName)
bool AnyoneFromGroupIsInArea(const char *in_szGroupName,const char *in_szAreaName)
bool EveryoneFromGroupIsInArea(const char *in_szGroupName,const char *in_szAreaName)
bool NamedUnitIsInTerritory(const char *in_szUnitName,const char *in_szTerritoryName)
bool AnyoneFromGroupIsInTerritory(const char *in_szGroupName,const char *in_szTerritoryName)
bool EveryoneFromGroupIsInTerritory(const char *in_szGroupName,const char *in_szTerritoryName)
void AddToControlGroupFromGroup(const char *in_szGroupName,int in_iPlayerID, int in_iControlGroupNumber)
void SetControlGroupFromGroup(const char *in_szGroupName,int in_iPlayerID, int in_iControlGroupNumber)
void ClearControlGroup(int in_iPlayerID, int in_iControlGroupNumber)
void AddToGroupFromControlGroup(int in_iControlGroupNumber,int in_iPlayerID, const char *in_szGroupName)
void LookAtControlGroup(int in_iPlayerID,int in_iControlGroupNumber)
bool ControlGroupHasUnits(int in_iPlayerID, int in_iControlGroupNumber)
void MoveSelection(float fX, float fY)
void MoveSelectionToArea(const char *in_szAreaName)
void MoveSelectionToTerritory(const char *in_szTerritoryName)
void MoveSelectionToAreaWithAttack(const char *in_szAreaName,bool in_bGroupAttack)
void MoveSelectionToTerritoryWithAttack(const char *in_szTerritoryName, bool in_bGroupAttack)
void InstantMoveSelectionToArea(const char* in_szAreaName, int iMaxDistance)
void InstantMoveSelection(float fX, float fY, int iMaxDistance)
ReloadSelection

void PatrolWithSelection(const char *in_szPoint1,const char *in_szPoint2, const char *in_szPoint3,const char *in_szPoint4, const char *in_szPoint5,const char *in_szPoint6, const char *in_szPoint7,const char *in_szPoint8)
void AttackAreaWithSelection(const char *in_szAreaName)
void GiveAttackBasePreference(int in_iPlayerID,const char *in_szAreaName, float in_priorityBoost)
void GiveDefendBasePreference(int in_iPlayerID,const char *in_szAreaName, float in_priorityBoost)
void GiveCaptureTerritoryPreference (int in_iPlayerID,const char *in_szTerritoryName, float in_priorityBoost)
void GiveAttackArmyPreference(int in_iPlayerID,const char* in_szTypeName, float in_priorityBoost)
void SetSelectionFormation(const char *in_szFormationName)
void AttackWithSelection(const char *in_szAttackee)
void AttackGroupWithSelection(const char *in_szTargetGroupName)
void CaptureWithSelection(const char *in_szTarget)
void SetSelectionStance(eStanceType in_eStance)
void SearchAndDestroyWithSelection()
void SearchAndDestroyWallsWithSelection()
void GatherFromNamedUnitWithSelection(const char *in_szUnitName)
GatherResourceWithSelection
void GuardWithSelection(const char* in_szUnitToGuard)
void StopSelection()
void ExploreWithSelection()
bool IsUnitExploring(const char* in_szUnitName)
bool IsAnyoneInGroupExploring(const char* in_szGroupName)
bool IsUnitPatrolling(const char* in_szUnitName)
bool IsAnyoneInGroupPatrolling(const char* in_szGroupName)
void RemoveGarrisonedUnitsFromGroup(const char* in_szGroupName)
void GarrisonSelection(const char *in_szContainerName)
void UngarrisonSelection()
UngarrisonSelectionAtLocation
bool IsUnitGarrisoned(const char* in_szUnitName)
IsUnitSabotaged
GetNumGarrisoned(const char *in_szGroupName)
int CountUnitsGarrisonedInUnit(const char* in_szUnitName)
int CountUnitsGarrisonedInGroup(const char* in_szGroup)

void KillSelection()
void RemoveSelection()
void HealUnit(const char *in_szUnitName)
void HealGroup(const char *in_szGroupName)
void DamageUnit(const char *in_szUnitName, float in_fAmount)
void DamageGroup(const char *in_szGroupName, float in_fAmount)
void SetUnitOwnedBy(const char *in_szUnitName,int in_iPlayerID)
void SetGroupOwnedBy(const char *in_szGroupName,int in_iPlayerID)
PauseUnitAI
PauseGroupAI
void SetUnitSpecialForces(const char *in_szUnitName,bool in_bSpecial)
void SetGroupSpecialForces(const char *in_szGroupName,bool in_bSpecial)
void SetResourcesGatheredTypeAndAmount(eResourceType in_resourceType, int in_iAmount)
void SetResourcesGatheredAmount(int in_iAmount)
bool IsSelectionInsideCity(const char* in_szCityName, bool in_bAll)
void UseSpecialPowerSelf(const char* in_szSpecialPower)
void UseSpecialPowerTarget(const char* in_szSpecialPower,const char* in_szTargetUnitName)
void UseSpecialPowerLocation(const char* in_szSpecialPower,float in_fX, float in_fY)
void UseSpecialPowerOnTargetInArea(const char* in_szPowerName,const char* in_szAreaName)
void UseSpecialPowerOnTargetInGroup(const char* in_szPowerName,const char* in_szGroupName)
void RechargePowerReserve()
bool HasPlayerUsedSpecialPowerRecently(int in_iWhichPlayer,eEffectType in_whichEffect, float in_fTimePeriod)
int NumTimesPlayerUsedRegionPower(int in_iPlayerID)
bool IsEffectOfTypeOnSelection(eEffectType in_whichEffect, bool in_bAll)
void StartBuildWall(int in_iPlayerID, float in_fX, float in_fY,const char* in_szWallBaseType);
void StartBuildRoad(int in_iPlayerID, float in_fX, float in_fY,const char* in_szRoadBaseType);
void AddConnectableWaypoint(float in_fX, float in_fY)
void SelectionBuildConnectable()
void BlinkSelectionCircles(float in_fDuration)

void ShowMissionTimerWidget(int in_iTimerID, bool in_bShow);
void ShowMissionStatusString(int in_iStringID, bool in_bShow)
void SetVisualStateOnUnit(const char *in_szUnitName, const char *in_szVisualStateName, float in_fStateLoopTime, EVisualLoopType in_eLoopType)
void PrintMessage(const char *in_szMessage)
void PrintMessageFromPlayer(const char* in_szMessage, int in_iPlayerID)
void ClearMessage()
void PrintSubtitle(const char *in_szMessage)
void ClearSubtitle()
SetCameraLookAt(float in_fX, float in_fY, bool in_bPIP)
void SetCameraLookAtArea(const char *in_szAreaName, bool in_bPIP)
void SetCameraHeading(float in_fAngle, bool in_bPIP)
void SetCameraDistanceFraction(float in_fFraction, bool in_bPIP)
void DebugOutputString(const char *in_szDebugString)
void ClearDebugBuffer()
bool IsUnitBookMarked(const char* in_szUnitName)
IsBookmarkSet
bool IsUnitSelectedUI(const char* in_szUnitName)
bool IsGroupSelectedUI(const char* in_szGroupName)
bool IsWidgetVisible(const char* in_szWidgetName)
void SetWarPlanDeleteEnabled(bool in_bEnabled)
void SetWarPlanCopyEnabled(bool in_bEnabled)
void SetWarPlanSendToAlliesEnabled(bool in_bEnabled)
bool ShowMonthWidget(bool in_bShow)
bool IsUserPlacingType(const char* in_szUnitTypeName)
void DisableCitizenManager()
void FlashWidgetUntilClicked(const char *in_szWidgetName, bool in_bStopFlashingIfHotkeyActivated)
void FlashWidgetForTime(const char *in_szWidgetName, float in_fTimeInSeconds)
void FlashWidgetUntilStopped(const char *in_szWidgetName)
void StopFlashingWidget(const char *in_szWidgetName)
HackMakeWidgetFlashable
void AddWidgetListenForSelection(const char *in_szWidgetName,bool in_bCountHotkeyActivationAsSelection)
void AddWidgetListenForSelectionWithEventAndArg(const char *in_szWidgetName, const char *in_szEventName, const char *in_szEventArg)
void RemoveWidgetListenForSelection(const char *in_szWidgetName)
bool HasWidgetBeenSelected(const char *in_szWidgetName)
int GetWidgetSelectionCount(const char *in_szWidgetName)
bool HasTextBeenTyped( const char *in_szText)
void SuppressTerritoryMessages(bool in_bSuppressMessages)
void SetDontPauseDuringEncyclopedia(bool in_bPauseGame)
void SetDontPauseDuringDiplomacy(bool in_bPauseGame)
void SetDontPauseDuringScenarioBriefing(bool in_bPauseGame)

int StartPlayingSound(const char *in_szSoundSampleName);
Void StopSound(int in_handle);
void StopAllScriptSounds();
int PlayVoiceOver(const char *in_filename);
int PlayUnpausableVoiceOver(const char *in_filename);
int PlayLoopingVoiceOver(const char *in_filename);
void FadeOutSound(int in_handle, float in_length);
bool IsSoundPlaying(int in_iNonce) = 0;
void ToggleStreamingMusic(bool in_enable);
int PlayLoopingMusic(const char *in_filename);
int PlayOneShotMusic(const char *in_filename);

eDiplomaticState GetDiplomaticState(int in_iFromPlayer, int in_iToPlayer)
void SetDiplomaticState(int in_iFromPlayer, int in_iToPlayer, eDiplomaticState in_eState)
bool IsDiplomaticStateLocked(int in_iPlayer1ID, int in_iPlayer2ID)
void LockDiplomaticState(int in_iPlayer1ID, int in_iPlayer2ID)
void UnlockDiplomaticState(int in_iPlayer1ID, int in_iPlayer2ID)
bool IsAllianceProposalWaiting(int in_iPlayer1ID, int in_iPlayer2ID)
float GetWaitingProposalTimeElapsed (int in_iFromPlayer,int in_iToPlayer)
eAllianceDuration GetWaitingProposalDurationType(int in_iFromPlayer,int in_iToPlayer)
float GetWaitingProposalDuration (int in_iFromPlayer,int in_iToPlayer)
eAllianceLOSState GetWaitingProposalLOSState(int in_iFromPlayer, int in_iToPlayer)
eAllianceBorderPerm GetWaitingProposalBorderPermission(int in_iFromPlayer, int in_iToPlayer)
bool WaitingProposalAllowsMiningOf(int in_iFromPlayer,int in_iToPlayer, eResourceType in_eResourceType)
int WaitingProposalTariffPercentage(int in_iFromPlayer,int in_iToPlayer, eResourceType in_eResourceType)
int GetWaitingProposalTribute(int in_iPlayerFromID,int in_iPlayerToID, eResourceType in_eResourceType)
void RejectWaitingProposal(int in_iFromPlayer, int in_iToPlayer)
void AcceptWaitingProposal(int in_iFromPlayer, int in_iToPlayer)
void EnterAllianceProposal(int in_iPlayer1ID, int in_iPlayer2ID,eAllianceDuration in_eDuration, float in_fLength,eAllianceLOSState in_eLOS,eAllianceBorderPerm in_eBorderPermission,eAllianceResRight in_eResourceRight)
StartAllianceProposal
SendAllianceProposal
SetAllianceProposalDurationUntilWarIsDeclared
SetAllianceProposalDurationTimed
SetAllianceProposalLOSState
SetAllianceProposalBorderPermission
SetAllianceProposalResourceRight
AddAllianceProposalTributeResource
AddAllianceProposalTributeUnits
AddAllianceProposalTributeTerritory
bool StartVerifyAllianceProposal(int in_iPlayer1ID, int in_iPlayer2ID)
bool VerifyProposalDurationNotLongerThan(eAllianceDuration in_eDurationType, float in_fDuration)
bool VerifyProposalDurationNotShorterThan(eAllianceDuration in_eDurationType, float in_fDuration)
bool VerifyProposalLOS(eAllianceLOSState in_eLOS)
bool VerifyProposalBorderPermissions(eAllianceBorderPermissions in_eBorderPermissions)
bool VerifyProposalResourceRightsNotMoreThan(int in_iPercent)
bool VerifyProposalResourceRightsNotLessThan(int in_iPercent)
bool VerifyProposalTributeResource( eResourceType in_eType,int in_iAmount)
bool VerifyProposalTributeTerritory(const char* in_szTerritoryName)
bool FinishVerifyAllianceProposal()
void ForceAlliance(int in_iPlayer1ID, int in_iPlayer2ID,eAllianceDuration in_eDuration, float in_fLength,eAllianceLOSState in_eLOS,eAllianceBorderPerm in_eBorderPermission,eAllianceResRight in_eResourceRight)
void TributeResource(int in_iPlayerFromID, int in_iPlayerToID,eResourceType in_eResourceType, int in_iAmount)
void TributeTerritory(const char *in_szTerritoryName)
void TributeUnits(const char *in_szUnitName)
void SetAIDiplomacyEnabled(int in_iPlayerID, bool bEnabled)
void SetAIWarplansEnabled (int in_iPlayerID, bool in_bEnabled)
void SetAITauntsEnabled(bool bEnabled)
void ForceSurrenderOffer(int in_iPlayerAI, int in_iPlayerHuman)
bool IsAnyWarplanSentFromPlayerToPlayer(int in_iPlayerSendID, int in_iPlayerReceiveID)
bool AcceptPendingPlanFromPlayer(int in_iSendingPlayer, int in_iReceivingPlayer)

int GetCurrentMonth()
int GetCurrentSeason()
void SetCurrentMonth(int in_iMonth)
void SetCurrentTimeOfDay(int in_iHour)
void SetSecondsPerYear(float in_fSecPerYear)
void PauseCalendar(bool in_bPause)
void PauseCalendarAtMonth(int in_iWhichMonth)
void PauseWeatherSystem(bool in_bPause)
void ChangeToWeather(enum eWeatherState in_whichWeather, float in_fTransitionTime)
void StartLightningBolt()
void StartLightningBoltAtLocation(float in_fX, float in_fY)
void StartLightningBoltHitUnit(const char* in_szTargetUnitName, float in_fDamageAmount)
void ChangeToSkybox(const char* in_szSkyboxName, float in_fTransitionTime);

int RandomIntBetween(int in_iLow, int in_iHigh)
float RandomFloatBetween(float in_fLow, float in_fHigh)
bool IsMissionTimerExpired(int in_iTimerID)
int GetMissionTimer(int in_iTimerID)
float GetDistanceFromUnitToPoint(const char *in_szUnitName, float in_fX, float in_fY)
float GetDistanceFromUnitToUnit(const char *in_szUnit1Name, const char *in_szUnit2Name)
float GetMinDistanceFromUnitToGroup(const char *in_szUnitName, const char *in_szGroupName)
float GetMaxDistanceFromUnitToGroup(const char *in_szUnitName, const char *in_szGroupName)
bool DoesWallCoverGap(int in_iPlayerID, const char* in_szAreaA, const char* in_szAreaB, int in_iMaxUnits)
bool DoesRoadCoverGap(int in_iPlayerID, const char* in_szAreaA, const char* in_szAreaB, int in_iMaxUnits)
bool DoesUnitExist(const char *in_szUnitName)
void NameRandomUnitInGroup(const char *in_szGroupName, const char *in_szUnitName)

eUnitGoalType GetUnitGoalType(const char *in_szUnitName)
float GetUnitHealth(const char *in_szUnitName)
int GetPlayerResource(int in_iPlayerID, eResourceType in_eResType)
float GetPlayerCrownScore(int in_iPlayerID, eCrownType in_eCrownType)
float GetPlayerCrownThreshold(int in_iPlayerID, eCrownType in_eCrownType)
void AdjustPlayerCrownScore(int in_iPlayerID, eCrownType in_eCrownType, float in_fAdjustment)
void AwardCrown(int in_iPlayerID, eCrownType whichCrown)
void AddCrownPowerForAllPlayers(eCrownType in_eCrownType, const char* in_szPowerName)
void RemoveCrownPowerForAllPlayers(eCrownType in_eCrownType, const char* in_szPowerName)
void AddCrownPowerForOnePlayer(int in_iPlayerID, eCrownType in_eCrownType, const char* in_szPowerName)
void RemoveCrownPowerForOnePlayer(int in_iPlayerID, eCrownType in_eCrownType, const char* in_szPowerName)
void LimitPlayerToOneCrownPower(int in_iPlayerID, eCrownType in_eCrownType, const char* in_szPowerName)
int PlayerWhoHasCrown(eCrownType in_eCrownType)
bool HasPlayerEarnedCrown(int in_iPlayerID, eCrownType in_eCrownType)
SetAllowLeaderForCrown(int in_iPlayerID, eCrownType in_eCrownType, bool m_bMayBuild)
GetAmountOfResourcesCollected
int GetAmountOfGoldFromTrade(int in_iPlayerID)

int GetNumCitizensGatheringResource(int in_iPlayerID, eResourceType in_eType)
int GetNumDeadUnits(int in_iFromPlayerID)
int GetNumDeadUnitsOfType(int in_iFromPlayerID, const char *in_szUnitTypeName)
int GetNumDeadUnitsByAttribute(int in_iFromPlayerID, const char *in_szAttributeName)

int GetNumConvertedUnitsOfType(int in_iToPlayerID, const char *in_szUnitTypeName)
int GetNumConvertedUnitsByAttribute(int in_iToPlayerID, const char *in_szAttributeName)
int GetNumConvertedAwayUnitsOfType(int in_iFromPlayerID, const char *in_szUnitTypeName)
int GetNumConvertedAwayUnitsByAttribute(int in_iFromPlayerID, const char *in_szAttributeName)
int GetNumConvertedUnitsFromPlayerOfType(int in_iFromPlayerID, int in_iToPlayerID, const char *in_szUnitTypeName)
int GetNumConvertedUnitsFromPlayerByAttribute(int in_iFromPlayerID, int in_iToPlayerID, const char *in_szAttributeName)

int GetNumKilledUnitsOfType(int in_iToPlayerID, const char *in_szUnitTypeName)
int GetNumKilledUnitsByAttribute(int in_iToPlayerID, const char *in_szAttributeName)
int GetNumKilledUnitsFromPlayerOfType(int in_iFromPlayerID, int in_iKillingPlayerID, const char *in_szUnitTypeName)
int GetNumKilledUnitsFromPlayerByAttribute(int in_iFromPlayerID, int in_iKillingPlayerID, const char *in_szAttributeName)
int GetNumProducedUnitsOfType(int in_iPlayerID, const char *in_szUnitTypeName)
int GetNumProducedUnitsByAttribute(int in_iPlayerID, const char *in_szAttributeName)

int GetAmountOfTribute(int in_iPlayerFromID, int in_iPlayerToID, eResourceType in_eResourceType)
int GetOwningPlayerID(const char *in_szUnitName)
bool IsGroupOwnedBy(const char *in_szGroupName, int in_iPlayerID)
int GetGroupOwnerID(const char *in_szGroupName)
float GetElapsedGameTime()
bool PlayerInGame(int in_iPlayerID)
bool PlayerHasResearchedTech(int in_iPlayerID, const char *in_szTechName)
int GetPlayerEpoch(int in_iPlayerID)
bool DoesPlayerHaveEnoughTechsToAdvance(int in_iPlayerID)
int NumUnitsInGroup(const char *in_szGroupName)
int NumUnitsInGroupNotDead(const char* in_szGroupName)
int GetNumPlayers()

bool IsPlayerAttackingInArea( int in_iAttackerID,int in_iTargetID,const char* in_szArea)
int GetLandTradeRoutesBetweenPlayers(int in_iPlayerA, int in_iPlayerB)
int GetSeaTradeRoutesBetweenPlayers(int in_iPlayerA, int in_iPlayerB)
int GetAllTradeRoutesBetweenPlayers(int in_iPlayerA, int in_iPlayerB)
int GetAllTradeRoutesForPlayer(int in_iPlayer)
bool HavePlayersTradedRecently(int in_iPlayerA,int in_iPlayerB,float in_fTimePeriod)

bool IsWeakestPlayer(int in_iPlayer, float in_fRequiredRatio);
bool IsStrongestPlayer(int in_iPlayer, float in_fRequiredRatio);
bool HasLeastResources(int in_iPlayer, float in_fRequiredRatio);
bool EnemiesArePlaneHappy(int in_iPlayer)
bool EnemiesHaveForsakenPlanes(int in_iPlayer)
int GetPlayerPopulation(int in_iPlayer);
OnIslandsMap
IsDeathmatchGame
HaveLowResources
float GetPercentOfMapExploredByPlayer(int in_iPlayerID)
bool IsPlayerHumanControlled(int in_iPlayerID)
void SetRollCreditsAfterScenario(bool in_bRollCredits)
WasHotKeyPressedRecently
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: List of all IES script commands for scenarios in EE2 and EE2X

Post by Loewenherz »

Here is a brief overview of all the operators used in IES scripting that were adopted from the C programming language.

C Arithmetic Operators


An arithmetic operator performs mathematical operations such as addition, subtraction, multiplication, division etc on numerical values (constants and variables).

Operator and Meaning of Operator

Code: Select all

+                       addition or unary plus

-                        subtraction or unary minus

*                        multiplication

/                        division

%                        remainder after division (modulo division) 
C Relational Operators

A relational operator checks the relationship between two operands. If the relation is true, it returns 1; if the relation is false, it returns value 0.

Relational operators are used in decision making and loops.

Code: Select all

Operator	    Meaning of Operator
				Example
		
==				Equal to
				5 == 3 is evaluated to 0
		
>				Greater than
				5 > 3 is evaluated to 1
		
<				Less than
				5 < 3 is evaluated to 0
		
!=				Not equal to
				5 != 3 is evaluated to 1
		
>=				Greater than or equal to
				5 >= 3 is evaluated to 1
		
<=				Less than or equal to
				5 <= 3 is evaluated to 0

C Logical Operators

An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false. Logical operators are commonly used in decision making in C programming.

Code: Select all

Operator			Meaning Example
				
		
&&				Logical AND. True only if all operands are true
				If c = 5 and d = 2 then, expression ((c==5) && (d>5)) equals to 0.
		
||				Logical OR. True only if either one operand is true
				If c = 5 and d = 2 then, expression ((c==5) || (d>5)) equals to 1.
		
!				Logical NOT. True only if the operand is 0
				If c = 5 then, expression !(c==5) equals to 0.
Explanation of logical operator program

(a == b) && (c > 5) evaluates to 1 because both operands (a == b) and (c > b) is 1 (true).
(a == b) && (c < b) evaluates to 0 because operand (c < b) is 0 (false).
(a == b) || (c < b) evaluates to 1 because (a = b) is 1 (true).
(a != b) || (c < b) evaluates to 0 because both operand (a != b) and (c < b) are 0 (false).
!(a != b) evaluates to 1 because operand (a != b) is 0 (false). Hence, !(a != b) is 1 (true).
!(a == b) evaluates to 0 because (a == b) is 1 (true). Hence, !(a == b) is 0 (false).

Probably the only assignment operator in the IES Scriptsystem.

Code: Select all

= 	Simple assignment operator. Assigns values from right side operands to left side operand 	C = A + B will assign the value of A + B to C
Data Types

Here's a table containing commonly used types in IES Scripting for quick access.

int

Integers are whole numbers that can have both zero, positive and negative values but no decimal values. For example, 0, -5, 10

float

float are used to hold real numbers.
In C, floating-point numbers can also be represented in exponential. For example,

float normalizationFactor = 22.442e2;

bool

In C, Boolean is a data type that contains two types of values, i.e., 0 and 1. Basically, the bool type value represents two types of behavior, either true or false. Here, '0' represents false value, while '1' represents true value.

string

In C programming, a string is a sequence of characters. In IES scripting, the names of areas, units or groups are stored here.

constant

Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.

cHotInt & cHotFloat

The IES Scripts use so-called hot-variables, the scripting system monitors these variables and re-evaluates rules that depend on them when the value changes.

cHotInt
cHotFloat

C - if...else statement


An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.

Code: Select all

////////////////////////////////////////////////////////////
// Make sure they have citizens
////////////////////////////////////////////////////////////
RULE ruleGiveCitizens
  if (CreateNamedGroup(GROUP_CITIZENS)
    && AddUnitsByAttributeToGroup(GROUP_CITIZENS, ATTRIBUTE_CITIZEN, HUMAN_PLAYER, kPlayerMode_Self, NULL)
    && (NumUnitsInGroup(GROUP_CITIZENS) < 5))
  then actionGiveCitizens
END_RULE

ACTION actionGiveCitizens
SCRIPT WORLD
    // Create/empty this group (don't want previously created citizens moving there too)
    CreateNamedGroup(GROUP_CITIZENS_SPAWN);
    // interp doesn't handle switches
    if(RandomIntBetween(0,1))
    {
      CreateGroupedUnitInArea(HUMAN_PLAYER, TYPE_CITIZEN_MALE, GROUP_CITIZENS_SPAWN, false, AREA_CITIZENS_START);
    }
    else
    {
      CreateGroupedUnitInArea(HUMAN_PLAYER, TYPE_CITIZEN_FEMALE, GROUP_CITIZENS_SPAWN, false, AREA_CITIZENS_START);
    }
    CreateNamedGroup("tempCity");
    AddUnitsByAttributeToGroup("tempCity", ATTRIBUTE_CITY_CENTER, HUMAN_PLAYER, kPlayerMode_Self, NULL);
    if (NumUnitsInGroup("tempCity") > 0)
    {
      // Select the new citizens, move them to the City Center and add them to the citizen group
      SelectGroup(GROUP_CITIZENS_SPAWN);
      MoveSelectionToArea("Group:tempCity");
      AddGroupToGroup(GROUP_CITIZENS, GROUP_CITIZENS_SPAWN);
    }
    else
    {
      // Select the new citizens, move them to the Camera start and add them to the citizen group
      SelectGroup(GROUP_CITIZENS_SPAWN);
      MoveSelectionToArea(AREA_CAMERA_START);
      AddGroupToGroup(GROUP_CITIZENS, GROUP_CITIZENS_SPAWN);
    }
END_SCRIPT
END_ACTION
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
Post Reply

Return to “Tutorials”