Skip to content

Latest commit

 

History

History
404 lines (395 loc) · 70.9 KB

kmr.Actions.orig.md

File metadata and controls

404 lines (395 loc) · 70.9 KB

Actions

All action parameters are numeric and get mapped to unit/house types according to default tables used in DAT scripts.

Actions are placed in a form Actions.ACT_NAME(ACT_PARAMETERS); like so:

    if States.GameTime = 300 then
      Actions.PlayerDefeat(0); //Defeat 1st player

Also there is a short name for Actions: just A, so you could use it as

  A.PlayerDefeat(0); //Defeat 1st player

"-" Means this will not be implemented.


Other scripts functions:

Dynamic scripts usefull info:



Ver
sion
Action description Parameters
and types
Returns
7000+ AIArmyType
Sets AI army type
aHand: Byte;
aType: TKMArmyType; //Type = (atIronThenLeather, atLeather, atIron, atIronAndLeather)
7000+ AIAttackAdd
Add AI attack
aHand - handID
aRepeating - is attack repeating
aDelay - attack delay from the game start (in ticks)
aTotalMen - total soldiers to attack
aMelleCount, aAntiHorseCount, aRangedCount, aMountedCount - soldiers groups count
aRandomGroups - use random groups for attack
aTarget - attack target of TKMAIAttackTarget type. Possible values:
TKMAIAttackTarget = (
attClosestUnit, //Closest enemy unit
attClosestBuildingFromArmy,
//Closest building from the group lauching the attack
attClosestBuildingFromStartPos,
//Closest building from the AI's start position
attCustomPosition
//Custom point defined with aCustomPosition
);
aCustomPosition - TKMPoint for custom position of attack. Used if attCustomPosition was set up as attack target
Result: Attack UID, that could be used to remove this attack later on
aMeleeGroupCount: Integer;
aAntiHorseGroupCount: Integer;
aRangedGroupCount: Integer;
aMountedGroupCount: Integer;
aRandomGroups: Boolean;
aTarget: TKMAIAttackTarget;
aCustomPosition: TKMPoint;
Integer
13900 AIAttackAddEx
Add AI attack for a specified hand (player)
Attack info is set via TKMAIAttackInfo record.
aHand: Integer;
var aAttackInfo: ;
var TKMAIAttackInfo: ;
Integer //Attack UID, that could be used to remove this attack later on
7000+ AIAttackRemove
Remove AI attack by attack UID
aHand: Integer;
aAIAttackUID: Integer;
Boolean //true, if attack was succesfully removed, false, if attack was not found
7000+ AIAttackRemoveAll
Remove all AI attacks
aHand: Integer;
13000 AIAutoAttack
Sets AI auto attack
aHand: Byte;
aAutoAttack: Boolean;
6251 AIAutoAttackRange
Sets AI auto attack range.
AI groups will automatically attack if you are closer than this many tiles.
aHand: Byte;
aRange: Integer; //Range (1 to 20)
5924 AIAutoBuild
Sets whether the AI should build and manage his own village
aHand: Byte;
aAuto: Boolean;
5924 AIAutoDefence
Sets whether the AI should position his soldiers automatically
aHand: Byte;
aAuto: Boolean;
5932 AIAutoRepair
Sets whether the AI should automatically repair damaged buildings
aHand: Byte;
aAuto: Boolean;
5932 AIDefencePositionAdd
Adds a defence position for the specified AI player
Returns added defence position UID or -1 if it could not be added
aHand: Byte;
X: Integer;
Y: Integer;
aDir: Byte;
aGroupType: Byte;
aRadius: Integer;
aDefType: Byte;
Integer
13900 AIDefencePositionAddEx
Adds a defence position for the specified AI player
If aOrder is not in range of [0; Count], then position would be added to the end of the list
Returns added defence position UID or -1 if it could not be added
aHand: Integer; //hand (player) ID
aOrder: Integer; //order (or priority) of the defence position.
var aDefencePosition: ;
var TKMDefencePositionInfo: ;
Integer
6309 AIDefencePositionRemove
Removes defence position at X, Y
aHand: Byte;
X: Integer;
Y: Integer;
6323 AIDefencePositionRemoveAll
Removes all defence positions for specified AI player
aHand: Byte;
13900 AIDefencePositionRemoveByUID
Removes defence position by its UID
aHand: Integer;
aUID: Integer;
6251 AIDefendAllies
Sets whether AI should defend units and houses of allies as if they were its own
aHand: Byte;
aDefend: Boolean;
5778 AIEquipRate
Sets the warriors equip rate for AI.
aHand: Byte;
aType: Byte; //type: 0 - leather, 1 - iron
aRate: Integer;
5778 AIGroupsFormationSet
Sets the formation the AI uses for defence positions. Works only for ClassicAI
aHand: Byte;
aType: Byte;
aCount: Integer;
aColumns: Integer;
13900 AIGroupsFormationSetEx
Sets the formation the AI uses for defence positions. Works only for ClassicAI
aHand: Integer; //hand (player) ID
aGroupType: Integer;
TKMGroupType: Integer;
aCount: Integer;
aColumns: Integer;
5924 AIRecruitDelay
Sets the number of ticks before the specified AI will start training recruits
aHand: Byte;
aDelay: Cardinal;
5345 AIRecruitLimit
Sets the number of recruits the AI will keep in each barracks
aHand: Byte;
aLimit: Byte;
13900 AIRepairMode
Sets whether the AI should automatically repair damaged buildings
rmNone unused
rmRepairNever disable repair for all houses
rmRepairAlways enable repair for all houses
rmRepairManual repair is set by script manually via Actions.HouseRepairEnable
aHand: Integer;
aRepairMode: ; //(rmNone, rmRepairNever, rmRepairAlways, rmRepairManual)
TKMAIRepairMode: ;
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)
aHand: Byte;
aSerfs: Single;
5932 AISoldiersLimit
Sets the maximum number of soldiers the AI will train, or -1 for unlimited
aHand: Byte;
aLimit: Integer;
6251 AIStartPosition
Sets the AI start position which is used for targeting AI attacks
aHand: Byte;
X: Integer;
Y: Integer;
5924 AIWorkerLimit
Sets the maximum number of laborers the AI will train
aHand: Byte;
aLimit: Byte;
5938 CinematicEnd
Exits cinematic mode
aHand: Byte;
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.
aHand: Byte;
X: Integer;
Y: Integer;
Duration: Integer;
5938 CinematicStart
Puts the player in cinematic mode, blocking user input and allowing the screen to be panned
aHand: Byte;
5097 FogCoverAll
Covers (un-reveals) the entire map in fog of war for player
aHand: Byte;
5097 FogCoverCircle
Reveals a circle in fog of war for player
aHand: Integer;
X: Integer;
Y: Integer;
aRadius: Integer;
5777 FogCoverRect
Covers a rectangular area in fog of war for player
aHand: Integer;
X1: Integer; //Left coordinate
Y1: Integer; //Top coordinate
X2: Integer; //Right coordinate
Y2: Integer; //Bottom coordinate
5097 FogRevealAll
Reveals the entire map in fog of war for player
aHand: Byte;
5097 FogRevealCircle
Reveals a circle in fog of war for player
aHand: Integer;
X: Integer;
Y: Integer;
aRadius: Integer;
5777 FogRevealRect
Reveals a rectangular area in fog of war for player
aHand: Integer;
X1: Integer; //Left coordinate
Y1: Integer; //Top coordinate
X2: Integer; //Right coordinate
Y2: Integer; //Bottom coordinate
11000 GameSpeed
Changes game speed
aSpeed: Single;
11000 GameSpeedChangeAllowed
Allows or blocks game speed change
aAllowed: Boolean;
5057 GiveAnimal
Adds an animal to the game and returns the unit ID or -1 if the animal was not able to be added
aType: Integer;
X: Integer;
Y: Integer;
Integer
14000 GiveAnimalEx
Adds an animal to the game and returns the unit ID or -1 if the animal was not able to be added
aType: TKMUnitType;
X,Y: Integer;
Integer
6311 GiveField
Adds finished field and returns true if field was successfully added
aHand: Integer;
X: Integer;
Y: Integer;
Boolean
7000+ GiveFieldAged
Sets field age if tile is corn field, or adds finished field and sets its age if tile is empty, and returns true if this was successfully done
aHand: Integer;
X: Integer;
Y: Integer;
aStage: Byte; //0..6, sets the field growth stage. 0 = empty field; 6 = corn has been cut
aRandomAge: Boolean; //RandomAge sets FieldAge to random, according to specified stage. Makes fields more realistic
Boolean
5057 GiveGroup
Give player group of warriors and return the group ID or -1 if the group was not able to be added
aHand: Integer;
aType: Integer;
X,Y: Integer;
aDir: Integer;
aCount: Integer;
aColumns: Integer; //Units per row
Integer
14000 GiveGroupEx
Give player group of warriors and return the group ID or -1 if the group was not able to be added
aHand: Integer;
aType: TKMUnitType;
X,Y: Integer;
aDir: Integer;
TKMDirection: Integer;
aCount: Integer;
aColumns: Integer; //Units per row
Integer
5097 GiveHouse
Give player a built house and returns the house ID or -1 if the house was not able to be added
aHand: Integer;
aHouseType: Integer;
X,Y: Integer;
Integer
14000 GiveHouseEx
Give player a built house and returns the house ID or -1 if the house was not able to be added
aHand: Integer;
aHouseType: TKMHouseType;
X,Y: Integer;
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
aHand: Integer;
aHouseType: Integer;
X: Integer;
Y: Integer;
aAddMaterials: Boolean;
Integer
14000 GiveHouseSiteEx
Give player a digged house area and returns House ID or -1 if house site was not able to be added.
aHand: Integer;
aHouseType: TKMHouseType;
X: Integer;
Y: Integer;
aWoodAmount: Integer;
aStoneAmount: Integer; //StoneAmount, aWoodAmount - number of resources to be added to the site
Integer
6311 GiveRoad
Adds finished road and returns true if road was successfully added
aHand: Integer;
X: Integer;
Y: Integer;
Boolean
5057 GiveUnit
Give player a single citizen and returns the unit ID or -1 if the unit was not able to be added
aHand: Integer;
aType: Integer;
X: Integer;
Y: Integer;
aDir: Integer;
Integer
14000 GiveUnitEx
Give player a single citizen and returns the unit ID or -1 if the unit was not able to be added
aHand: Integer;
aType: TKMUnitType;
X,Y: Integer;
aDir: ;
TKMDirection: ;
Integer
5057 GiveWares
Adds amount of wares to players 1st Store
Wares are added to first Store
aHand: Integer;
aType: Integer;
aCount: Integer;
14000 GiveWaresEx
Adds amount of wares to players 1st Store
Wares are added to first Store
aHand: Integer;
aType: TKMWareType;
aCount: Integer;
5165 GiveWeapons
Adds amount of weapons to players 1st Barracks
Weapons are added to first Barracks
aHand: Integer;
aType: Integer;
aCount: Integer;
14000 GiveWeaponsEx
Adds amount of weapons to players 1st Barracks
Weapons are added to first Barracks
aHand: Integer;
aType: TKMWareType;
aCount: Integer;
12600 GroupAllowAllyToSelect
Allows allies to select and view specified group
aGroupID: Integer;
aAllow: Boolean;
6277 GroupBlockOrders
Disables (Disable = True) or enables (Disable = False) control over specifed warriors group
aGroupID: Integer;
aBlock: 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)
aGroupID: Integer;
aDisable: Boolean;
5993 GroupHungerSet
Set hunger level for all group members
aGroupID: Integer;
aHungerLevel: Integer; //Hunger level (ticks until death)
5993 GroupKillAll
Kills all members of the specified group
aGroupID: Integer;
aSilent: Boolean;
5057 GroupOrderAttackHouse
Order the specified group to attack the specified house
aGroupID: Integer;
aHouseID: Integer;
5057 GroupOrderAttackUnit
Order the specified group to attack the specified unit
aGroupID: Integer;
aUnitID: Integer;
5057 GroupOrderFood
Order the specified group to request food
aGroupID: Integer;
5057 GroupOrderHalt
Order the specified group to halt
aGroupID: Integer;
5057 GroupOrderLink
Order the first specified group to link to the second specified group
aGroupID: Integer;
aDestGroupID: Integer;
5057 GroupOrderSplit
Order the specified group to split in half.
Return the newly create group ID or -1 if splitting failed (e.g. only 1 member)
aGroupID: Integer; Integer
6338 GroupOrderSplitUnit
Splits specified unit from the group.
Returns the newly create group ID or -1 if splitting failed (e.g. only 1 member)
aGroupID: Integer;
aUnitID: Integer;
Integer
5057 GroupOrderStorm
Order the specified group to storm attack
aGroupID: Integer;
5057 GroupOrderWalk
Order the specified group to walk somewhere
aGroupID: Integer;
X: Integer;
Y: Integer;
aDirection: Integer;
14000 GroupOrderWalkEx
Order the specified group to walk somewhere
aGroupID: Integer;
X: Integer;
Y: Integer;
aDirection: ;
TKMDirection: ;
5057 GroupSetFormation
Sets the number of columns (units per row) for the specified group
aGroupID: Integer;
aNumColumns: Byte;
13900 HandHouseLock
Sets hand (player) house lock aLock for a specified house type aHouseType
if htAny is passed for house type then aLock will be applied to all house types
aHand: Integer;
aHouseType: TKMHouseType;
aLock: ;
TKMHandHouseLock: ;
14000 HandTradeAllowed
Sets whether the player is allowed to trade the specified resource.
if aHand = -1, then apply it to all hands (players)
aHand: Integer;
aWareType: TKMWareType;
aAllowed: Boolean;
14000 HandUnitCanTrain
Sets whether the specified player can train/equip the specified unit type
if aHand = -1, then apply it to all hands (players)
aHand: Integer;
aUnitType: TKMUnitType;
aCanTrain: Boolean;
14000 HandWareDistribution
Sets ware distribution for the specified resource, house and hand (player).
Note: distribution should be set after 1st tick of the game,
thus it will not make effect to use it in OnMissionStart event handler
aHand: Integer;
aWareType: TKMWareType;
aHouseType: TKMHouseType;
aAmount: Integer; //Distribution amount (0..5)
6510 HouseAddBuildingMaterials
Add all building materials to the specified WIP house area
aHouseID: Integer;
14000 HouseAddBuildingMaterialsEx
Add or remove building materials to the specified WIP house area
if aWoodAmount or aStoneAmount > 0 then add build wares to the site
if aWoodAmount or aStoneAmount < 0 then remove build wares from the site
aHouseID: Integer;
aWoodAmount: Integer;
aStoneAmount: Integer;
6297 HouseAddBuildingProgress
Add 5 points of building progress to the specified WIP house area
aHouseID: Integer;
14000 HouseAddBuildingProgressEx
Add 5 * aBuildSteps points of building progress to the specified WIP house area
aHouseID: Integer;
aBuildSteps: Integer;
5057 HouseAddDamage
Add damage to the specified house
aHouseID: Integer;
aDamage: Integer;
5441 HouseAddRepair
Reduces damage to the specified house
aHouseID: Integer;
aRepair: Integer;
5057 HouseAddWaresTo
Add wares to the specified house
aHouseID: Integer;
aType: Integer;
aCount: Integer;
14000 HouseAddWaresToEx
Add wares to the specified house
aHouseID: Integer;
aType: TKMWareType;
aCount: Integer;
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.
aHand: Integer;
aHouseType: Integer;
aAllowed: Boolean;
10940 HouseAllowAllyToSelect
Allows allies to view specified house
aHouseID: Integer;
aAllow: Boolean;
10940 HouseAllowAllyToSelectAll
Allows allies to view all houses of specified player, or for all players, if aHand is -1
This function applies only to already build houses.
New houses will be selectable for allies. To avoid it use OnHouseBuilt event
aHand: Shortint;
aAllow: Boolean;
5174 HouseBarracksEquip
Equips the specified unit from the specified barracks.
Returns the number of units successfully equipped.
aHouseID: Integer;
aUnitType: Integer;
aCount: Integer;
Integer
13900 HouseBarracksEquipEx
Equips the specified unit from the specified barracks.
Returns the number of units successfully equipped.
aHouseID: Integer;
aUnitType: TKMUnitType;
aCount: Integer;
Integer
6125 HouseBarracksGiveRecruit
Adds a recruit inside the specified barracks
aHouseID: Integer;
14000 HouseBarracksGiveRecruits
Adds aCount recruits inside the specified barracks
aHouseID: Integer;
aCount: Integer;
14000 HouseBarracksRecruitBlock
Blocks or allows recruit to get into specified Barracks
aHouseID: Integer;
aBlocked: Boolean;
5057 HouseDeliveryBlock
Sets delivery blocking for the specified house
aHouseID: Integer;
aDeliveryBlocked: Boolean;
13900 HouseDeliveryMode
Sets delivery mode for the specified house
aHouseID: Integer;
aDeliveryMode: ;
TKMDeliveryMode: ;
5263 HouseDestroy
Destroys the specified house.
Silent means the house will not leave rubble or play destroy sound
aHouseID: Integer;
aSilent: Boolean;
5345 HouseDisableUnoccupiedMessage
Sets whether the specified house displays unoccupied messages to the player
aHouseID: Integer;
aDisabled: Boolean;
5057 HouseRepairEnable
Enables house repair for the specified house
aHouseID: Integer;
aRepairEnabled: Boolean;
5174 HouseSchoolQueueAdd
Adds the specified unit to the specified school's queue.
Returns the number of units successfully added to the queue.
aHouseID: Integer;
aUnitType: Integer;
aCount: Integer;
Integer
14000 HouseSchoolQueueAddEx
Adds the specified unit to the specified school's queue.
Returns the number of units successfully added to the queue.
aHouseID: Integer;
aUnitType: TKMUnitType;
aCount: Integer;
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.
aHouseID: Integer;
QueueIndex: Integer;
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
aHouseID: Integer;
aType: Integer;
aCount: Integer;
14000 HouseTakeWaresFromEx
Remove wares from the specified house.
If a serf was on the way to pick up the ware, the serf will abandon his task
aHouseID: Integer;
aType: TKMWareType;
aCount: Integer;
7000+ HouseTownHallEquip
Equips the specified unit from the specified TownHall.
Returns the number of units successfully equipped.
aHouseID: Integer;
aUnitType: Integer;
aCount: Integer;
Integer
14000 HouseTownHallEquipEx
Equips the specified unit from the specified TownHall.
Returns the number of units successfully equipped.
aHouseID: Integer;
aUnitType: TKMUnitType;
aCount: Integer;
Integer
7000+ HouseTownHallMaxGold
Set TownHall Max Gold parameter (how many gold could be delivered in it)
aHouseID: Integer;
aMaxGold: Integer;
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.
aHand: Integer;
aHouseType: Integer;
5099 HouseWareBlock
Blocks a specific ware in a storehouse or barracks
aHouseID: Integer;
aWareType: Integer;
aBlocked: Boolean;
14000 HouseWareBlockEx
Blocks a specific ware in a storehouse or barracks
aHouseID: Integer;
aWareType: TKMWareType;
aBlocked: Boolean;
14000 HouseWareBlockTakeOut
Blocks taking out of a specific ware from a storehouse or barracks
aHouseID: Integer;
aWareType: TKMWareType;
aBlocked: Boolean;
5165 HouseWeaponsOrderSet
Sets the amount of the specified weapon ordered to be produced in the specified house
aHouseID: Integer;
aWareType: Integer;
aAmount: Integer;
14000 HouseWeaponsOrderSetEx
Sets the amount of the specified weapon ordered to be produced in the specified house
aHouseID: Integer;
aWareType: TKMWareType;
aAmount: Integer;
5099 HouseWoodcutterChopOnly
Sets whether a woodcutter's hut is on chop-only mode
aHouseID: Integer;
aChopOnly: Boolean;
14000 HouseWoodcutterMode
Sets woodcutter's hut woodcutter mode as TKMWoodcutterMode = (wmChopAndPlant, wmChop, wmPlant)
aHouseID: Integer;
aWoodcutterMode: ;
TKMWoodcutterMode: ;
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
aText: AnsiString;
12989 LogLinesMaxCnt
Set max number of error lines saved in the logs
aMaxLogLinesCnt: Integer;
11000 MapBrush
Apply brush from MapEd to the map
X: Integer; //coodinates
Y: Integer;
aSquare: Boolean; //is brush square or circle
aSize: Integer; //brush size
aTerKind: TKMTerrainKind; //terrain kind
aRandomTiles: Boolean; //use random tiles
aOverrideCustomTiles: Boolean; //override tiles, that were manually set from tiles table
11000 MapBrushElevation
Apply Elevation change brush from MapEd to the map
X: Integer; //coodinates
Y: Integer;
aSquare: Boolean; //is brush square or circle
aRaise: Boolean; //raise elevation or lower it
aSize: Integer; //brush size
aSlope: Integer; //elevation slope
aSpeed: Integer; //elevation change speed
11000 MapBrushEqualize
Apply Equalize brush from MapEd to the map
X: Integer; //coodinates
Y: Integer;
aSquare: Boolean; //is brush square or circle
aSize: Integer; //brush size
aSlope: Integer; //elevation slope
aSpeed: Integer; //elevation change speed
11000 MapBrushFlatten
Apply Flatten brush from MapEd to the map
X: Integer; //coodinates
Y: Integer;
aSquare: Boolean; //is brush square or circle
aSize: Integer; //brush size
aSlope: Integer; //elevation slope
aSpeed: Integer; //elevation change speed
11000 MapBrushMagicWater
Apply magic water brush from MapEd to the map
X: Integer; //coodinates
Y: Integer;
11000 MapBrushWithMask
Apply brush with mask specified from MapEd to the map
X: Integer; //coodinates
Y: Integer;
aSquare: Boolean; //is brush square or circle
aSize: Integer; //brush size
aTerKind: TKMTerrainKind; //terrain kind
aRandomTiles: Boolean; //use random tiles
aOverrideCustomTiles: Boolean; //override tiles, that were manually set from tiles table
aBrushMask: TKMTileMaskKind; //brush mask type
aBlendingLvl: Integer; //blending level for masks. Allowed values are from 0 to 15
aUseMagicBrush: Boolean; //enable/disable magic brush to change/remove brush mask from the area
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
X: Integer;
Y: Integer;
Height: Integer; //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
X: Integer;
Y: Integer;
Obj: Integer; //Object type (0..255)
Boolean
11000 MapTileOverlaySet
Sets the terrain overlay on the tile at the specified XY coordinates.
aOverwrite = False means safe way to change tile overlay, disallowing to set it on top of old fields/roads
X: Integer;
Y: Integer;
aOverlay: TKMTileOverlay;
aOverwrite: Boolean; //Overwrite = True allows to destroy roads and re-dig fields (like in game we can build road on top of field and when laborer dies there is a digged overlay left)
Boolean
7000+ MapTilesArraySet
Sets array of tiles info, with possible change of
1. terrain (tile type) and/or rotation (same as for MapTileSet),
2. tile height (same as for MapTileHeightSet)
3. tile object (same as for MapTileObjectSet)
Works much faster, then applying all changes successively for every tile, because pathfinding compute is executed only once after all changes have been done
TKMTerrainTileBrief = record
X, Y: Byte; // Tile map coordinates
Terrain: Byte; // Terrain tile type (0..255)
Rotation: Byte; // Tile rotation (0..3)
Height: Byte; // Heigth (0..100)
Obj: Byte; // Object (0..255)
ChangeSet: TKMTileChangeTypeSet; // Set of changes.
end;
TKMTileChangeTypeSet = set of TKMTileChangeType
TKMTileChangeType =
(tctTerrain, tctRotation, tctHeight, tctObject)
ChangeSet determines what should be changed on tile
F.e. if we want to change terrain type and height, then ChangeSet should contain tctTerrain and tctHeight
Note: aTiles elements should start from 0, as for dynamic array. So f.e. to change map tile 1,1 we should set aTiles[0][0].
Note: Errors are shown as map tiles (f.e. for error while applying aTiles[0][0] tile there will be a message with for map tile 1,1)

