Skip to content

Posts from Scripts

4.8 (8 ratings)
Auto-translated
No, the scripts still don't work. What's the problem? Could you take a look, if possible?
Attachments 1
1 file attached • Total size: 1.2 KB
In reply to Аскет2
User Avatar
Auto-translated
Aскет2
No, the scripts still don't work. What's the problem? Could you take a look if possible?

You need to unlock the console in the game, and it will show you exactly what the problem is with the script. There's no need to post the entire script here every time.

Regarding the script, I took a quick look and noticed this:
function SetPlayerStartResources (player, wood, ore, mercury, crystal, sulfur, gem, gold)
if player == 1
then wood = 20
ore = 20
mercury = 10
crystal = 15
sulfur = 10
gem = 10
gold = 15000
end
end

What is this? Reinventing the wheel, and doing it wrong.
SetPlayerStartResources (1, 20, 20, 10, 15, 10, 10, 15000)

--without any function, etc.
Maybe it's simpler this way?

And yes, what is this function for?
function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1)
end
If it's what I think it is, it can be done much simpler and clearer, without any loops
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
Auto-translated
Well, the main thing is that it works.
In reply to Аскет2
User Avatar
Auto-translated
Aescet2
Well, the main thing is that it works.

Just for general information, there is a trigger that reacts to the player losing a hero. You can make it so that if "that specific" hero is lost, the player immediately loses the game.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
Auto-translated
Although, to be honest, nothing works.
User Avatar
Auto-translated
function gnom (heroname)
if heroname == "Hero9"
then MessageBox (GetMapDataPath().."ha.txt")
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "Ha", nil);
end;
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "Ha", "ha"); ```
Here's another error. The script contains two functions named "gnom," but only one function named "ha." This could have been checked independently.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
Auto-translated
I'm a newbie. I forgot to add this to the map.xdb file: ``

Added 1 minute ago
``

Added 35 seconds ago
Basically, I forgot about the line, so the scripts weren't working.

Added 2 minutes ago
I've already fixed it.
In reply to Аскет2
User Avatar
Auto-translated
function QuestPervii ()
if HasArtefact ("Hero9", "TOME_OF_DESTRUCTION") without quotes, incorrect id
then MessageBox (GetMapDataPath().."QuestPervii.txt")
ChangeHeroStat ("Hero9", STAT_DEFENSE, 7) STAT_DEFENCE
RemoveArtefact ("Hero9", "TOME_OF_DESTRUCTION") without quotes, incorrect id
Trigger(OBJECT_TOUCH_TRIGGER, "Pervii", nil)
else MessageBox (GetMapDataPath().."LoseL.txt")
end;
end;
function QuestVtoroi ()
if HasArtefacts ("Hero9", "SKULL_OF_MARKAL") incorrect function name, id without quotes, incorrect id
then MessageBox (GetMapDataPath().."QuestVtoroi.txt")
ChangeHeroStat ("Hero9", STAT_OFFENCE, 7)
RemoveArtefact ("Hero9", "SKULL_OF_MARKAL" ) without quotes, incorrect id
Trigger(OBJECT_TOUCH_TRIGGER, "Vtoroi", nil)
else MessageBox (GetMapDataPath().."LoseLI.txt")
end;
end;

function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1)
remove, so as not to confuse anyone

end
Trigger(OBJECT__TRIGGER, 'X', 'capture_town')  incorrect trigger id, pointer to a non-existent function
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
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 more convenient to use.

Added 3 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")
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
In reply to MasteR
User Avatar
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
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
Nargott wouldn't approve.
In Notepad++, where I write scripts, for example, when I type the first letters of a constant, a list of words from the file is suggested, and I just have to choose one. This reduces the chance of making a mistake.

Added 2 minutes later


The second one will trigger with any loss of a hero by the player, the first one - only upon death.

That's true. But in this specific case, loss = death and death = loss. If there were any transfers of a hero from one owner to another or something like that, then yes, there would be a difference. And even then, the trigger can be disabled at any time.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
Auto-translated
How can I make it so that the border guard demands money for further passage?
In reply to Аскет2
User Avatar
Auto-translated
function borderGuard() QuestionBox("link to text with question", "bgok") end function bgok() local gold = GetPlayerResource(1, GOLD) if gold >= amount_of_gold then SetPlayerResource(1, GOLD, gold - amount_of_gold) RemoveObject("script name of border guard") else MessageBox("link to text with notification about lack of resources") end end SetObjectEnabled("script name of border guard", nil) Trigger(4, "script name of border guard", "borderGuard")
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
Auto-translated
So, you can place any creature regardless of its color, right?

Statistics

Welcome our newest member: Emil