Skip to content

Posts from Scripts for beginners. Auto-translated

4.5 (2 ratings)
User Avatar
#226
Auto-translated
How to create infinite action points in a script for all 8 players.
In reply to _De1My_
User Avatar
#227
Auto-translated
_De1My_
How to create infinite action points in a script for all 8 players
I would suggest using the following loop:
while 1 do
for player = PLAYER_1, PLAYER_8 do
if GetPlayerState(player) == PLAYER_ACTIVE then
for i, hero in GetPlayerHeroes(player) do
ChangeHeroStat(hero, STAT_MOVE_POINTS, 10000)
end
end
end
sleep()
end
Нет войне.
User Avatar
#228
Auto-translated
Thank you very much, everything is working now.

Added 4 minutes later
And one more thing, how do I make it so that at the beginning of the game, there is a week of gold?
User Avatar
#229
Auto-translated
There are no scripts for this, but you can try another method: copy the file data/GameMechanics/MoonCalendar/Default into your map. It will contain lines like this:

    WEEK_OF_PLAGUE
    WEEK_OF_IDLENESS
    WEEK_OF_TREANT
    WEEK_OF_TOAD
    WEEK_OF_MAGIC
Change the very first entry to WEEK_OF_GOLD. Then, in the editor, set the map property RandomMoons to false. The downside is that all weeks will become non-random and will follow the sequence from the specified file.
Нет войне.
User Avatar
#230
Auto-translated
Is there a way to make it so that in the Haven castle, you can train 20-40 thousand creatures?

Added after 22 hours 0 minutes
How do you make the training cost 1 coin per unit?
#231
Auto-translated
Hello everyone! I have a question: how do I create a local script for an object (garrison, mine, etc.) so that upon capturing it (once), it grants a reward (e.g., experience, creatures, resources)? Thank you!
In reply to RamZZes
User Avatar
#232
Auto-translated
RamZZes
Hello everyone! I have a question: how do I create a local script for a specific object (garrison, mine, etc.) so that upon capturing it (once), it grants a reward (e.g., experience, creatures, resources)? Thank you!

Good afternoon. This type of question has been discussed many times in the Scripts topic. I recommend searching there, or, as a universal tip for this and 100+ other similar questions, you can take someone's map where this is already implemented and examine the script.
Кампании для Heroes V 3.1 (Трилогия):

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

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

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


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


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

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

Легендарная война
Сердце вулкана
Передел мира
#234
Auto-translated
Good afternoon! Colleagues, could you suggest a script for the following event: When entering a region, a battle begins with 6 Crystal Dragons. I created something like this (see below), but it doesn't work. ``` function Def( heroname ) if heroname == hero then StartCombat(hero,nil,1,CREATURE_CRYSTAL_DRAGON,6,nil,nil,nil,nil); Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", nil ); end; end; Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", "Def" );
User Avatar
#235
Auto-translated
Look at the hero's script name in its settings (Select => Space => Settings => Script name). And replace "hero" with this name. That is:
function Def( heroname )
if heroname == hero then
StartCombat(hero,nil,1,CREATURE_CRYSTAL_DRAGON,6);
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", nil );
end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", "Def" );
Since you left the last 4 parameters as nil, you can simply omit them.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
#236
Auto-translated
I also recommend checking the console if the code doesn't work; the error message there often holds the key to solving the problem.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
#237
Auto-translated
}{0TT@6bI4
I also recommend checking the console if the code doesn't work, as the error there is often the key to solving the problem.
That's where I saw that the script (check button) wasn't working.

There was a message that the line `function Def(heroname)` is not defined
and the line `function CREATURE_CRYSTAL_DRAGON` is not defined

Added 1 minute ago
}{0TT@6bI4
Look at the script name of the hero in its settings (Select => Space => Settings => Script name). And replace `hero` with this name.
That is:
function Def(heroname)
if heroname == hero then
StartCombat(hero,nil,1,CREATURE_CRYSTAL_DRAGON,6);
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "def", nil);
end;
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "def", "Def");

Since you left the last 4 parameters as nil, you can simply not specify them.

But I need any hero, except for the heroes of the Forest Pact, to enter into combat when entering the area
User Avatar
#238
Auto-translated
Do not confuse the editor log and the game console. You can find instructions on how to unlock it online. I also recommend using a dedicated script editor => https://yadi.sk/d/W6cz5UBu3SGAvb. It is more stable and works better, plus it is more convenient. You need to create a table of script names for the Elven heroes:
preserve_heroes={"Name", "Name1", ..., "Name7"}.
Then, in the function:
function Def(heroname)
for key, name in preserve_heroes do
if name==heroname then
local PreserveHero=1
end
end
if not PreserveHero then
StartCombat(...)
end
...
end

Trigger...
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
#239
Auto-translated
}{0TT@6bI4
Don't confuse the log editor and the game console. You can find instructions on how to unlock it online. I also recommend using a dedicated script editor => https://yadi.sk/d/W6cz5UBu3SGAvb. It doesn't crash and works better, plus it's more convenient. You need to create a table of script names for the Elven heroes:
preserve_heroes={"Name", "Name1", ..., "Name7"}.
Then, in the function:
function Def(heroname)
for key, name in preserve_heroes do
if name==heroname then
local PreserveHero=1
end
end
if not PreserveHero then
StartCombat(...)
end
...
end

Trigger...

Thank you!
In reply to }{0TT@6bI4
#240
Auto-translated
}{0TT@6bI4
Don't confuse the log editor with the game console. You can find instructions on how to unlock it online. I also recommend using a dedicated script editor => https://yadi.sk/d/W6cz5UBu3SGAvb. It's more stable, works better, and is more convenient. You need to create a table of script names for the elf heroes:
preserve_heroes={"Name", "Name1", ..., "Name7"}.
Then, in the function:
function Def(heroname)
for key, name in preserve_heroes do
if name==heroname then
local PreserveHero=1
end
end
if not PreserveHero then
StartCombat(...)
end
...
end

Trigger...

Good afternoon!

As a result, I got the following script:

preserve_heroes={"Elleshar", "Linaas", "Gillion", "Diraya", "Itil", "Ossir", "Nadaur"}
function Def( heroName )
for key, name in preserve_heroes do
if name == heroName then
local PreserveHero=1
end;
end;
if not PreserveHero then
         StartCombat(heroName, "Metlirn",7,44,24,146,80,148,16,147,48,50,16,48,48,44,24)
     end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", "Def" );

It intercepts all heroes without exception...
I even tried having Ilfina ("Itil") enter the region, and a battle starts, and the console displays the message: Value was NIL when getting global with name 'PreserveHero'
User Avatar
#241
Auto-translated
Okay, try it like this: preserve_heroes={"Elleshar", "Linaas", "Gillion", "Diraya", "Itil", "Ossir", "Nadaur"} function Def( heroName ) PreserveHero=0 for key, name in preserve_heroes do if name == heroName then PreserveHero=1 end; end; if PreserveHero==0 then StartCombat(heroName, "Metlirn",7,44,24,146,80,148,16,147,48,50,16,48,48,44,24) end; end; Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", "Def" );
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________