All states parameters are numeric and get mapped to unit/house types according to default tables used in DAT scripts.
States are queried in a form States.STATE_NAME(STATE_PARAMETERS) like so:
if States.StatPlayerCount > 5 then
UnitCnt := States.StatUnitCount(1);
Also there is a short name for States: just S, so you could use it as
UnitCnt := S.StatUnitCount(1); //Get 1st player units count and store it in variable UnitCnt
Other scripts functions:
Dynamic scripts usefull info:
- AIArmyType
- AIAutoAttack
- AIAutoAttackRange
- AIAutoBuild
- AIAutoDefence
- AIAutoRepair
- AIDefencePositionGet
- AIDefencePositionGetByIndex
- AIDefendAllies
- AIEquipRate
- AIGroupsFormationGet
- AIGroupsFormationGetEx
- AIRecruitDelay
- AIRecruitLimit
- AIRepairMode
- AISerfsPerHouse
- AISoldiersLimit
- AIStartPosition
- AIWorkerLimit
- CampaignMissionID
- CampaignMissionsCount
- ClosestGroup
- ClosestGroupEx
- ClosestGroupMultipleTypes
- ClosestGroupMultipleTypesEx
- ClosestHouse
- ClosestHouseEx
- ClosestHouseMultipleTypes
- ClosestHouseMultipleTypesEx
- ClosestUnit
- ClosestUnitEx
- ClosestUnitMultipleTypes
- ClosestUnitMultipleTypesEx
- ConnectedByRoad
- ConnectedByWalking
- FogRevealed
- GameSpeed
- GameSpeedChangeAllowed
- GameTime
- GroupAllowAllyToSelect
- GroupAssignedToDefencePosition
- GroupAt
- GroupColumnCount
- GroupDead
- GroupIdle
- GroupInFight
- GroupManualFormation
- GroupMember
- GroupMemberCount
- GroupOrder
- GroupOwner
- GroupType
- GroupTypeEx
- HandHouseCanBuild
- HandHouseLock
- HandUnitCanTrain
- HandWareDistribution
- HouseAllowAllyToSelect
- HouseAt
- HouseBarracksRallyPointX
- HouseBarracksRallyPointY
- HouseBarracksRecruitBlock
- HouseBarracksRecruitsCount
- HouseBuildingProgress
- HouseCanReachResources
- HouseDamage
- HouseDeliveryBlocked
- HouseDeliveryMode
- HouseDestroyed
- HouseFlagPoint
- HouseGetAllUnitsIn
- HouseHasOccupant
- HouseHasWorker
- HouseIsComplete
- HouseOwner
- HousePosition
- HousePositionX
- HousePositionY
- HouseRepair
- HouseResourceAmount
- HouseSchoolQueue
- HouseSiteIsDigged
- HouseTownHallMaxGold
- HouseType
- HouseTypeEx
- HouseTypeMaxHealth
- HouseTypeMaxHealthEx
- HouseTypeName
- HouseTypeNameEx
- HouseTypeToOccupantType
- HouseTypeToWorkerType
- HouseUnlocked
- HouseWareBlocked
- HouseWareBlockedEx
- HouseWareBlockedTakeOut
- HouseWeaponsOrdered
- HouseWeaponsOrderedEx
- HouseWoodcutterChopOnly
- HouseWoodcutterMode
- HouseWorker
- IsFieldAt
- IsFieldPlanAt
- IsHousePlanAt
- IsMissionBlockColorSelection
- IsMissionBlockFullMapPreview
- IsMissionBlockPeacetime
- IsMissionBlockTeamSelection
- IsMissionBuildType
- IsMissionCoopType
- IsMissionFightType
- IsMissionPlayableAsSP
- IsMissionSpecialType
- IsPlanAt
- IsRoadAt
- IsRoadPlanAt
- IsWinefieldAt
- IsWinefieldPlanAt
- KaMRandom
- KaMRandomI
- LocationCount
- MapHeight
- MapTileHasOnlyTerrainKind
- MapTileHasOnlyTerrainKinds
- MapTileHasTerrainKind
- MapTileHeight
- MapTileIsCoal
- MapTileIsGold
- MapTileIsIce
- MapTileIsInMapCoords
- MapTileIsIron
- MapTileIsSand
- MapTileIsSnow
- MapTileIsSoil
- MapTileIsStone
- MapTileIsWater
- MapTileObject
- MapTileOverlay
- MapTileOwner
- MapTilePassability
- MapTilePassabilityEx
- MapTileRotation
- MapTileType
- MapWidth
- MarketFromWare
- MarketFromWareEx
- MarketLossFactor
- MarketOrderAmount
- MarketToWare
- MarketToWareEx
- MarketValue
- MarketValueEx
- MissionAuthor
- MissionDifficulty
- MissionDifficultyLevels
- MissionVersion
- PeaceTime
- PlayerAllianceCheck
- PlayerColorFlag
- PlayerColorText
- PlayerDefeated
- PlayerEnabled
- PlayerGetAllGroups
- PlayerGetAllHouses
- PlayerGetAllUnits
- PlayerIsAI
- PlayerName
- PlayerVictorious
- PlayerWareDistribution
- StatAIDefencePositionsCount
- StatArmyCount
- StatArmyPower
- StatCitizenCount
- StatHouseCount
- StatHouseMultipleTypesCount
- StatHouseMultipleTypesCountEx
- StatHouseTypeCount
- StatHouseTypeCountEx
- StatHouseTypePlansCount
- StatHouseTypePlansCountEx
- StatPlayerCount
- StatResourceProducedCount
- StatResourceProducedCountEx
- StatResourceProducedMultipleTypesCount
- StatResourceProducedMultipleTypesCountEx
- StatUnitCount
- StatUnitKilledCount
- StatUnitKilledCountEx
- StatUnitKilledMultipleTypesCount
- StatUnitKilledMultipleTypesCountEx
- StatUnitLostCount
- StatUnitLostCountEx
- StatUnitLostMultipleTypesCount
- StatUnitLostMultipleTypesCountEx
- StatUnitMultipleTypesCount
- StatUnitMultipleTypesCountEx
- StatUnitTypeCount
- StatUnitTypeCountEx
- UnitAllowAllyToSelect
- UnitAt
- UnitCarrying
- UnitCarryingEx
- UnitDead
- UnitDirection
- UnitDirectionEx
- UnitDismissable
- UnitHome
- UnitHPCurrent
- UnitHPInvulnerable
- UnitHPMax
- UnitHunger
- UnitIdle
- UnitInHouse
- UnitLowHunger
- UnitMaxHunger
- UnitOwner
- UnitPosition
- UnitPositionX
- UnitPositionY
- UnitsGroup
- UnitType
- UnitTypeEx
- UnitTypeName
- UnitTypeNameEx
- WareTypeName
- WareTypeNameEx
- WarriorInFight
Ver sion |
State description | Parameters and types |
Returns |
---|---|---|---|
7000+ | AIArmyType Gets AI army type |
aHand: Byte; | TKMArmyType |
13000 | AIAutoAttack Gets AI AutoAttack (True or False) |
aHand: Byte; | Boolean |
7000+ | AIAutoAttackRange Gets AI auto attack range. Returns -1 if used with wrong parameters |
aHand: Byte; | Integer |
7000+ | AIAutoBuild Gets whether the AI should build and manage his own village Returns False if used with wrong parameters |
aHand: Byte; | Boolean |
7000+ | AIAutoDefence Gets whether the AI should position his soldiers automatically Returns False if used with wrong parameters |
aHand: Byte; | Boolean |
7000+ | AIAutoRepair Gets whether the AI should automatically repair damaged buildings Returns False if used with wrong parameters |
aHand: Byte; | Boolean |
12000+ | AIDefencePositionGet Gets the parameters of AI defence position Parameters are returned in aX, aY, aGroupType, aRadius, aDefType variables Group types: 0 = Melee; 1 = Anti-horse; 2 = Ranged; 3 = Mounted Defence type: 0 = Defenders; 1 = Attackers |
aHand: Byte; aID: Byte; out aX: Integer; out aY: Integer; out aGroupType: Byte; out aRadius: Integer; out aDefType: Byte; |
|
13900 | AIDefencePositionGetByIndex Gets the parameters of AI defence position Returns defence position parameters |
aHand: Integer; aIndex: Integer; //index in the list of all defence positions for the specified player |
TKMDefencePositionInfo |
7000+ | AIDefendAllies Gets whether AI should defend units and houses of allies as if they were its own Returns False if used with wrong parameters |
aHand: Byte; | Boolean |
7000+ | AIEquipRate Gets the warriors equip rate for AI. Returns -1 if used with wrong parameters |
aHand: Byte; aType: Byte; //type: 0 - leather, 1 - iron |
Integer |
7000+ | AIGroupsFormationGet Gets the formation the AI uses for defence positions for specified player and group type GroupType: 0 = Melee, 1 = AntiHorse, 2 = Ranged, 3 = Mounted group count and columns are returned in aCount and aColumns variables |
aHand: Byte; aType: Byte; out aCount: Integer; out aColumns: Integer; |
|
13900 | AIGroupsFormationGetEx Gets the formation the AI uses for defence positions for specified player and group type group count and columns are returned in aCount and aColumns variables |
aHand: Integer; aGroupType: Integer; TKMGroupType: Integer; out aCount: Integer; out aColumns: Integer; |
|
7000+ | AIRecruitDelay Gets the number of ticks before the specified AI will start training recruits Returns -1 if used with wrong parameters |
aHand: Byte; | Integer |
7000+ | AIRecruitLimit Gets the number of recruits the AI will keep in each barracks Returns -1 if used with wrong parameters |
aHand: Byte; | Integer |
13900 | AIRepairMode Gets whether the AI should automatically repair damaged buildings Returns rmNone if used with wrong parameters rmNever if disable repair for all houses rmAlways if enable repair for all houses rmManual if repair is set by script manually via Actions.HouseRepairEnable |
aHand: Integer; | TKMAIRepairMode |
7000+ | AISerfsPerHouse Gets the number of serfs the AI will train per house. Can be a decimal (0.25 for 1 serf per 4 houses) Returns -1 if used with wrong parameters |
aHand: Byte; | Single |
7000+ | AISoldiersLimit Gets the maximum number of soldiers the AI will train, or -1 for unlimited Returns -2 if used with wrong parameters |
aHand: Byte; | Integer |
7000+ | AIStartPosition Gets the AI start position which is used for targeting AI attacks Returns (-1;-1) if used with wrong parameters |
aHand: Byte; | TKMPoint |
7000+ | AIWorkerLimit Gets the maximum number of laborers the AI will train Returns -1 if used with wrong parameters |
aHand: Byte; | Integer |
12600 | CampaignMissionID Returns current campaing mission number or -1 if this is not a campaign mission First mission got ID = 1 |
Integer | |
12600 | CampaignMissionsCount Returns current campaign missions count or -1 if this is not a campaign mission |
Integer | |
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 |
aHand: Integer; X: Integer; Y: Integer; aGroupType: Integer; |
Integer //Group ID |
13900 | ClosestGroupEx 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. |
aHand: Integer; X: Integer; Y: Integer; aGroupType: ; TKMGroupType: ; |
Integer //Group ID |
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] |
aHand: Integer; X: Integer; Y: Integer; aGroupTypes: set of Byte; //Set of group types |
Integer //Group ID |
13900 | ClosestGroupMultipleTypesEx 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] |
aHand: Integer; X: Integer; Y: Integer; aGroupTypes: ; //Set of group types TKMGroupTypeSet: ; |
Integer //Group ID |
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 |
aHand: Integer; X: Integer; Y: Integer; aHouseType: Integer; |
Integer //House ID |
13900 | ClosestHouseEx 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 htAny any house type will be accepted |
aHand: Integer; X: Integer; Y: Integer; aHouseType: TKMHouseType; |
Integer //House ID |
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] |
aHand: Integer; X: Integer; Y: Integer; aHouseTypes: set of Byte; //Set of house types |
Integer //House ID |
13900 | ClosestHouseMultipleTypesEx 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 TKMHouseType", for example [htQuary, htSchool, htStore] |
aHand: Integer; X: Integer; Y: Integer; aHouseTypes: ; //Set of house types TKMHouseTypeSet: ; |
Integer //House ID |
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 |
aHand: Integer; X: Integer; Y: Integer; aUnitType: Integer; |
Integer //Unit ID |
13900 | ClosestUnitEx 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 utAny any unit type will be accepted |
aHand: Integer; X: Integer; Y: Integer; aUnitType: TKMUnitType; |
Integer //Unit ID |
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] |
aHand: Integer; X: Integer; Y: Integer; aUnitTypes: set of Byte; //Set of unit types |
Integer //Unit ID |
13900 | ClosestUnitMultipleTypesEx 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 TKMUnitType", for example [utSerf, utMilitia] |
aHand: Integer; X: Integer; Y: Integer; aUnitTypes: ; //Set of unit types TKMUnitTypeSet: ; |
Integer //Unit ID |
6602 | ConnectedByRoad Check if two tiles are connected by walkable road |
X1: Integer; //left coordinate Y1: Integer; //top coordinate X2: Integer; //right coordinate Y2: Integer; //bottom coordinate |
Boolean //Connected |
6602 | ConnectedByWalking Check if two tiles are connected by a walkable route |
X1: Integer; //Left coordinate Y1: Integer; //Top coordinate X2: Integer; //Right coordinate Y2: Integer; //Bottom coordinate |
Boolean //Connected |
5097 | FogRevealed Check if a tile is revealed in fog of war for a player |
aHand: Byte; aX: Integer; aY: Integer; |
Boolean //Revealed |
11000 | GameSpeed Get the game speed |
Single //Game speed | |
11000 | GameSpeedChangeAllowed Return true if game speed change is allowed |
Boolean //Is game speed change allowed | |
5057 | GameTime Get the number of game ticks since mission start |
Cardinal //Ticks (~10 per second) | |
12600 | GroupAllowAllyToSelect Return if specified group is allowed to be selected and viewed by his allies |
aGroupID: Integer; | Boolean |
7000+ | GroupAssignedToDefencePosition Returns true if target Group is assigned to the Defence Position at coordinates X, Y |
aGroupID: Integer; X: Integer; Y: Integer; |
Boolean //Group assigned to Defence position |
5057 | GroupAt Returns the ID of the group of the unit on the specified tile or -1 if no group exists there |
aX: Integer; aY: Integer; |
Integer //Group ID |
5272 | GroupColumnCount Returns the number of columns (units per row) of the specified group |
aGroupID: Integer; | Integer //Column count |
5057 | GroupDead Returns true if the group is dead (all members dead or joined other groups) |
aGroupID: Integer; | Boolean //Dead |
6523 | GroupIdle Returns true if specified group is idle (has no orders/action) |
aGroupID: Integer; | Boolean //Idle |
7000+ | GroupInFight Returns true if specified group is in fight |
aGroupID: Integer; aCountCitizens: Boolean; //CountCitizens - including fights with citizens |
Boolean //InFight |
11200 | GroupManualFormation Returns the manual formation parameter of the specified group (false for new group, true if player changed formation manually at least once) |
aGroupID: Integer; | Boolean //manual formation |
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) |
aGroupID: Integer; aMemberIndex: Integer; |
Integer //Unit ID |
5057 | GroupMemberCount Returns the total number of members of the specified group |
aGroupID: Integer; | Integer //Member count |
7000+ | GroupOrder Returns current order of the specified group |
aGroupID: Integer; | TKMGroupOrder //TKMGroupOrder |
5057 | GroupOwner Returns the owner of the specified group or -1 if Group ID invalid |
aGroupID: Integer; | Integer //Player ID |
5932 | GroupType Returns the type of the specified group or -1 if Group ID invalid |
aGroupID: Integer; | Integer //Group type |
13900 | GroupTypeEx Returns the type of the specified group or gtNone if Group ID invalid |
aGroupID: Integer; | TKMGroupType //Group type |
13900 | HandHouseCanBuild Returns true if the specified hand (player) can build the specified house type |
aHand: Integer; aHouseType: TKMHouseType; |
Boolean //House can build |
13900 | HandHouseLock Returns hand (player) house lock as enum value of TKMHandHouseLock = (hlDefault, hlBlocked, hlGranted) |
aHand: Integer; aHouseType: TKMHouseType; |
TKMHandHouseLock //Hand house lock |
13900 | HandUnitCanTrain Returns true if the specified player can train/equip the specified unit type |
aHand: Integer; aUnitType: TKMUnitType; |
Boolean //Unit unlocked |
13900 | HandWareDistribution Returns the ware distribution for the specified resource, house and player |
aHand: Integer; aWareType: TKMWareType; aHouseType: TKMHouseType; |
Integer //Ware distribution [0..5] |
10940 | HouseAllowAllyToSelect Return if specified house is allowed to be selected and viewed by his allies |
aHouseID: Integer; | Boolean |
5057 | HouseAt Returns the ID of the house at the specified location or -1 if no house exists there |
aX: Integer; aY: Integer; |
Integer //House ID |
6516 | HouseBarracksRallyPointX Returns X coordinate of Rally Point of specified barracks or 0 if BarracksID is invalid |
aBarracks: Integer; | Integer //X coordinate |
6516 | HouseBarracksRallyPointY Returns Y coordinate of Rally Point of specified barracks or 0 if BarracksID is invalid |
aBarracks: Integer; | Integer //Y coordinate |
14000 | HouseBarracksRecruitBlock Returns if recruits are blocked in the specified Barracks |
aHouseID: Integer; | Boolean |
12600 | HouseBarracksRecruitsCount Return number of recruits in the specified barracks or 0 if BarracksID is invalid |
aBarracks: Integer; | Integer |
6285 | HouseBuildingProgress Returns building progress of the specified house |
aHouseID: Integer; | Integer //Building progress |
5993 | HouseCanReachResources Returns true if the specified house can reach the resources that it mines (coal, stone, fish, etc.) |
aHouseID: Integer; | Boolean //Reachable |
5057 | HouseDamage Returns the damage of the specified house or -1 if House ID invalid |
aHouseID: Integer; | Integer //House damage |
5057 | HouseDeliveryBlocked Returns true if the specified house has delivery disabled |
aHouseID: Integer; | Boolean //Blocked |
13900 | HouseDeliveryMode Returns house delivery mode, if no house was found then ID = 1 is returned |
aHouseID: Integer; | TKMDeliveryMode //Delivery mode |
5057 | HouseDestroyed Returns true if the house is destroyed |
aHouseID: Integer; | Boolean //Destroyed |
7000+ | HouseFlagPoint Returns House Flag Point of specified house or KMPoint(0,0) if aHouseId is invalid |
aHouseID: Integer; | TKMPoint //Flag Point |
12982 | HouseGetAllUnitsIn Returns an array with IDs for all the units in the specified house |
aHouseID: Integer; | array of Integer //Array of unit IDs |
5057 | HouseHasOccupant ❌ Deprecated Method could be removed in the future game versions, use HouseHasWorker instead Returns true if the specified house currently has a worker |
aHouseID: Integer; | Boolean //Has worker |
13050 | HouseHasWorker Returns true if the specified house currently has a worker |
aHouseID: Integer; | Boolean //Has worker |
5345 | HouseIsComplete Returns true if the specified house is fully built |
aHouseID: Integer; | Boolean |
5057 | HouseOwner Returns the owner of the specified house or -1 if House ID invalid |
aHouseID: Integer; | Integer //Player ID |
7000+ | HousePosition Returns the Entrance Point of the specified house or (-1;-1) point if House ID invalid |
aHouseID: Integer; | TKMPoint //TKMPoint |
5057 | HousePositionX Returns the X coordinate of the specified house or -1 if House ID invalid |
aHouseID: Integer; | Integer //X coordinate |
5057 | HousePositionY Returns the Y coordinate of the specified house or -1 if House ID invalid |
aHouseID: Integer; | Integer //Y coordinate |
5057 | HouseRepair Returns true if the specified house has repair enabled |
aHouseID: Integer; | Boolean //Repair enabled |
5057 | HouseResourceAmount Returns the amount of the specified resource in the specified house |
aHouseID: Integer; aResource: Integer; |
Integer //Number of resources |
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. |
aHouseID: Integer; QueueIndex: Integer; //Queue index (0..5) |
Integer //Unit type |
6510 | HouseSiteIsDigged Returns true if specified WIP house area is digged |
aHouseID: Integer; | Boolean //Digged |
7000+ | HouseTownHallMaxGold Returns Max amount of gold which is possible to deliver into the TownHall or -1 if TownHall house was not found |
aHouseID: Integer; | Integer //Max gold for specified TownHall |
5057 | HouseType Returns the type of the specified house |
aHouseID: Integer; | Integer //House type |
13900 | HouseTypeEx Returns the type of the specified house |
aHouseID: Integer; | TKMHouseType //House type |
6284 | HouseTypeMaxHealth Returns max health of the specified house type |
aHouseType: Integer; | Integer //Max health |
13900 | HouseTypeMaxHealthEx Returns max health of the specified house type |
aHouseType: TKMHouseType; | Integer //Max health |
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. |
aHouseType: Byte; | AnsiString //House type name |
13900 | HouseTypeNameEx 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. |
aHouseType: TKMHouseType; | AnsiString //House type name |
5345 | HouseTypeToOccupantType ❌ Deprecated Method could be removed in the future game versions, use HouseTypeToWorkerType instead Returns the type of unit that should work in the specified type of house, or -1 if no unit should work in it. |
aHouseType: Integer; | Integer //Unit type |
13900 | HouseTypeToWorkerType Returns the type of unit that should work in the specified type of house, or utNone if no unit should work in it. |
aHouseType: TKMHouseType; | TKMUnitType //Unit type |
6220 | HouseUnlocked Returns true if the specified player can build the specified house type (unlocked and allowed). |
aHand: Integer; aHouseType: Integer; |
Boolean //House unlocked |
5099 | HouseWareBlocked Returns true if the specified ware in the specified storehouse or barracks is blocked |
aHouseID: Integer; aWareType: Integer; |
Boolean //Ware blocked |
13900 | HouseWareBlockedEx Returns true if the specified ware in the specified storehouse or barracks is blocked |
aHouseID: Integer; aWareType: TKMWareType; |
Boolean //Ware blocked |
13900 | HouseWareBlockedTakeOut Returns true if the specified ware in the specified storehouse or barracks is blocked for taking out (yellow triangle) |
aHouseID: Integer; aWareType: TKMWareType; |
Boolean //Ware blocked for taking out |
5165 | HouseWeaponsOrdered Returns the number of the specified weapon ordered to be produced in the specified house |
aHouseID: Integer; aWareType: Integer; |
Integer //Number of ordered weapons |
13900 | HouseWeaponsOrderedEx Returns the number of the specified weapon ordered to be produced in the specified house |
aHouseID: Integer; aWareType: TKMWareType; |
Integer //Number of ordered weapons |
5099 | HouseWoodcutterChopOnly Returns true if the specified woodcutter's hut is on chop-only mode |
aHouseID: Integer; | Boolean //Chop-only |
13900 | HouseWoodcutterMode Returns woodcutter mode value for the specified woodcutter's hut |
aHouseID: Integer; | TKMWoodcutterMode //woodcutter mode as TKMWoodcutterMode = (wmChopAndPlant, wmChop, wmPlant) |
13050 | HouseWorker Returns ID of a citizen, who works in specified house or -1 if there is no worker or aHouseID is incorrect |
aHouseID: Integer; | Integer |
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 |
aHand: Shortint; X: Integer; Y: Integer; |
Boolean //Is field |
7000+ | IsFieldPlanAt Returns true if the specified player has a field plan (ftCorn) at the specified location. If aHand index is -1 it will return true if any player has field plan at the specified location. If Corn (Field) Plan found then aHand will contain its player id |
var aHand: Integer; X: Integer; Y: Integer; |
Boolean //Is field plan found |
7000+ | IsHousePlanAt Returns true if the specified player has a house plan of the specified type at the specified location. If aHand index is -1 it will return true if any player has house plan of the specified type at the specified location. If aHouseType is htAny it will return if the specified player has a house plan of the any type at the specified location. If aHand index is -1 and aHouseType is htNone it will return if any player has a house plan of the any type at the specified location. If house plan found then after execution aHand will contain its player id and aHouseType its type |
var aHand: Integer; var aHouseType: TKMHouseType; X: Integer; Y: Integer; |
Boolean //Is house plan found |
11230 | IsMissionBlockColorSelection Returns if color selection is locked for current mission |
Boolean | |
7000+ | IsMissionBlockFullMapPreview Returns if full map preview is blocked for current mission |
Boolean | |
7000+ | IsMissionBlockPeacetime Returns if peacetime is locked for current mission |
Boolean | |
7000+ | IsMissionBlockTeamSelection Returns if team selection is locked for current mission |
Boolean | |
7000+ | IsMissionBuildType Returns if mission is build type |
Boolean | |
7000+ | IsMissionCoopType Returns if mission is cooperative type |
Boolean | |
7000+ | IsMissionFightType Returns if mission is fight type |
Boolean | |
7000+ | IsMissionPlayableAsSP Returns if mission is playable as Singleplayer map |
Boolean | |
7000+ | IsMissionSpecialType Returns if mission is special type |
Boolean | |
7000+ | IsPlanAt Returns true if the specified player has a field plan of the specified type at the specified location. If aHand index is -1 it will return true if any player has plan of the specified type at the specified location. If aFieldType is ftNone it will return if the specified player has a field plan of the any type (ftCorn, ftRoad, ftWine) at the specified location. If aHand index is -1 and aFieldType is ftNone it will return if any player has a field plan of the any type (ftCorn, ftRoad, ftWine) at the specified location. If Plan found then aHand will contain its player id and aFieldType its type |
var aHand: Integer; var aFieldType: TKMFieldType; X: Integer; Y: Integer; |
Boolean //Is plan found |
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 |
aHand: Shortint; X: Integer; Y: Integer; |
Boolean //Is road |
7000+ | IsRoadPlanAt Returns true if the specified player has a field plan (ftRoad) at the specified location. If aHand index is -1 it will return true if any player has road plan at the specified location. If Road plan found then aHand will contain its player id |
var aHand: Integer; X: Integer; Y: Integer; |
Boolean //Is road plan found |
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 |
aHand: Shortint; X: Integer; Y: Integer; |
Boolean //Is winefield |
7000+ | IsWinefieldPlanAt Returns true if the specified player has a field plan (ftWine) at the specified location. If aHand index is -1 it will return true if any player has winefield plan at the specified location. If Winefield Plan found then aHand will contain its player id |
var aHand: Integer; X: Integer; Y: Integer; |
Boolean //Is winefield plan found |
6216 | KaMRandom Returns a random single (float) such that: 0 <= Number < 1.0 |
Single //Decimal number 0.0 to 1.0 | |
6216 | KaMRandomI Returns a random integer such that: 0 <= Number |
aMax:Integer: ; | Integer //Number 0 to aMax |
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) |
Integer //Number of locations | |
6613 | MapHeight Returns the height of the map |
Integer //Height | |
11000 | MapTileHasOnlyTerrainKind Check if tile at XY coordinates has only requested terrain kind. F.e. water, but no transition with shallow or stone. |
X: Integer; Y: Integer; TerKind: TKMTerrainKind; |
Boolean //Tile has only requested terrain kind |
11000 | MapTileHasOnlyTerrainKinds Check if tile at XY coordinates has only requested terrain kinds. F.e. water and stone, but no dirt |
X: Integer; Y: Integer; TerKinds: ; array of TKMTerrainKind: ; |
Boolean //Tile has only requested terrain kinds |
11000 | MapTileHasTerrainKind Check if tile at XY coordinates has a part of requested terrain kind. F.e. water tile has corner transition with dirt |
X: Integer; Y: Integer; TerKind: TKMTerrainKind; |
Boolean //Tile has requested terrain kind part |
6587 | MapTileHeight Returns the height of the terrain at the top left corner (vertex) of the tile at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //Height (0..100) |
11000 | MapTileIsCoal Check coal deposit size at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //Coal deposit size at X, Y |
11000 | MapTileIsGold Check gold deposit size at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //Gold deposit size at X, Y |
11000 | MapTileIsIce Check if tile at the specified XY coordinates has ice |
X: Integer; Y: Integer; |
Boolean //Tile has ice |
11750 | MapTileIsInMapCoords Check if tile at the specified XY coordinates is within map borders (map has specified XY coordinates). F.e. coordinates (150, 200) are invalid for 128x128 map and not within map borders |
X: Integer; Y: Integer; |
Boolean //tile is in map coordinates |
11000 | MapTileIsIron Check iron deposit size at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //Iron deposit size at X, Y |
11000 | MapTileIsSand Check if tile at the specified XY coordinates has sand |
X: Integer; Y: Integer; |
Boolean //Tile has sand |
11000 | MapTileIsSnow Check if tile at the specified XY coordinates has snow |
X: Integer; Y: Integer; |
Boolean //Tile has snow |
11000 | MapTileIsSoil Check if tile at the specified XY coordinates has fertile soil (grass, dirt etc terrain good for fields, trees) |
X: Integer; Y: Integer; |
Boolean //Tile has soil |
11000 | MapTileIsStone Check stone deposit size at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //Stone deposit size at X, Y |
11000 | MapTileIsWater Check if tile at the specified XY coordinates has water. FullTilesOnly = True means we check only water tiles not containing transition with grass/sand/stone etc tiles. |
X: Integer; Y: Integer; FullTilesOnly: Boolean; //ullTilesOnly = False checks any water containing tiles including transitions. |
Boolean //Tile has water |
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". If there is no object on the tile, the result will be 255. |
X: Integer; Y: Integer; |
Integer //Object type (0..255) |
11000+ | MapTileOverlay Returns the terrain overlay on the tile at the specified XY coordinates. |
X: Integer; Y: Integer; |
TKMTileOverlay //tile overlay |
11000+ | MapTileOwner Returns the tile owner at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //tile owner ID |
7000+ | MapTilePassability Returns true if specified tile has requested passability. |
X: Integer; Y: Integer; aPassability: Byte; //passability index as listed in KM_Defaults (starts from 0) |
Boolean //True or False |
13900 | MapTilePassabilityEx Returns true if specified tile has requested passability. |
X: Integer; Y: Integer; aPassability: ; //TKMTerrainPassability TKMTerrainPassability: ; |
Boolean //True or False |
6587 | MapTileRotation Returns the rotation of the tile at the specified XY coordinates. |
X: Integer; Y: Integer; |
Integer //Rotation (0..3) |
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. |
X: Integer; Y: Integer; |
Integer //Tile type (0..597) |
6613 | MapWidth Returns the width of the map |
Integer //Width | |
6287 | MarketFromWare Returns type of FromWare in specified market, or -1 if no ware is selected |
aMarketID: Integer; | Integer //Ware type |
13900 | MarketFromWareEx Returns type of FromWare in specified market, or wtNone if no ware is selected |
aMarketID: Integer; | TKMWareType //Ware type |
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 |
Single //Loss factor | |
6287 | MarketOrderAmount Returns trade order amount in specified market |
aMarketID: Integer; | Integer //Order amount |
6287 | MarketToWare Returns type of ToWare in specified market, or -1 if no ware is selected |
aMarketID: Integer; | Integer //Ware type |
13900 | MarketToWareEx Returns type of ToWare in specified market, or wtNone if no ware is selected |
aMarketID: Integer; | TKMWareType //Ware type |
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) |
aRes: Integer; | Single //Value |
13900 | MarketValueEx 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) |
aWareType: TKMWareType; | Single //Value |
7000+ | MissionAuthor Returns mission author |
UnicodeString | |
7000+ | MissionDifficulty Returns mission difficulty for current game |
TKMMissionDifficulty | |
7000+ | MissionDifficultyLevels Returns allowed mission difficulty levels |
TKMMissionDifficultySet | |
11300 | MissionVersion Returns mission version |
UnicodeString | |
5057 | PeaceTime Length of peacetime in ticks (multiplayer) |
Cardinal //Ticks (~10 per second) | |
5057 | PlayerAllianceCheck Check how player 1 feels towards player 2 (order matters). Returns true for ally, false for enemy |
aHand1: Byte; aHand2: Byte; |
Boolean //Allied |
10940 | PlayerColorFlag Get players color in hex format |
aHand: Byte; | AnsiString //Player color |
4758 | PlayerColorText Get players color as text in hex format |
aHand: Byte; | AnsiString //Player color as text |
5057 | PlayerDefeated See if player was defeated |
aHand: Byte; | Boolean //Defeated |
5057 | PlayerEnabled Will be false if nobody selected that location in multiplayer |
aHand: Byte; | Boolean //Enabled |
5209 | PlayerGetAllGroups Returns an array with IDs for all the groups of the specified player |
aHand: Byte; | array of Integer //Array of group IDs |
5209 | PlayerGetAllHouses Returns an array with IDs for all the houses of the specified player |
aHand: Byte; | array of Integer //Array of house IDs |
5165 | PlayerGetAllUnits Returns an array with IDs for all the units of the specified player |
aHand: Byte; | array of Integer //Array of unit IDs |
5927 | PlayerIsAI Wherever player is controlled by AI |
aHand: Byte; | Boolean //Player is AI |
5057 | PlayerName Get name of player as a string (for multiplayer) |
aHand: Byte; | AnsiString //Player name |
4545 | PlayerVictorious See if player is victorious |
aHand: Byte; | Boolean //Victorious |
5345 | PlayerWareDistribution Returns the ware distribution for the specified resource, house and player |
aHand: Byte; aWareType: Byte; aHouseType: Byte; |
Byte //Ware distribution [0..5] |
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" |
aHand: Byte; | Integer //Defence position count |
5057 | StatArmyCount How many military units player has |
aHand: Byte; | Integer //Army count |
13660 | StatArmyPower The power factor of a player's army |
aHand: Byte; | Single //Army power |
5057 | StatCitizenCount How many citizen player has |
aHand: Byte; | Integer //Citizen count |
10940 | StatHouseCount Returns the number of houses of the specified player |
aHand: Byte; | Integer //Number of houses |
6328 | StatHouseMultipleTypesCount Returns number of specified house types for specified player. |
aHand: Byte; aTypes: set of Byte; //House types eg. [11, 13, 21] |
Integer //Total number of houses |
13900 | StatHouseMultipleTypesCountEx Returns number of specified house types for specified player. |
aHand: Integer; aTypes: ; //House types eg. [htQuary, htSchool, htStore] TKMHouseTypeSet: ; |
Integer //Total number of houses |
5057 | StatHouseTypeCount Returns the total number of the specified house type for the specified player. |
aHand: Byte; aHouseType: Byte; |
Integer //Number of houses |
13900 | StatHouseTypeCountEx Returns the total number of the specified house type for the specified player. |
aHand: Integer; aHouseType: TKMHouseType; |
Integer //Number of houses |
6313 | StatHouseTypePlansCount Specified house type plans count |
aHand: Byte; aHouseType: Byte; |
Integer //Number of plans |
13900 | StatHouseTypePlansCountEx Specified house type plans count |
aHand: Integer; aHouseType: TKMHouseType; |
Integer //Number of plans |
5057 | StatPlayerCount How many active players there are. |
Integer //Number of players | |
5057 | StatResourceProducedCount Returns the number of the specified resource produced by the specified player |
aHand: Byte; aResType: Byte; |
Integer //Number of produced resources |
13900 | StatResourceProducedCountEx Returns the number of the specified resource produced by the specified player if wtFood is passed, then all produced food will be returned if wtWarfare is passed, then all produced warfare will be returned, including horses if wtAll is passed, then all produced wares will be returned |
aHand: Integer; aWareType: TKMWareType; |
Integer //Number of produced resources |
6331 | StatResourceProducedMultipleTypesCount Returns the number of the specified resource types produced by the specified player. |
aHand: Byte; aTypes: set of Byte; //Set of ware types eg. [8, 10, 13, 27] for food |
Integer //Number of produced resources |
13900 | StatResourceProducedMultipleTypesCountEx Returns the number of the specified resource types produced by the specified player. |
aHand: Integer; aTypes: ; //Set of ware types eg. [wtCoal, wtSteel, wtGold] TKMWareTypeSet: ; |
Integer //Number of produced resources |
4289 | StatUnitCount Returns the number of units of the specified player |
aHand: Byte; | Integer //Number of units |
5057 | StatUnitKilledCount Returns the number of the specified unit killed by the specified player |
aHand: Byte; aUnitType: Byte; |
Integer //Number of killed units |
13900 | StatUnitKilledCountEx Returns the number of the specified unit killed by the specified player if utAny is passed, then return all killed units by the specified player |
aHand: Integer; aUnitType: TKMUnitType; |
Integer //Number of killed units |
6331 | StatUnitKilledMultipleTypesCount Returns the number of the specified unit types killed by the specified player. |
aHand: Byte; aTypes: set of Byte; |
Integer //Set of unit types eg. [0, 5, 13] |
13900 | StatUnitKilledMultipleTypesCountEx Returns the number of the specified unit types killed by the specified player. |
aHand: Integer; aTypes: ; TKMUnitTypeSet: ; |
Integer //Set of unit types eg. [utMilitia, utAxeFighter, utSwordsman] |
5057 | StatUnitLostCount Returns the number of the specified unit lost by the specified player |
aHand: Byte; aUnitType: Byte; |
Integer //Number of lost units |
13900 | StatUnitLostCountEx Returns the number of the specified unit lost by the specified player if utAny is passed, then return number of all lost units by the specified player |
aHand: Integer; aUnitType: TKMUnitType; |
Integer //Number of lost units |
6331 | StatUnitLostMultipleTypesCount Returns the number of the specified unit types lost by the specified player. |
aHand: Byte; aTypes: set of Byte; //Set of unit types eg. [0, 5, 13] |
Integer //Number of lost units |
13900 | StatUnitLostMultipleTypesCountEx Returns the number of the specified unit types lost by the specified player. |
aHand: Byte; aTypes: ; //Set of unit types eg. [utMilitia, utAxeFighter, utSwordsman] TKMUnitTypeSet: ; |
Integer //Number of lost units |
6328 | StatUnitMultipleTypesCount Returns number of specified unit types for specified player. |
aHand: Byte; aTypes: set of Byte; //Set of unit types eg. [0, 5, 13] |
Integer //Total number of units |
13900 | StatUnitMultipleTypesCountEx Returns number of specified unit types for specified player. |
aHand: Integer; aTypes: ; //Set of unit types eg. [utSerf, utMilitia] TKMUnitTypeSet: ; |
Integer //Total number of units |
5057 | StatUnitTypeCount Returns number of specified unit type for specified player |
aHand: Byte; aUnitType: Byte; |
Integer //Number of units |
13900 | StatUnitTypeCountEx Returns number of specified unit type for specified player if passed utAny as unit type, then returns number of all units for the specified player |
aHand: Integer; aUnitType: TKMUnitType; |
Integer //Number of units |
12600 | UnitAllowAllyToSelect Return if specified unit is allowed to be selected and viewed by his allies For warriors returns if allies can select their group |
aUnitID: Integer; | Boolean |
5057 | UnitAt Returns the ID of the unit on the specified tile or -1 if no unit exists there |
aX: Integer; aY: Integer; |
Integer //Unit ID |
5057 | UnitCarrying Returns the ware a serf is carrying, or -1 if the unit is not a serf or is not carrying anything |
aUnitID: Integer; | Integer //Ware type |
13900 | UnitCarryingEx Returns the ware a serf is carrying, or wtNone if the unit is not a serf or is not carrying anything |
aUnitID: Integer; | TKMWareType //Ware type |
5057 | UnitDead Returns true if the unit is dead |
aUnitID: Integer; | Boolean //Dead |
5165 | UnitDirection Returns the direction the specified unit is facing |
aUnitID: Integer; | Integer //Direction (0..7) |
13900 | UnitDirectionEx Returns the direction the specified unit is facing |
aUnitID: Integer; | TKMDirection //Direction (dirNA, dirN, dirNE, dirE, dirSE, dirS, dirSW, dirW, dirNW) |
7000+ | UnitDismissable Returns the 'Dismissable' status of specified unit |
aUnitID: Integer; | Boolean //is unit dismissable |
5997 | UnitHome Returns the ID of the house which is the home of the specified unit (house where he works) or -1 if the unit does not have a home |
aUnitID: Integer; | Integer //House ID |
7000+ | UnitHPCurrent Returns current hitpoints for specified unit or -1 if Unit ID invalid |
aUnitID: Integer; | Integer //HitPoints |
7000+ | UnitHPInvulnerable See if unit is invulnerable |
aUnitID: Integer; | Boolean //true or false |
7000+ | UnitHPMax Returns max hitpoints for specified unit or -1 if Unit ID invalid |
aUnitID: Integer; | Integer //HitPoints |
5057 | UnitHunger Returns the hunger level of the specified unit as number of ticks until death or -1 if Unit ID invalid |
aUnitID: Integer; | Integer //Hunger level |
6523 | UnitIdle Returns true if specified unit is idle (has no orders/action) |
aUnitID: Integer; | Boolean //Idle |
12982 | UnitInHouse Returns HouseID where specified Unit is now, at this particular moment, or -1 if Unit not found or Unit is not in any house |
aUnitID: Integer; | Integer //HouseId, where unit is placed |
5057 | UnitLowHunger Gives the hunger level when a unit will try to eat in ticks until death |
Integer //Hunger in ticks | |
5057 | UnitMaxHunger Gives the maximum hunger level a unit can have in ticks until death |
Integer //Hunger in ticks | |
5057 | UnitOwner Returns the owner of the specified unit or -1 if Unit ID invalid |
aUnitID: Integer; | Integer //Player ID |
7000+ | UnitPosition Returns the TKMPoint with coordinates of the specified unit or (-1;-1) point if Unit ID invalid |
aUnitID: Integer; | TKMPoint //TKMPoint |
5057 | UnitPositionX Returns the X coordinate of the specified unit or -1 if Unit ID invalid |
aUnitID: Integer; | Integer //X coordinate |
5057 | UnitPositionY Returns the Y coordinate of the specified unit or -1 if Unit ID invalid |
aUnitID: Integer; | Integer //Y coordinate |
5057 | UnitsGroup Returns the group that the specified unit (warrior) belongs to or -1 if it does not belong to a group |
aUnitID: Integer; | Integer //Group ID |
5057 | UnitType Returns the type of the specified unit or -1 if unit id is invalid |
aUnitID: Integer; | Integer //Unit type |
13900 | UnitTypeEx Returns the type of the specified unit or utNone if unit id is invalid |
aUnitID: Integer; | TKMUnitType //Unit type |
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. |
aUnitType: Byte; | AnsiString //Unit type name |
13900 | UnitTypeNameEx 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. |
aUnitType: TKMUnitType; | AnsiString //Unit type name |
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. |
aWareType: Byte; | AnsiString //Ware type name |
13900 | WareTypeNameEx 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. |
aWareType: TKMWareType; | AnsiString //Ware type name |
7000+ | WarriorInFight Returns true if specified warrior is in fight |
aUnitID: Integer; aCountCitizens: Boolean; //CountCitizens - including fights with citizens |
Boolean //InFight |