Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
User Avatar
Auto-translated
Good day. I have a question: how can I make it so that when I defeat a specific hero, that hero is placed back on the map?

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
User Avatar
Auto-translated

BlueHeavenHero, you can add the hero to the player's reserve pool and then respawn him using a script when needed. I think you'll figure out how to add him to the reserve, but here's how to spawn the hero from the reserve: DeployReserveHero( "scripted hero name", x, y, surface/underground );

Important: Don't place a hero on the map who is in the reserve of any player, otherwise you will break the script.

If you need a script for respawning, you can use a check for hero loss by the player and spawn a reserve hero if that specific hero was killed. That is...

DeployReserveHero( "scripted hero name", x coordinate, y coordinate, surface/underground ); -- I don't know the idea, but let's assume that at the beginning of the game, we spawn a hero from the reserve as if he was initially placed on the map

function RespawnFromReserve( MyHero )
if MyHero == "scripted hero name" then
DeployReserveHero( "scripted hero name", x coordinate, y coordinate, surface/underground );
end
end

Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_player number to whom the hero belongs, "RespawnFromReserve") -- when the player loses heroes, we run a script in which we spawn the desired hero if he was lost
In reply to Азгалор
User Avatar
Auto-translated
Azgalor

BlueHeavenHero, you can add the hero to the player's reserve pool and then respawn him using a script when needed. I think you'll figure out how to add him to the reserve, and here's how to spawn the hero from the reserve: DeployReserveHero( "scripted hero name", x, y, surface/underground );

Important note: Don't place a hero on the map who is in the reserve of any player, otherwise you will break the script.

If you need a script for respawning, you can use a check for hero loss by the player and spawn a reserve hero if that specific hero was killed. That is...

DeployReserveHero( "scripted hero name", x coordinate, y coordinate, surface/underground ); -- I don't know the idea, but let's assume that at the beginning of the game, we spawn a hero from the reserve as if he was initially placed on the map

function RespawnFromReserve( MyHero )
if MyHero == "scripted hero name" then
DeployReserveHero( "scripted hero name", x coordinate, y coordinate, surface/underground );
end
end

Trigger( PLAYER_REMOVE_HERO_TRIGGER, PLAYER_player number to whom the hero belongs, "RespawnFromReserve") --when the player loses heroes, we run a script in which we spawn the desired hero if he was lost
Thank you for your help!

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
User Avatar
Auto-translated
Hello. This question might be off-topic, but how do you add mana to a hero? I want to give the final boss 300 mana.

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
User Avatar
Auto-translated
BlueHeavenHero
Hello. This might not be the right place to ask, but how do you add mana to a hero? I want to give the final boss 300 mana.
There are a few options:
1) Set the "knowledge" parameter to 30 in the editor.
2) Use the script ChangeHeroStat(Hero Name, 7, 300) (7 is the mana parameter).
3) You can also give it through a combat script, but that's too complicated; the first two examples work much more reliably.
Сценарий: "Наследие прошлого"
Кампании:
"
Новый порядок", "Серый Альянс""Поиски Истины"

Трейлер №2 кампании "Дыхание Пустоты": https://www.youtube.com/watch?v=XkHKXk5BctA&ab_channel=%D0%90ndrei_21

User Avatar
Auto-translated
Andrei_21, 7 represents movement points; mana is granted through STAT_MANA_POINTS, I don't remember the exact number. But I'm 100% sure that 7 represents movement points, as my constant command in the console is: @ChangeHeroStat(GetPlayerHeroes(1)[0], 7, 2500) biggrin
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
User Avatar
Auto-translated
The scenario is already 47% complete; only some design and scripting need to be finished. And now I'm stuck. According to the plot, the main character transforms into a Necromancer. How can I do this, while still keeping the survival challenge relevant?

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to AstralLein
User Avatar
Auto-translated
AstralLein
Implement the goal through a script. Disable the trigger linked to the previous hero's death at the appropriate moment, remove the hero, add a new one, and then enable the trigger linked to the new hero's death. This is one possible approach.
How exactly can this be done?

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

User Avatar
Auto-translated
Let's say this is the most standard check to see if the player's main hero is still alive.

Trigger(PLAYER_REMOVE_HERO_TRIGGER, player number, "script")

function script(hero)
if (hero == "hero") or (hero == "necromancer") then
Loose()
end
end

