Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
Try using the KnowHeroSpell(heroName, spell) function; I haven't used it, but I recommend giving it a try. Example: KnowHeroSpell(Raelag, 16, nil); Or, instead of nil, put false.
Создаётся карта "Забытый Авангард (готовность 80%)
In reply to AkaR
User Avatar
Auto-translated
AkaR
Try using the KnowHeroSpell(heroName, spell) function;
I haven't used it, but I recommend trying it. Example:

KnowHeroSpell(Raelag, 16, nil);

Or instead of nil, put false.
That's not true. The function checks if a hero knows a spell.

Added 2 minutes later
Juss456
Perhaps this question has already been asked: how to ban a specific skill for heroes on a map?
There is no civilized way to do this.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Then, the only option left is TeachHeroSpell(heroName, spell);
Again, I'm not sure, but you can try it. Example:

TeachHeroSpell(Raelag, 16, nil);
Создаётся карта "Забытый Авангард (готовность 80%)
In reply to AkaR
User Avatar
Auto-translated
AkaR
Then the only option left is TeachHeroSpell(heroName, spell);
Again, I'm not sure, but it's worth a try :) Example:

TeachHeroSpell(Raelag, 16, nil);
Nope, that's not it either. This already teaches the hero a spell.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
sta=GetHeroStats(vh, 7);
ChangeHeroStat(vh, 7, -sta);

why isn't this piece of the function working and how do I fix it?

vh is a variable containing the hero's name. The idea is to reset the hero's move points

Added after 50 minutes
Another question: Is there a function that returns an array of creature IDs in the hero's army?
Кампании для 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
Juss456
sta=GetHeroStats(vh, 7);
ChangeHeroStat(vh, 7, -sta);

why isn't this piece of the function working and how do I fix it?

vh is a variable containing the hero's name. The idea is to reset the hero's move points

Added after 50 minutes
Another question: Is there a function that returns an array of creature IDs in the hero's army?
1) extra s. Not Stats, but Stat
2) array — no, there is a function that returns a list with IDs:
_1, _2, _3, _4, _5, _6, _7 = GetHeroCreaturesTypes(hero)
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
1) лишняя s. Not Stats, but Stat
2) массив — нет, there is a function that returns a list with IDs:
_1, _2, _3, _4, _5, _6, _7 = GetHeroCreaturesTypes(hero)

Thank you. But this snippet doesn't work for me. The console displays something like "invalid ID=0 (arg1)".

c1, c2, c3, c4, c5, c6, c7=GetHeroCreaturesTypes(heroname);
sleep(1);
if c1~=nil then
c11=GetHeroCreatures(heroname, c1);
else c11=0;
end;
if c2~=nil then
c22=GetHeroCreatures(heroname, c2);
else c22=0;
end;
if c3~=nil then
c33=GetHeroCreatures(heroname, c3);
else c33=0;
end;
if c4~=nil then
c44=GetHeroCreatures(heroname, c4);
else c44=0;
end;
if c5~=nil then
c55=GetHeroCreatures(heroname, c5);
else c55=0;
end;
if c6~=nil then
c66=GetHeroCreatures(heroname, c6);
else c66=0;
end;
if c7~=nil then
c77=GetHeroCreatures(heroname, c7);
else c77=0;
end;
sleep(1);
if c11~=0 then
RemoveHeroCreatures(heroname, c1, intg(c11*0.33));
end;
if c22~=0 then
RemoveHeroCreatures(heroname, c2, intg(c22*0.33));
end;
if c33~=0 then
RemoveHeroCreatures(heroname, c3, intg(c33*0.33));
end;
if c44~=0 then
RemoveHeroCreatures(heroname, c4, intg(c44*0.33));
end;
if c55~=0 then
RemoveHeroCreatures(heroname, c5, intg(c55*0.33));
end;
if c66~=0 then
RemoveHeroCreatures(heroname, c6, intg(c66*0.33));
end;
if c77~=0 then
RemoveHeroCreatures(heroname, c7, intg(c77*0.33));
end;
Кампании для 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
Juss456
Thank you! But this snippet doesn't work for me. The console displays something like "invalid ID=0 (arg1)".

