Skip to content
User Avatar
#2032
Auto-translated
MasteR
To avoid dealing with various constants like REGION_ENTER_AND_STOP_TRIGGER or TOME_OF_DESTRUCTION, it's better to replace them with numbers (all numbers are listed in the document IDs for scripts). This makes the code more compact and helps avoid several errors that are almost unnoticeable during debugging.

For example, the codes
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "Gnom", "gnom")
and
Trigger(6, "Gnom", "gnom")
work the same, but the second entry is much easier to use.
Nargott wouldn't approve.
In Notepad++, where I write scripts, for example, when you enter the first letters of a constant, a list of words from the file is suggested, and you just need to choose one. This reduces the chance of making a mistake.

Added 2 minutes later
function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1)
end

function alive(heroname)
if heroname=="Hero9" then
Loose()
end
end
Trigger(2, 1, "alive")
I need a script so that the mission fails after a hero dies. Thanks in advance.
The second one will work for any hero loss, the first one - only for death/escape.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4

Statistics

Welcome our newest member: leyu