But I'm not sure you won't lose as soon as the initial hero disappears from the map, and besides, I think the necromancer appears from a reserve, not teleporting from somewhere on the edge of the map... so I suggest doing this:

necromant = 0, write this at the very beginning of the entire map script, on a separate line

At the beginning of the script with the hero replacement, write necromant = 1

Trigger(PLAYER_REMOVE_HERO_TRIGGER, 1, "Heroes")

function Heroes(hero)
if (hero == "hero 1") and necromant == 0 then
UnreserveHero("necromancer") if the necromancer appears from the reserve
Loose()
elseif (hero == "necromancer") then
UnreserveHero("necromancer") if the necromancer appears from the reserve
Loose()
end
end
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
In reply to BlueHeavenHero
User Avatar
Auto-translated
BlueHeavenHero
The scenario is already 47% complete; only some design and scripting need to be finished. And now I'm stuck. The plot involves the main hero transforming into a Necromancer. How can I do this in a way that keeps the survival objective relevant?

It's actually quite easy. Reserve a Necromancer hero, create a quest to save the main hero, but make it technically empty (OBJECTIVE_KIND_MANUAL) so you can control it through scripts. In the scripts, write something like this:

NowNecromancer = 0 --Condition that will be triggered when the hero becomes a Necromancer

function prim_save_gg( heroName ) --You can name this function differently; this is just for clarity.
if ( heroName == Duncan ) and NowNecromancer ~= 1 then --Duncan is used as an example. Insert the script name of your hero here.
SetObjectiveState("script name of the quest", OBJECTIVE_FAILED) --Fail the quest to save the main hero.
sleep(10) --Give the player time to see the quest failure and realize that they have lost the main hero.
Loose() --Fail the mission, as our hero died before becoming a Necromancer.
elseif ( heroName == Duncan ) and NowNecromancer == 1 then --We lose the hero, but because we now have the condition that we are a Necromancer, we don't lose.
print("Everything is okay, the condition is met. He died, and he died. It happens. Now I'm a Necromancer, maybe I'll go buy some skulls.")
end
if ( heroName == DuncanNecro ) and NowNecromancer == 1 then --Our hero is a Necromancer, and the condition that we made him a Necromancer has been met.
SetObjectiveState("script name of the quest", OBJECTIVE_FAILED) --Fail the quest to save the main hero.
sleep(10) --Give the player time to see the quest failure and realize that they have lost the main hero.
Loose() --Fail the mission, as our hero died after becoming a Necromancer.
end
end

function TransformToNecromancer() --Here, specify what will happen after the main hero becomes a Necromancer. Where it will be called from is up to you.
--Various things from the author; who knows what conditions he has?
NowNecromancer = 1 --Set the condition so that the game doesn't fail after the main hero is removed.
sleep(2) --Just in case, give the game time to process the information.
DeployReserveHero("DuncanNecro", x, y, GROUND/UNDERGROUND) --Place the new main hero so that the game doesn't fail if the player only has one hero and no castle with a tavern.
sleep(2) --Also, just in case, give the game time to process everything.
RemoveObject("Duncan") --Painlessly remove the main hero.
end

Trigger(PLAYER_REMOVE_HERO_TRIGGER, PLAYER_1, "prim_save_gg") --Trigger to track hero losses by player PLAYER_1.

Give it a try!

User Avatar
Auto-translated
Okay. What’s wrong with the MakeHeroNecromancer function? It turns any hero into a Necromancer with dark energy.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
User Avatar
Auto-translated
}{0TT@6bI4
Okay, but why isn't the MakeHeroNecromancer function suitable? It turns any hero into a necromancer with dark energy.
The main hero initially has dark energy and the necromancy skill, but he is a Knight class. I need this Knight to be removed from the map and replaced with a hero with the same name, but with a custom necromancer skin (taken from NHF and edited) and the Necromancer class.

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

User Avatar
Auto-translated
Hello everyone,
I'm new here, and I'd like to create maps with scripts.
Why am I writing here?
Because the script isn't working for some reason.
Here's the script:

function MakeHeroes()
DeployReserveHero("Itil", 127, 74, 0);
ChangeHeroStat("Itil", 0, 90000);
end;

Trigger(REGION_ENTER_AND_STOP_TRIGGER, "geroy", "MakeHeroes");

I just want a hero to spawn when I stand in a specific area.
I hope to get an answer.)
Damn, I hope I posted in the right topic.

Statistics

Welcome our newest member: Emil