Skip to content

Scripts for beginners.

User Avatar
#335
Auto-translated
Azgalor

Well, basically it's easy. We reserve a Necromancer hero, create a quest to keep the main hero alive (OBJECTIVE_KIND_MANUAL) to control his actions through scripts. In the scripts, we'll write something like this:

NowNecromancer = 0 --Condition that we'll set 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 keep the main hero alive
sleep(10) --Give the player time to see the quest failure and realize that they've lost the main hero
Loose() --Fail the mission, because our hero died before becoming a Necromancer
elseif ( heroName == Duncan ) and NowNecromancer == 1 then --We lose the hero, but we have the condition that we are now a Necromancer, so we don't lose
print("Everything is okay, the condition is met. He died, and that's that. 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, the condition that we made him a Necromancer is met
SetObjectiveState("script name of the quest", OBJECTIVE_FAILED) --Fail the quest to keep the main hero alive
sleep(10) --Give the player time to see the quest failure and realize that they've lost the main hero
Loose() --Fail the mission, because our hero died after becoming a Necromancer
end
end

function TransformToNecromancer() --Here we'll specify what happens after the main hero becomes a Necromancer. Where it will be called from is up to you
--All sorts of things from the author, who knows what conditions he has?
NowNecromancer = 1 --Set the condition so that the game doesn't fail after deleting the main hero
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 delete the main hero
end

Trigger(PLAYER_REMOVE_HERO_TRIGGER, PLAYER_1, "prim_save_gg") --Trigger to track the player's hero losses for PLAYER_1

Try it)

Okay, comrade Azgalor, I tested the script and have some disappointing news - the script doesn't work. If I write NowNecromanser = 0 at the beginning of the script, the rest of the script doesn't work

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

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

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