MissionScriptsDynamic - LauraRozier/kam_remake GitHub Wiki
Missions can be easily extended with custom scripts to add special events to them. Each missions script is located in \Maps\map_name\map_name.script
file, which can be opened in any plain text editor (e.g. Notepad). Scripts are written in !PascalScript language (syntax is very similar to usual Pascal).
Script has 3 ways of interacting with the game - Events, States and Actions. Events get called by the game when they happen. States are values that can be queried from the game. Actions are way to tell the game what to do. Scripts get verified on mission load and any errors are output in a message to a player.
Script file consists of several parts:
//Global constants section, accessible from any place in the script.
//Useful to make parameters easy to change in one place.
const MY_CONSTANT = 7; //by convention constants are written in upper case
//Global variables section, accessible from any place in the script and stored in game memory
var
I: Integer; //variable number
A: array [0..3] of Boolean; //array of 4 booleans accessible as A[0], A[1] etc.
//Event handler, when the event happens ingame this function gets called
procedure OnHouseBuilt(..); //Each event has different input parameters list
var //Local variables, they exist only within this procedure
L: Integer; //variable number
begin
//Event code
L := 7; //assignment of number to a variable
Actions.ShowMsg(L,'hello'); //Calling a games action with 2 parameters: L and a string 'hello'
end;
//Event handler for "tick" event, which happens 10 times per second (on each game logic update).
procedure OnTick;
begin
//Code here
if States.GameTime = 60 then //Check game time and show a message
Actions.ShowMsg(0,'<>'); //<> is markup to fetch text ID 3 from LIBX translation file
end;
Here is Battle Tutorial script explained:
procedure OnPlayerDefeated(aIndex: Integer);
begin
if aIndex = 2 then Actions.ShowMsg(0, '<>');
if aIndex = 3 then Actions.ShowMsg(0, '<>');
if aIndex = 4 then Actions.ShowMsg(0, '<>');
end;
procedure OnTick;
begin
if States.GameTime = 20 then
Actions.ShowMsg(0, '<>');
end;
Above line means that when PlayerDefeated
event comes from the game, we check the index of the player that was defeated (aIndex) and issue a command to show certain message to specified player (0, who is human). Also, each tick we check the games time and on tick 20 (2 seconds from mission starting) we show another message. Message text is retrieved from the mission's .LIBX file using the markup <$123> (fetches text ID 123 from LIBX), meaning it will be in the player's own language if a translation has been made.
####Global campaign data
This feature allows you to store data between missions in a campaign. First, create a file in your campaign folder campaigndata.script
. In that file you must put the definition of the data you want to store. We recommend using a record so you can easily add more data in the future. Here is an example campaigndata.script
:
record
Mission1: record
SoldiersRemaining: Integer;
TimeOfVictory: Integer;
end;
Mission2: record
Army: array of record
UnitType, X, Y: Integer;
end;
TimeOfVictory: Integer;
end;
end;
The data can then be accessed and modified with the global variable CampaignData
(the type is TCampaignData), for example: CampaignData.Mission1.TimeOfVictory
. The data is stored in the user's campaign progress file (Saves\Campaigns.dat).
- The data will be loaded when a campaign mission is started, and saved whenever the user exits, regardless of whether they won the mission. This allows you to record information about failed attempts. If you only want to record data when the user wins the mission, you should only save data into the global variable
CampaignData
within the eventOnPlayerVictory
. - The user may go back and play an earlier mission, so it is advised to separate the data which each mission will modify, as shown in the above example. In other words, don't reuse the same structures in every mission since missions might be played out of order.
####Other resources
- Lookup tables (unit/house/ware types): MissionScriptsLookups
- Scripting tutorial: MissionScriptsDynamicTutorial
- Scripting hints: MissionScriptsHints
- Language reference: http://www.delphibasics.co.uk/ (note: our scripts don't have all the features of Delphi, but this is still a useful reference)
####Events
Version | Name | Description | Parameters and types | Returns |
---|---|---|---|---|
6570 | OnBeacon | Occurs when a player places a beacon on the map. | 1 - aPlayer: TKMHandIndex 2 - aX: Word 3 - aY: Word |
|
6216 | OnMarketTrade | Occurs when a trade happens in a market (at the moment when resources are exchanged by serfs). | 1 - aMarket: TKMHouse 2 - aFrom: TWareType 3 - aTo: TWareType |
|
5057 | OnMissionStart | Occurs immediately after the mission is loaded. | ||
5057 | OnTick | Occurs every game logic update. | ||
5057 | OnHouseBuilt | Occurs when player has built a house. | 1 - aHouse: TKMHouse | |
5882 | OnHouseDamaged | Occurs when a house is damaged by the enemy soldier. !AttackerIndex is -1 the house was damaged some other way, such as from Actions.!HouseAddDamage. | 1 - aHouse: TKMHouse 2 - aAttacker: TKMUnit |
|
5407 | OnHouseDestroyed | Occurs when a house is destroyed. If !DestroyerIndex is -1 the house was destroyed some other way, such as from Actions.!HouseDestroy. If !DestroyerIndex is the same as the house owner (States.!HouseOwner), the house was demolished by the player who owns it. Otherwise it was destroyed by an enemy. Called just before the house is destroyed so HouseID is usable only during this event, and the area occupied by the house is still unusable. | 1 - aHouse: TKMHouse 2 - aDestroyerIndex: TKMHandIndex |
|
6114 | OnHouseAfterDestroyed | Occurs after a house is destroyed and has been completely removed from the game, meaning the area it previously occupied can be used. If you need more information about the house use the !OnHouseDestroyed event. | 1 - aHouseType: THouseType 2 - aOwner: TKMHandIndex 3 - aX: Word 4 - aY: Word |
|
5871 | OnHousePlanPlaced | Occurs when player has placed a house plan. | 1 - aPlayer: TKMHandIndex 2 - aX: Word 3 - aY: Word 4 - aType: THouseType |
|
6298 | OnHousePlanRemoved | Occurs when player has removed a house plan. | 1 - aPlayer: TKMHandIndex 2 - aX: Word 3 - aY: Word 4 - aType: THouseType |
|
6220 | OnGroupHungry | Occurs when the player would be shown a message about a group being hungry (when they first get hungry, then every 4 minutes after that if there are still hungry group members). Occurs regardless of whether the group has hunger messages enabled or not. | 1 - aGroup: TKMUnitGroup | |
5407 | OnUnitDied | Occurs when a unit dies. If !KillerIndex is -1 the unit died from another cause such as hunger or Actions.!UnitKill. Called just before the unit is killed so UnitID is usable only during this event, and the tile occupied by the unit is still taken. | 1 - aUnit: TKMUnit 2 - aKillerOwner: TKMHandIndex |
|
6114 | OnUnitAfterDied | Occurs after a unit has died and has been completely removed from the game, meaning the tile it previously occupied can be used. If you need more information about the unit use the !OnUnitDied event. Note: Because units have a death animation there is a delay of several ticks between !OnUnitDied and !OnUnitAfterDied. | 1 - aUnitType: TUnitType 2 - aOwner: TKMHandIndex 3 - aX: Word 4 - aY: Word |
|
6587 | OnUnitAttacked | Happens when a unit is attacked (shot at by archers or hit in melee). Attacker is always a warrior (could be archer or melee). This event will occur very frequently during battles. | 1 - aUnit: TKMUnit 2 - aAttacker: TKMUnit |
|
5057 | OnUnitTrained | Occurs when player trains a unit. | 1 - aUnit: TKMUnit | |
5884 | OnUnitWounded | Happens when unit is wounded. Attacker can be a warrior, recruit in tower or unknown (-1). | 1 - aUnit: TKMUnit 2 - aAttacker: TKMUnit |
|
5057 | OnWarriorEquipped | Occurs when player equips a warrior. | 1 - aUnit: TKMUnit 2 - aGroup: TKMUnitGroup |
|
5057 | OnPlayerDefeated | Occurs when certain player has been defeated. Defeat conditions are checked separately by Player AI. | 1 - aPlayer: TKMHandIndex | |
5057 | OnPlayerVictory | Occurs when certain player is declared victorious. Victory conditions are checked separately by Player AI. | 1 - aPlayer: TKMHandIndex | |
Events are written in a form procedure EVENT_NAME(EVENT_PARAMETERS); like so: |
procedure OnHouseBuilt(aHouseID: Integer);
begin
//code
end;
####States All states parameters are numeric and get mapped to unit/house types according to default tables used in DAT scripts.
Version | StateDescription | Query parameters | Type of return value |
---|---|---|---|
- | FindUnitInZone |
||
6216 | ClosestGroup |
Returns the group of the specified player and group type that is closest to the specified coordinates, or -1 if no such group was found. If the group type is -1 any group type will be accepted | 1 - player index 2 - X 3 - Y 4 - Group type |
6216 | ClosestHouse |
Returns the house of the specified player and house type that is closest to the specified coordinates, or -1 if no such house was found. If the house type is -1 any house type will be accepted | 1 - player index 2 - X 3 - Y 4 - House type |
6216 | ClosestUnit |
Returns the unit of the specified player and unit type that is closest to the specified coordinates, or -1 if no such unit was found. If the unit type is -1 any unit type will be accepted | 1 - player index 2 - X 3 - Y 4 - Unit type |
6216 | ClosestGroupMultipleTypes |
Returns the group of the specified player and group types that is closest to the specified coordinates, or -1 if no such group was found. The group types is a "set of Byte", for example [1,3] | 1 - player index 2 - X 3 - Y 4 - Group types |
6216 | ClosestHouseMultipleTypes |
Returns the house of the specified player and house types that is closest to the specified coordinates, or -1 if no such house was found. The house types is a "set of Byte", for example [11,13,21] | 1 - player index 2 - X 3 - Y 4 - House types |
6216 | ClosestUnitMultipleTypes |
Returns the unit of the specified player and unit types that is closest to the specified coordinates, or -1 if no such unit was found. The unit types is a "set of Byte", for example [0,9] | 1 - player index 2 - X 3 - Y 4 - Unit types |
6602 | ConnectedByRoad |
Check if two tiles are connected by walkable road | 1 - X1 2 - Y1 3 - X2 4 - Y2 |
6602 | ConnectedByWalking |
Check if two tiles are connected by a walkable route | 1 - X1 2 - Y1 3 - X2 4 - Y2 |
5097 | FogRevealed |
Check if a tile is revealed in fog of war for a player | 1 - player index 2 - X 3 - Y |
5057 | GameTime |
Get the number of game ticks since mission start | - |
5057 | GroupAt |
Returns the ID of the group of the unit on the specified tile or -1 if no group exists there | 1 - X coordinate 2 - Y coordinate |
5272 | GroupColumnCount |
Returns the number of columns (units per row) of the specified group | 1 - Group ID |
5057 | GroupDead |
Returns true if the group is dead (all members dead or joined other groups) | 1 - Group ID |
6523 | GroupIdle |
Returns true if specified group is idle (has no orders/action) | 1 - Group ID |
5057 | GroupMember |
Returns the unit ID of the specified group member. Member 0 will be the flag holder, 1...!GroupMemberCount-1 will be the other members (0 <= !MemberIndex <= !GroupMemberCount-1) | 1 - Group ID 2 - Member index |
5057 | GroupMemberCount |
Returns the total number of members of the specified group | 1 - Group ID |
5057 | GroupOwner |
Returns the owner of the specified group or -1 if Group ID invalid | 1 - Group ID |
5932 | GroupType |
Returns the type of the specified group or -1 if Group ID invalid | 1 - Group ID |
5057 | HouseAt |
Returns the ID of the house at the specified location or -1 if no house exists there | 1 - X coordinate 2 - Y coordinate |
6516 | HouseBarracksRallyPointX |
Returns X coordinate of Rally Point of specified barracks or 0 if BarracksID is invalid | 1 - Barracks ID |
6516 | HouseBarracksRallyPointY |
Returns Y coordinate of Rally Point of specified barracks or 0 if BarracksID is invalid | 1 - Barracks ID |
6285 | HouseBuildingProgress |
Returns building progress of the specified house | 1 - House ID |
5993 | HouseCanReachResources |
Returns true if the specified house can reach the resources that it mines (coal, stone, fish, etc.) | 1 - House ID |
5057 | HouseDamage |
Returns the damage of the specified house or -1 if House ID invalid | 1 - House ID |
5057 | HouseDeliveryBlocked |
Returns true if the specified house has delivery disabled | 1 - House ID |
5057 | HouseDestroyed |
Returns true if the house is destroyed | 1 - House ID |
5057 | HouseHasOccupant |
Returns true if the specified house currently has an occupant | 1 - House ID |
5345 | HouseIsComplete |
Returns true if the specified house is fully built | 1 - House ID |
6284 | HouseTypeMaxHealth |
Returns max health of the specified house type | 1 - House type |
5345 | HouseTypeToOccupantType |
Returns the type of unit that should occupy the specified type of house, or -1 if no unit should occupy it. | 1 - House ID |
5057 | HouseOwner |
Returns the owner of the specified house or -1 if House ID invalid | 1 - House ID |
5057 | HousePositionX |
Returns the X coordinate of the specified house or -1 if House ID invalid | 1 - House ID |
5057 | HousePositionY |
Returns the Y coordinate of the specified house or -1 if House ID invalid | 1 - House ID |
5057 | HouseRepair |
Returns true if the specified house has repair enabled | 1 - House ID |
5057 | HouseResourceAmount |
Returns the amount of the specified resource in the specified house | 1 - House ID 2 - Resource type |
5165 | HouseSchoolQueue |
Returns the unit type in the specified slot of the school queue. Slot 0 is the unit currently training, slots 1..5 are the queue. | 1 - House ID 2 - slot |
6510 | HouseSiteIsDigged |
Returns true if specified WIP house area is digged | 1 - House ID |
5057 | HouseType |
Returns the type of the specified house | 1 - House ID |
6001 | HouseTypeName |
Returns the the translated name of the specified house type. Note: To ensure multiplayer consistency the name is returned as a number encoded within a markup which is decoded on output, not the actual translated text. Therefore string operations like !LowerCase will not work. | 1 - House type |
6220 | HouseUnlocked |
Returns true if the specified player can build the specified house type (unlocked and allowed). | 1 - Player index 2 - House type |
5099 | HouseWareBlocked |
Returns true if the specified ware in the specified storehouse or barracks is blocked | 1 - House ID 2 - ware type |
5165 | HouseWeaponsOrdered |
Returns the number of the specified weapon ordered to be produced in the specified house | 1 - House ID 2 - ware type |
5099 | HouseWoodcutterChopOnly |
Returns true if the specified woodcutter's hut is on chop-only mode | 1 - House ID |
5345 | IsFieldAt |
Returns true if the specified player has a corn field at the specified location. If player index is -1 it will return true if any player has a corn field at the specified tile | 1 - player index 2 - X 3 - Y |
5345 | IsWinefieldAt |
Returns true if the specified player has a winefield at the specified location. If player index is -1 it will return true if any player has a winefield at the specified tile | 1 - player index 2 - X 3 - Y |
5345 | IsRoadAt |
Returns true if the specified player has a road at the specified location. If player index is -1 it will return true if any player has a road at the specified tile | 1 - player index 2 - X 3 - Y |
5057 | KaMRandom |
Returns a random single (float) such that: 0 <= Number < 1.0 | |
5057 | KaMRandomI |
Returns a random integer such that: 0 <= Number < !LimitPlusOne | 1 - !LimitPlusOne |
6611 | LocationCount |
Returns the number of player locations available on the map (including AIs), regardless of whether the location was taken in multiplayer (use !PlayerEnabled to check if a location is being used) | |
6587 | MapTileHeight |
Returns the height of the terrain at the top left corner (vertex) of the tile at the specified XY coordinates. Return value range is 0..100 | 1 - X 2 - Y |
6587 | MapTileObject |
Returns the terrain object ID on the tile at the specified XY coordinates. Object IDs can be seen in the map editor on the objects tab. Object 61 is "block walking". Return value range is 0..255. If there is no object on the tile, the result will be 255. | 1 - X 2 - Y |
6587 | MapTileRotation |
Returns the rotation of the tile at the specified XY coordinates. Return value range is 0..3 | 1 - X 2 - Y |
6587 | MapTileType |
Returns the tile type ID of the tile at the specified XY coordinates. Tile IDs can be seen by hovering over the tiles on the terrain tiles tab in the map editor. Return value range is 0..255 | 1 - X 2 - Y |
6613 | MapWidth |
Returns the width of the map | |
6613 | MapHeight |
Returns the height of the map | |
6287 | MarketFromWare |
Returns type of !FromWare in specified market, or -1 if no ware is selected | 1 - Market ID |
6217 | MarketLossFactor |
Returns the factor of resources lost during market trading, used to calculate the !TradeRatio (see explanation in MarketValue ). This value is constant within one KaM Remake release, but may change in future KaM Remake releases |
|
6287 | MarketOrderAmount |
Returns trade order amount in specified market | 1 - Market ID |
6287 | MarketToWare |
Returns type of !ToWare in specified market, or -1 if no ware is selected | 1 - Market ID |
6216 | MarketValue |
Returns the relative market value of the specified resource type, which is a rough indication of the cost to produce that resource. These values are constant within one KaM Remake release, but may change in future KaM Remake releases. The !TradeRatio is calculated as: MarketLossFactor * MarketValue(To) / (MarketValue(From) . If the !TradeRatio is >= 1, then the number of From resources required to receive 1 To resource is: Round(TradeRatio) . If the trade ratio is < 1 then the number of To resources received for trading 1 From resource is: Round(1 / TradeRatio)
|
1 - Resource type |
5057 | PeaceTime |
Length of peacetime in ticks (multiplayer) | - |
5057 | PlayerAllianceCheck |
Check how player 1 feels towards player 2 (order matters). Returns true for ally, false for enemy | 1 - player index 2 - player index |
4758 | PlayerColorText |
Get players color as text in hex format | 1 - player index |
5057 | PlayerDefeated |
See if player was defeated | 1 - player index |
5057 | PlayerEnabled |
Will be false if nobody selected that location in multiplayer | 1 - player index |
5165 | PlayerGetAllUnits |
Returns an array with IDs for all the units of the specified player | 1 - player index |
5209 | PlayerGetAllHouses |
Returns an array with IDs for all the houses of the specified player | 1 - player index |
5209 | PlayerGetAllGroups |
Returns an array with IDs for all the groups of the specified player | 1 - player index |
5927 | PlayerIsAI |
Wherever player is controlled by AI | 1 - player index |
5057 | PlayerName |
Get name of player as a string (for multiplayer) | 1 - player index |
4545 | PlayerVictorious |
See if player is victorious | 1 - player index |
5345 | PlayerWareDistribution |
Returns the ware distribution for the specified resource, house and player | 1 - player index 2 - Resource type 3 - House type |
6323 | StatAIDefencePositionsCount |
How many defence positions AI player has. Useful for scripts like "if not enough positions and too much groups then add a new position" | 1 - player index |
5057 | StatArmyCount |
How many military units player has | 1 - player index |
5057 | StatCitizenCount |
How many citizen player has | 1 - player index |
6328 | StatHouseMultipleTypesCount |
Returns number of specified house types for specified player. Types is a set of byte, f.e. [11, 13, 21] | 1 - player index 2 - Types - Set of byte |
5057 | StatHouseTypeCount |
Specified house type count | 1 - player index 2 - house type |
6313 | StatHouseTypePlansCount |
Specified house type plans count | 1 - player index 2 - house type |
5057 | StatPlayerCount |
How many active players there are | - |
5057 | StatResourceProducedCount |
Returns the number of the specified resource produced by the specified player | 1 - Player index 2 - Resource type |
6331 | StatResourceProducedMultipletypesCount |
Returns the number of the specified resource types produced by the specified player. Types is a set of byte, f.e. [8, 10, 13, 27] for food | 1 - Player index 2 - Resource types - set of byte |
4289 | StatUnitCount |
Returns the number of units of the specified player | 1 - Player index |
5057 | StatUnitKilledCount |
Returns the number of the specified unit killed by the specified player | 1 - Player index 2 - Unit type |
6331 | StatUnitKilledMultipleTypesCount |
Returns the number of the specified unit types killed by the specified player. Types is a set of byte, f.e. [0, 5, 13] | 1 - Player index 2 - Unit types - set of byte |
5057 | StatUnitLostCount |
Returns the number of the specified unit lost by the specified player | 1 - Player index 2 - Unit type |
6331 | StatUnitLostMultipleTypesCount |
Returns the number of the specified unit types lost by the specified player. Types is a set of byte, f.e. [0, 5, 13] | 1 - Player index 2 - Unit types - set of byte |
6328 | StatUnitMultipleTypesCount |
Returns number of specified unit types for specified player. Types is a set of byte, f.e. [0, 5, 13] | 1 - player index 2 - Types - Set of byte |
5057 | StatUnitTypeCount |
Specified unit type count | 1 - player index 2 - unit type |
5057 | UnitAt |
Returns the ID of the unit on the specified tile or -1 if no unit exists there | 1 - X coordinate 2 - Y coordinate |
5057 | UnitCarrying |
Returns the ware a serf is carrying, or -1 if the unit is not a serf or is not carrying anything | 1 - Unit ID |
5057 | UnitDead |
Returns true if the unit is dead | 1 - Unit ID |
5165 | UnitDirection |
Returns the direction the specified unit is facing | 1 - Unit ID |
5997 | UnitHome |
Returns the ID of the house which is the home of the specified unit or -1 if the unit does not have a home | 1 - Unit ID |
5057 | UnitHunger |
Returns the hunger level of the specified unit as number of ticks until death or -1 if Unit ID invalid | 1 - Unit ID |
6523 | UnitIdle |
Returns true if specified unit is idle (has no orders/action) | 1 - Unit ID |
5057 | UnitLowHunger |
Gives the hunger level when a unit will try to eat in ticks until death | |
5057 | UnitMaxHunger |
Gives the maximum hunger level a unit can have in ticks until death | |
5057 | UnitOwner |
Returns the owner of the specified unit or -1 if Unit ID invalid | 1 - Unit ID |
5057 | UnitPositionX |
Returns the X coordinate of the specified unit or -1 if Unit ID invalid | 1 - Unit ID |
5057 | UnitPositionY |
Returns the Y coordinate of the specified unit or -1 if Unit ID invalid | 1 - Unit ID |
5057 | UnitsGroup |
Returns the group that the specified unit (warrior) belongs to or -1 if it does not belong to a group | 1 - Unit ID |
5057 | UnitType |
Returns the type of the specified unit | 1 - Unit ID |
6001 | UnitTypeName |
Returns the the translated name of the specified unit type. Note: To ensure multiplayer consistency the name is returned as a number encoded within a markup which is decoded on output, not the actual translated text. Therefore string operations like !LowerCase will not work. | 1 - Unit type |
6001 | WareTypeName |
Returns the the translated name of the specified ware type. Note: To ensure multiplayer consistency the name is returned as a number encoded within a markup which is decoded on output, not the actual translated text. Therefore string operations like !LowerCase will not work. | 1 - Ware type |
States are queried in a form States.STATE_NAME(STATE_PARAMETERS) like so:
`if States.PlayerCount > 5 then
A := States.UnitCount(1);
####Actions All action parameters are numeric and get mapped to unit/house types according to default tables used in DAT scripts.
Version | Action | Description | Parameters (Integer) | Return value () |
---|---|---|---|---|
6251 | AIAutoAttackRange |
Sets AI auto attack range. AI groups will automatically attack if you are closer than this many tiles. | 1 - player index 2 - range (1 to 20) |
|
5924 | AIAutoBuild |
Sets whether the AI should build and manage his own village | 1 - player index 2 - Enabled: Boolean |
|
5924 | AIAutoDefence |
Sets whether the AI should position his soldiers automatically | 1 - player index 2 - Enabled: Boolean |
|
5932 | AIAutoRepair |
Sets whether the AI should automatically repair damaged buildings | 1 - player index 2 - Enabled: Boolean |
|
5932 | AIDefencePositionAdd |
Adds a defence position for the specified AI player | 1 - player index 2 - X 3 - Y 4 - Direction 5 - Group type 6 - Radius 7 - Defence type |
|
6309 | AIDefencePositionRemove |
Removes defence position at X, Y | 1 - player index 2 - X 3 - Y |
|
6323 | AIDefencePositionRemoveAll |
Removes all defence positions for specified AI player | 1 - player index | |
6251 | AIDefendAllies |
Sets whether AI should defend units and houses of allies as if they were its own | 1 - player index 2 - Defend: Boolean |
|
5778 | AIEquipRate |
Sets the warriors equip rate for AI. (type: 0 - leather, 1 - iron) | 1 - player index 2 - type 3 - rate |
|
5778 | AIGroupsFormationSet |
Sets the formation the AI uses for defence positions | 1 - player index 2 - Group type 3 - Units 4 - Columns |
|
5932 | AISoldiersLimit |
Sets the maximum number of soldiers the AI will train, or -1 for unlimited | 1 - player index 2 - count |
|
5924 | AIRecruitDelay |
Sets the number of ticks before the specified AI will start training recruits | 1 - player index 2 - delay in ticks |
|
5345 | AIRecruitLimit |
Sets the number of recruits the AI will keep in each barracks | 1 - player index 2 - recruit limit |
|
5924 | AISerfsPerHouse |
Sets the number of serfs the AI will train per house. Can be a decimal (0.25 for 1 serf per 4 houses) | 1 - player index 2 - value (float) |
|
6251 | AIStartPosition |
Sets the AI start position which is used for targeting AI attacks | 1 - player index 2 - X 3 - Y |
|
5924 | AIWorkerLimit |
Sets the maximum number of laborers the AI will train | 1 - player index 2 - count |
|
5938 | CinematicStart |
Puts the player in cinematic mode, blocking user input and allowing the screen to be panned | 1 - player index | |
5938 | CinematicEnd |
Exits cinematic mode | 1 - player index | |
5938 | CinematicPanTo |
Pans the center of the player's screen to the given location over a set number of ticks. If Duration = 0 then the screen moves instantly. | 1 - player index 2 - X 3 - Y 4 - Duration |
|
5097 | FogCoverAll |
Covers (un-reveals) the entire map in fog of war for player | 1 - player index | |
5097 | FogCoverCircle |
Covers (un-reveals) a circle in fog of war for player | 1 - player index 2 - location X 3 - location Y 4 - radius |
|
5777 | FogCoverRect |
Covers a rectangular area in fog of war for player | 1 - player index 2 - from X 3 - from Y 4 - to X 5 - to Y |
|
5097 | FogRevealAll |
Reveals the entire map in fog of war for player | 1 - player index | |
5097 | FogRevealCircle |
Reveals a circle in fog of war for player | 1 - player index 2 - location X 3 - location Y 4 - radius |
|
5777 | FogRevealRect |
Reveals a rectangular area in fog of war for player | 1 - player index 2 - from X 3 - from Y 4 - to X 5 - to Y |
|
5057 | GiveAnimal |
Adds an animal to the game and returns the unit ID or -1 if the animal was not able to be added | 1 - Animal type 2 - location X 3 - location Y |
UnitID: Integer |
6311 | GiveField |
Adds finished field and returns true if field was successfully added | 1 - Player ID 2 - X 3 - Y |
Success: Boolean |
5057 | GiveGroup |
Give player group of warriors and return the group ID or -1 if the group was not able to be added | 1 - player index 2 - Unit type 3 - location X 4 - location Y 5 - face direction 6 - unit count 7 - units per row |
GroupID: Integer |
5097 | GiveHouse |
Give player a built house and returns the house ID or -1 if the house was not able to be added | 1 - player index 2 - House type 3 - location X 4 - location Y |
HouseID: Integer |
6288 | GiveHouseSite |
Give player a digged house area and returns House ID or -1 if house site was not able to be added. If !AddMaterials = True, wood and stone will be added | 1 - player index 2 - House type 3 - location X 4 - location Y 5 - !AddMaterials: Boolean |
HouseID: Integer |
6311 | GiveRoad |
Adds finished road and returns true if road was successfully added | 1 - Player ID 2 - X 3 - Y |
Success: Boolean |
5057 | GiveUnit |
Give player a single citizen and returns the unit ID or -1 if the unit was not able to be added | 1 - player index 2 - Unit type 3 - location X 4 - location Y 5 - face direction |
UnitID: Integer |
5057 | GiveWares |
Adds amount of wares to players 1st Store | 1 - player index 2 - ware type 3 - count |
|
5165 | GiveWeapons |
Adds amount of weapons to players 1st Barracks | 1 - player index 2 - ware type 3 - count |
|
6311 | GiveWineField |
Adds finished winefield and returns true if winefield was successfully added | 1 - Player ID 2 - X 3 - Y |
Success: Boolean |
6277 | GroupBlockOrders |
Disables (Disable = True) or enables (Disable = False) control over specifed warriors group | 1 - Group ID 2 - Disable: Boolean |
|
5993 | GroupDisableHungryMessage |
Sets whether the specified group will alert the player when they become hungry (true to disable hunger messages, false to enable them) | 1 - Group ID 2 - Disabled: Boolean |
|
5993 | GroupHungerSet |
Set hunger level for all group members | 1 - Group ID 2 - Hunger level (ticks until death) |
|
5993 | GroupKillAll |
Kills all members of the specified group | 1 - Group ID 2 - Silent: Boolean |
|
5057 | GroupOrderAttackHouse |
Order the specified group to attack the specified house | 1 - Group ID 2 - House ID |
|
5057 | GroupOrderAttackUnit |
Order the specified group to attack the specified unit | 1 - Group ID 2 - Unit ID |
|
5057 | GroupOrderFood |
Order the specified group to request food | 1 - Group ID | |
5057 | GroupOrderHalt |
Order the specified group to halt | 1 - Group ID | |
5057 | GroupOrderLink |
Order the first specified group to link to the second specified group | 1 - Group ID 2 - Group ID |
|
5057 | GroupOrderSplit |
Order the specified group to split in half and return the newly create group ID or -1 if splitting failed (e.g. only 1 member) | 1 - Group ID | NewGroupID: Integer |
6338 | GroupOrderSplitUnit |
Splits specified unit from the group and returns the newly create group ID or -1 if splitting failed (e.g. only 1 member) | 1 - Group ID 2 - Unit ID |
NewGroupID: Integer |
5057 | GroupOrderStorm |
Order the specified group to storm attack | 1 - Group ID | |
5057 | GroupOrderWalk |
Order the specified group to walk somewhere | 1 - Group ID 2 - X 3 - Y 4 - Direction |
|
5057 | GroupSetFormation |
Sets the number of columns (units per row) for the specified group | 1 - Group ID 2 - Columns |
|
6510 | HouseAddBuildingMaterials |
Add building materials to the specified WIP house area | 1 - House ID | |
6297 | HouseAddBuildingProgress |
Add 5 points of building progress to the specified WIP house area | 1 - House ID | |
5057 | HouseAddDamage |
Add damage to the specified house | 1 - House ID 2 - Damage amount |
|
5441 | HouseAddRepair |
Reduces damage to the specified house | 1 - House ID 2 - Repair amount |
|
5057 | HouseAddWaresTo |
Add wares to the specified house | 1 - House ID 2 - ware type 3 - count |
|
5057 | HouseAllow |
Sets whether the player is allowed to build the specified house. Note: The house must still be unlocked normally (e.g. sawmill for farm), use !HouseUnlock to override that. | 1 - player index 2 - House type 3 - Allowed: Boolean |
|
5174 | HouseBarracksEquip |
Equips the specified unit from the specified barracks. Returns the number of units successfully equipped. | 1 - House ID 2 - Unit type 3 - Count |
Succeeded: Integer |
6125 | HouseBarracksGiveRecruit |
Adds a recruit inside the specified barracks | 1 - House ID | |
5057 | HouseDeliveryBlock |
Sets delivery blocking for the specified house | 1 - House ID 2 - Blocked: Boolean |
|
5263 | HouseDestroy |
Destroys the specified house. Silent means the house will not leave rubble or play destroy sound | 1 - House ID 2 - Silent |
|
5345 | HouseDisableUnoccupiedMessage |
Sets whether the specified house displays unoccupied messages to the player | 1 - House ID 2 - Disabled: Boolean |
|
- | HouseOwnerSet |
Take house from one player and give it to another | ||
5057 | HouseRepairEnable |
Enables house repair for the specified house | 1 - House ID 2 - !EnableRepair: Boolean |
|
5174 | HouseSchoolQueueAdd |
Adds the specified unit to the specified school's queue. Returns the number of units successfully added to the queue. | 1 - House ID 2 - Unit type 3 - Count |
Succeeded: Integer |
5174 | HouseSchoolQueueRemove |
Removes the unit from the specified slot of the school queue. Slot 0 is the unit currently training, slots 1..5 are the queue. | 1 - House ID 2 - slot |
|
6015 | HouseTakeWaresFrom |
Remove wares from the specified house. If a serf was on the way to pick up the ware, the serf will abandon his task | 1 - House ID 2 - ware type 3 - count |
|
5057 | HouseUnlock |
Allows player to build the specified house even if they don't have the house built that normally unlocks it (e.g. sawmill for farm). Note: Does not override blocked houses, use !HouseAllow for that. | 1 - player index 2 - House type |
|
5099 | HouseWareBlock |
Blocks a specific ware in a storehouse or barracks | 1 - House ID 2 - ware type 3 - Blocked: Boolean |
|
5099 | HouseWoodcutterChopOnly |
Sets whether a woodcutter's hut is on chop-only mode | 1 - House ID 2 - !ChopOnly: Boolean |
|
5165 | HouseWeaponsOrderSet |
Sets the amount of the specified weapon ordered to be produced in the specified house | 1 - House ID 2 - ware type 3 - amount |
|
6067 | Log |
Writes a line of text to the game log file. Useful for debugging. Note that many calls to this procedure will have a noticeable performance impact, as well as creating a large log file, so it is recommended you don't use it outside of debugging | 1 - Text: !AnsiString | |
6587 | MapTileHeightSet |
Sets the height of the terrain at the top left corner (vertex) of the tile at the specified XY coordinates. Returns true if the change succeeded or false if it failed. The change will fail if it would cause a unit to become stuck or a house to be damaged | 1 - X 2 - Y 3 - height (0..100) |
Boolean |
6587 | MapTileObjectSet |
Sets the terrain object on the tile at the specified XY coordinates. Object IDs can be seen in the map editor on the objects tab. Object 61 is "block walking". To set no object, use object type 255. Returns true if the change succeeded or false if it failed. The change will fail if it would cause a unit to become stuck or a house/field to be damaged | 1 - X 2 - Y 3 - object type (0..255) |
Boolean |
6587 | MapTileSet |
Sets the tile type and rotation at the specified XY coordinates. Tile IDs can be seen by hovering over the tiles on the terrain tiles tab in the map editor. Returns true if the change succeeded or false if it failed. The change will fail if it would cause a unit to become stuck or a house/field to be damaged | 1 - X 2 - Y 3 - tile type (0..255) 4 - tile rotation (0..3) |
Boolean |
6216 | MarketSetTrade |
Sets the trade in the specified market | 1 - House ID 2 - from ware type 3 - to ware type 4 - amount |
|
5333 | OverlayTextSet |
Sets text overlaid on top left of screen. If the player index is -1 it will be set for all players. | 1 - player index 2 - text (!AnsiString) |
|
5333 | OverlayTextSetFormatted |
Sets text overlaid on top left of screen with formatted arguments (same as Format function). If the player index is -1 it will be set for all players. | 1 - player index 2 - text (!AnsiString) 3 - Array of arguments |
|
5333 | OverlayTextAppend |
Appends to text overlaid on top left of screen. If the player index is -1 it will be appended for all players. | 1 - player index 2 - text (!AnsiString) |
|
5333 | OverlayTextAppendFormatted |
Appends to text overlaid on top left of screen with formatted arguments (same as Format function). If the player index is -1 it will be appended for all players. | 1 - player index 2 - text (!AnsiString) 3 - Array of arguments |
|
5057 | PlanAddField |
Adds a corn field plan. Returns true if the plan was successfully added or false if it failed (e.g. tile blocked) | 1 - Player index 2 - X 3 - Y |
Success: Boolean |
5057 | PlanAddHouse |
Adds a house plan. Returns true if the plan was successfully added or false if it failed (e.g. location blocked) | 1 - Player index 2 - House type 3 - X 4 - Y |
Success: Boolean |
5057 | PlanAddRoad |
Adds a road plan. Returns true if the plan was successfully added or false if it failed (e.g. tile blocked) | 1 - Player index 2 - X 3 - Y |
Success: Boolean |
5057 | PlanAddWinefield |
Adds a wine field plan. Returns true if the plan was successfully added or false if it failed (e.g. tile blocked) | 1 - Player index 2 - X 3 - Y |
Success: Boolean |
6303 | PlanConnectRoad |
Connects road plans between two points like AI builder and returns True if road plan was successfully added. If CompletedRoad = True, road will be added instead of plans | 1 - Player index 2 - X1 3 - Y1 4 - X2 5 - Y2 6 - Completed road - Boolean |
Success: Boolean |
5345 | PlanRemove |
Removes house, road or field plans from the specified tile for the specified player | 1 - player index 2 - X 3 - Y |
Success: Boolean |
5165 | PlayerAddDefaultGoals |
Add default goals/lost goals for the specified player. If the parameter buildings is true the goals will be important buildings. Otherwise it will be troops. | 1 - player index 2 - buildings: Boolean |
|
5097 | PlayerAllianceChange |
Change whether player1 is allied to player2. If Compliment is true, then it is set both ways (so also whether player2 is allied to player1) | 1 - player1 index 2 - player2 index 3 - Compliment: Boolean 4 - Allied: Boolean |
|
5057 | PlayerDefeat |
Proclaims player defeated | 1 - player index | |
5345 | PlayerShareFog |
Sets whether player A shares his vision with player B. Sharing can still only happen between allied players, but this command lets you disable allies from sharing. | 1 - player A 2 - player B 3 - Share: Boolean |
|
5345 | PlayerWareDistribution |
Sets ware distribution for the specified resource, house and player. | 1 - player index 2 - resource type 3 - house type 4 - distribution amount (0..5) |
|
5057 | PlayerWin |
Set specified player(s) victorious, and all team members of those player(s) if the 2nd parameter !TeamVictory is set to true. All players who were not set to victorious are set to defeated. | 1 - array of player index 2 - !TeamVictory: Boolean |
|
5309 | PlayWAV |
Plays audio file. If the player index is -1 the sound will be played to all players. Mono or stereo WAV files are supported. WAV file goes in mission folder named: Mission Name.filename.wav | 1 - player index 2 - filename 3 - Volume (0.0 to 1.0) |
|
6220 | PlayWAVFadeMusic |
Same as PlayWAV except music will fade then mute while the WAV is playing, then fade back in afterwards. You should leave a small gap at the start of your WAV file to give the music time to fade |
1 - player index 2 - filename 3 - Volume (0.0 to 1.0) |
|
5309 | PlayWAVAtLocation |
Plays audio file at a location on the map. If the player index is -1 the sound will be played to all players. Radius specifies approximately the distance at which the sound can no longer be heard (normal game sounds use radius 32). Only mono WAV files are supported. WAV file goes in mission folder named: Mission Name.filename.wav. Will not play if the location is not revealed to the player. Higher volume range is allowed than PlayWAV as positional sounds are quieter |
1 - player index 2 - filename 3 - Volume (0.0 to 4.0) 4 - Radius (minimum 28) 5 - X 6 - Y |
|
6222 | PlayWAVLooped |
Plays looped audio file. If the player index is -1 the sound will be played to all players. Mono or stereo WAV files are supported. WAV file goes in mission folder named: Mission Name.filename.wav. The sound will continue to loop if the game is paused and will restart automatically when the game is loaded. Returns the !LoopIndex of the sound which can be used to stop it with Actions.StopLoopedWAV
|
1 - player index 2 - filename 3 - Volume (0.0 to 1.0) |
!LoopIndex: Integer |
6222 | PlayWAVAtLocationLooped |
Plays looped audio file at a location on the map. If the player index is -1 the sound will be played to all players. Radius specifies approximately the distance at which the sound can no longer be heard (normal game sounds use radius 32). Only mono WAV files are supported. WAV file goes in mission folder named: Mission Name.filename.wav. Will not play if the location is not revealed to the player (will start playing automatically when it is revealed). Higher volume range is allowed than PlayWAV as positional sounds are quieter. The sound will continue to loop if the game is paused and will restart automatically when the game is loaded. Returns the !LoopIndex of the sound which can be used to stop it with Actions.StopLoopedWAV
|
1 - player index 2 - filename 3 - Volume (0.0 to 4.0) 4 - Radius (minimum 28) 5 - X 6 - Y |
!LoopIndex: Integer |
5927 | RemoveRoad |
Removes road | 1 - X 2 - Y |
|
5057 | SetTradeAllowed |
Sets whether the player is allowed to trade the specified resource. | 1 - player index 2 - ware type 3 - Allowed: Boolean |
|
5057 | ShowMsg |
Displays a message to a player. If the player index is -1 the message will be shown to all players. | 1 - player index 2 - text (!AnsiString) |
|
5345 | ShowMsgGoto |
Displays a message to a player with a goto button that takes the player to the specified location. If the player index is -1 the message will be shown to all players. | 1 - player index 2 - X 3 - Y 4 - text (!AnsiString) |
|
5333 | ShowMsgFormatted |
Displays a message to a player with formatted arguments (same as Format function). If the player index is -1 the message will be shown to all players. | 1 - player index 2 - text (!AnsiString) 3 - Array of arguments |
|
5345 | ShowMsgGotoFormatted |
Displays a message to a player with formatted arguments (same as Format function) and a goto button that takes the player to the specified location. If the player index is -1 the message will be shown to all players. | 1 - player index 2 - X 3 - Y 4 - text (!AnsiString) 5 - Array of arguments |
|
6222 | StopLoopedWAV |
Stops playing a looped sound that was previously started with either Actions.PlayWAVLooped or Actions.PlayWAVAtLocationLooped . !LoopIndex is the value that was returned by either of those functions when the looped sound was started. |
1 - !LoopIndex | |
5993 | UnitBlock |
Sets whether the specified player can train/equip the specified unit type | 1 - player index 2 - Unit type 3 - Block: Boolean |
|
5057 | UnitDirectionSet |
Makes the specified unit face a certain direction. Note: Only works on idle units so as not to interfere with game logic and cause crashes. Returns true on success or false on failure. | 1 - Unit ID 2 - Direction |
Success: Boolean |
5057 | UnitHungerSet |
Sets the hunger level of the specified unit in ticks until death | 1 - Unit ID 2 - Hunger level (ticks until death) |
|
5099 | UnitKill |
Kills the specified unit. Silent means the death animation (ghost) and sound won't play | 1 - Unit ID 2 - Silent: Boolean |
|
- | UnitLock |
Lock out the unit from game updates and make it manually scriptable (?) | ||
5057 | UnitOrderWalk |
Order the specified unit to walk somewhere. Note: Only works on idle units so as not to interfere with game logic and cause crashes. Returns true on success or false on failure. | 1 - Unit ID 2 - X 3 - Y |
Success: Boolean |
- | UnitOwnerSet |
Take unit from one player and give it to another | ||
- | UnitPositionSet |
Magically move unit from one place to another (?) |
Actions are placed in a form Actions.ACT_NAME(ACT_PARAMETERS); like so:
if States.GameTime = 300 then
Actions.PlayerDefeat(0); //Defeat 1st player