Having trouble Respawning Hero from unit.

Level 3
Joined
May 11, 2009
Messages
32
So as title says I'm having a real difficult time making this happen, the problems I'm encountering and the methods I've used are as follows.

Enabling hero revive as an ability to the unit makes the unit always use Rally as a command instead of Move and this works but the hero must be clicked on and then it starts spawning but there is no progress bar. So I moved on from this method.

I tried a trigger and here it is.
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Pick every unit in (Units of type Human Zone Controller) and do (Actions)
        • Loop - Actions
          • Countdown Timer - Create a timer window for (Last started timer) with title Hero Respawning at ...
          • Countdown Timer - Start (Last started timer) as a One-shot timer that will expire in 10.00 seconds
          • Wait 10.00 game-time seconds
          • Hero - Instantly revive (Triggering unit) at (Position of (Picked unit)), Show revival graphics
          • Countdown Timer - Destroy (Last created timer window)
But its not working, not sure if its because I update with a picked unit over a triggering unit or not, I've tried removing the wait timer and it still doesnt work. The picked unit is the unit I want the hero to spawn at, I have also been told not to use wait timers in triggers before but cant find other thread suggestions like "timer expires" or something like that.

I also set the unit as the respawning unit in the hero data. Found it by accident but it gave me hope for a second.

Any ideas?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You didn't actually explain what you are trying to do here, so it would help if you can describe that. Revive each hero 10s after they die? Revive all heroes 10s after any of them die? Where does an ability get involved? Why are you looping over every Human Zone Controller unit when the Triggering Unit is the one that died?

