• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

"Kills one hero as other one revives" system?

Status
Not open for further replies.
Level 7
Joined
Jul 1, 2008
Messages
1,025
Ok I'm having a major problem with this and I've tried lots of things. Im trying to create a hero system which only allows you to have one hero at a time but allows you to rechoose them at any point through the game.

Example: if player revives one hero from altar then his current one needs to die to make room for the one he's just brought but I cant remove it from the game as it needs to be stored in the hero altar for later resurection. Ive tried killing every unit of type when player revives their hero but this kills the reviving/summoning hero as soon as it re-enters game.

All help appreciated with this

(ps: I don't have jass or know much about variables)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Simple, you store the active hero in a unit variable (a variable is like a maths variable).
You then when they get another hero store it in a unit array under a unique index and change ownership to neutral, hide it and then set the active hero to the fresh hero.

If they buy another hero, you simply have to check if there is one stored in the array under that hero type's slot and if not do above. If there is one you remove the fresh hero and simply set the old hero as the new one from the array (ofcourse unhiding it).
 
Status
Not open for further replies.
Top