• 🏆 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!

[Trigger] Hero Units wont revive properly [SOLVED]

Level 11
Joined
Aug 11, 2009
Messages
594
I wanted to change so regular enemies in the map are all Hero units instead of regular units. But now the respawn triggers I try to use wont work properly. The problem is that only 7 out of 15 units revive.


  • Time - Elapsed game time is 0.00 seconds
  • Set VariableSet Camp_UnitGroup[1] = (Units in Camp11 Area <gen> owned by Neutral Hostile)
  • Unit Group - Pick every unit in Camp_UnitGroup[1] and do (Actions)
    • Loop - Actions
      • Set VariableSet CampScale_Count = (CampScale_Count + 1)
      • Set VariableSet Camp11_Unit[CampScale_Count] = (Picked unit)
      • Set VariableSet Camp11_Point[CampScale_Count] = (Position of (Picked unit))
      • Set VariableSet Camp11_Facing[CampScale_Count] = (Facing of (Picked unit))
      • Set VariableSet CampScale_Unit[CampScale_Count] = (Picked unit)
      • Set VariableSet CampScale_VIT[CampScale_Count] = (Strength of (Picked unit) (Exclude bonuses))
      • Set VariableSet CampScale_POW[CampScale_Count] = (Agility of (Picked unit) (Exclude bonuses))
      • Unit - Set the custom value of (Picked unit) to CampScale_Count

  • Camp11 Reset
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Camp_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Unit - Kill (Picked unit)
              • Hero - Instantly revive (Picked unit) at Camp11_Point[(Custom value of (Picked unit))], Hide revival graphics
              • Unit - Make (Picked unit) face Camp11_Facing[(Custom value of (Picked unit))] over 0.00 seconds
            • Else - Actions
              • Hero - Instantly revive (Picked unit) at Camp11_Point[(Custom value of (Picked unit))], Hide revival graphics
              • Unit - Make (Picked unit) face Camp11_Facing[(Custom value of (Picked unit))] over 0.00 seconds
Maybe it is a bad idea to use Hero units as regular enemies?
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I suggest using a Unit Indexer instead of setting the custom value yourself, but I suppose you may have your reasons not to.

Anyway, I recall there being hardcoded limitations for most Hero stuff.

Some solutions come to mind:

1) When a hero dies, instantly revive them and hide them. Now whenever you reset a camp, instead of resurrecting the hero, simply unhide them, heal them, and move them where they need to go.

2) Use a Damage Event to detect when a unit takes lethal damage and make them survive the hit and become hidden in response. You can then do what I suggested in #1 to return them back to the game when you see fit. This one is nice because it doesn't need to rely on Heroes. You can make your non-Hero units "revivable" by preventing them from ever dying and simply "faking" their death. Note that this prevents the "A unit Dies" event from firing, but you're already detecting when they die so you still have full control of the situation.
 
Level 11
Joined
Aug 11, 2009
Messages
594
Thanks, they seemed to work when testing. Even when pulling every enemy and killing them at the same time they revived properly with this method. Guess its a difference when trigger runs X times instead of one trigger with loop X times :)

Only "issue" is that enemy just disappears without a death animation but its not really a big deal. Could probably be fixed with a dummy unit that looks the same that is killed, though it would require a dummy unit for each enemy if there is no other way to go around it.

Thanks alot for the help with this!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Thanks, they seemed to work when testing. Even when pulling every enemy and killing them at the same time they revived properly with this method. Guess its a difference when trigger runs X times instead of one trigger with loop X times :)

Only "issue" is that enemy just disappears without a death animation but its not really a big deal. Could probably be fixed with a dummy unit that looks the same that is killed, though it would require a dummy unit for each enemy if there is no other way to go around it.

Thanks alot for the help with this!
At the end of the day you're going to have the least trouble if you can avoid using Heroes for every unit. I should've asked sooner but why do you need them to be Heroes in the first place?
 
Level 11
Joined
Aug 11, 2009
Messages
594
Yeah I think I will use regular units. It was more a visual reason so not really necessary xD giving enemies a visual classification in the level field.

But I will just limit it to more important ones that is Rare, Elite and Boss by changing the classifications Tauren, Undead and Mechanical, so its ok :)

Also thought reviving the same Hero every time instead of creating a new unit when reseting an area would be better but that may not be a big deal.
 
Last edited:
Level 11
Joined
Aug 11, 2009
Messages
594
Oh, so thats how it works, that makes sense.

If I still want the death animations for enemies killed, do you think its worth using option:

1. Units and creating new ones (which from my understanding still leaks a little even if removed properly?) when reset.
2. Heroes with high death time and revive when reset (which does not leak, right?)

Maybe the leak from units is so small it doesnt matter?

---

Bonus question: When removing units, is it necessary to kill them first or is it enough to just remove them?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Oh, so thats how it works, that makes sense.

If I still want the death animations for enemies killed, do you think its worth using option:

1. Units and creating new ones (which from my understanding still leaks a little even if removed properly?) when reset.
2. Heroes with high death time and revive when reset (which does not leak, right?)

Maybe the leak from units is so small it doesnt matter?

---

Bonus question: When removing units, is it necessary to kill them first or is it enough to just remove them?
You shouldn't worry about Unit leaks (aside from nulling locals but that's not what you're talking about). The overhead of an object pooling system for this many Units is definitely not worth it unless you have some very special reason for doing so.

Removing a unit bypasses the Death event, so if you want this Event to happen:
  • Unit - A unit Dies
Then you should kill them first. Some other death related abilities will be affected by this, and some systems in your map may be affected as well.

But it's not like you're going to break the game by using this function.

The memory leaks to focus on are inside of triggers that run often:
  • Events
    • Time - Every 0.10 seconds
  • Conditions
  • Actions
    • Unit - Create 1 Footman at (Center of some Region)...
    • Unit - Create 1 Rifleman at (Center of some Region)...
This leaks 20 Points (locations) per second. At the 30 minute mark you will have leaked 36,000 Points.

Most maps have unresolved memory leaks and run just fine - it's these serious cases of memory leaks that you want to focus on and avoid.
 
Last edited:
Top