You're creating a bunch of different timer windows for the same timer rather than starting a bunch of different timers. The use of Last Started Timer is extremely problematic here (imagine what happens if some other trigger starts a timer for some unrelated reason) and you should instead be using a dedicated timer variable or array of timers. Creating the timer window needs to happen after the timer is started, not before. When using a timer for this purpose, instead of involving both a timer and a wait you should be looking to use the "Countdown Timer - <TIMER> expires" event to run the revive at the correct time. Yes that can require that you store the data somehow since the timer callback trigger won't know the correct unit to revive (TU won't work).

Finally: you cannot ever use a wait in a Unit Group or Player Group loop. Those functions will cause a thread crash in the loop and nothing after the wait will run. Code after the loop itself will run but not the parts of the loop after its wait.
I also set the unit as the respawning unit in the hero data.
I have no idea what this means.
 
Level 3
Joined
May 11, 2009
Messages
32
You didn't actually explain what you are trying to do here, so it would help if you can describe that.
Ok sorry, my bad, so I have a worker unit that does pretty much everything, he is invulnerable and just a staple of gameplay, building buildings and respawning heroes, also cannot die. I want the hero which you pick elsewhere for gameplay to respawn from this worker unit as it’s the only constant of your units, it’s always there until you lose all buildings and lose.

I tried making this unit resurrect normally like in a Melee game(example like an Altar) but there’s a feature for that missing in the data table that only appears on buildings, so I used an ability called resurrect heroes and it works but like I said, there’s no progress bar on resurrecting the hero and the worker unit also gains this bug where it cannot move unless you use the M key and instead sets rallies. Also, while resurrecting, the worker unit cannot move or use any commands other than cancel.
 
Level 30
Joined
Aug 29, 2012
Messages
1,382
Here's how I'd do it. This is all assuming that all players can only have 1 hero, and we'll use the player number to keep track of who belongs to whom (1 red, 2 blue etc)
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet HumanZoneController[1] = Circle of Power 0000 <gen> // Change this to the unit/building where the hero should be revived
      • Set VariableSet HumanZoneController[2] = Circle of Power 0001 <gen>
      • Set VariableSet HumanZoneController[3] = Circle of Power 0002 <gen>
      • (repeat as many times as there are players in your map)
      • -------- ------------------------------ --------
      • Set VariableSet RevivePosition[1] = (Position of HumanZoneController[1])
      • Set VariableSet RevivePosition[2] = (Position of HumanZoneController[2])
      • Set VariableSet RevivePosition[3] = (Position of HumanZoneController[3])
  • Hero Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Countdown Timer - Start ReviveTimer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 10.00 seconds
      • -------- ------------------------------ --------
      • Countdown Timer - Create a timer window for ReviveTimer[(Player number of (Owner of (Triggering unit)))] with title Hero Respawning In....
      • Set VariableSet ReviveTimerWindow[(Player number of (Owner of (Triggering unit)))] = (Last created timer window)
      • Countdown Timer - Show ReviveTimerWindow[(Player number of (Owner of (Triggering unit)))]
      • -------- ------------------------------ --------
      • Wait 10.00 seconds
      • -------- ------------------------------ --------
      • Countdown Timer - Hide ReviveTimerWindow[(Player number of (Owner of (Triggering unit)))]
      • -------- ------------------------------ --------
      • Hero - Instantly revive (Triggering unit) at RevivePosition[(Player number of (Owner of (Triggering unit)))], Show revival graphics
You need to create a Timer variable in order to start it properly, otherwise you only have "last started timer" as an option, which refers to nothing
Also, if you use Destroy timer window, you won't be able to show it again, so use show/hide instead
 

Attachments

  • Test.w3x
    19 KB · Views: 1
Level 45
Joined
Feb 27, 2007
Messages
5,578
You can remove the Rally ability from units manually, which will then stop the rally behavior on right-click and return to moving on right-click. This only has to be done once per-unit after it enters the map.

Instead of mucking about with the revive abilities (notice that none of the altars actually use them), there is a relevant OE field: Techtree - Revives Dead Heroes. This field only appears when the unit also has Stats - Is a Building set to True, but such fields can still be used by temporarily making the unit a building in the OE, altering the field, and setting the building flag back to false. This works here, and we can still remove Rally on map init to avoid that behavior!

Unfortunately, doing so will not show a revival progress bar. That bar is intrinsically linked to the unit having the Structure flag, so you might as well just leave the unit as a building since it's already invulnerable. That gets you 90% of what you want with no triggers except to remove Rally from the units after they exist. The unit not being able to move while it is reviving a hero is probably a hardcoded limitation you can't get around, since I have never seen a mobilly-training unit by normal movement. Interestingly, the unit can still successfully execute an attack order on a unit in range while reviving so it's not an order thing per-se.

One weird hack way to get this to work while moving would be to 'fake' a revival progress bar by using Devour on a target, since units Devouring can still move and it does flat damage per second. Then you involve using Charge Gold & Lumber for the revival costs and it gets a bit more complicated. Another way would be to intercept player right-click commands while the unit is selected (using the mouse event natives we now have) and simply move the unit with triggers to the targeted coordinates when such an input is detected.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
You can remove the Rally ability from units manually, which will then stop the rally behavior on right-click and return to moving on right-click. This only has to be done once per-unit after it enters the map.

Instead of mucking about with the revive abilities (notice that none of the altars actually use them), there is a relevant OE field: Techtree - Revives Dead Heroes. This field only appears when the unit also has Stats - Is a Building set to True, but such fields can still be used by temporarily making the unit a building in the OE, altering the field, and setting the building flag back to false. This works here, and we can still remove Rally on map init to avoid that behavior!

Unfortunately, doing so will not show a revival progress bar. That bar is intrinsically linked to the unit having the Structure flag, so you might as well just leave the unit as a building since it's already invulnerable. That gets you 90% of what you want with no triggers except to remove Rally from the units after they exist. The unit not being able to move while it is reviving a hero is probably a hardcoded limitation you can't get around, since I have never seen a mobilly-training unit by normal movement. Interestingly, the unit can still successfully execute an attack order on a unit in range while reviving so it's not an order thing per-se.

One weird hack way to get this to work while moving would be to 'fake' a revival progress bar by using Devour on a target, since units Devouring can still move and it does flat damage per second. Then you involve using Charge Gold & Lumber for the revival costs and it gets a bit more complicated. Another way would be to intercept player right-click commands while the unit is selected (using the mouse event natives we now have) and simply move the unit with triggers to the targeted coordinates when such an input is detected.
Could you Add the Structure classification a frame/step before the Revival starts, then Remove it after?

Edit: nvm, misread.

Edit 2:
How about Upgrades, do they hinder movement?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
No, wholesale adding it with triggers on map init doesn't allow the bar to exist. As far as I can tell it changes nothing. Must be a building in the OE for the training bar. (Edit: Researches have the same no-movement restriction.)

There's a difference in which button positions the revivable hero ends up on (command card) when using the Revive Heroes ability vs the OE revives heroes flag. The ability puts them after the normal CC functions, but the OE field puts them starting at 0,0 and forcibly shifts everything else by one tile. The 'best case' behavior I described in my previous post can be achieved with the ability to fix these revive icons moving the CC buttons:
  • Stats - Is A Building: True
  • Abilities - Normal: Revive Hero
  • Stats - Revives Dead Heroes: False
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
No, wholesale adding it with triggers on map init doesn't allow the bar to exist. As far as I can tell it changes nothing. Must be a building in the OE for the training bar. (Edit: Researches have the same no-movement restriction.)

There's a difference in which button positions the revivable hero ends up on (command card) when using the Revive Heroes ability vs the OE revives heroes flag. The ability puts them after the normal CC functions, but the OE field puts them starting at 0,0 and forcibly shifts everything else by one tile. The 'best case' behavior I described in my previous post can be achieved with the ability to fix these revive icons moving the CC buttons:
  • Stats - Is A Building: True
  • Abilities - Normal: Revive Hero
  • Stats - Revives Dead Heroes: False
I see, pretty lame. Although, maybe some morph ability shenanigans could work but that's getting messy.

Two random ideas:

1) Trigger the revival system using Timers + Floating text + Charge Gold and Lumber (you can modify it's costs via triggers!). Have the text follow the Builder and display the Hero name and a percentage based on it's completion status.
"Paladin: 38%" -> 39%...40%...41%... etc

2) Use custom UI to create a revive button layered over the dead hero icon. Sort of intuitive but requires a bit of work. Easier if only 1 hero per player.
 
