Skip to content

Scripts for beginners.

User Avatar
#277
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