Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
In reply to HeroOfDestiny
User Avatar
Auto-translated

HeroOfDestiny
I have a question! How do I make a hero stay in the castle?
We place the hero in the castle and write the following in the scripts: EnableHeroAI( "script name of the hero", nil )

In reply to Азгалор
User Avatar
Auto-translated
Azgalor

We place the hero in the castle and write in the scripts: EnableHeroAI( "scripted hero name", nil )

Thank you! But a problem arose here.

And what does this mean?
Value was NIL when getting global with name 'Ingvar'
Wrong type of argument 1, when calling function 'EnableHeroAI'
In reply to HeroOfDestiny
User Avatar
Auto-translated
HeroOfDestiny

Thank you! But a problem arose here.

Value was NIL when getting global with name 'Ingvar'
Wrong type of argument 1, when calling function 'EnableHeroAI'
I tried to pass a hero that isn't on the map to EnableHeroAI. Does the script name of the hero in the castle match what you wrote in the script?
In reply to Азгалор
User Avatar
Auto-translated
Azgalor
1. It works the same way as for a hero, but instead of Combat Script, you need to go lower in the city's properties and use the script string.
2. I don't know if it will work with Prayer, but try UnitCastGlobalSpell(GetDefenderHero(), SPELL_PRAYER). Don't forget to give the hero the Prayer skill.
3. StartDialogScene("link to the video", "function")
Thank you for your help.

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

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

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

In reply to Азгалор
User Avatar
Auto-translated
Azgalor
Tried to force a hero that doesn't exist on the map into the EnableHeroAI function. Does the script name of the hero in the castle match what you wrote in the script?

That's strange, the names match. I wrote the script in the town and just...
In reply to HeroOfDestiny
User Avatar
Auto-translated
HeroOfDestiny

It's strange that the names match; I wrote a script in the town and just...
Send me the map, and I'll take a look at what the problems are. If you want, you can send it to me in a private message.
User Avatar
Auto-translated


Here, I hope you'll figure it out.
P.s. I didn't understand how to send a private message with a file.
Attachments 1
1 file attached • Total size: 29.1 KB
User Avatar
Auto-translated

HeroOfDestiny, I wrote the hero's scripted name without parentheses in the scripts. And for some reason, I added a command to the hero's block for controlling the AI in the combat script. It won't work there.

Correct the line in the script to EnableHeroAI( "Ingvar", nil ) and remove it from the combat script altogether.

In reply to Азгалор
User Avatar
Auto-translated
Azgalor

HeroOfDestiny, I wrote the hero's scripted name in the scripts without parentheses. And for some reason, I added a command to the hero block for controlling the AI in the combat script. It won't work there.

Correct the line in the script to EnableHeroAI( "Ingvar", nil ) and remove it from the combat script altogether.


Oh, these scripts... I missed a sign, and the game immediately complains.
But as always, thank you!
In reply to Азгалор
User Avatar
Auto-translated
Azgalor

Well, basically it's easy. We reserve a Necromancer hero and create a quest to "save" the main hero, making it technically empty (OBJECTIVE_KIND_MANUAL) so we can control it 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; it's just for clarity
if ( heroName == Duncan ) and NowNecromancer ~= 1 then --Duncan is just an example. Replace it with the script name of your hero
SetObjectiveState("scripted quest name", OBJECTIVE_FAILED) --Fail the quest to save the main hero
sleep(10) --Give the player time to see the quest fail and realize 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 because we now have the condition that we're a Necromancer, we don't lose the game
print("It's okay, the condition is met. He died, and that's life. 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("scripted quest name", OBJECTIVE_FAILED) --Fail the quest to save the main hero
sleep(10) --Give the player time to see the quest fail and realize 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 define what happens after the main hero becomes a Necromancer. How it's called is up to you.
--It's up to the author to decide what the conditions are.
NowNecromancer = 1 --Set the condition so 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 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 when the player loses a hero (PLAYER_1)

Give it a try)

Hello. I wrote this script to save the main hero and transform him into a Necromancer, like yours, but I changed "Duncans" and "NecroDuncans" to my own script names. Will this work? I have a feeling it won't.
NowNecromancer = 0
function PrimSaveGG(heroName)
if (heroName == Hafad) and NowNecromanser ~= 1
then SetObjectiveState("prim1", OBJECTIVE_FAILED)
sleep(10)
Loose()
elseif (heroName == Hafad) and NowNecromanser == 1
end;
if (heroName == HafadNecro) and NowNecromanser == 1
then SetObjectiveState("prim1", OBJECTIVE_FAILED)
sleep(10)
Loose()
end;
end;

function TransformGG()
NowNecromanser = 1
sleep(2)
DeployReserveHero("HafadNecro", 31, 93, GROUND)
sleep(2)
RemoveObject("Hafad")
end;

Trigger(PLAYER_REMOVE_HERO_TRIGGER, PLAYER_1, "PrimSaveGG")

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

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

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

In reply to BlueHeavenHero
User Avatar
Auto-translated
BlueHeavenHero, please correct the lines with your hero's script name so that the name is enclosed in quotation marks everywhere, i.e., "Hafad" and "HafadNecro" respectively. Then, test it and let me know if something doesn't work or, conversely, works. Don't forget to put the hero HafadNecro into the reserve pool of heroes for the appropriate player so that the script doesn't break when trying to deploy him.
In reply to Азгалор
User Avatar
Auto-translated
Azgalor
BlueHeavenHero, please correct the lines with your hero's script name so that the name is enclosed in quotation marks everywhere, i.e., "Hafad" and "HafadNecro" respectively. Then, test it and let me know if something doesn't work or, conversely, if it works). Don't forget to put the hero HafadNecro into the reserve pool of the appropriate player so that the script doesn't break when trying to deploy him.
I already put the Hafad-Necromancer in reserve, and I also added quotation marks.

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

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

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

User Avatar
Auto-translated
BlueHeavenHero, I'll add that to prevent the battle from ending when all creatures are defeated, you need to call the EnableAutoFinish(nil) function in advance.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
Auto-translated
BlueHeavenHero, I don't know who's giving dislikes here, but as I mentioned above: double-check that everything is correct, and as Hottabych rightly pointed out, don't forget to add the option to disable the standard battle (if you haven't already), and then check the scripts in the game. We're waiting for your feedback.

Statistics

Welcome our newest member: Emil