scripting2.01
scripting2.01
1
Version 1.0 © Celestial Heavens, 2007
Version 2.0 © Celestial Heavens, 2008
Version 2.01 © Celestial Heavens, 2008
Layout: Robenhagen
Scripting your maps is a way to make them more interesting, describe all the individual script functions, since they already
and personal. Also, scripting allows you to control the course of are quite well covered in official materials. But, it does cover the
the game to a much greater extent than you can with even the details of SCRIPT writing: the syntax, how to build a custom
most creative terrain building. The Heroes of Might and Magic function and set triggers properly. However, even with this guide
Editor (game patch 1.3 or later, or either the HOF or ToTE and the official editor documentation at hand, be ready to expe-
expansions required) allows you to add scripting to your maps. rience a little frustration when doing you first scripts ☺. Luckily,
However, even though the game folder contains documentation there are online forums where other people can help you during
for the using the Editor and describes the commands and script the darkest hours. I must admit that, without people asking for
functions required to create scripts, it is easy to get lost when help and without other mapmakers demonstrating their neat so-
opening the script editing window and seeing the blank white lutions, this little guide could not have been written. My thanks
page. Just what are you supposed to write there, and is there a to all the regulars of Round Table Mapmaking guild!
special format or syntax for doing it?
This humble guide is meant as a supplementary material Wishing you good luck with scripts,
for the official editor documentation. For example, it does not Pitsu
OTHER IDs HERO IDs DEBUGGING TRIGGERS FUNCTIONS VARIABLES SYNTAX SCRIPT FILE LAYOUT Hero IDs
4
Table of Contents
2. Syntax ....................................................... 5
2.1. Empty lines, semicolons, and the number of spaces . . . . . . . . . . . . . . . . . . 5
2.2. Case sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3. Quotation marks and their use 5
2.3.1. Use No Quotes When . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.2. Use Quotes When . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.3. Example script for quotes usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4. How to create and refer to text files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4.1. Displaying variables within message text . . . . . . . . . . . . . . . . . . . . . 6
2.5. How to refer to map objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.6. How to refer to heroes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.7. Meaning of some symbols and special commands . . . . . . . . . . . . . . . . . . . 7
3. Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1. Variable types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1. Local variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.2. Global variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.3. Game variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4. Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1. Defining functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2. IF .. THEN, WHILE.. DO etc. blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3. How many “end;”s does there have to be? . . . . . . . . . . . . . . . . . . . . . . . . 11
4.4. Function fname() or function fname(parameter) . . . . . . . . . . . . . . . . . . . . 11
4.5. Special functionName(heroName) functions . . . . . . . . . . . . . . . . . . . . . . . 12
4.6. Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5. Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1. Instant triggering of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2. Binding functions to map events and objects . . . . . . . . . . . . . . . . . . . . . . 14
5.3. Triggering fname(parameter) type of functions . . . . . . . . . . . . . . . . . . . . . 15
5.4. Removing a trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6. Hints for debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.1. Enabling the console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.2. Using the print() command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.3. My script does not run! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.4. My script runs but doesn’t do what I want . . . . . . . . . . . . . . . . . . . . . . . . . 17
2
8.16. Feats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8.16.1. Knight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8.16.2. Demon Lord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8.16.3. Necromancer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.16.4. Ranger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.16.5. Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.16.6. Warlock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.16.7. Runemage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.16.8. Runmage & Barbarian (cross-class) . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.16.9. Barbarian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
8.17. Town type IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.18. Town buildings IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8.19. Monster mood IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.20. Monster courage IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.21. Borderguard key colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.22. Trigger type IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.23. Saved combat results types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.24. Custom abilities IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.25. Custom abilities modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.26. Moon weeks (for GetCurrentMoonWeek adventure script function) . . . . . 25
8.27. Animation Action Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.28. Disabled interactive objects modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.29. Region Auto Action modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.30. Region Auto Action enable variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.31. Heroes Roles Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.32. Players Teams constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.33. Game difficulty IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.34. Creature IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.35. War machines IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.36. Spell IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3
Script file layout
1. Script file layout
SCRIPT FILE LAYOUT
When you create a new map and open its script file (View/Map Commands – a command is simply a complete, executable
Properties/Script tab, and click Edit Script) you see only a blank scripting statement of some kind. Most of the time com-
white sheet. When you open a heavily scripted map script file mands are user-defined or pre-defined H5 script functions,
you see quite an extensive amount of text. Is there any particu- but they can be any executable block of scripting statements
lar layout to follow? The answer is no; the various elements in consisting of any combination of Lua programming state-
the script do not have to appear in any particular order, though ments and functions.
there is a command syntax that must be adhered to. Once defined in a script, functions become commands
Depending on the style of the script writer, a script file can that can be used within the definitions of other functions
have the following things in a chaotic array or an orderly ar- in the script, or simply placed in the script outside any of its
rangement: functions.
SYNTAX
• Functions – user-defined groups of pre-defined H5 script All commands in your script that are NOT part of any
functions, commands, and Lua programming state- of the functions in your script are triggered when the map
ments. They make up the main part of the script file. is started and the script file is read the first time. In other
Basically, you must create one or more functions for words, they are executed by the game on dawn of day 1, week
each custom action or object behavior that you desire 1, month 1 before any action can be taken by the player. For
in your map. The scripts for lightly customized maps example, you may wish to show a message box that displays a
VARIABLES
may require only one or two functions, while the scripts prolog to the player before he or she begins playing.
for highly customized maps require many functions. • Comments – Comments start with double minus (double
Often it is best to split a complex function into several hyphen) -- and end with a line break. Comments are ignored
smaller functions just to have a better overview of the dif- by the game and are meant for script writer only. For ex-
ferent parts. ample, if you are afraid of forgetting the meaning of a func-
• Trigger –a specialized pre-defined defined H5 script func- tion in your script, simply add a comment to it. Also, placing
FUNCTIONS
tion that determines when a function in your script is run double minus in front of a block of statements in your script is
during the course of the game. As a general rule, you’ll find a simple way to test how your script runs without that block.
you will need to tie a particular function to a specific action For example, you may wish to see if a particular command is
taken by the player while playing the map. For example, you causing the bug you are hunting for.
may wish to display a warning message to the player when a
hero first enters a certain area on your map.
TRIGGERS
DEBUGGING
HERO IDs
Layout Example
OTHER IDs
Note the text color code shown in the example. This code helps a programming language. When it is red, it is a properly spelled
bit to avoid spelling and other mistakes. When it is green (com- pre-defined H5 script function. Text between a pair quotation
ment), you can write anything, it is ignored by the game. When marks (parameter names) is orange. The rest is black.
it is blue, it is a number or has a certain meaning for the Lua
4
Syntax
2. Syntax
SYNTAX
and make relationships clear is an excellent habit to get into.
(The Layout Example uses an excellent, systematic approach to
indenting and the use of spaces. Go forth and do ye likewise.) • Typing the names of local and global variables, which are
Breaking a long line of text into one or more lines, or adding always without quotes.
half a page of empty lines between two functions does not affect
the script’s functionality. NOTE: “Game variables,” which are accessible via SetGame
VARIABLES
Var() and GetGameVar(), are different.
Commands as well as variable names and map object names all function transform(townname) -- townname with-
are case sensitive. Spelling and capitalization mistakes are one of out quotes since it is a variable.
FUNCTIONS
the most common errors when a script does not run. local towntype =5; -- defining a local variable
called towntype. No quotes any-
where.
2.3. Quotation marks and their use TransformTown(townname, towntype); -- town-
name and towntype are both variables. The
Proper using of quotation marks with function names, variable value of the first is defined when the function
names, and map object names is quite confusing, but it follows a is called up (see examples below), the value of
system nevertheless. (You may need to read the function and pa- the second was set to 5 right before.
TRIGGERS
rameter descriptions in the official documentation before fully end;
understanding the samples presented here.) Also, note that there
are two types of quotes that can be used " and '. Generally it does
not matter which kind of quotation marks you use as long as the 2.3.2. Use Quotes When
starting and ending marks of each pair are the same. A specific • The name of a function, adventure map object, scenario ob-
usage example for using both types of quotes in the same line is jective etc. is a parameter for a command. In other words, use
DEBUGGING
given later on in this guide under “Triggering fname(parameter) quotes for everything that is inside parenthesis and is a name
type of functions”. of a function, message text file, hero, adventure map object, or
scenario objective.
2.3.1. Use No Quotes When
• Declaring a function: Example
• The function name acts as a command. Namely, each func- • Calling up or saving game variables. (See official documenta-
tion that you write can be called up in the same way as the tion for examples.)
pre-defined H5 script functions.
5
Syntax
2.3.3. Example script for quotes usage 11. Click OK.
SCRIPT FILE LAYOUT
Suppose you have a map with towns that have the script names A blank text entry window appears.
town1 and town2. (In order to refer to an object on your map 12. Type your message text.
from within your script, you must give the object a script name 13. Click OK and then Yes to save.
in its properties window.) Then further suppose that you desire
to change town1 to an Academy upon capture. As script code To refer to a text file you must provide the full path starting
goes, this example is unnecessarily long, but it shows quotes us- from Maps directory. (This full path appears in the SaveFilena-
age quite well: meFileRef value field after you’ve created the file as described
earlier.)
function transform(townname) -- townname with-
out quotes since it is a variable Example
TransformTown(townname, TOWN_ACADEMY); Displaying a message to the player:
-- townname is a variable name and
SYNTAX
names of map object and function, CAUTION: The Descriptions given in official HoF editor
respectively. They are parameters for manuals for MessageBox() and QuestionBox() for com-
Trigger command and not variables, plex messages are misleading and erroneous. Additionally, you
thus must have quotes. cannot display variables in any 1.x game version prior to the
Hammers Of Fate expansion.
2.4. How to create and refer to text files To display the value of a numeric variable within a complex message
1. Create a resource text file for the complex message using
TRIGGERS
It is very hard for beginners to get the references to external text <value= variablename> at places where the value of the
files correct. Yet, you must learn to do it because each individual numeric variable should be displayed.
piece of text that appears during the course of playing your map
must come from a text file that you have added to the map’s Example
resources during the creation of the map. For example, you will
have to refer to a resource file that contains the text for each mes- Filename: Pillage.txt
DEBUGGING
sage box or a question box you wish the player to see. Text in file: The enemy has pillaged
<value=goldamount> gold from
To create a resource text file local villages.
1. Open the Map Properties Tree.
2. Select Resources and expand its list if necessary.
3. Select SavesFilenames. 2. In the script, the MessageBox() command for the above
4. Right click and select the Add command. example would look like:
5. Expand the SaveFilenames list if necessary.
HERO IDs
6
Syntax
3. In the game the complex message displayed to the player 3. Find the Name property and click in its value field.
Example Once you’ve completed these steps for an object, you can use its
scripting name to refer to the object.
Filename: JonnyBlackeye.txt
SYNTAX
Text in file: Jonny Blackeye CAUTION: Giving the same, identical name to two or more
objects, will not cause an error message right away, but the script
will eventually crash when run.
2. Create a resource text file for the complex message, using
<value=variablename> at places where variables should be
displayed. 2.6. How to refer to heroes
VARIABLES
Example Referring to heroes must be done by their internal H5 ID. You
can give them a scripting name as described earlier, but scripts
Filename: Pillage.txt do not recognize those names, nor do scripts recognize the
Text in file: <value=name> has pillaged standard game names.
<value=goldamount> gold from
FUNCTIONS
local villages. To find a hero’s internal ID
1. Open the Map Properties Tree
2. Select the hero on the map (may be a temporary placement
3. In the script, the MessageBox() command for the above of the hero).
example would look like: The hero’s property list appears in the Map Properties
Tree
Example 3. Find the Shared property and click in its value field.
Two buttons, “…” and “New” appear.
TRIGGERS
MessageBox( { "Maps/SingleMissions/ 4. Click on the “…” button.
MyMap/Pillage.txt "; name = "Maps/ The Browse Object Link screen appears. A specific hero
SingleMissions/MyMap/JonnyBlackeye.txt", will be selected in the left window, and list of that hero’s
goldamount = 526 }); Properties will appear in the right window.
5. Find the InternalName property in the right window, and
make note of the value, for it is the internal H5 ID for the
DEBUGGING
Notice that commas separate the elements in the variable list hero.
inside the {}. 6. Close the Browse Object Link screen without making any
changes to the values.
4. In the game the message displayed to the player it would
look like: If this procedure seems too complicated for you, then simply
refer to the “Internal hero ID names needed for scripts” section
“Jonny Blackeye has pillaged 526 gold from local villages.” towards the end of this guide.
HERO IDs
7
Syntax
Symbol or Command Description
SCRIPT FILE LAYOUT
= Assignment
Assigns a value to a variable.
Example
m = 2, means that henceforth the variable m has a value of two.
== Equality
Compares a value on the left with the value on the right to see if they are equal.
(Relational operator, returns true or false.)
Example
Where: x =2 y = 3
SYNTAX
~= Not equal
Compares a value on the left with the value on the right to see if they are not equal.
(Relational operator, returns true or false.)
Example
Where: x =2 y = 3
DEBUGGING
Example
Where: x =2 y = 3
(x == 2 and y == 3) would return true.
HERO IDs
or Logical OR
Between two relational comparisons, means that either of the tests can be true in order to proceed.
Example
Where: x =2 y = 3
(x == 4 or y == 3) would return true.
OTHER IDs
nil A special, unique value generally meaning “none”. A global variable has a nil value by default
before a first assignment. You can use nil as a kind of non-value, to disable a trigger by setting
its target to “nothing.”
In an equality test, only nil is equal to nil.
8
Syntax
.. String concatenation operator (two dots)
Example
Where x = 8
“Mine”..x results in the string “Mine8”
random(nTop) Arithmetic function
Returns a random number from zero to the nTop - 1.
Example
Random(6)
Returns a random in the range of 0 to 5.
SYNTAX
mod(x, y) Arithmetic function
Returns the remainder from dividing the number x by the number y.
Both arguments must be numbers (not necessarily whole).
The second argument must be not equal to zero.
VARIABLES
Example
Mod(42, 7)
Returns: 0
+ Addition
Adds the number on the left to the right
FUNCTIONS
Example
Where: x =2 y = 3
x + y results in 5
- Subtraction
Example
Where: x =2 y = 3
TRIGGERS
x - y results in -1
* Multiplication
Example
Where: x =2 y = 3
DEBUGGING
x * y results in 6
/ Division
Example
Where: x =3 y = 2
x / y results in 1.5
HERO IDs
OTHER IDs
9
Variables
3. Variables
SCRIPT FILE LAYOUT
A variable is a container in your script with a name and a value. It 3.1.2. Global variables
can have different values while the script is run. Do not confuse In actual scripting, global variables are used more than the other
variable names with function names and names of adventure types of variables. You do not have to define them prior use. The
map objects, scenario objectives, file names, etc. Variable names first time you use a variable name outside of a function and give
are used and handled differently from these other names. When it a value, you have defined a global variable. From then on, it
in doubt as to whether a name refers to a variable or not, check can be used at any place in the script file. However, for keeping
to see if there is a function with the same name, or an adventure better track of them and avoiding potential errors where you use
map object or scenario objective with a scripting name that is the a variable before giving it a value, you may wish to define them
same. If there is not, it is most likely a variable name. at the start of a script file and give them an initial value of the
correct type.
SYNTAX
There are three types of variables based on their accessibility. bankAccount = 0; -- defines a numerical type global
1. Local variables are accessible only from inside a particular value named bankAccount and
function. assigns it a value of zero.
VARIABLES
function day2()
local day =2; -- defines a local variable with value 2
if GetDate(DAY)== day then -- comparison
returns true on day two.
HERO IDs
blabla();
end;
end;
10
Functions
4. Functions
SYNTAX
You will use these pre-defined commands and Lua program- if boolean test then
ming statements to define your own functions. You will likely commands;
have to define many functions if your map is to be customized else
to any great degree. commands;
end;
Simpler user-defined functions look like this: while boolean test do
VARIABLES
commands;
function function_name() end;
commands_of_your_choice; for variable name = start_value, end_value do
end; commands;
end;
repeat
FUNCTIONS
More complicated user-defined functions can have different commands;
blocks. For example: until boolean test
function function_name()
commands_that_run_always_when_the_ 4.3. How many “end;”s
function_is_triggered;
if boolean_test then
does there have to be?
commands_that_run_only_if_boolean_ An “end;” is required for each “block” that is started with:
TRIGGERS
test_returns_true;
end; · function
again_commands_that_run_always_when_the_ · if … then
function_is_triggered; · if … then … else
end; · while … do
· for … do
DEBUGGING
And, you can have blocks within other blocks: Everything that is between an above listed command and its
respective end; statement forms a block, and all the commands
function function_name() in that block are run or none of them are run. See the examples
commands_that_run_always_when_the_ under the general description of functions.
function_is_triggered; One block that does not require “end” is:
if boolean_test then
commands_that_run_only_if_boolean_ repeat
HERO IDs
test_returns_true; commands;
if boolean_test2 then until boolean test;
commands_that_run_only_if_
boolean_test_and_boolean_ test2_
BOTH_return_true; 4.4. Function fname() or
end;
function fname(parameter)
OTHER IDs
end;
end; Imagine a situation where you have several objects which trigger
similar functions. For example, suppose your map had several
NOTE: The map Editor’s Check Map and Check commands towns that are converted to another town type upon capture.
give you an ERROR “function xxx not defined” for each user- You could write a specific function for each town, but you could
defined function. This error is meant only to confuse and scare also write a general function and specify the town that has to be
you. Ignore it. changed in the trigger for that function.
11
Functions
To write such a general function, you define variables in pa- 4.5. Special functionName(heroName)
functions
SCRIPT FILE LAYOUT
renthesis after the function name. You can have more than one
such variable there, separated by commas, if needed.
Heroes have a special relationship with functionName
Example (parameter) type of functions. Namely, one does not need
The general function looks like this: to specify the specific hero to which a generic function applies.
The ID of the currently selected hero who triggered the script is
function transform(townname) used as the value for what ever parameter name is used inside the
TransformTown(townname, TOWN_ACADEMY); parenthesis when the function is defined.
end;
Examples
When calling transform() you must specify a value for function blockHero(heroName) -- the script will
SYNTAX
the “townname” parameter, which is used like a local variable use the ID of the current hero as the
within the transform() function. Lets say the town script value of the heroName parameter.
names are town1 and town2. if HasArtefact(heroName, 2 ) then -- tests
When you trigger this function by calling: whether current hero (whose ID is in the
heroName variable) has artefact number 2
transform("town1"); SetRegionBlocked("passage",not nil,
VARIABLES
PLAYER_3);
end;
The townname parameter in the TransformTown() func- end;
tion is given value “town1” and the general function trans
form() is understood as:
The parameter can have any name you wish. Just remember that
FUNCTIONS
function transform() you must use that same name as the name of the variable within
TransformTown("town1", TOWN_ACADEMY); the commands in the function.
end;
function blockHero(xxx) -- the script will use the
ID of the current hero as the value of the xxx parameter.
When you trigger this function by calling: if HasArtefact(xxx, 2 ) then -- tests wheth-
er current hero (whose ID is in the
transform("town2"); xxx variable) has artefact number 2.
TRIGGERS
SetRegionBlocked("passage",not nil,
PLAYER_3);
The very same general function transform() would be end;
understood as: end;
function transform()
DEBUGGING
TransformTown("town2", TOWN_ACADEMY); This example function can be called up without specifying the
end; hero name like with this command:
blockHero();
In the following example of bad scripting, the “townname”
variable is not used for anything. It is defined, but the function
always converts town2. Thus, it is more appropriate to define or
the function as transform() than it is to define the function
HERO IDs
as transform(townname). Trigger(REGION_ENTER_AND_STOP_TRIGGER,
"area1"," blockHero " );
Bad scripting example
end;
12
Functions
4.6. Threads time specified by its parameter, the sleep() command al-
SYNTAX
name) command.
As long as the boolean test (e.g., x == y) returns true, commands CAUTION: Triggering threads in ways other than start
are run. Most often you need the opposite: commands are held Thread() blocks access to other script functions as long as the
back until a certain requirement is fulfilled. For that require- (infinite) thread runs.
ment use the following:
VARIABLES
Example script
You want a script that gives the player an instant win when he
function funcname() accumulates 100.000 gold.
while boolean test do
if boolean test2 then function checkGold()
commands; while 1 do
FUNCTIONS
end; if GetPlayerResources(PLAYER_1, 6)
sleep(10); >= 100000 then
end; win();
end; end;
sleep(10);
end;
If you have problems defining the first boolean test which deter- end;
mines how long the thread lives, give it eternal life with “while 1 startThread(checkGold); -- Note exception to rule:
TRIGGERS
do”. Official maps use this statement quite often. It is startThread(fname) NOT startThread("name")
Why is the sleep(10) command necessary? During the
DEBUGGING
HERO IDs
OTHER IDs
13
Triggers
5. Triggers
SCRIPT FILE LAYOUT
blah.txt"); or
end;
Trigger(NEW_DAY_TRIGGER, "day1");
function day2()
if GetDate(DAY)== 2 then Trigger(NEW_DAY_TRIGGER, "day2");
blabla(); -- here function blabla is triggered
and the messagebox is shown at day 2.
end; In both cases only the latter Trigger command would work,
TRIGGERS
Suppose you require a function to run when a certain event oc- function days()
curs on your map. How do you tie the function to the event? day1();
That is what you have the Trigger() command for. The day2();
Trigger() command is thoroughly described in the official end;
editor document Script_Functions.pdf, and you should consult function day1();
that document before you actually use the Trigger() com- commands;
mand in your script. Briefly, the generalized syntax for the end;
Trigger() command looks like this: function day2();
HERO IDs
commands;
Trigger(EVENT _TYPE, "object to which the end;
event is bound", "function name that is to
be triggered");
Of course different objects can have the same type triggers
without problems and the same object can have different type of
Examples triggers without problems.
OTHER IDs
Trigger(OBJECT_TOUCH_TRIGGER,
"festivalArena", "offerFestival");
Trigger(REGION_ENTER_AND_STOP_TRIGGER,
"monolithOneRgn", "openMonoliths");
14
Triggers
5.3. Triggering fname(parameter) 5.4. Removing a trigger
type of functions
SYNTAX
Trigger(NEW_DAY_TRIGGER, "transform1"); Trigger(NEW_DAY_TRIGGER, "transform");
VARIABLES
Trigger(NEW_DAY_TRIGGER, nil);
function transform(townname) end;
TransformTown(townname, 5); end;
end;
FUNCTIONS
Example of the short way
Trigger(NEW_DAY_TRIGGER, "transform
('town1')"); -- NOTE: Different types of quota-
tion marks are used. Check that
"transform1('town1')" is entirely
orange colored in your editor!
TRIGGERS
function transform(townname)
TransformTown(townname, 5);
end;
DEBUGGING
HERO IDs
OTHER IDs
15
Debugging
6. Hints for debugging
SCRIPT FILE LAYOUT
message on the developer’s console. If the error is bad enough, print('works to here'); -- shows works to here in
the script will be ignored when the map opens for play. This type the console window.
of error is the main reason why new mapmakers complain “my
script doesn’t run” or “nothing happens” when I test my map. print(test1); -- shows the value of the test1 variable
Unfortunately, the developer’s console is disabled during the in the console window.
installation process for the game, so you cannot see it while you
VARIABLES
play the game, nor can you use it to debug your script. But, there print("x1 = ", x1) -- shows x1 = followed by the
is a way to enable it. value of the x1 variable in the console window.
For the Tribes of The East expansion, follow these steps:
profiles directory. If your script does not run when you try to play your map, follow
2. Find the autoexec_a2.cfg file and open it for editing these steps:
with a text editing program such as Notepad or WordPad. 1. Make sure that the map is SingleMission not MultiPlayer
3. Add this line of text setvar dev_console_password (open the map’s *.h5m file with zip or rar archiver and see
= schwinge-des-todes as the last line in the file. the names of subdirectories).
4. Go into the My Documents/My Games/Heroes of 2. Enable console and read the error messages that are dis-
Might and Magic V - Tribes of the East/ played there. Make notes on a piece of scratch paper so you
Profiles directory. You will see some folders, each with can remember what they are.
TRIGGERS
the name of a game profile you created to play the game 3. Get out of the game and open your map with the Editor.
with. If you don’t see any folders with profile names, launch 4. Look into your script and see if you can find the problems
the game and create a new profile with a name such as Tester. indicated in the error messages. Typically, an error message
5. Decide which profile you are going to use for testing your will tell you what line the error is on, or identify the last line
script and open its folder. the compiler worked on, and tell you what it expected to
6. Find the input_a2.cfg file and open it for editing with a find versus what it did find. Examine your code carefully in
DEBUGGING
text editing program such as Notepad or WordPad. light of this information, and decide what changes you wish
7. Add the string bind show_console '`' right after the to make before trying to compile it again. For example, you
line saying bind enter_pressed 'NUM_ENTER'. could do any or all of the following:
a. Check your spelling and capitalization. Even the most
If you are using the Hammers of Fate expansion, you need to trivial spelling or capitalization error can stop the com-
edit autoexec_a1.cfg and cfg input_a1.cfg. piler in its tracks.
If you are using just Heroes V, you need to edit b. Check your use of quotes.
autoexec.cfg and input.cfg. c. Check that there are enough end;-s. A common problem
HERO IDs
If the console screen does not appear, go back over the steps this manner. You are advised to do likewise.
and check your work. Even the most trivial typing error, capital- d. Check that you didn’t use = where you should have used
ization error, or missing space will prevent enabling the console. ==.
In addition to error messages for faulty scripts, the console
shows you many things about the game, most of which are too
obscure or cryptic to be of much use.
16
Debugging
e. Reread each error message carefully, and try to under- a. Double-check triggers. Maybe a trigger is accidentally set
SYNTAX
3. Make changes to the function and test it again. Repeat as
Once your script compiles without errors, it is entirely possible necessary.
that it still won’t do what you wanted or expected. In this case, 4. If all else fails, discard the function and rewrite it using a
proceed as follows: different approach.
1. Study the results you do see in the game and then go into
your script and look at the function that is supposed to be
VARIABLES
generating those results.
FUNCTIONS
TRIGGERS
DEBUGGING
HERO IDs
OTHER IDs
17
Hero IDs
7. Internal hero ID names
needed for scripts
SCRIPT FILE LAYOUT
Referring to heroes in your scripts must be done by their internal Bold Italic indicates names from the Tribes of the East expan-
H5 ID names. You can give them a scripting name as described sion pack.
earlier, but scripts do not recognize scripting names, nor do
scripts recognize the standard game names as seen by the player (The information in this table comes from Curios cheat guide
in an tuncustomized map. http://www.heroesofmightandmagic.com/heroes5/heroes5_
Here is a list of the standard game names (in bold) versus the cheats_names.shtml)
internal hero ID names:
Standard Game Name Internal Hero ID Standard Game Name Internal Hero ID
SYNTAX
18
Hero IDs
Standard Game Name Internal Hero ID Standard Game Name Internal Hero ID
SYNTAX
Sinitar Inagost Ylaya Shadwyn
Sorgal Ferigl Ylthin Itil
Svea Vegeyr Yrbeth Almegir
Talanar Nadaur Yrwanna Urunir
VARIABLES
Telsek Hero8 Zehir Zehir
Temkhan Timerkhan Zoltan Aberrar
FUNCTIONS
TRIGGERS
DEBUGGING
HERO IDs
OTHER IDs
19
Other IDs
8. Other IDs Needed For Scripts
SCRIPT FILE LAYOUT
Many of the H5 script functions require IDs for parameter val- 8.6. Kinds of treasures
ues to make them work properly. This section covers all the IDs TREASURE_CRYSTAL = 0
you will need to write your scripts. TREASURE_GEMS = 1
NOTE: Each expansion to the original H5 game brought TREASURE_GOLD = 2
new heroes, artifacts, and other objects. This list has notes indi- TREASURE_MERCURY = 3
cating which IDs belong to each expansion where required. TREASURE_ORE = 4
NOTE: For some reason, the official documentation for the TREASURE_SULFUR= 5
Editor was not updated for the new creature, town, and artifact TREASURE_WOOD = 6
IDs added by the Tribes of the East expansion. You must use this TREASURE_CAMPFIRE = 8
section for reference instead of the official documentation. TREASURE_CHEST = 9
SYNTAX
TREASURE_SEA_CHEST = 10
TREASURE_FLOATSAM = 11
TREASURE_SHIPWRECK = 13
8.1. Logical constants
true = not nil
false = nil
VARIABLES
PLAYER_2 = 2
PLAYER_3 = 3
PLAYER_4 = 4
PLAYER_5 = 5 8.8. Advmap predefided names
PLAYER_6 = 6 OBJECT_GRAIL = 'grail'
PLAYER_7 = 7
PLAYER_8 = 8
TRIGGERS
PLAYER_LOST = 3 STAT_EXPERIENCE = 0
STAT_ATTACK = 1
STAT_DEFENCE = 2
STAT_SPELL_POWER = 3
8.4. Floor names STAT_KNOWLEDGE = 4
GROUND = 0 STAT_LUCK = 5
UNDERGROUND = 1 STAT_MORALE = 6
STAT_MOVE_POINTS = 7
HERO IDs
STAT_MANA_POINTS = 8
CRYSTAL = 3 OBJECTIVE_UNKNOWN = 1
SULFUR = 4 OBJECTIVE_ACTIVE = 2
GEM = 5 OBJECTIVE_COMPLETED = 3
GOLD= 6 OBJECTIVE_FAILED = 4
20
Other IDs
8.12. Artifact sets IDs ARTIFACT_STAFF_OF_MAGI = 45
(for basic artifact sets)
SYNTAX
ARTIFACT_MOONBLADE = 58
ARTIFACT_RING_OF_CELERITY = 59
8.13. Artifact type IDs ARTIFACT_BAND_OF_CONJURER = 60
ARTIFACT_SWORD_OF_RUINS = 1 ARTIFACT_EARTHSLIDERS = 61
ARTIFACT_GREAT_AXE_OF_GIANT_SLAYING = 2 ARTIFACT_RIGID_MANTLE = 62
ARTIFACT_WAND_OF_X = 3 ARTIFACT_JINXING_BAND = 63
VARIABLES
ARTIFACT_UNICORN_HORN_BOW = 4 ARTIFACT_BONESTUDDED_LEATHER = 64
ARTIFACT_TITANS_TRIDENT = 5 ARTIFACT_WISPERING_RING = 65
ARTIFACT_STAFF_OF_VEXINGS = 6 ARTIFACT_HELM_OF_CHAOS = 66
ARTIFACT_SHACKLES_OF_WAR = 7 ARTIFACT_TWISTING_NEITHER = 67
ARTIFACT_FOUR_LEAF_CLOVER = 8 ARTIFACT_SANDALS_OF_THE_SAINT = 68
ARTIFACT_ICEBERG_SHIELD = 9 ARTIFACT_SHAWL_OF_GREAT_LICH = 69
FUNCTIONS
ARTIFACT_GOLDEN_SEXTANT = 10 ARTIFACT_RING_OF_DEATH = 70
ARTIFACT_CROWN_OF_COURAGE = 11 ARTIFACT_NECROMANCER_PENDANT = 71
ARTIFACT_CROWN_OF_MANY_EYES = 12 ARTIFACT_FREIDA = 72
ARTIFACT_PLATE_MAIL_OF_STABILITY = 13 ARTIFACT_RING_OF_THE_SHADOWBRAND = 73
ARTIFACT_BREASTPLATE_OF_PETRIFIED_WOOD = 14 ARTIFACT_OGRE_CLUB = 74
ARTIFACT_PEDANT_OF_MASTERY = 15 ARTIFACT_OGRE_SHIELD = 75
ARTIFACT_NECKLACE_OF_BRAVERY = 16 ARTIFACT_TOME_OF_DESTRUCTION = 76
ARTIFACT_WEREWOLF_CLAW_NECKLACE = 17 ARTIFACT_TOME_OF_LIGHT_MAGIC = 77
TRIGGERS
ARTIFACT_EVERCOLD_ICICLE = 18 ARTIFACT_TOME_OF_DARK_MAGIC = 78
ARTIFACT_NECKLACE_OF_POWER = 19 ARTIFACT_TOME_OF_SUMMONING_MAGIC = 79
ARTIFACT_RING_OF_LIGHTING_PROTECTION = 20 ARTIFACT_BEGINNER_MAGIC_STICK = 80
ARTIFACT_RING_OF_LIFE = 21 ARTIFACT_RUNIC_WAR_AXE = 81
ARTIFACT_RING_OF_HASTE = 22 ARTIFACT_RUNIC_WAR_HARNESS = 82
ARTIFACT_NIGHTMARISH_RING = 23 ARTIFACT_SKULL_OF_MARKAL = 83
DEBUGGING
ARTIFACT_BOOTS_OF_SPEED = 24 ARTIFACT_BEARHIDE_WRAPS = 84
ARTIFACT_GOLDEN_HORSESHOE = 25 ARTIFACT_DWARVEN_SMITHY_HUMMER = 85
ARTIFACT_WAYFARER_BOOTS = 26 ARTIFACT_RUNE_OF_FLAME = 86
ARTIFACT_BOOTS_OF_INTERFERENCE = 27 ARTIFACT_TAROT_DECK = 87
ARTIFACT_ENDLESS_SACK_OF_GOLD = 28 ARTIFACT_CROWN_OF_LEADER = 88
ARTIFACT_ENDLESS_BAG_OF_GOLD = 29 ARTIFACT_MASK_OF_DOPPELGANGER = 89
ARTIFACT_ANGEL_WINGS = 30 ARTIFACT_EDGE_OF_BALANCE = 90
ARTIFACT_LION_HIDE_CAPE = 31 ARTIFACT_RING_OF_MACHINE_AFFINITY = 91
HERO IDs
ARTIFACT_PHOENIX_FEATHER_CAPE = 32 ARTIFACT_HORN_OF_PLENTY = 92
ARTIFACT_CLOAK_OF_MOURNING = 33 ARTIFACT_RING_OF_UNSUMMONING = 93
ARTIFACT_HELM_OF_ENLIGHTMENT = 34 ARTIFACT_BOOK_OF_POWER = 94
ARTIFACT_CHAIN_MAIL_OF_ENLIGHTMENT = 35 ARTIFACT_TREEBORN_QUIVER = 95
ARTIFACT_DRAGON_SCALE_ARMOR = 36 ARTIFACT_PRINCESS = 96
ARTIFACT_DRAGON_SCALE_SHIELD = 37 ARTIFACT_ARTIFACT_EFFECT_COUNT = 97
OTHER IDs
ARTIFACT_DRAGON_BONE_GRAVES = 38
ARTIFACT_DRAGON_WING_MANTLE = 39
ARTIFACT_DRAGON_TEETH_NECKLACE = 40
ARTIFACT_DRAGON_TALON_CROWN = 41
ARTIFACT_DRAGON_EYE_RING = 42
ARTIFACT_DRAGON_FLAME_TONGUE = 43
ARTIFACT_ROBE_OF_MAGI = 44
21
Other IDs
8.14. Skill type IDs PERK_MASTER_OF_CREATURES = 53
SCRIPT FILE LAYOUT
SKILL_SUMMONING_MAGIC = 12
PERK_RAISE_ARCHERS = 61
8.14.2. Class skills PERK_NO_REST_FOR_THE_WICKED = 62
SKILL_TRAINING = 13 PERK_DEATH_SCREAM = 63
SKILL_GATING = 14
SKILL_NECROMANCY = 15 8.15.4. Ranger perks
VARIABLES
SKILL_AVENGER = 16 PERK_MULTISHOT = 64
SKILL_ARTIFICIER = 17 PERK_SNIPE_DEAD = 65
SKILL_INVOCATION = 18 PERK_IMBUE_ARROW = 66
PERK_MELT_ARTIFACT = 68
PERK_PATHFINDING = 19 PERK_MAGIC_MIRROR = 69
PERK_SCOUTING = 20
PERK_NAVIGATION = 21 8.15.6. Warlock perks
PERK_FIRST_AID = 22 PERK_EMPOWERED_SPELLS = 70
PERK_BALLISTA = 23 PERK_DARK_RITUAL = 71
PERK_CATAPULT = 24 PERK_ELEMENTAL_VISION = 72
PERK_INTELLIGENCE = 25
TRIGGERS
PERK_SCHOLAR = 26
PERK_EAGLE_EYE = 27
PERK_RECRUITMENT = 28 8.16. Feats
PERK_ESTATES = 29 8.16.1. Knight
PERK_DIPLOMACY = 30 KNIGHT_FEAT_ROAD_HOME = 73
PERK_RESISTANCE = 31 KNIGHT_FEAT_TRIPLE_BALLISTA = 74
DEBUGGING
PERK_LUCKY_STRIKE = 32 KNIGHT_FEAT_ENCOURAGE = 75
PERK_FORTUNATE_ADVENTURER = 33 KNIGHT_FEAT_RETRIBUTION = 76
PERK_TACTICS = 34 KNIGHT_FEAT_HOLD_GROUND = 77
PERK_ARCHERY = 35 KNIGHT_FEAT_GUARDIAN_ANGEL = 78
PERK_FRENZY = 36 KNIGHT_FEAT_STUDENT_AWARD = 79
PERK_PROTECTION = 37 KNIGHT_FEAT_GRAIL_VISION = 80
PERK_EVASION = 38 KNIGHT_FEAT_CASTER_CERTIFICATE = 81
PERK_TOUGHNESS = 39 KNIGHT_FEAT_ANCIENT_SMITHY = 82
HERO IDs
PERK_MYSTICISM = 40 KNIGHT_FEAT_PARIAH = 83
PERK_WISDOM = 41 KNIGHT_FEAT_ELEMENTAL_BALANCE = 84
PERK_ARCANE_TRAINING = 42 KNIGHT_FEAT_ABSOLUTE_CHARGE = 85
PERK_MASTER_OF_ICE = 43
PERK_MASTER_OF_FIRE = 44 8.16.2. Demon Lord
PERK_MASTER_OF_LIGHTNINGS = 45 DEMON_FEAT_QUICK_GATING = 86
OTHER IDs
PERK_MASTER_OF_CURSES = 46 DEMON_FEAT_MASTER_OF_SECRETS = 87
PERK_MASTER_OF_MIND = 47 DEMON_FEAT_TRIPLE_CATAPULT = 88
PERK_MASTER_OF_SICKNESS = 48 DEMON_FEAT_GATING_MASTERY = 89
PERK_MASTER_OF_BLESSING = 49 DEMON_FEAT_CRITICAL_GATING = 90
PERK_MASTER_OF_ABJURATION = 50 DEMON_FEAT_CRITICAL_STRIKE = 91
PERK_MASTER_OF_WRATH = 51 DEMON_FEAT_DEMONIC_RETALIATION = 92
PERK_MASTER_OF_QUAKES = 52 DEMON_FEAT_EXPLODING_CORPSES = 93
22
Other IDs
DEMON_FEAT_DEMONIC_FLAME = 94 WARLOCK_FEAT_SECRETS_OF_DESTRUCTION = 146
SYNTAX
NECROMANCER_FEAT_CHILLING_BONES = 105 HERO_SKILL_TAP_RUNES = 157
NECROMANCER_FEAT_SPELLPROOF_BONES = 106 HERO_SKILL_RUNIC_ATTUNEMENT = 158
NECROMANCER_FEAT_DEADLY_COLD = 107 HERO_SKILL_DWARVEN_LUCK = 159
NECROMANCER_FEAT_SPIRIT_LINK = 108 HERO_SKILL_OFFENSIVE_FORMATION = 160
NECROMANCER_FEAT_TWILIGHT = 109 HERO_SKILL_DEFENSIVE_FORMATION = 161
NECROMANCER_FEAT_HAUNT_MINE = 110 HERO_SKILL_DISTRACT = 162
VARIABLES
NECROMANCER_FEAT_ABSOLUTE_FEAR = 111 HERO_SKILL_SET_AFIRE = 163
HERO_SKILL_SHRUG_DARKNESS = 164
8.16.4. Ranger HERO_SKILL_ETERNAL_LIGHT = 165
RANGER_FEAT_DISGUISE_AND_RECKON = 112 HERO_SKILL_RUNIC_ARMOR = 166
RANGER_FEAT_IMBUE_BALLISTA = 113 HERO_SKILL_ABSOLUTE_PROTECTION = 167
RANGER_FEAT_CUNNING_OF_THE_WOODS = 114
FUNCTIONS
RANGER_FEAT_FOREST_GUARD_EMBLEM = 115 8.16.8. Runmage & Barbarian cross-class
RANGER_FEAT_ELVEN_LUCK = 116 HERO_SKILL_SNATCH = 168
RANGER_FEAT_FOREST_RAGE = 117 HERO_SKILL_MENTORING = 169
RANGER_FEAT_LAST_STAND = 118 HERO_SKILL_EMPATHY = 170
RANGER_FEAT_INSIGHTS = 119 HERO_SKILL_PREPARATION = 171
RANGER_FEAT_SUN_FIRE = 120
RANGER_FEAT_SOIL_BURN = 121 8.16.9. Barbarian
RANGER_FEAT_STORM_WIND = 122 HERO_SKILL_DEMONIC_RAGE = 172
TRIGGERS
RANGER_FEAT_FOG_VEIL = 123 HERO_SKILL_MIGHT_OVER_MAGIC = 173
RANGER_FEAT_ABSOLUTE_LUCK = 124 HERO_SKILL_MEMORY_OF_OUR_BLOOD = 174
HERO_SKILL_POWERFULL_BLOW = 175
8.16.5. Wizard HERO_SKILL_ABSOLUTE_RAGE = 176
WIZARD_FEAT_MARCH_OF_THE_MACHINES = 125 HERO_SKILL_PATH_OF_WAR = 177
WIZARD_FEAT_REMOTE_CONTROL = 126 HERO_SKILL_BATTLE_ELATION = 178
DEBUGGING
WIZARD_FEAT_ACADEMY_AWARD = 127 HERO_SKILL_LUCK_OF_THE_BARBARIAN = 179
WIZARD_FEAT_ARTIFICIAL_GLORY = 128 HERO_SKILL_STUNNING_BLOW = 180
WIZARD_FEAT_SPOILS_OF_WAR = 129 HERO_SKILL_DEFEND_US_ALL = 181
WIZARD_FEAT_WILDFIRE = 130 HERO_SKILL_GOBLIN_SUPPORT = 182
WIZARD_FEAT_SEAL_OF_PROTECTION = 131 HERO_SKILL_BARBARIAN_LEARNING = 183
WIZARD_FEAT_COUNTERSPELL = 132 HERO_SKILL_POWER_OF_BLOOD = 184
WIZARD_FEAT_MAGIC_CUSHION = 133 HERO_SKILL_WARCRY_LEARNING = 185
WIZARD_FEAT_SUPRESS_DARK = 134 HERO_SKILL_BODYBUILDING = 186
HERO IDs
23
Other IDs
HERO_SKILL_CORRUPT_LIGHT = 200 TOWN_BUILDING_SPECIAL_7 = 23
SCRIPT FILE LAYOUT
TOWN_HEAVEN = 0 BUILDING_SPECIAL_3
TOWN_PRESERVE = 1 TOWN_BUILDING_DUNGEON_TRADE_GUILD = TOWN_
TOWN_ACADEMY = 2 BUILDING_SPECIAL_4
TOWN_DUNGEON = 3 TOWN_BUILDING_DUNGEON_TREASURE_DIG_SITE =
TOWN_NECROMANCY = 4 TOWN_BUILDING_SPECIAL_5
TOWN_INFERNO = 5 TOWN_BUILDING_DUNGEON_HALL_OF_INTRIGUE =
TOWN_FORTRESS = 6 TOWN_BUILDING_SPECIAL_6
TOWN_STRONGHOLD = 7 TOWN_BUILDING_ACADEMY_LIBRARY = TOWN_
TRIGGERS
BUILDING_SPECIAL_1
TOWN_BUILDING_ACADEMY_ARCANE_FORGE = TOWN_
BUILDING_SPECIAL_2
8.18. Town buildings IDs TOWN_BUILDING_ACADEMY_ARTIFACT_MERCHANT =
TOWN_BUILDING_TOWN_HALL = 0 TOWN_BUILDING_SPECIAL_3
TOWN_BUILDING_FORT = 1 TOWN_BUILDING_ACADEMY_TREASURE_CAVE =
DEBUGGING
TOWN_BUILDING_MARKETPLACE = 2 TOWN_BUILDING_SPECIAL_4
TOWN_BUILDING_SHIPYARD = 3 TOWN_BUILDING_ACADEMY_ELEMENTAL_ENCLAVE =
TOWN_BUILDING_TAVERN = 4 TOWN_BUILDING_SPECIAL_5
TOWN_BUILDING_BLACKSMITH = 5 TOWN_BUILDING_PRESERVE_AVENGERS_
TOWN_BUILDING_MAGIC_GUILD = 6 BROTHERHOOD = TOWN_BUILDING_SPECIAL_0
TOWN_BUILDING_DWELLING_1 = 7 TOWN_BUILDING_PRESERVE_MYSTIC_POND = TOWN_
TOWN_BUILDING_DWELLING_2 = 8 BUILDING_SPECIAL_2
TOWN_BUILDING_DWELLING_3 = 9 TOWN_BUILDING_PRESERVE_SPARKLING_FONTAINS
HERO IDs
TOWN_BUILDING_DWELLING_4 = 10 = TOWN_BUILDING_SPECIAL_3
TOWN_BUILDING_DWELLING_5 = 11 TOWN_BUILDING_PRESERVE_BLOOMING_GROVE =
TOWN_BUILDING_DWELLING_6 = 12 TOWN_BUILDING_SPECIAL_4
TOWN_BUILDING_DWELLING_7 = 13 TOWN_BUILDING_PRESERVE_TREANT_SAMPLING =
TOWN_BUILDING_GRAIL = 14 TOWN_BUILDING_SPECIAL_5
TOWN_BUILDING_WONDER = 15 TOWN_BUILDING_NECROMANCY_AMPLIFIER = TOWN_
OTHER IDs
TOWN_BUILDING_SPECIAL_0 = 16 BUILDING_SPECIAL_1
TOWN_BUILDING_SPECIAL_1 = 17 TOWN_BUILDING_NECROMANCY_UNHOLY_TEMPLE =
TOWN_BUILDING_SPECIAL_2 = 18 TOWN_BUILDING_SPECIAL_2
TOWN_BUILDING_SPECIAL_3 = 19 TOWN_BUILDING_NECROMANCY_UNEARHED_GRAVES =
TOWN_BUILDING_SPECIAL_4 = 20 TOWN_BUILDING_SPECIAL_3
TOWN_BUILDING_SPECIAL_5 = 21 TOWN_BUILDING_NECROMANCY_DRAGON_TOMBSTONE
TOWN_BUILDING_SPECIAL_6 = 22 = TOWN_BUILDING_SPECIAL_4
24
Other IDs
TOWN_BUILDING_NECROMANCY_SHROUD_OF_ REGION_ENTER_WITHOUT_STOP_TRIGGER = 7
SYNTAX
TOWN_BUILDING_SPECIAL_1 COMBAT_RESULT_SURRENDER = 3
TOWN_BUILDING_STRONGHOLD_GARBAGE_PILE =
TOWN_BUILDING_SPECIAL_2
TOWN_BUILDING_STRONGHOLD_TRAVELLERS_
SHELTER = TOWN_BUILDING_SPECIAL_3 8.24. Custom abilities IDs
TOWN_BUILDING_STRONGHOLD_PILE_OF_OUR_FOES CUSTOM_ABILITY_1 = 1
VARIABLES
= TOWN_BUILDING_SPECIAL_4 CUSTOM_ABILITY_2 = 2
TOWN_BUILDING_STRONGHOLD_SLAVE_MARKET = CUSTOM_ABILITY_3 = 3
TOWN_BUILDING_SPECIAL_5 CUSTOM_ABILITY_4 = 4
FUNCTIONS
MONSTER_MOOD_FRIENDLY = 0 CUSTOM_ABILITY_NOT_PRESENT = -1
MONSTER_MOOD_AGGRESSIVE = 1 CUSTOM_ABILITY_DISABLED = 0
MONSTER_MOOD_HOSTILE = 2 CUSTOM_ABILITY_ENABLED = 1
MONSTER_MOOD_WILD = 3
TRIGGERS
8.20. Monster courage IDs WEEK_OF_NOTHING = 0
MONSTER_COURAGE_ALWAYS_JOIN = 0 WEEK_OF_TOAD = 1
MONSTER_COURAGE_ALWAYS_FIGHT = 1 WEEK_OF_SALAMANDER = 2
MONSTER_COURAGE_CAN_FLEE_JOIN = 2 WEEK_OF_BEETLE = 3
WEEK_OF_WYVERN = 4
WEEK_OF_DRAGONFLY = 5
DEBUGGING
WEEK_OF_FOX = 6
8.21. Borderguard key colors WEEK_OF_SHAMAN = 7
RED_KEY = 1 WEEK_OF_RABBIT = 8
BLUE_KEY = 2 WEEK_OF_SQUIRREL = 9
GREEN_KEY = 3 WEEK_OF_CATERPILLAR = 10
YELLOW_KEY = 4 WEEK_OF_HAMSTER = 11
ORANGE_KEY = 5 WEEK_OF_PIGEON = 12
TEAL_KEY = 6 WEEK_OF_RAGE = 13
HERO IDs
PURPLE_KEY = 7 WEEK_OF_EAGLE = 14
TAN_KEY = 8 WEEK_OF_BEE = 15
WEEK_OF_WASP = 16
WEEK_OF_SWAN = 17
WEEK_OF_BUTTERFLY = 18
8.22. Trigger type IDs WEEK_OF_THANE = 19
OTHER IDs
NEW_DAY_TRIGGER = 0 WEEK_OF_ANTILOPE = 20
PLAYER_ADD_HERO_TRIGGER = 1 WEEK_OF_ORC = 21
PLAYER_REMOVE_HERO_TRIGGER = 2 WEEK_OF_RAVEN = 22
OBJECTIVE_STATE_CHANGE_TRIGGER = 3 WEEK_OF_BADGER = 23
OBJECT_TOUCH_TRIGGER = 4 WEEK_OF_FLAMINGO = 24
OBJECT_CAPTURE_TRIGGER = 5 WEEK_OF_TORTOISE = 25
REGION_ENTER_AND_STOP_TRIGGER = 6 WEEK_OF_LYNX = 26
25
Other IDs
WEEK_OF_PENGUIN = 27 WEEK_OF_GRIFFIN = 87
SCRIPT FILE LAYOUT
WEEK_OF_FALCON = 28 WEEK_OF_PRIEST = 88
WEEK_OF_HEDGEHOG = 29 WEEK_OF_CAVALIER = 89
WEEK_OF_SPARROW = 30 WEEK_OF_ANGEL = 90
WEEK_OF_SWALLOW = 31 WEEK_OF_GREMLIN = 91
WEEK_OF_LION = 32 WEEK_OF_GARGOYLE = 92
WEEK_OF_SPEARS = 33 WEEK_OF_GOLEM = 93
WEEK_OF_BEAR = 34 WEEK_OF_MAGI = 94
WEEK_OF_CHIEFTAIN = 35 WEEK_OF_GENIE = 95
WEEK_OF_CENTAUR = 36 WEEK_OF_RAKSHASA = 96
WEEK_OF_GOBLIN = 37 WEEK_OF_GIANT = 97
WEEK_OF_DEER = 38 WEEK_OF_PIXIE = 98
WEEK_OF_OWL = 39 WEEK_OF_WARDANCER = 99
SYNTAX
WEEK_OF_CALM = 66
WEEK_OF_HOPE = 67
WEEK_OF_WATER = 68
WEEK_OF_FIRE = 69 8.27. Animation Action Types
WEEK_OF_EARTH = 70 INVISIBLE = 0
WEEK_OF_AIR = 71 IDLE = 1
WEEK_OF_FIRENICE = 72 ONESHOT_STILL = 2
WEEK_OF_MIGHT = 73 ONESHOT = 3
HERO IDs
WEEK_OF_BALANCE = 74 MOVE = 4
WEEK_OF_MIGHTNMAGIC = 75 NON_ESSENTIAL = 5
WEEK_OF_INFIRMITY = 76
WEEK_OF_LIGHT = 77
WEEK_OF_EVOCATION = 78
WEEK_OF_ABJURATION = 79 8.28. Disabled interactive objects modes
OTHER IDs
WEEK_OF_ALTERATION = 80 DISABLED_DEFAULT = 0
WEEK_OF_CONJURATION = 81 DISABLED_ATTACK = 1
WEEK_OF_ETHER = 82 DISABLED_INTERACT = 2
WEEK_OF_TOUGHNESS = 83 DISABLED_BLOCKED = 3
WEEK_OF_PEASANT = 84
WEEK_OF_ARCHER = 85
WEEK_OF_FOOTMAN = 86
26
Other IDs
8.29. Region Auto Action modes CREATURE_ARCHANGEL = 14
SYNTAX
CREATURE_DEVIL = 27
NOTE: for SetHeroRoleMode(heroName,roleMode) script CREATURE_ARCHDEVIL = 28
commmand CREATURE_SKELETON = 29
HERO_ROLE_MODE_REGULAR = 0 CREATURE_SKELETON_ARCHER = 30
HERO_ROLE_MODE_FREEMAN = 1 -- always CREATURE_WALKING_DEAD = 31
Freelancer CREATURE_ZOMBIE = 32
VARIABLES
HERO_ROLE_MODE_HERMIT = 2 -- always CREATURE_MANES = 33
Freelancer, never interact with CREATURE_GHOST = 34
other heroes CREATURE_VAMPIRE = 35
CREATURE_VAMPIRE_LORD = 36
CREATURE_LICH = 37
CREATURE_DEMILICH = 38
8.32. Players Teams constants
FUNCTIONS
CREATURE_WIGHT = 39
PLAYERS_TEAM_1 = 1 CREATURE_WRAITH = 40
PLAYERS_TEAM_2 = 2 CREATURE_BONE_DRAGON = 41
PLAYERS_TEAM_3 = 3 CREATURE_SHADOW_DRAGON = 42
PLAYERS_TEAM_4 = 4 CREATURE_PIXIE = 43
PLAYERS_TEAM_5 = 5 CREATURE_SPRITE = 44
PLAYERS_TEAM_6 = 6 CREATURE_BLADE_JUGGLER = 45
PLAYERS_TEAM_7 = 7 CREATURE_WAR_DANCER = 46
TRIGGERS
PLAYERS_TEAM_8 = 8 CREATURE_WOOD_ELF = 47
CREATURE_GRAND_ELF = 48
CREATURE_DRUID = 49
CREATURE_DRUID_ELDER = 50
8.33. Game difficulty IDs CREATURE_UNICORN = 51
DIFFICULTY_EASY = 0 CREATURE_WAR_UNICORN = 52
DEBUGGING
DIFFICULTY_NORMAL = 1 CREATURE_TREANT = 53
DIFFICULTY_HARD = 2 CREATURE_TREANT_GUARDIAN = 54
DIFFICULTY_HEROIC = 3 CREATURE_GREEN_DRAGON = 55
CREATURE_GOLD_DRAGON = 56
CREATURE_GREMLIN = 57
CREATURE_MASTER_GREMLIN = 58
8.34. Creature IDs CREATURE_STONE_GARGOYLE = 59
CREATURE_UNKNOWN = 0 CREATURE_OBSIDIAN_GARGOYLE = 60
HERO IDs
CREATURE_PEASANT = 1 CREATURE_IRON_GOLEM = 61
CREATURE_MILITIAMAN = 2 CREATURE_STEEL_GOLEM = 62
CREATURE_ARCHER = 3 CREATURE_MAGI = 63
CREATURE_MARKSMAN = 4 CREATURE_ARCH_MAGI = 64
CREATURE_FOOTMAN = 5 CREATURE_GENIE = 65
CREATURE_SWORDSMAN = 6 CREATURE_MASTER_GENIE = 66
OTHER IDs
CREATURE_GRIFFIN = 7 CREATURE_RAKSHASA = 67
CREATURE_ROYAL_GRIFFIN = 8 CREATURE_RAKSHASA_RUKH = 68
CREATURE_PRIEST = 9 CREATURE_GIANT = 69
CREATURE_CLERIC = 10 CREATURE_TITAN = 70
CREATURE_CAVALIER = 11 CREATURE_SCOUT = 71
CREATURE_PALADIN = 12 CREATURE_ASSASSIN = 72
CREATURE_ANGEL = 13 CREATURE_WITCH = 73
27
Other IDs
CREATURE_BLOOD_WITCH = 74 CREATURE_FIREBREATHER_HOUND = 133
SCRIPT FILE LAYOUT
28
Other IDs
8.36. Spell IDs SPELL_DEATH_SCREAM = 59;
SYNTAX
SPELL_SLOW = 12; SPELL_SKILL_FRENZY = 72;
SPELL_DISRUPTING_RAY = 13; SPELL_SKILL_DEFENCE1 = 73;
SPELL_PLAGUE = 14; SPELL_SKILL_DEFENCE2 = 74;
SPELL_WEAKNESS = 15; SPELL_SKILL_DEFENCE3 = 75;
SPELL_ABILITY_WEAKNING_STRIKE = 16; SPELL_SKILL_PROTECTION = 76;
SPELL_FORGETFULNESS = 17; SPELL_SKILL_EVASION = 77;
VARIABLES
SPELL_BERSERK = 18; SPELL_SKILL_TOUGHNESS = 78;
SPELL_BLIND = 19; SPELL_SKILL_LUCK1 = 79;
SPELL_HYPNOTIZE = 20; SPELL_SKILL_LUCK2 = 80;
SPELL_UNHOLY_WORD = 21; SPELL_SKILL_LUCK3 = 81;
SPELL_UNHOLY_WORD_HIT_EFFECT = 22; SPELL_SKILL_RESISTANCE = 82;
SPELL_BLESS = 23; SPELL_SKILL_LUCKY_STRIKE = 83;
FUNCTIONS
SPELL_HASTE = 24; SPELL_SKILL_LEADERSHIP1 = 84;
SPELL_STONESKIN = 25; SPELL_SKILL_LEADERSHIP2 = 85;
SPELL_DISPEL = 26; SPELL_SKILL_LEADERSHIP3 = 86;
SPELL_DISPEL_FAIL = 27; SPELL_SKILL_WAR_MACHINES1 = 87;
SPELL_BLOODLUST = 28; SPELL_SKILL_WAR_MACHINES2 = 88;
SPELL_DEFLECT_ARROWS = 29; SPELL_SKILL_WAR_MACHINES3 = 89;
SPELL_DEFLECT_ARROWS_HIT_EFFECT = 30; SPELL_SKILL_FIRST_AID = 90;
SPELL_ANTI_MAGIC = 31; SPELL_SKILL_BALLISTA = 91;
TRIGGERS
SPELL_TELEPORT = 32; SPELL_SKILL_CATAPULT = 92;
SPELL_TELEPORT_FINISH_EFFECT = 33; SPELL_SKILL_DEMONIC_FIRE = 93;
SPELL_CELESTIAL_SHIELD = 34; SPELL_SKILL_ELVEN_VOLLEY = 94;
SPELL_HOLY_WORD = 35; SPELL_SKILL_MATRON_SALVO = 95;
SPELL_HOLY_WORD_HIT_EFFECT = 36; SPELL_SKILL_ANCIENT_SMITHY = 96;
SPELL_ARMAGEDDON_HIT_EFFECT = 37; SPELL_SKILL_FIRE_PROTECTION = 97;
DEBUGGING
SPELL_LAND_MINE = 38; SPELL_SPEC_JOUSTER = 98;
SPELL_WASP_SWARM = 39; SPELL_SPEC_PEASANTS = 99;
SPELL_PHANTOM = 40; SPELL_SPEC_ARCHERS = 100;
SPELL_EARTHQUAKE = 41; SPELL_SPEC_FOOTMEN = 101;
SPELL_ANIMATE_DEAD = 42; SPELL_SPEC_GRIFFINS = 102;
SPELL_SUMMON_ELEMENTALS = 43; SPELL_SPEC_ARTILLERYMAN = 103;
SPELL_EFFECT_SUMMON_ELEMENTALS_AIR = 44; SPELL_SPEC_FURIOUS = 104;
SPELL_EFFECT_SUMMON_ELEMENTALS_EARTH = 45; SPELL_SPEC_BOMBARDIER = 105;
HERO IDs
29
Other IDs
SPELL_SPEC_MASTER_OF_ELEMENTS = 119; SPELL_EFFECT_ARMOR_CRUSHING = 179;
SCRIPT FILE LAYOUT
30
Other IDs
SPELL_DEMON_SOVEREIGN_FX = 239; SPELL_BLADE_BARRIER = 284;
SYNTAX
VARIABLES
FUNCTIONS
TRIGGERS
DEBUGGING
HERO IDs
OTHER IDs
31
OTHER IDs HERO IDs DEBUGGING TRIGGERS FUNCTIONS VARIABLES SYNTAX SCRIPT FILE LAYOUT Hero IDs
32
www.celestialheavens.com
Visit Celestial Heavens online