Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Heroist
User Avatar
Auto-translated
SetHeroRoleMode('hero name', HERO_ROLE_MODE_HERMIT)
This should, in theory, prevent AI heroes from interacting with each other.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Wow, I'll try it now.

Added 22 minutes later
Excellent! You helped me out again. Thank you very much. It seems to be working as expected:
a) Hero 0 tiles away from the town: The AI hid him in the garrison, and he's working as a defender.
b) Hero 1 tile away from the town: The AI completely ignores him. Everything worked perfectly.

Added 21 minutes later
Maybe someone can tell me more about the AI behavior types?

warrior - warrior? Obviously, aggressively runs towards the player.
builder - builder. Probably builds a castle and gathers resources.
explorer - scout, explorer? Runs around the map the whole game?
hunter - hunter? Kills low-level heroes?!
victim - ???

Whatever
In reply to Heroist
User Avatar
Auto-translated
victim - probably waiting for someone to finish him off :D
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Google Translate is a victim. It seems that different personalities are activated here depending on the situation...

Whatever
In reply to Heroist
User Avatar
Auto-translated
Is it possible to obtain the script name of a creature located at specified coordinates?
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля
User Avatar
Auto-translated
Not sure. You can create a region and call the GetObjectsInRegion function. Or you can write a function that does what you need manually, by getting the names of all the monsters on the map and checking the coordinates of each one in a loop.
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
I spawned monsters using a loop, so there's no need to get all the monster names, at least that's what I think.
Here's the script:
for x=66,67 do
for y=127,159 do
if IsTilePassable(x, y, 0)==1 then
CreateMonster ("name"..i, 32, 1, x, y, 0,1,2,270)

if x==67 and y==130 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==67 and y==154 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==66 and y==155 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
i=i+1
end
end
end

That is, the result should be monsters standing in a rectangle, some of them dead. However, the game doesn't play the death animation for creatures at the checked coordinates, and the console says that a monster with the name name(...) was not found.
If I put a sleep between CreateMonster and the checks, the monsters don't spawn in a rectangle, but are scattered randomly according to some unclear principle. What could be the problem?
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля
In reply to Олегарх
User Avatar
Auto-translated
Oligarch
I spawned monsters through a loop, so there is no need to get all the monster names, at least I think so.
Here is the script:
for x=66,67 do
for y=127,159 do
if IsTilePassable(x, y, 0)==1 then
CreateMonster ("name"..i, 32, 1, x, y, 0,1,2,270)

if x==67 and y==130 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==67 and y==154 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==66 and y==155 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
i=i+1
end
end
end

That is, as a result, it should produce monsters standing in a rectangle, some of them dead. At the same time, the game does not play the death animation for creatures at the checked coordinates; the console says that a monster with the name name(...) was not found.
If I put sleep between CreateMonster and the checks, the monsters spawn not in a rectangle, but randomly according to some unclear principle. What could be the problem?
for x=66,67 do
for y=127,159 do
startThread(function(int)
local name="name"..int
CreateMonster(name, 32, 1, %x, %y, 0, 1, 2, -90)
sleep(1)
SetObjectPosition(name, %x, %y, 0)
if (%x==67 and %y==130) or (%x==67 and %y==154) or (%x==66 and %y==155) then
PlayObjectAnimation(name, "death", ONESHOT_STILL)
end
end, i)
i=i+1
end
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
Thank you! What is the difference between x and %x? And I didn't even realize that you could write: startThread(function(int) end, i) Now I know. As I understand it, this is a call to a thread that is inside the function body, with the argument i passed as a number?
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля
In reply to Олегарх
User Avatar
Auto-translated
Olegarkh
Thank you! What is the difference between x and %x?
For this unnamed function, x and y are external local variables, and you need to put % before them; otherwise, there will be an error.

Added 2 minutes later
Olegarkh

And I didn't know that you could write
startThread(function(int)
end, i)
Now I'll know. As I understand it, this is a call to a thread that is in the body of the function, passing the argument i as a number?
You can pass any parameters, not just numbers.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Don't bother reading the thread, just answer right away (it's a hundred pages long, sorry).
Maybe someone could kindly share an archive of scripts? Specifically, the ones that are "default Wog scripts," whether it's Market of Time or Casino. I would be very grateful.
User Avatar
Auto-translated
I don't understand... Are you looking for a library of scripts styled after WOG?
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Is there a way to bypass the problematic function in a script, so that if an error occurs, the script simply skips over it and continues execution?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
User Avatar
Auto-translated
Dyrman
Is there a "bypass" where a script that produces an error simply skips the problematic function and continues?
I searched and found this:

try
... (block) ...
end

If an error occurs in the block, the control immediately jumps to the first statement after END, and
the error will be ignored.

another form,

try
... (block) ...
catch err do
... (handler) ...
end
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля

Statistics

Welcome our newest member: Emil