HOMM5 Script Functions
HOMM5 Script Functions
AdvMap.................................................................................................................... 4
GetGameVar................................................................................................................................4
length ...........................................................................................................................................4
GetDifficulty................................................................................................................................5
Load .............................................................................................................................................5
mod ..............................................................................................................................................5
print..............................................................................................................................................6
Save .............................................................................................................................................6
SetGameVar ................................................................................................................................6
sleep .............................................................................................................................................7
sqrt ...............................................................................................................................................7
startThread ...................................................................................................................................8
AddHeroCreatures .......................................................................................................................8
AddObjectCreatures ....................................................................................................................9
BlockGame ..................................................................................................................................9
CalcHeroMoveCost ...................................................................................................................10
CanMoveHero ...........................................................................................................................10
ChangeHeroStat.........................................................................................................................10
CreateMonster ...........................................................................................................................11
DeployReserveHero ..................................................................................................................12
EnableAIHeroHiring .................................................................................................................13
EnableHeroAI............................................................................................................................13
IsObjectExists............................................................................................................................14
GenerateMonsters......................................................................................................................14
GetCurrentPlayer .......................................................................................................................15
GetDate......................................................................................................................................15
GetHeroCreatures ......................................................................................................................16
GetHeroLevel ............................................................................................................................16
GetHeroStat ...............................................................................................................................17
GetObjectCreatures ...................................................................................................................17
GetObjectiveProgress ................................................................................................................18
GetObjectiveState......................................................................................................................18
GetObjectOwner........................................................................................................................19
GetObjectsInRegion ..................................................................................................................19
GetObjectPosition......................................................................................................................20
GetPlayerHeroes........................................................................................................................20
GetPlayerResource ....................................................................................................................21
GetTownBuildingLevel .............................................................................................................21
GetTownBuildingLimitLevel ....................................................................................................23
GetTownBuildingMaxLevel......................................................................................................24
GetTownHero ............................................................................................................................24
GiveArtefact ..............................................................................................................................25
LevelUpHero .............................................................................................................................25
GiveHeroSkill............................................................................................................................25
GiveHeroWarMachine...............................................................................................................26
HasArtefact................................................................................................................................26
HasBorderguardKey ..................................................................................................................27
HasHeroSkill .............................................................................................................................27
HasHeroWarMachine ................................................................................................................28
IsHeroAlive ...............................................................................................................................28
IsHeroLootable ..........................................................................................................................28
IsObjectEnabled.........................................................................................................................29
IsObjectInRegion.......................................................................................................................29
IsObjectiveVisible .....................................................................................................................30
IsObjectVisible ..........................................................................................................................30
IsRegionBlocked .......................................................................................................................31
KnowHeroSpell .........................................................................................................................31
Loose .........................................................................................................................................31
MarkObjectAsVisited................................................................................................................32
MessageBox ..............................................................................................................................32
MoveCamera .............................................................................................................................33
MoveHero..................................................................................................................................33
MoveHeroRealTime ..................................................................................................................34
GetAllNames .............................................................................................................................34
OpenCircleFog ..........................................................................................................................35
OpenRegionFog.........................................................................................................................35
Play2DSound .............................................................................................................................35
Play3DSound .............................................................................................................................36
PlayObjectAnimation ................................................................................................................36
random .......................................................................................................................................37
RazeTown..................................................................................................................................37
RegionToPoint...........................................................................................................................38
RemoveArtefact.........................................................................................................................38
RemoveHeroCreatures...............................................................................................................39
RemoveHeroWarMachine .........................................................................................................39
RemoveObject ...........................................................................................................................40
RemoveObjectCreatures............................................................................................................40
ResetHeroCombatScript ............................................................................................................41
ResetObjectFlashlight................................................................................................................41
SetAIHeroAttractor ...................................................................................................................42
SetAIPlayerAttractor .................................................................................................................42
SetCombatLight.........................................................................................................................43
SetHeroCombatScript................................................................................................................43
SetHeroLootable........................................................................................................................44
SetAmbientLight .......................................................................................................................44
SetObjectEnabled ......................................................................................................................45
SetObjectiveProgress.................................................................................................................45
SetObjectiveState ......................................................................................................................46
SetObjectiveVisible ...................................................................................................................47
SetObjectFlashlight ...................................................................................................................47
SetObjectOwner ........................................................................................................................47
SetObjectPosition ......................................................................................................................48
SetPlayerResource .....................................................................................................................48
SetPlayerStartResources............................................................................................................49
SetRegionBlocked .....................................................................................................................50
SetTownBuildingLimitLevel.....................................................................................................50
SetWarfogBehaviour .................................................................................................................51
ShowFlyingSign ........................................................................................................................51
SiegeTown .................................................................................................................................51
StartCombat ...............................................................................................................................52
StartCutScene ............................................................................................................................53
StartDialogScene .......................................................................................................................54
StopPlaySound ..........................................................................................................................54
TeachHeroSpell .........................................................................................................................54
TransformTown .........................................................................................................................55
Trigger .......................................................................................................................................55
UnblockGame............................................................................................................................57
UnreserveHero...........................................................................................................................58
Win ............................................................................................................................................58
COMBAT ............................................................................................................... 58
Prepare .......................................................................................................................................59
Start............................................................................................................................................59
IsHuman ....................................................................................................................................59
IsComputer ................................................................................................................................59
SetControlMode ........................................................................................................................60
EnableAutoFinish ......................................................................................................................60
Finish .........................................................................................................................................61
GetAttackerHero........................................................................................................................61
GetAttackerCreatures ................................................................................................................61
GetAttackerWarMachines .........................................................................................................62
GetAttackerWarMachine...........................................................................................................62
GetDefenderHero.......................................................................................................................63
GetDefenderCreatures ...............................................................................................................63
GetDefenderWarMachines ........................................................................................................63
GetDefenderWarMachine..........................................................................................................63
GetDefenderBuildings ...............................................................................................................64
GetDefenderBuilding ................................................................................................................64
IsAttacker ..................................................................................................................................65
IsDefender .................................................................................................................................65
IsHero ........................................................................................................................................66
IsCreature ..................................................................................................................................66
IsWarMachine ...........................................................................................................................66
IsBuilding ..................................................................................................................................67
GetHeroName............................................................................................................................67
GetCreatureType .......................................................................................................................67
GetCreatureNumber...................................................................................................................68
GetWarMachineType ................................................................................................................68
GetBuildingType .......................................................................................................................68
GetUnitPosition .........................................................................................................................69
AddCreature ..............................................................................................................................69
EnableCinematicCamera ...........................................................................................................70
Tutorial................................................................................................................... 70
IsTutorialItemEnabled ...............................................................................................................70
IsTutorialMessageBoxOpen ......................................................................................................71
TutorialActivateHint..................................................................................................................71
TutorialMessageBox..................................................................................................................71
TutorialSetBlink ........................................................................................................................72
Town ....................................................................................................................... 72
HeroHired ..................................................................................................................................72
CreatureHired ............................................................................................................................72
ADVMAP
GetGameVar
GetGameVar – return the value of the game’s general variable
Syntax
GetGameVar(name);
Description
This function returns the value of the game’s general variable with name name if there is such, or
a null string if there isn’t.
length
length – determine the length of the array (table)
Synopsis
length(array);
Description
Let us determine the meaning of ‘array’ as a special case of a talbe, in which the keys are only
numbers, and the numeration starts from zero and goes on without missed elements. The length
function will determine the number of elements in this array.
Sytax
GetDifficulty(void);
Description
This function returns the game’s difficulty level. The following constants are set to identify the
difficulty levels: DIFFICULTY_NORMAL, DIFFICULTY_HARD, DIFFICULTY_HEROIC. The constants
are sorted by growth, which makes it possible to use constructions like GetDifficulty() >
DIFFICULTY_NORMAL, etc.
Load
Load – Load the game from the specified file
Sytax
Load(fileName);
Description
fileName is the name of the text file specified in the map’s properties (resources-
>saveFilenames) and containing the localized name of the game’s save file.
mod
mod – return the remainder from dividing one number to the other.
Sytax
mod(x, y);
Description
This function returns the remainder of the division of the first argument to the second one. Both
arguments must be numbers (not necessarily whole). The second argument must be not equal to
zero.
print
print – show the textual presentation of the arguments in the console.
Sytax
print(...);
Description
This function shows the textual textual presentation of the argument(s) in the console.
Example:
Save
Save – saves the game into the specified file
Sytax
Save(fileName);
Description
fileName is the name of the text file specified in the map’s properties
(resources->saveFilenames) and containing the localized name of the game’s
save file.
SetGameVar
SetGameVar – set the value of the game’s general variable.
Sytax
SetGameVar(name, value);
Description
This function alternates the value of the game’s general variable name to value. If there is no
such variable, it will be created.
sleep
sleep – suspend the current execution thread temporarily.
Sytax
sleep(number-of-segments);
Description
This function suspends the work of the current execution thread for the time specified. The time
is set in game segments.
The sleep command is necessary to create scripts that are supposed to perform periodical
actions within long periods of time (like scripts that realize map scenarios):
while 1 do
sleep(100)
print("another 100 game segments has passed")
end
The important effect of the sleep command is that its execution results in the control’s being
transferred from the current script thread back to the threads planner of the scripting engine,
which, thus, is enabled to let other script threads work and, finally, restore the control back to the
game.
For example, if the script cited above is run with the sleep(100)call removed from it, the game
will ‘freeze’: the thread in which the script will be executed, will never restore the control to the
scripting engine, which could restore it to the game.
sqrt
sqrt – return the number’s square root.
Sytax
sqrt(x);
Description
This function returns the square root of its only argument, which must be a non-negative number.
startThread
startThread – start a new execution thread.
Sytax
startThread(func);
Description
The func parameter must be a script function: func cannot be, for example, a number or one of
the commands described in this manual (because they are realized in C).
function eternalLoop()
while 1 do
if not exist(%immortal) then
resurrect(%immortal)
end
sleep(1)
end
end
AddHeroCreatures
AddHeroCreatures – add a stack of creatures to the hero’s army.
Sytax
Description
Adds a quantity of creatures of creatureID type to the army of the hero heroname.
heroname is the hero’s internal name, set when the map is created.
The command works regardless of where the hero is: he may be absent from the map (being in a
town or among the dead (?)).
Only creatures, and not war machines (ballistae, catapultae, etc.) can be added.
AddObjectCreatures
AddObjectCreatures – add a stack of creatures to the object’s army.
Sytax
Description
This function adds a quantity of creatures of creatureID type to the army of the object
objectName. Creatures can be added to any map object that can have an army (including
monsters and heroes). Monsters can only have creatures of the same type that the monster
already contains added.
Only creatures, and not war machines (ballistae, catapultae, etc.) can be added.
BlockGame
BlockGame – block the user interface and the AI work.
Sytax
BlockGame(void);
Description
The command blocks the user interface and the AI work as well as the camera management. This
way, the world comes to a stop, and the script remains as the only source of in-game events. The
command also stops the running heroes (while preserving their paths). To unblock the game, the
UnblockGame command is used. Game blocks are accumulated, which means that the game will
be unblocked once the number of calls for UnblockGame will be equal to that of BlockGame.
CalcHeroMoveCost
CalcHeroMoveCost – calculate the hero’s movement cost to the specified point.
Sytax
Description
This function calculates the hero’s movement cost to the specified point, using movement points
as the calculating unit. If the floor is not specified, the one in which the hero is currently located
is used. This function can only be invoked for heroes controlled by the AI players. Only static
objects are taken into account when the path is formed. If the specified point can’t be reached,
the function returns -1.
floorID – the floor number (-1 by default, which means the floor in which the hero is located)
CanMoveHero
CanMoveHero – determine if the hero can be moved to the specified point
Syntax
CanMoveHero(heroName, x, y, floorID = -1);
Description
This function returns true if the specified point can be reached by the hero. Otherwise it returns
false. If the floor is not specified, the one in which the hero is currently located is used. This
function can only be invoked for heroes controlled by the AI players.
floorID – the floor number (-1 by default, which means the floor in which the hero is located)
ChangeHeroStat
ChangeHeroStat – change the hero’s stats
Syntax
Description
The following stats can be modified: experience, attack, defense, spell power, knowledge, luck,
morale, move points, mana points.
delta can take on either positive (the stat is increased) or negative (the stat is decreased) values
for all stats except experience, since experience can only grow, and for it, delta can only be a
positive number or zero.
All the stats’ values themselves can not be negative. The top values of move points and mana
points stats are additionally limited by the move points max and mana points max values. If the
modification results in the stat’s exceeding the permissible limitations, it is truncated.
statID – the stat’s ID, which can take on the following values:
STAT_KNOWLEDGE – knowledge
STAT_LUCK – luck
STAT_MORALE – morale
CreateMonster
CreateMonster– create a monster on the map
Syntax
CreateMonster( monsterName,
creatureType,
creaturesCount,
x,
y,
floorID,
mood= MONSTER_MOOD_AGGRESSIVE,
courage= MONSTER_COURAGE_CAN_FLEE_JOIN,
rotation= 0 );
Description
Creates a monster with creaturesCount of creatures of the monsterType type in the tile ( x, y
) on the floor floorID, setting the name monsterName for it. If the specified tile is occupied
(there is another object on it, or an object for which it is interactive), the monster is put onto one
of the nearby free tiles. The latter two parameters affect the monster’s behavior when it
encounters a hero (according to the standard logics of this interaction).
monsterName – name of the monster, which can then be used in other script commands.
floorID – the number of the floor onto which the monster is to be placed.
mood, courage – these parameters affect the monster’s choice of behavior when it encounters a
hero, and can take on the following values:
MONSTER_MOOD_FRIENDLY,
MONSTER_MOOD_AGGRESSIVE,
MONSTER_MOOD_HOSTILE,
MONSTER_MOOD_WILD and
MONSTER_COURAGE_ALWAYS_JOIN,
MONSTER_COURAGE_ALWAYS_FIGHT,
MONSTER_COURAGE_CAN_FLEE_JOIN accordingly.
DeployReserveHero
DeployReserveHero – puts the hero who has been in the player’s reserve onto the map.
Syntax
DeployReserveHero(heroName, x, y, floor);
Description
When a map is created, some heroes can be reserved after this or that player. Such heroes will
not appear in taverns and can’t be hired by usual means. To put the hero reserved after a player
onto the map, use the DeployReserveHero command, setting the hero’s name and desired
position on the map as its parameters. If the specified tile is inaccessible due to some reason, the
hero will be put onto one of the nearby tiles. Reserved heroes who are killed, flee, or disappear
from the list of heroes owned by the player for any other reason are put back into the reserve and
can be restored to the map by the same command. Their armies are restored to those specified in
the editor. To remove a hero from the player’s reserve and make him available in other players’
taverns use the UnreserveHero function.
floorID – the number of the floor onto which the hero is to be put.
EnableAIHeroHiring
EnableAIHeroHiring – turn the AI’s hiring heroes in the town’s tavern on/off
Syntax
Description
This function lets you allow/prohibit the AI to hire heroes in the tavern of the specified town (by
default, this is allowed).
playerID – player’s ID
EnableHeroAI
EnableHeroAI – turn the AI control over the specified hero on/off
Syntax
EnableHeroAI(heroName, enable);
Description
This function allows turning on/off the AI control over the specified hero. It can only be used in
singleplayer mode. When this function is invoked for a human-controlled hero, an error message
is generated. If the hero’s control status is the same as the function is trying to set it, no action
takes place.
IsObjectExists
IsObjectExists – determine whether the specified object is existent on the map
Syntax
IsObjectExists(objectName);
Description
This function returns true if the object with the specified name is present on the map, and false
if it isn’t. This function can be used for …, giving OBJECT_GRAIL as the object’s name.
GenerateMonsters
GenerateMonsters – generate monsters on the map
Syntax
GenerateMonsters( monsterTypeID ,
countGroupsMin ,
countGroupsMax ,
countInGroupMin,
countInGroupMax);
Description
This function generates monsters at random locations of the adventure map. There are
countGroupsMin to countGroupsMax groups of creatures generated, numbering
countInGroupMin to countInGroupMax each.
GetCurrentPlayer
GetCurrentPlayer – determine the current player
Syntax
GetCurrentPlayer(void);
Description
GetDate
GetDate – return the current in-game time (day, week, month or day of the week)
Syntax
GetDate(dateTypeID);
Description
This function returns the current in-game time. The parameter defines what is to be determined:
the current day, week, month, or day of the week. By default (when invoked without any
parameters), it returns the current day.
Possible values:
DAY – day
WEEK – week
MONTH – month
GetHeroCreatures
GetHeroCreatures – determine the number of creatures of the specified type under the hero’s
command
Syntax
GetHeroCreatures(heroName, creatureID);
Description
This function returns the number of creatures of the specified type under the specified hero’s
command.
GetHeroLevel
GetHeroLevel – determine the hero’s level
Syntax
GetHeroLevel(heroname);
Description
Error
Syntax
GetHeroStat(heroName, statID);
Description
This function returns the value of the specified stat of the hero. The following stats can be
determined: experience, attack, defense, spell power, knowledge, luck, morale, move points,
mana points. The stats’ values are determined, taking into account all the effects (artifacts, etc.)
statID – the stat’s ID, which can assume the following values:
STAT_KNOWLEDGE – knowledge
STAT_LUCK – luck
STAT_MORALE – morale
GetObjectCreatures
GetObjectCreatures – determine the number of creatures of the specified type in the object’s
army
Syntax
GetObjectCreature(objectName, creatureID);
Description
This function returns the number of creatures of the specified type in the specified object’s army.
This can be applied to any on-map objects (including monsters and heroes).
GetObjectiveProgress
GetObjectiveProgress – determine the progress towards the objective
Syntax
Description
This function returns the progress towards the objectiveName objective. For objectives that are
common for all players, the playerID parameter specifies the player for whom the progress is to
be determined (if the parameter isn’t set, the 1st player’s progress is determined). For player-
specific objectives, the playerID parameter is ignored.
The number of steps towards the manually controlled objectives is determined by the number of
progress comments as set in the editor. The objectives ‘seize the specified on-map objects’ and
‘destroy the specified neutral armies’ have a number of progress steps equal to the number of on-
map objects to be seized or the number of armies to be eliminated, accordingly. The other types
of objectives have no progress steps and can either be completed or not.
playerID – the ID of the player for whom the progress towards objective is to be determined
(igroned for objectives that pertain only to this or that player, and equal to PLAYER_1 by default)
GetObjectiveState
GetObjectiveState – determine the status of the objective
Syntax
Description
This function returns the status of the objective objectiveName for the specified player. For
player-specific objectives, the playerID parameter is ignored. For common objectives, if the
playerID parameter is specified, it indicates the player for whom the objective’s status is to be
determined; otherwise the status for the 1st player is returned.
playerID – the ID of the player for whom the status of the objective is to be determined
(igroned for objectives that pertain only to this or that player, and equal to PLAYER_1 by default)
OBJECTIVE_SCENARIO_INFO – a special status which means that this objective is in fact the
current map’s scenario description.
OBJECTIVE_UNKNOWN – the objective is unknown to the player. If the visibility flag is specified
for the objective (see the functions GetObjectiveState / SetObjectiveState), the objectives
interface only contains a vague description of the task.
GetObjectOwner
GetObjectOwner – determine the belonging of the specified on-map objects
Syntax
GetObjectOwner(objectName);
Description
This function returns the ID of the player who owns the specified object. If the object belongs to
no one, it returns PLAYER_NONE.
GetObjectsInRegion
GetObjectsInRegion – determine what objects are present in the specified region
Syntax
GetObjectsInRegion(regionName, objectType);
Description
This function returns the names of the on-map objects of the specified type that are within the
region. Objects with no names are ignored.
OBJECT_HERO – heroes
GetObjectPosition
GetObjectPosition – determine the object’s position on the map
Syntax
GetObjectPosition(objectName);
Description
This function returns three values: the x and y coordinates of the tile in which the object is
positioned (or, if it occupies more than one tile, the function retuns the position of its center) and
the number of the floor in which it stands. This function can be used for …, giving
OBJECT_GRAIL as the object’s name.
GetPlayerHeroes
GetPlayerHeroes – return the names of the heroes belonging to the player
Syntax
GetPlayerHeroes(playerID);
Description
This function returns an array that contains the names of the heroes belonging to the specified
player.
GetPlayerResource
GetPlayerResource – get the amount of the specified player’s resources.
Syntax
GetPlayerResource(player, resourceKind);
Description
This function returns the amount of resources of the type resourceKind possessed by the player
player.
player — the player’s number from 1 to 8. Global constants PLAYER_1 to PLAYER_8 can be
used instead of the numbers.
resourceKind – a number from 0 to 6, or one of the constants: WOOD, ORE, MERCURY, CRYSTAL,
SULFUR, GEM, or GOLD.
The command works for both active and failed players. Requesting the amount of resources
owned by a player who did not take part in the current game is an error.
Error
GetTownBuildingLevel
GetTownBuildingLevel – determine the level of the building in the town
Syntax
GetTownBuildingLevel(townName, buildingID);
Description
This function returns the level of the specified building in the town. Level 0 means that the
building has not been erected.
townName – town name
buildingID – the ID of the building type, which can take on the following values:
TOWN_BUILDING_TOWN_HALL,
TOWN_BUILDING_FORT,
TOWN_BUILDING_MARKETPLACE,
TOWN_BUILDING_SHIPYARD,
TOWN_BUILDING_TAVERN,
TOWN_BUILDING_BLACKSMITH,
TOWN_BUILDING_MAGIC_GUILD,
TOWN_BUILDING_DWELLING_1,
TOWN_BUILDING_DWELLING_2,
TOWN_BUILDING_DWELLING_3,
TOWN_BUILDING_DWELLING_4,
TOWN_BUILDING_DWELLING_5,
TOWN_BUILDING_DWELLING_6,
TOWN_BUILDING_DWELLING_7,
TOWN_BUILDING_GRAIL,
TOWN_BUILDING_WONDER,
TOWN_BUILDING_HAVEN_TRAINING_GROUNDS,
TOWN_BUILDING_HAVEN_MONUMENT_TO_FALLEN_HEROES,
TOWN_BUILDING_HAVEN_HOSPITAL,
TOWN_BUILDING_HAVEN_STABLE,
TOWN_BUILDING_HAVEN_FARMS,
TOWN_BUILDING_INFERNO_INFERNAL_LOOM,
TOWN_BUILDING_INFERNO_ORDER_OF_FIRE,
TOWN_BUILDING_INFERNO_HALLS_OF_HORROR,
TOWN_BUILDING_INFERNO_SACRIFICIAL_PIT,
TOWN_BUILDING_DUNGEON_ALTAR_OF_ELEMENTS,
TOWN_BUILDING_DUNGEON_RITUAL_PIT,
TOWN_BUILDING_DUNGEON_TRADE_GUILD,
TOWN_BUILDING_DUNGEON_TREASURE_DIG_SITE,
TOWN_BUILDING_DUNGEON_HALL_OF_INTRIGUE,
TOWN_BUILDING_ACADEMY_LIBRARY,
TOWN_BUILDING_ACADEMY_ARCANE_FORGE,
TOWN_BUILDING_ACADEMY_ARTIFACT_MERCHANT,
TOWN_BUILDING_ACADEMY_TREASURE_CAVE,
TOWN_BUILDING_ACADEMY_ELEMENTAL_ENCLAVE,
TOWN_BUILDING_PRESERVE_AVENGERS_BROTHERHOOD,
TOWN_BUILDING_PRESERVE_MYSTIC_POND,
TOWN_BUILDING_PRESERVE_SPARKLING_FONTAINS,
TOWN_BUILDING_PRESERVE_BLOOMING_GROVE,
TOWN_BUILDING_PRESERVE_TREANT_SAMPLING,
TOWN_BUILDING_NECROMANCY_AMPLIFIER,
TOWN_BUILDING_NECROMANCY_UNHOLY_TEMPLE,
TOWN_BUILDING_NECROMANCY_UNEARHED_GRAVES,
TOWN_BUILDING_NECROMANCY_DRAGON_TOMBSTONE,
TOWN_BUILDING_NECROMANCY_SHROUD_OF_DARKNESS.
NB: Giving a building that is specific for another race’s towns can cause erroneous results.
GetTownBuildingLimitLevel
GetTownBuildingLimitLevel – determine the level limitations for a building in the town.
Syntax
GetTownBuildingLimitLevel(townName, buildingID);
Description
This function returns the possible level limitation of the specified building in the town. Level 0
means that the building can not been erected.
buildingID – the building type ID (see the description of GetTownBuildingLevel for the list of
the possible values).
GetTownBuildingMaxLevel
GetTownBuildingMaxLevel – determine the maximal level of the building in the town
Syntax
GetTownBuildingMaxLevel(townName, buildingID);
Description
This function returns the maximal possible level of the specified building in the town. Level 0
means that the building can not been erected.
buildingID – the building type ID (see the description of GetTownBuildingLevel for the list of
the possible values).
GetTownHero
GetTownHero – return the hero garrisoned in the town
Syntax
GetTownHero(townName);
Description
This function retuns the name of the hero garrisoned in the specified town, or nil if there is no
hero in the garrison.
townName – town name
GiveArtefact
GiveArtefact – give an artifact to the hero
Syntax
Description
artefactID – the number of the artifact from 0 to 55, or a character constant from the list
bindToHero – bind the artifact to the hero (making it impossible to hand over the artifact to
another hero)
Error
LevelUpHero
LevelUpHero – gives the hero as many experience points as needed to gain the next level
Syntax
LevelUpHero(heroName);
Description
This function gives the hero heroName as namy experience points as he or she needs to gain the
next level. This function returns true if it has been possible to grant a level to the hero, and nil
if it’s impossible (the hero having the maximal possible level already).
GiveHeroSkill
GiveHeroSkill – give the specified basic skill to the hero
Syntax
GiveHeroSkill(heroName, skillID);
Description
This function tries to give a specified basic skill to the hero. It returns false if this is impossible
(for ex., the hero already has ‘EXPERT’ mastery of this skill, or there is no space on the bar for it),
and otherwise it returns true.
GiveHeroWarMachine
GiveHeroWarMachine – give the hero a war machine of the specified type
Syntax
GiveHeroWarMachine(heroName, warMachineType);
Description
This function tries to give the specified war machine to the hero. It returns nil if the hero
already has such a war machine, and otherwise it returns non nil.
HasArtefact
HasArtefact – determine whether the hero has the artifact
Syntax
HasArtefact(heroname, artefactID);
Description
This function returns whether the hero heroname has the artifact artefactID.
artefactID – the number of the artifact from 0 to 54 (the artifacts description at the H5 web
site says, ‘there are 54 artifacts, and one of them can become double, so there will be 55’, but in
fact there are only 53 of them in the game).
We should also (maybe) fix character constants for the artifacts, to use
HasArtefact("Agrael", SWORD_OF_RUINS) instead of HasArtefact("Agrael", 0).
Error
HasBorderguardKey
HasBorderguardKey – determine whether the player has the key of the specified color
Syntax
HasBorderguardKey(player, color);
Description
This function returns not nil if the player has the key of the specified color, and nil if not.
color – the color of the key; can take on the following values:
HasHeroSkill
HasHeroSkill – checks if the hero has the specified skill
Syntax
HasHeroSkill(heroName, skillID);
Description
This function returns true if the hero has the specified skill (by his or her own, or granted by an
artifact), and otherwise it returns false.
HasHeroWarMachine
HasHeroWarMachine - determines whether the hero has a war machine of the specified type
Syntax
HasHeroWarMachine(heroName, warMachineType);
Description
It returns not nil if the hero has a war machine of the specified type, and nil otherwise.
IsHeroAlive
IsHeroAlive – is the hero alive?
Syntax
IsHeroAlive(heroname);
Description
This function returns if there is a hero heroname, and if yes, if this hero is alive.
A hero is considered as alive if belongs to any of the active players (for whom GetPlayerState()
returns true). It does not matter where the hero is during the enquiry: in the surface, in the
Underworld, in the town, or in a boat.
heroname is an internal scripting name of the hero (not only the name that is specified when the
map is created).
IsHeroLootable
IsHeroLootable – determine whether it is possible to loot artifacts from the hero by defeating
him or her.
Syntax
IsHeroLootable(heroName);
Description
It returns not nil if the hero’s artifacts are delivered to the winner after the hero is defeated, or
nil of they remain with the defeated hero.
IsObjectEnabled
IsObjectEnabled – determine whether the interactive object interacts with the hero standardly
Syntax
IsObjectEnabled(objectName);
Description
If the function returns true, the interactive object behaves standardly when a hero comes to it. If
the function returns false, when the hero comes to this object, nothing happens but the
invocation of the trigger handler function, if such function has been set. By default, an
interactive object behaves standardly.
IsObjectInRegion
IsObjectInRegion – determine whether the object is within the specified region
Syntax
IsObjectInRegion(objectName, regionName);
Description
This function returns true, if the object is within the specified region, and false if not.
IsObjectiveVisible
IsObjectiveVisible – determine whether the objective is shown in the specified player’s interface
Syntax
Description
This function returns true, if the objective is shown in the specified player’s interface, and
false if not. For player-specific objectives, the playerID parameter is ignored. For common
objectives, if the playerID parameter is given, it sets the player for whom the objective’s
visibility is to be determined; if not, the function determines whether the 1st player sees the
objective.
playerID – the player’s ID (for player-specific objectives, the parameter is ignored, and it is
equal to PLAYER_1 by default).
IsObjectVisible
IsObjectVisible – determine whether the object is visible to the player
Syntax
IsObjectVisible(playerID, objectName);
Description
This function returns true, if the object is visible to the player, and false if not.
Syntax
IsRegionBlocked(regionName, playerID);
Description
This function returns not nil if the region is blocked for the maneuvers of the specified player’s
heroes, and nil if not.
KnowHeroSpell
KnowHeroSpell – checks whether the hero knows the spell
Syntax
KnowHeroSpell(heroName, spell);
Description
This function returns true, if the hero knows the specified spell (regardless of whether this
knowledge was learned or granted by an artifact), otherwise it returns false.
Loose
Loose – the human player loses the game when the function is invoked.
Syntax
Loose(void);
Description
This the function should only be used in the single-player mode. It generates an error if invoked
in the multiplayer mode. When the function is invoked, the human player loses immediately.
MarkObjectAsVisited
MarkObjectAsVisited – mark the inoperative interactive object as ‘visited’ by the specified hero
Syntax
MarkObjectAsVisited(objectName, heroName);
Description
The command should be invoked when the hero interacts with an interactive object that has been
made inoperative by the SetObjectEnabled command.
heroName – the name of the hero who interacts with the object
MessageBox
MessageBox – send a message to the screen
Syntax
Description
This function sends a message to the screen, which is a dialogue box with the only button ‘OK’.
The callback parameter (if it is given) sets the name of the function to be invoked when the
user clicks on the ‘OK’ button.
callback – name of the function to be invoked when the user clicks on the ‘OK’ button
MoveCamera
MoveCamera – move the camera to the specified point of the map
Syntax
MoveCamera(x, y, floorID, zoom = 50, pitch = pi/2, yaw = 0, noZoom = 0, noRotate = 0);
Description
This function moves the camera to the specified position and sets the specified values of zoom
and angle.
x, y, floorID – these parameters specify the tile of the map on which the camera is to be
focused
zoom – this parameter determines how far will the camera be set from the specified tile
pitch – the camera’s angle ( 0 – the camera watches horizontally, pi/2 – the camera watches
vertically down)
noZoom – set to 1 for the camera not to change its zoom when it moves
MoveHero
MoveHero – orders the hero to move to a specified point
Syntax
Description
This function orders the hero to move to the specified location. If the floor number is not
specified, the hero is supposed to go to the point with the specified coordinates on the floor he or
she already stands on. This function can only be invoked for heroes controlled by the AI players,
with their AI turned off. If the specified location is inaccessible, the function generates an error.
If the hero’s movement points are depleted en route, the movement will be continued in the next
turn.
MoveHeroRealTime
MoveHeroRealTime – make the hero move the the specified point
Syntax
Description
This function orders the hero to move to the specified location. If the floor number is not
specified, the hero is supposed to go to the point with the specified coordinates on the floor he or
she already stands on. If the specified location is inaccessible, the function generates an error.
The movement begins immediately after the command has been invoked, regardless of whose
turn it is now. He script continues its work immediately after the command is executed, without
waiting for the hero to reach the destination. The user interface and the AI’s actions are blocked
while the hero moves. If the hero’s movement points are depleted en route, or the hero
encounters an obstacle, he or she stops without interacting with the object (which, in particular,
means that the hero is unable to use teleports, boats, etc.).
floorID – the floor number (-1 by default, which means the floor in which the hero is located)
GetAllNames
GetAllNames – give the list of on-map objects’ names
Syntax
GetAllNames(filter = 0);
Description
This function returns a string with the list of on-map objects. The unit names are separated by the
space.
The filter parameter sets the type of objects which names are to be included in the result. The
possible values of filter:
• 0 – names of the active players’ heroes
OpenCircleFog
OpenCircleFog – remove the warfog within the specified cricle
Syntax
Description
This function opens the player’s fog of war at the floor floorID, within a circle that has its
center at(x, y) and radius range.
OpenRegionFog
OpenRegionFog – remove the warfog within the specified region
Syntax
OpenRegionFog(player, regionName);
Description
This function opens the player’s fog of war within the specified region.
Play2DSound
Play2DSound – play 2D sound
Syntax
Play2DSound(soundName);
Description
If the base determines the sound as being cyclic, the function returns the number which is an ID
of the sound that can then be sent to the function StopPlaySound to stop the sound.
Play3DSound
Play3DSound – play 3D sound
Syntax
Play3DSound(soundName, x, y, floor);
Description
Play the 3D sound with the specified name. The sound’s source is in the tile with coordinates x и
y, at the floor.
If the base determines the sound as being cyclic, the function returns the number which is an ID
of the sound that can then be sent to the function StopPlaySound to stop the sound.
PlayObjectAnimation
PlayObjectAnimation – play an animation at the on-map object
Syntax
The action determines how the animation is played. There are the following action types in the
game:
random
random – return a random number
Syntax
random(top);
Description
This function returns a random whole number from within the range from zero to до top – 1.
The function’s argument must be a positive integer.
RazeTown
RazeTown – raze a town on the map
Syntax
RazeTown(townName);
Description
Removes the specified town from the map and replaces it with a static object – razed town. The
‘razed town’ object is determined by the razed field in AdvMapTownShared. If this field is
empty, the town can’t be razed. The set of blocking tiles of the razed town must be the same as
those of the original one’s. The razed town, as any other static object, must have no interactive
tiles.
Warning!
The modifications made in the "Shared" properties of an object will affect all the objects of that
kind in the game. If you want your modification to affect to be effective only on a specific map
follow these steps:
3) In the Objects list create a new folder (Right click-New Folder) with the name of your map.
For the modifications to be in effect make sure that the that path of the shared property leads to
the copy.
RegionToPoint
RegionToPoint – determine the coordinates and number of floor of the punctual region
Syntax
RegionToPoint(regionName);
Description
This function returns the X and Y coordinates, and the floor number, in which the singular, one-
tile region is located. If a non-singular region is passed to the function, an error is generated.
RemoveArtefact
RemoveArtefact – remove the artifact from the hero
Syntax
RemoveArtefact(heroname, artefactID);
Description
artefactID – the number of the artifact from 0 to 55, or a character constant from the list
Error
RemoveHeroCreatures
RemoveHeroCreatures – remove creatures from the hero’s army
Syntax
Description
Remove a quantity of creatures of the creatureID type from the army of the hero heroname.
If the number of creatures of the specified type in the hero’s army is lower than that set in the
quantity parameter, all such creatures are removed from his or her army. If there are no other
creatures except those to be removed in the hero’s army, the command removes them all except
one.
The command also works for inactive heroes (who are in the taverns, prisons, etc.)
Only creatures, and not war machines (ballistae, catapultae, etc.) can be removed.
RemoveHeroWarMachine
RemoveHeroWarMachine – remove the war machine of the specified type from the hero
Syntax
RemoveHeroWarMachine(heroName, warMachineType);
Description
This function tries to take the specified war machine from the hero. If the hero does not have it,
or it’s impossible to remove it, the function returns nil, otherwise it returns not nil.
RemoveObject
RemoveObject – remove an object from the adventure map.
Syntax
RemoveObject(objectName);
Description
This function removes the object with the specified name from the adventure map.
RemoveObjectCreatures
RemoveObjectCreatures – remove creatures from the object’s army
Syntax
Description
Remove a quantity of creatures of the creatureID type from the army of the object
objectName. If the number of creatures of the specified type in the object’s army is lower than
that set in the quantity parameter, all such creatures are removed from its army. The command
can be applied to all on-map objects that have armies (including monsters and heroes). If the
object is a hero and there are no other creatures except those to be removed in the hero’s army,
the command removes them all except one. If the object is a monster and all creatures that form
it are removed, the monster is removed from the map.
Only creatures, and not war machines (ballistae, catapultae, etc.) can be removed.
ResetHeroCombatScript
ResetHeroCombatScript – resets the script that would have been started when combating this
hero
Syntax
ResetHeroCombatScript(heroName);
Description
This function tells that no script is to be run when combating this hero. If the combat takes place
in a location for which another combat script is specified (town, garrison, etc.), that script will be
run.
ResetObjectFlashlight
ResetObjectFlashlight – remove the point-light source from the on-map object
Syntax
ResetObjectFlashlight(objectName);
Description
The command removes the additional light source, added by the SetObjectFlashlight
command, from the selected object.
Syntax
Description
This function modifies the house evaluation for the specified AI hero.
1 – house evaluation increases greatly. But the AI will not risk its heroes for claiming this house.
2 – house is evaluated equally to winning the game. The AI will ignore all dangers for seizing
this house.
SetAIPlayerAttractor
SetAIPlayerAttractor – set the goal for all the AI player’s heroes
Syntax
Description
This function modifies the house rating for the all the heroes of the specified AI player.
1 – house evaluation increases greatly. But the AI will not risk its heroes for claiming this house.
2 – house is evaluated equally to winning the game. The AI will ignore all dangers for seizing
this house.
SetCombatLight
SetCombatLight – modify the illumination in all the map’s combat arenas
Syntax
SetCombatLight(lightName);
Description
This function changes the ambient light source for all the combat arenas of the map for that
specified in the command’s parameters.
lightName – reference to resource of the the ambient light source from the resources base
SetHeroCombatScript
SetHeroCombatScript – tell which script is to be run when combating this hero
Syntax
SetHeroCombatScript(heroName, scriptName);
Description
This function lets you tell which script is to be run when combating this hero The script is only
run if the hero is under the AI player’s control, and no other script is set for the location where
the combat is taking place (town, garrison, etc.). The script is reset automatically when the player
somehow loses this hero.
SetHeroLootable
SetHeroLootable – set whether it is possible to take the hero’s artifacts by defeating him or her
Syntax
SetHeroLootable(heroName, enable);
Description
The enable parameter determines whether the heroes’ artifacts will be given to his or her winner
(not nil) or remain with the defeated hero (nil).
enable – the parameter determines whether the heroes’ artifacts are taken from him or her after
defeat
SetAmbientLight
SetAmbientLight – change the ambient light at the specified floor of the map
Syntax
Description
This function sets a new source of ambient light at the specified floor of the map. The list of
available light sources is specified in the map description.
SetObjectEnabled
SetObjectEnabled – turn on/off the interactive object’s standard interaction with heroes
Syntax
SetObjectEnabled(objectName, enable);
Description
The command allows turning on/off the interactive object’s standard behavior when a hero
comes to it. By default, an interactive object behaves standardly. If the function is invoked with
enable parameter equal to false, when the hero comes to this object, nothing happens but the
invocation of the trigger handler function, if such function has been set.
enable – the flag that sets whether the object will behave standadly when a hero comes to it
SetObjectiveProgress
SetObjectiveProgress – set the progress towards objective
Syntax
Description
This function sets the progress towards the objectiveName objective. For objectives that are
common for all players, the playerID parameter specifies the player for whom the progress is to
be set (if the parameter isn’t set, the 1st player’s progress is set). For player-specific objectives,
the playerID parameter is ignored.
The progress can only be managed for the manually controlled objectives. The number of steps
towards the manually controlled objectives is determined by the number of progress comments
as set in the editor.
objectiveName – objective name
playerID – the ID of the player for whom the progress is to be set (for player-specific
objectives, the parameter is ignored, and it is equal to PLAYER_1 by default).
SetObjectiveState
SetObjectiveState – change the objective’s status
Syntax
Description
This function changes the status of the objective objectiveName for the specified player. For
player-specific objectives, the playerID parameter is ignored. For common objectives, if the
playerID parameter is specified, it indicates the player for whom the objective’s status is to be
changed; otherwise the status for the 1st player is changed.
playerID – the ID of the player for whom the objective’s status is to be set (for player-specific
objectives, the parameter is ignored, and it is equal to PLAYER_1 by default).
NB: When an objective is set to OBJECTIVE_ACTIVE status, it becomes visible to the player
automatically (see the IsObjectiveVisible / SetObjectiveVisible functions).
SetObjectiveVisible
SetObjectiveVisible – show/hide the objective in the specified player’s interface
Syntax
Description
The objective objectiveName will be show in the player’s interface if the enable parameter is
equal to true, or it will be hidden if the parameter is equal to false. For player-specific
objectives, the playerID parameter is ignored. For common objectives, if the playerID
parameter is given, it sets the player for whom the objective’s visibility is to be determined; if
not, the function determines whether the 1st player sees the objective.
SetObjectFlashlight
SetObjectFlashlight – attach a point-light source to the on-map object
Syntax
SetObjectFlashlight(objectName, lightName);
Description
The command attaches an additional point-light source to the selected on-map object. The list of
light sources that can be used is specified in the map description (the resources->pointLights
field). Their names are specified there as well.
SetObjectOwner
SetObjectOwner – change the belonging of the specified on-map objects
Syntax
SetObjectOwner(objectName, playerID);
Description
This command changes the belonging of an on-map object. It can only be used for static objects
that can have owners, and heroes. If the hero was in the reserve, he or she will be removed from
it. Heroes can not become neutral.
SetObjectPosition
SetObjectPosition – move the object
Syntax
Description
This function instantly moves the object into the position specified by the tile coordinates and
floor number. If the floor parameter is not specified in the invocation of the function, the
object’s current floor will be used by default. Only mobile objects can be moved. If the target
position is inaccessible, occupied with another object, or is an interactive tile of another object,
the function generates an error.
SetPlayerResource
GetPlayerResource – set the amount of the specified player’s resources.
Syntax
SetPlayerResource(player, resourceKind, quantity);
Description
Sets the new amount of resource type resourceKind for the player.
player – is the player’s number from 1 to 8. Global constants PLAYER_1 to PLAYER_8 can be
used instead of the numbers.
The command works for both active and failed players. Changing the amount of resources
owned by a player who did not take part in the current game is an error.
Error
SetPlayerStartResources
GetPlayerResource – set the initial amount of the specified player’s resources
Syntax
Description
Sets the new initial amount of resource type resourceKind for the player.
player is the player’s number from 1 to 8. Global constants PLAYER_1 to PLAYER_8 can be
used instead of the numbers.
wood, ore, mercury, crystal, sulfur, gem, gold – initial resource values, which can’t be below
zero.
The command is equivalent to invoking SetPlayerResource for each type of resources, except for
its effect on the mission results interface.
The command works for both active and failed players. Changing the amount of resources
owned by a player who did not take part in the current game is an error.
Error
• If the arguments don’t meet the values permissibility criteria;
• if the specified player does not take part in the current game
SetRegionBlocked
SetRegionBlocked – set on/off the blocking of the region for the maneuvers of the players’
heroes
Syntax
Description
This function blocks or unblocks the region for the specified players’ maneuvers, depending on
the status parameter. If the playerID parameter is set, the region is only blocked for this
player’s heroes; if not, it will be blocked for all heroes.
playerID – the player’s ID (equal to -1, which means all players, by default)
SetTownBuildingLimitLevel
SetTownBuildingLimitLevel – set the level limitations for a building in the town
Syntax
Description
This function sets the possible level limitation of the specified building in the town. Level 0
means that the building can not been erected. The set limitation must not be lower than the
specified building’s current level.
buildingID – the building type ID (see the description of GetTownBuildingLevel for the list
of the possible values)
Syntax
SetWarfogBehaviour(onLand, onSea);
Description
onLand(1/0) – whether the player’s hero will remove the fog of war when moving on land.
onSea(1/0) – whether the player’s hero will remove the fog of war when moving on sea.
ShowFlyingSign
ShowFlyingSign – show a message flying off the object
Syntax
Description
This function shows a message that flies off the object with name objectName. The message is
specified according to the resource name in the base (messageName). Messages can be shown for
one player only, or for all of them. To show a message to one player only, the targetPlayerID
parameter must contain this player’s ID, and to show it to all players it must be -1. The
message’s flying time is time (one second by default).
objectName – the name of the object over which the message will appear
targetPlayerID – the ID of the player who will see the message (-1 for all players)
SiegeTown
SiegeTown – initiate the siege of the town
Syntax
Description
This function initiates the siege of town townName by the hero heroName; either the town’s on-
map name or the reference to this town’s description in the resources base can be specified as the
town’s name. In both cases, the combat will be run just as a usual on-map town siege, that is –
with the use of information like the town's garrison, the hero positioned in it, the town's combat
script, etc. The arenaName parameter allows to replace the standard combat arena with any other.
heroName – the name of the hero for whom the combat is to be started
townName – the name of the town, which can be either the town’s on-map name or the reference
to this town’s description in the resources base.
arenaName – a reference to the resource of the arena on which the combat is to take place ("" by
default, which means fighting at the town’s standard arena)
StartCombat
StartCombat – start a combat with the specified parameters
Syntax
StartCombat(heroName ,
enemyHeroName ,
enemyHeroName ,
creaturesCount ,
creatureType[1] ,
creatureAmount[1] ,
… ,
creatureType[Count] ,
creatureAmount[Count] ,
combatScriptName ,
combatFinishTrigger ,
arenaName ,
allowQuickCombat );
Description
Starts combat for the hero heroName, against the specified set of creatures and hero (if such a
hero is given). The enemy hero’s existing army is ignored. It is possible to specify a script that
will be run in the beginning of the combat. Also, it is possible to specify a function that will be
invoked in the end of the combat and get name of the hero for whom the combat has been started
and the combat’s results as its arguments.
heroName – the name of the hero for whom the combat is to be started
enemyHeroName – the name of the enemy hero (nil – for none, fighting against creatures only)
combatScriptName – name of the script to be run in the beginning of the combat (nil by
default, which means running no scripts)
combatFinishTrigger – name of the function (map script) that will be run in the end of the
combat. This function must receive two parameters: the name of the fighting hero and the result
of the combat (nil – if the hero has lost and not nil – if the hero has won).
arenaName – a reference to the resource of the arena on which the combat is to take place (nil
by default, which means that the arena will be determined according to the terrain type on which
the hero is standing)
allowQuickCombat – if not nil, the combat will be run in the Quick Combat mode in case if
that mode is on in the game's options and the hero heroName does not have Quick Combat option
turned off (nil by default, which means running a usual combat)
StartCutScene
StartCutScene – run a cutscene
Syntax
Description
saveName – name of the save file (see the Save function) to be created before the cutscene
StartDialogScene
StartDialogScene – run a dialogue scene
Syntax
Description
callback – name of the function to be invoked after the dialogue scene is played
saveName – name of the save file (see the Save function) to be created before the dialogue scene
Example 1. Example:
StartDialogScene("/DialogScenes/C6/M4/C1/DialogScene.xdb#xpointer(/DialogScene)")
StopPlaySound
StopPlaySound – stop playing the cycled sound
Syntax
StopPlaySound(loopingSoundID);
Description
loopingSoundID – the sound ID, as returned by the functions Play2DSound / Play3DSound for
cycled sounds
TeachHeroSpell
TeachHeroSpell – gives the specified spell to the hero
Syntax
TeachHeroSpell(heroName, spell);
Description
This function tries to give the spell to the hero. If the hero already knows that spell, the function
returns nil, otherwise it returns not nil.
TransformTown
TransformTown – change the type of the on-map town
Syntax
TransformTown(townName, type);
Description
This function changes the type of the on-map town to the what is specified. (In the current
realization, all information regarding the town, except its name and number of the player who
owns it, is lost).
type – new type of the town; can take on one of the following values:
TOWN_HEAVEN,
TOWN_PRESERVE,
TOWN_ACEDEMY,
TOWN_DUNGEON,
TOWN_NECROMANCY,
TOWN_INFERNO.
Trigger
Trigger – set on/off the handler functions that work with events in the world
Syntax
Description
If the functionName parameter is not equal to nil, the function sets the handler function with
that name for the specified in-game event. Otherwise the function removes the handler from this
event. For each event, there can be only one handler function set. Setting another function onto
the event which is already handled will remove the first handler.
triggerType – in-game event type; can take on one of the following values:
WAR_FOG_ENTER_TRIGGER – the hero enters the fog of war (the behavior of the fog of war is
controlled by the SetWarfogBehaviour function)
REGION_ENTER_AND_STOP_TRIGGER – the hero enters the region (and must stay within it)
REGION_ENTER_WITHOUT_STOP_TRIGGER – the hero enters the region (and does not have to stay
within it)
One or more parameters can follow the even type, determining, the events of which of the in-
game objects have to be handled. The number and meaning of these parameters depend on the
even type:
When the trigger works, the following parameters are sent to the handler function:
NEW_DAY_TRIGGER – none
PLAYER_REMOVE_HERO_TRIGGER – the hero’s name and the name of the hero who defeated him
or her (nil – if the hero has been fired)
OBJECT_CAPTURE_TRIGGER – the old owner of the object, the new owner of the object, the name
of the hero who captured it (if any), and the name of the object itself
HERO_LEVELUP_TRIGGER – none
UnblockGame
UnblockGame – unblock the user interface and the AI work
Syntax
UnblockGame(void);
Description
The command unblocks the user interface, the AI work, and as the camera management that have
been blocked by the BlockGame command.
UnreserveHero
UnreserveHero – make the hero who has been reserved after a certain player available for all
other players again
Syntax
UnreserveHero(heroName);
Description
The hero stops being reserved after a certain player and takes part in the heroes’ assignment in
the players’ taverns in the beginning of every new week.
NB: If the is alive when the function is invoked, he or she stops being reserved but is not
removed from the list of heroes controlled by the player. Such a hero can only become available
for other players by the same ways as other heroes who belong to someone (that is: if he or she
dies, flees the battlefield and is not hired again till the end of the week, is fired, etc.). But if the
hero is dead when the function is invoked, he or she becomes immediately available for all
players except the one who owned him or her before, because he or she is considered as one who
lost a combat.
Win
Win – the human player wins the game when the function is invoked
Syntax
Win(void);
Description
This the function should only be used in the single-player mode. It generates an error if invoked
in the multiplayer mode. When the function is invoked, the human player wins immediately, and
all the AI players lose.
COMBAT
Prepare
Prepare – preparation for the combat
Syntax
Prepare(void);
Description
This function is invoked before the players begin arranging their troops at the battlefield. Troops
arrangement will only begin after this function finishes its work.
Start
Start – the start of the combat
Syntax
Start(void);
Description
This function is invoked after the players have arranged their troops at the battlefield and
immediately before the combat begins. The combat will only begin after this function finishes its
work.
IsHuman
IsHuman – determine whether there is a human playing for the certain party
Syntax
IsHuman(side);
Description
This function returns not nil if the specified party that takes part in combat belongs to a human
(regardless of whether this human controls the party’s actions, or they are under auctomatic
control), and nil if not.
IsComputer
IsComputer – determine whether there is the AI playing for the certain party
Syntax
IsComputer(side);
Description
This function returns not nil if the specified party that takes part in combat belongs to the AI,
and nil if not.
SetControlMode
SetControlMode(side, mode) – set the combat control mode for the human player
Syntax
Description
The command turns on/off the automatic combat mode and sets on/off the human player’s ability
to switch this mode manually. The specified party must be human-controlled.
mode – number of the mode; one of the following actions is performed according to it:
MODE_NORMAL – the status of the automatic combat mode is not changed, and its blocking is set
off.
MODE_MANUAL – the automatic combat mode is turned off, and the player’s ability to switch it is
set off.
MODE_AUTO – the automatic combat mode is turned on, and the player’s ability to switch it is set
off.
EnableAutoFinish
EnableAutoFinish – turn on/off the standard mechanism of checking the combat’s results
Syntax
EnableAutoFinish(enable);
Description
The parameter sent to the command determines whether the combat will be finished if one of the
parties has no more troops. If parameter is equal to nil, the combat will not be finished. This
mode is on by default.
Finish
Finish – finish the combat
Syntax
Finish(winnerSide);
Description
The command finishes the combat, and the party winnerSide is considered as winner.
winnerSide – the party that wins the combat, can be ATTACKER or DEFENDER.
GetAttackerHero
GetAttackerHero – return the attacking party’s hero
Syntax
GetAttackerHero(void);
Description
This function returns the name of the attacking party’s hero, or nil if there is no hero.
GetAttackerCreatures
GetAttackerCreatures – return the attacking party’s creatures
Syntax
GetAttackerCreatures(void);
Description
GetAttackerWarMachines
GetAttackerWarMachines – return the attacking party’s war machines
Syntax
GetAttackerWarMachines(void);
Description
This function returns an array of names of the attacking party’s war machines.
GetAttackerWarMachine
GetAttackerWarMachine – return the attacking party’s war machine of the specified type
Syntax
GetAttackerWarMachine(type);
Description
This function returns the name of the attacking party’s war machine of the specified type, or nil
if it does not exist.
type – the type of the war machine; can take on one of the following values:
WAR_MACHINE_BALLISTA – ballista
WAR_MACHINE_CATAPULT – catapult
Syntax
GetDefenderHero(void);
Description
This function returns the name of the defending party’s hero, or nil if there is no hero.
GetDefenderCreatures
GetDefenderCreatures – return the defending party’s creatures
Syntax
GetDefenderCreatures(void);
Description
GetDefenderWarMachines
GetDefenderWarMachines – return the defending party’s war machines
Syntax
GetDefenderWarMachines(void);
Description
This function returns an array of names of the defending party’s war machines.
GetDefenderWarMachine
GetDefenderWarMachine – return the defending party’s war machine of the specified type
Syntax
GetDefenderWarMachine(type);
Description
This function returns the name of the defending party’s war machine of the specified type, or nil
if it does not exist.
type – the type of the war machine; can take on one of the following values:
WAR_MACHINE_BALLISTA – ballista
WAR_MACHINE_CATAPULT – catapult
GetDefenderBuildings
GetDefenderBuildings – return the defending party’s buildings
Syntax
GetDefenderBuildings(void);
Description
GetDefenderBuilding
GetDefenderBuilding – return the defending party’s building of the specified type
Syntax
GetDefenderBuilding(type);
Description
This function returns the name of the defending party’s building of the specified type, or nil if it
does not exist.
type – building type, can take on one of the following values:
BUILDING_WALL – wall
BUILDING_GATE – gate
BUILDING_MOAT – moat
IsAttacker
IsAttacker – determine whether the object belongs to the attacking party
Syntax
IsAttacker(unitName);
Description
This function returns not nil if the object belongs to the attacking party, and nil if not.
IsDefender
IsDefender – determine whether the object belongs to the defending party
Syntax
IsDefender(unitName);
Description
This function returns not nil if the object belongs to the defending party, and nil if not.
Syntax
IsHero(unitName);
Description
This function returns not nil if the object is a hero, and nil if not.
IsCreature
IsCreature – determine whether the object is a creature
Syntax
IsCreature(unitName);
Description
This function returns not nil if the object is a creature, and nil if not.
IsWarMachine
IsWarMachine – determine whether the object is a war machine
Syntax
IsWarMachine(unitName);
Description
This function returns not nil if the object is a war machine, and nil if not.
Syntax
IsBuilding(unitName);
Description
This function returns not nil if the object is a building, and nil if not.
GetHeroName
GetHeroName – return the hero’s name
Syntax
GetHeroName(unitName);
Description
This function returns the hero’s real name (not the battle name).
GetCreatureType
GetCreatureType – return the creature’s type
Syntax
GetCreatureType(unitName);
Description
Syntax
GetCreatureNumber(unitName);
Description
GetWarMachineType
GetWarMachineType – return the type of the war machine
Syntax
GetWarMachineType(unitName);
Description
This function returns the type of the war machine. It can return one of the following values:
WAR_MACHINE_BALLISTA – ballista
WAR_MACHINE_CATAPULT – catapult
GetBuildingType
GetBuildingType – return the building’s type
Syntax
GetBuildingType(unitName);
Description
This function returns the building’s type. It can return one of the following values:
BUILDING_WALL – wall
BUILDING_GATE – gate
BUILDING_MOAT – moat
GetUnitPosition
GetUnitPosition – return the object’s coordinates
Syntax
GetUnitPosition(unitName);
Description
AddCreature
AddCreature – add creatures of the specified type to one of the parties
Syntax
This function adds number of creatures of the type to the party side. If the x and y parameters
are set, the creature appears in the free tile closets to (x,y); otherwise it appears in the random
location at the arena. It is also possible to set only one of the tile’s coordinates. Creatures that are
added by this command remain in the hero’s army after the combat (if there is room for them
there).
side – the party to which the creature is summoned; can take on one of the two values:
x, y – coordinates of the tile in which the creature must appear (-1 is for random coordinates)
EnableCinematicCamera
EnableCinematicCamera – turn the cinematic camera on/off in the combat
Syntax
EnableCinematicCamera(enable);
Description
This function works correctly only for the current combat. The camera can now switch to
cinematic mode only if this is allowed in the settings and not prohibited by the script.
TUTORIAL
IsTutorialItemEnabled
IsTutorialItemEnabled – get to know whether the tutorial element will be shown
Syntax
IsTutorialItemEnabled(name);
Description
IsTutorialMessageBoxOpen
IsTutorialMessageBoxOpen – get to know whether any window with the tutorial text is currently
open
Syntax
IsTutorialMessageBoxOpen();
Description
This function returns true if there is a window invoked by the TutorialMessageBox function
present at the screen.
TutorialActivateHint
TutorialActivateHint – set on the trigger for a specified window’s appearance, and a window
with the tutorial text is shown when the trigger works
Syntax
TutorialActivateHint(stringID);
Description
TutorialMessageBox
TutorialMessageBox – show the window with the tutorial text
Syntax
TutorialMessageBox(stringID);
Description
This function finds the descriptor element in UIConsts.tutorialOptions.hints by its stringID and
shows a window with the text to which that element is referring.
TutorialSetBlink
TutorialSetBlink – turn the control element highlighting on/off
Syntax
TutorialSetBlink(stringID, turnOn);
Description
TOWN
HeroHired
HeroHired – a hero is hired
Syntax
HeroHired(name);
Description
This function is invoked if a player hires the hero.
CreatureHired
CreatureHired – a creature is hired
Syntax
CreatureHired(type, number);
Description
This function is invoked if a player hires the troops.