I have a question! How do I make a hero stay in the castle?
Posts from Scripts for beginners.
We place the hero in the castle and write in the scripts: EnableHeroAI( "scripted hero name", nil )
And what does this mean?
Value was NIL when getting global with name 'Ingvar'
Wrong type of argument 1, when calling function 'EnableHeroAI'
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'
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")
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...
It's strange that the names match; I wrote a script in the town and just...
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.
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!
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)
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")
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.
Statistics
Users Online 9 users 1285 guests
Today's Visitors 32
- ALVYDAS
- Arandor
- AstralLein
- burymm
- Dark Jack
- dotahcxun
- elizbar1967
- fktifzobr@mail.ru
- Golvek
- Happy Life
- Heroist
- Hottler
- HwKeeper
- IchGViji
- kcfgogbfalgfl
- LifeForm
- Narron
- OrnsteinDragonslayer
- PingWing
- Ple-Sen
- Sir Syddan
- Siverfale
- Valery59
- Валера 111
- Граф Орлов
- Джек
- Драккошка
- Дугал
- Злобный Ящур
- Небо
- Нэйко
- Саргон