c1, c2, c3, c4, c5, c6, c7 = GetHeroCreaturesTypes(heroname);
sleep(1);
if c1 ~= nil then
c11 = GetHeroCreatures(heroname, c1);
else c11 = 0;
end;
if c2 ~= nil then
c22 = GetHeroCreatures(heroname, c2);
else c22 = 0;
end;
if c3 ~= nil then
c33 = GetHeroCreatures(heroname, c3);
else c33 = 0;
end;
if c4 ~= nil then
c44 = GetHeroCreatures(heroname, c4);
else c44 = 0;
end;
if c5 ~= nil then
c55 = GetHeroCreatures(heroname, c5);
else c55 = 0;
end;
if c6 ~= nil then
c66 = GetHeroCreatures(heroname, c6);
else c66 = 0;
end;
if c7 ~= nil then
c77 = GetHeroCreatures(heroname, c7);
else c77 = 0;
end;
sleep(1);
if c11 ~= 0 then
RemoveHeroCreatures(heroname, c1, intg(c11 * 0.33));
end;
if c22 ~= 0 then
RemoveHeroCreatures(heroname, c2, intg(c22 * 0.33));
end;
if c33 ~= 0 then
RemoveHeroCreatures(heroname, c3, intg(c33 * 0.33));
end;
if c44 ~= 0 then
RemoveHeroCreatures(heroname, c4, intg(c44 * 0.33));
end;
if c55 ~= 0 then
RemoveHeroCreatures(heroname, c5, intg(c55 * 0.33));
end;
if c66 ~= 0 then
RemoveHeroCreatures(heroname, c6, intg(c66 * 0.33));
end;
if c77 ~= 0 then
RemoveHeroCreatures(heroname, c7, intg(c77 * 0.33));
end;
If a slot is empty, the corresponding element is not nil, but 0. Therefore, ~=nil should be replaced with ~=0.
The idea is to remove one-third of the army? Then there is a shorter script.
for i=0,6 do
local t, n = GetObjectArmySlotCreature(heroname, i)
if t ~= 0 then
RemoveHeroCreatures(heroname, t, n/3)
end
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
If the slot is empty, then the corresponding element is not nil, but 0. Therefore, ~=nil should be replaced with ~=0.
The idea is to remove one-third of the army? Then there is a shorter script.
for i=0,6 do
local t, n = GetObjectArmySlotCreature(heroname, i)
if t ~= 0 then
RemoveHeroCreatures(heroname, t, n/3)
end
end

thank you)) And if n/3 is not an integer, will it throw an error? Or should I still use the intg() function?
Кампании для 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
Juss456
thank you)) And if n/3 is not a whole number, will it throw an error? Or will it still apply the intg() function?
It won't. The functions for army operations round the numbers themselves.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
It won't happen. The functions for army operations round the numbers automatically.

It worked! However, when a hero has only one creature in a particular slot, the function resets, and an error occurs (the number cannot be negative). And probably the last question: how can I, at certain moments, transfer control to another (main) hero from the player (human)? (I mean, move the camera from the secondary hero to the main one and highlight him).
Кампании для 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
Juss456
It worked! However, when a hero has only one creature in a particular slot, the function resets, and an error occurs (the number cannot be negative). And probably the last question: how to transfer control to another (main) hero at certain moments. (I.e., move the camera from the secondary hero to the main one and highlight him).
Then you need to use not intg, but ceil.
You can move the camera, but you won't be able to highlight him with a frame.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
Auto-translated
Good day!

Please help me write a script that, each day, increases the number of units in a specified garrison (for example, +10 for the first slot, +5 for the second, +2 for the third).

Thank you in advance.
In reply to Incorer
User Avatar
Auto-translated
Incorer
Good afternoon!

Please help me write a script that increases the number of units in a specified garrison each day (for example, +10 for the first slot, +5 for the second, +2 for the third).

Thank you in advance.
function newday()
local add = {[0]=10; 5, 2}
for i=0,6 do
local type, number = GetObjectArmySlotCreature("script name of the garrison", i)
if type ~= 0 and addthen
AddObjectCreatures("script name of the garrison", type, add)
end
end
end
Trigger(0, "newday")
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Are there any interceptors for console commands?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...

Statistics

Welcome our newest member: Emil