Posts from Scripts for beginners.
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
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
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.
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.
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.
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
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!
Okay, but why isn't the MakeHeroNecromancer function suitable? It turns any hero into a necromancer with dark energy.
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
Users Online 9 users 1265 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
- Граф Орлов
- Джек
- Драккошка
- Дугал
- Злобный Ящур
- Небо
- Нэйко
- Саргон