Returns true, if there was no errors on any tile. False if there was at least 1 error.
aTiles: array of TKMTerrainTileBrief; //Check detailed info on this type in description
aRevertOnFail: Boolean; //do we need to revert all changes on any error while applying changes. If True, then no changes will be applied on error. If False - we will continue apply changes where possible
aShowDetailedErrors: Boolean; //show detailed errors after. Can slow down the execution, because of logging. If aRevertOnFail is set to True, then only first error will be shown
Boolean
7000+ MapTilesArraySetS
Sets array of tiles info, like MapTilesArraySet, but parameters are
passed as an TAnsiStringArray instead of array of TKMTerrainTileBrief.
This function is useful if you need to create dynamic map from scratch.
Array must contain strings in following format: 'X,Y,Terrain,Rotation,Height,Obj'
f.e. '1,1,20,2,87,12'
In case of invalid structure detection / failed variable parsing you can find
detailed errors in LOG file.
If you need to skip terrain or rotation/height/obj use -1 as parameter
f.e.
Skipping rotation for tile [7,2]: '7,2,20,-1,87,12'
Skipping obj for tile [7,2]: '7,2,20,2,87,-1'
Skipping height for tile [7,2]: '7,2,20,2,-1,5' etc.
aTilesS: array of AnsiString;
aRevertOnFail: Boolean;
aShowDetailedErrors: Boolean;
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
X: Integer;
Y: Integer;
aType: Integer; //Tile type (0..255)
aRotation: Integer; //Tile rotation (0..3)
Boolean
6216 MarketSetTrade
Sets the trade in the specified market
aMarketID: Integer;
aFrom: Integer;
aTo: Integer;
aAmount: Integer;
14000 MarketSetTradeEx
Sets the trade in the specified market
aMarketID: Integer;
aFrom: TKMWareType;
aTo: TKMWareType;
aAmount: Integer;
5333 OverlayTextAppend
Appends to text overlaid on top left of screen.
If the player index is -1 it will be appended for all players.
aHand: Shortint;
aText: 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.
Params: Array of arguments
aHand: Shortint;
aText: AnsiString;
aParams: array of const;
5333 OverlayTextSet
Sets text overlaid on top left of screen.
If the player index is -1 it will be set for all players.
aHand: Shortint;
aText: AnsiString;
14000 OverlayTextSetFont
Sets text overlay font
Possible values are: fntAntiqua, fntGame, fntGrey, fntMetal, fntMini, fntOutline, fntArial, fntMonospaced
If the player index is -1 it will be set for all players.
aHand: Integer;
aFont: ;
TKMFont: ;
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.
Params: Array of arguments
aHand: Shortint;
aText: AnsiString;
aParams: array of const;
14000 OverlayTextSetWordWrap
Sets or unsets text overlay word wrap
If the player index is -1 it will be set for all players.
aHand: Integer;
aWordWrap: Boolean;
11000 Peacetime
Sets game peacetime. Peacetime will be set to the value of aPeacetime div 600
aPeacetime: Cardinal; //game time in ticks
5057 PlanAddField
Adds a corn field plan.
Returns true if the plan was successfully added or false if it failed (e.g. tile blocked)
aHand: Integer;
X: Integer;
Y: Integer;
Boolean
5057 PlanAddHouse
Adds a road plan.
Returns true if the plan was successfully added or false if it failed (e.g. tile blocked)
aHand: Integer;
aHouseType: Integer;
X: Integer;
Y: Integer;
Boolean
14000 PlanAddHouseEx
Adds a road plan.
Returns true if the plan was successfully added or false if it failed (e.g. tile blocked)
aHand: Integer;
aHouseType: TKMHouseType;
X: Integer;
Y: Integer;
Boolean
5057 PlanAddRoad
Adds a road plan.
Returns true if the plan was successfully added or false if it failed (e.g. tile blocked)
aHand: Integer;
X: Integer;
Y: Integer;
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)
aHand: Integer;
X: Integer;
Y: Integer;
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
aHand: Integer;
X1: Integer; //Left coordinate
Y1: Integer; //Top coordinate
X2: Integer; //Right coordinate
Y2: Integer; //Bottom coordinate
aCompleted: Boolean; //Completed road
Boolean
5345 PlanRemove
Removes house, road or field plans from the specified tile for the specified player
Returns true if the plan was successfully removed or false if it failed (e.g. tile blocked)
aHand: Integer;
X: Integer;
Y: Integer;
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.
aHand: Byte;
aBuildings: 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)
aHand1: Byte;
aHand2: Byte;
aCompliment: Boolean; //Both ways
aAllied: Boolean;
7000+ PlayerAllianceNFogChange
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)
aHand1: Byte;
aHand2: Byte;
aCompliment: Boolean; //Both ways
aAllied: Boolean;
aSyncAllyFog: Boolean; //Synchronize allies fogs of war
5057 PlayerDefeat
Proclaims player defeated
aHand: Integer;
11000 PlayerGoalsRemoveAll
Remove all player goals
aHand: Integer; //PlayerID
aForAllPlayers: Boolean; //also remove other player goals, related to this player
7000+ PlayerShareBeacons
Sets whether player A shares his beacons with player B.
Sharing can still only happen between allied players, but this command lets you disable allies from sharing.
aHand1: Integer;
aHand2: Integer;
aBothWays: Boolean; //share in both ways
aShare: Boolean;
5345 PlayerShareFog
Sets whether player A shares his vision with player B (one way, for both ways use PlayerShareFogCompliment).
Sharing can still only happen between allied players, but this command lets you disable allies from sharing.
aHand1: Integer;
aHand2: Integer;
aShare: Boolean;
7000+ PlayerShareFogCompliment
Sets whether players A and B share their vision (both ways).
Sharing can still only happen between allied players, but this command lets you disable allies from sharing.
aHand1: Integer;
aHand2: Integer;
aShare: Boolean;
5345 PlayerWareDistribution
Sets ware distribution for the specified resource, house and player.
Note: distribution should be set after 1st tick of the game,
thus it will not make effect to use it in OnMissionStart event handler
aHand: Byte;
aWareType: Byte;
aHouseType: Byte;
aAmount: Byte; //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.
aVictors: array of Integer; //Array of player IDs
aTeamVictory: Boolean;
7000+ PlayOGG
Plays OGG audio file.
If the player index is -1 the sound will be played to all players.
Mono and stereo OGG files are supported.
OGG file goes in mission folder named: Mission Name.filename.ogg
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 1.0)
Integer //SoundIndex of the sound
7000+ PlayOGGAtLocation
Plays OGG 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 OGG files are supported.
OGG file goes in mission folder named: Mission Name.filename.ogg.
Will not play if the location is not revealed to the player.
Higher volume range is allowed than PlayOGG as positional sounds are quieter
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 4.0)
aRadius: Single; //Radius (minimum 28)
aX: Integer;
aY: Integer;
Integer //SoundIndex of the sound
7000+ PlayOGGAtLocationLooped
Plays looped audio file at a location on the map.
If the player index is -1 the sound will be played to all players.
aRadius specifies approximately the distance at which the sound can no longer be heard (normal game sounds use aRadius 32).
Only mono OGG files are supported.
OGG file goes in mission folder named: Mission Name.filename.ogg.
Will not play if the location is not revealed to the player (will start playing automatically when it is revealed).
Higher aVolume range is allowed than PlayOGG 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.
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 4.0)
aRadius: Single; //aRadius (minimum 28)
aX: Integer;
aY: Integer;
Integer //SoundIndex of the sound
7000+ PlayOGGFadeMusic
Same as PlayOGG except music will fade then mute while the OGG is playing, then fade back in afterwards.
You should leave a small gap at the start of your OGG file to give the music time to fade
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 1.0)
Integer //SoundIndex of the sound
7000+ PlayOGGLooped
Plays looped OGG audio file.
If the player index is -1 the sound will be played to all players.
Mono or stereo OGG files are supported.
OGG file goes in mission folder named: Mission Name.filename.ogg.
The sound will continue to loop if the game is paused and will restart automatically when the game is loaded.
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 1.0)
Integer //SoundIndex of the sound
7000+ PlaySound
Plays audio file.
If the player index is -1 the sound will be played to all players.
Possible to specify Looped or FadeMusic parameter
Mono and stereo WAV and OGG files are supported.
To specify audio format use afWav or afOgg
WAV file goes in mission folder named: Mission Name.filename.wav.
OGG file goes in mission folder named: Mission Name.filename.ogg
If MusicFaded then sound will fade then mute while the file is playing, then fade back in afterwards.
If looped, the sound will continue to loop if the game is paused and will restart automatically when the game is loaded.
aHand: Shortint;
aFileName: AnsiString;
aAudioFormat: TKMAudioFormat; //afWav or afOgg
aVolume: Single; //Audio level (0.0 to 1.0)
aFadeMusic: Boolean;
aLooped: Boolean;
Integer //SoundIndex of the sound
7000+ PlaySoundAtLocation
Plays audio file at a location on the map.
If the player index is -1 the sound will be played to all players.
Possible to specify Looped or FadeMusic parameter
aRadius specifies approximately the distance at which the sound can no longer be heard (normal game sounds use aRadius 32).
Only mono WAV or OGG files are supported.
To specify audio format use afWav or afOgg
WAV file goes in mission folder named: Mission Name.filename.wav.
OGG file goes in mission folder named: Mission Name.filename.ogg.
Will not play if the location is not revealed to the player (will start playing automatically when it is revealed).
Higher aVolume range is allowed than PlaySound as positional sounds are quieter.
If looped, the sound will continue to loop if the game is paused and will restart automatically when the game is loaded.
aHand: Shortint;
aFileName: AnsiString;
aAudioFormat: TKMAudioFormat; //afWav or afOgg
aVolume: Single; //Audio level (0.0 to 4.0)
aFadeMusic: Boolean;
aLooped: Boolean;
aRadius: Single; //aRadius (minimum 28)
aX: Integer;
aY: Integer;
Integer //SoundIndex of the sound
5309 PlayWAV
Plays WAV audio file.
If the player index is -1 the sound will be played to all players.
Mono and stereo WAV files are supported.
WAV file goes in mission folder named: Mission Name.filename.wav
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 1.0)
Integer //SoundIndex of the sound
5309 PlayWAVAtLocation
Plays WAV 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
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 4.0)
aRadius: Single; //Radius (minimum 28)
aX: Integer;
aY: Integer;
Integer //SoundIndex of the sound
6222 PlayWAVAtLocationLooped
Plays looped WAV audio file at a location on the map.
If the player index is -1 the sound will be played to all players.
aRadius specifies approximately the distance at which the sound can no longer be heard (normal game sounds use aRadius 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 aVolume 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.
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 4.0)
aRadius: Single; //aRadius (minimum 28)
aX: Integer;
aY: Integer;
Integer //SoundIndex of the sound
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
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 1.0)
Integer //SoundIndex of the sound
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.
aHand: Shortint;
aFileName: AnsiString;
aVolume: Single; //Audio level (0.0 to 1.0)
Integer //SoundIndex of the sound
5927 RemoveRoad
Removes road
X: Integer;
Y: Integer;
5057 SetTradeAllowed
Sets whether the player is allowed to trade the specified resource.
aHand: Integer;
aResType: Integer;
aAllowed: Boolean;
5057 ShowMsg
Displays a message to a player.
If the player index is -1 the message will be shown to all players.
aHand: Shortint;
aText: 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.
aHand: Shortint;
aText: AnsiString;
Params: array of const; //Array of arguments
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.
aHand: Shortint;
aX: Integer;
aY: Integer;
aText: AnsiString;
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.
aHand: Shortint;
aX: Integer;
aY: Integer;
aText: AnsiString;
Params: array of const; //Array of arguments
7000+ StopLoopedOGG
Stops playing a looped sound that was previously started with either Actions.PlayOGGLooped or Actions.PlayOGGAtLocationLooped.
aSoundIndex: Integer; //value that was returned by either of those functions when the looped sound was started.
6222 StopLoopedWAV
Stops playing a looped sound that was previously started with either Actions.PlayWAVLooped or Actions.PlayWAVAtLocationLooped.
aSoundIndex: Integer; //value that was returned by either of those functions when the looped sound was started.
7000+ StopSound
Stops playing any sound that was previously started by any of PlayWAV***, PlayOGG*** or PlaySound*** functions
aSoundIndex: Integer; //value that was returned by either of those functions when the sound was started.
12600 UnitAllowAllyToSelect
Allows allies to select and view specified unit
For warriors: allow to select their group
aUnitID: Integer;
aAllow: Boolean;
5993 UnitBlock
Sets whether the specified player can train/equip the specified unit type
aHand: Byte;
aType: Integer;
aBlock: 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.
aUnitID: Integer;
aDirection: Integer;
Boolean
14000 UnitDirectionSetEx
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.
aUnitID: Integer;
aDirection: ;
TKMDirection: ;
Boolean
7000+ UnitDismiss
Dismiss the specified unit
aUnitID: Integer;
7000+ UnitDismissableSet
Makes the specified unit 'dismiss' command available
aUnitID: Integer;
aDismissable: Boolean;
7000+ UnitDismissCancel
Cancel dismiss task for the specified unit
aUnitID: Integer;
7000+ UnitHPChange
Heals/Wounds specified unit for aHP HP
aUnitID: Integer;
aHP: Integer;
7000+ UnitHPSetInvulnerable
Makes the unit invulnerable. Such unit can not be killed or die from hunger.
aUnitID: Integer;
aInvulnerable: Boolean;
5057 UnitHungerSet
Sets the hunger level of the specified unit in ticks until death
aUnitID: Integer;
aHungerLevel: Integer; //Hunger level (ticks until death)
5099 UnitKill
Kills the specified unit.
Silent means the death animation (ghost) and sound won't play
aUnitID: Integer;
aSilent: Boolean;
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.
aUnitID: Integer;
X: Integer;
Y: Integer;
Boolean