Level 3
Joined
May 11, 2009
Messages
32
Ok so I just woke up but this is what I did before bed, Its currently set to remove rally when I create the unit and now everything works fine. So the unit will be able to ressurect the hero and no progress bar shows plus the unit cannot move during this time although that doesnt matter too much as its a penalty losing a hero and 30 seconds is kind of a good way of punishing the player.

Right so thats where its at right now, now I want some way of showing progress, i've got a message that pops up and tells you the situation "the unit cannot move or build while ressurecting" so forth but a floating text above the worker unit saying reviving hero at the least would be nice, I cant get it working. Posstion of Reviving Hero is set to where they died, not the Worker unit Reviving which is confusing.

A countdown would be absolutly top shelf floating text but I have a feeling thats beyond my knowledge.
 
Level 3
Joined
May 11, 2009
Messages
32
Reread my message. I described exactly how you can get the progress bar to show up.
I tried like 10 times, so confused. Anyway I took a note out of other maps and put the taverns in the middle of the map instead of behind each forces spawn and now after 60 seconds you can no longer select a hero. This also means I can place 2 buildings behind each force which can now resurrect heroes and upgrades.

My new issue is trying to make buildings only buildable on mines. I think I need to create a new thread for that. I found one existing thread but the solution was to build near a mine not what I'm after, which is to ONLY build on the mine. This way I can make buildings only buildable in exact locations and removing the problem where Blight wont spread because I've place unbuildable terrain around the area currently. Also defensive buildings become a viable building.
 
Top