• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Hero Revive Question

Status
Not open for further replies.
Level 28
Joined
Jul 26, 2008
Messages
1,491
Hi guys,

I know this topic is a very common topic, and i have looked at other guides, but i dont feel just copying what others make will help me really learn, so i tried doing my own thing and i failed lol. Was hoping someone could help. I did a trigger for a wisp to choose one of two heroes, a timer of 30 seconds to appear when a hero dies, and a revival after thirty seconds. I wont post the choosing hero trigger as it works fine. I will post the timer trigger, even though it works fine, incase it has the bug causing the hero revival to fail. I would be grateful for any hellp.

Tulee

upload_2016-8-31_16-44-3.png



upload_2016-8-31_16-44-59.png
 

Attachments

  • upload_2016-8-31_16-38-54.png
    upload_2016-8-31_16-38-54.png
    441.5 KB · Views: 69
  • upload_2016-8-31_16-39-14.png
    upload_2016-8-31_16-39-14.png
    22.8 KB · Views: 72
  • upload_2016-8-31_16-43-57.png
    upload_2016-8-31_16-43-57.png
    22.8 KB · Views: 70
Do you use the same timer for all heroes? Each unit needs it's own timer. For making it compatible for multiple players, for simplicity timer[array] variables is often used.

It is also hard to see, if "Playerunit", and "timerwindow" are explicitly for Player 1. (which should be)

The line where you "Set timerwindow" makes no sense, because it layed out on top of the trigger and above there is nothing that validates you to use "Last Created timer window".

Can you post also the triggers for Player 2? Here is a simple way how to post triggers exaplined. No screenshots needed. :) How To Post Your Trigger

so i tried doing my own thing and i failed lol.
Good you search around and tried yourself!
 
Level 28
Joined
Jul 26, 2008
Messages
1,491
Do you use the same timer for all heroes? Each unit needs it's own timer. For making it compatible for multiple players, for simplicity timer[array] variables is often used.

It is also hard to see, if "Playerunit", and "timerwindow" are explicitly for Player 1. (which should be)

The line where you "Set timerwindow" makes no sense, because it layed out on top of the trigger and above there is nothing that validates you to use "Last Created timer window".

Can you post also the triggers for Player 2? Here is a simple way how to post triggers exaplined. No screenshots needed. :) How To Post Your Trigger


Good you search around and tried yourself!

Hi Iceman,

There is no player 2. Choosehero and Choosehero2 are triggers for the wisp to choose a paladin/ mountain king here respectively.
I can try moving the "last created timer window" to the bottom of the trigger to see if that does anything. Though the timer itself works fine, its just that the hero (neither the paladin nor mountain king) revive when they die.

I believe "player unit" and "timer window" are just for player 1, since i didn't add anything one else (except 10 granite rock golems so they could kill my hero and i can test the revive function :).

Player unit was used to sore the variable when the wisp chose the hero, and timer window was just to set the timer.

Hope that is not too confusing
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
IcemanBo said:
Is ensured the hero is not removed from game during the revive time out?
I think it probably is decaying or being otherwise removed. To test this you could pause the hero and unpause it when it's revived. (Unit - Pause Playerunit)
Tulee said:
I dont feel just copying what others make will help me really learn, so i tried doing my own thing and i failed lol
This attitude will get you far quickly in WC3 modding-- keep it up!
 
Level 28
Joined
Jul 26, 2008
Messages
1,491
Is ensured the unit variable is properly set? Could you show the respective trigger?

Try to print a message when the timer expires, so you can see if the revive trigger actually runs or not.

Is ensured the hero is not removed from game during the revive time out?

Oké, I have not thought it is only for Player 1. :)
When you say print a message when the timer expires what exactly do you mean? Do you mean post a screenshot?

I will post the triggers for the choose hero as soon as I can access my world editor. Though I should say I am using the same unit variable for the choose hero trigger as I am for the revivehero trigger (action: revive hero instantly variable.)
 
Level 28
Joined
Jul 26, 2008
Messages
1,491
  • choosehero
    • Events
      • Unit - A unit enters 地区 000 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Wisp
    • Actions
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
      • Set Playerunit = (Last created unit)
      • Unit - Create 1 (Unit-type of Paladin 0000 <gen>) for Player 1 (Red) at (Center of 地区 002 <gen>) facing Default building facing degrees
      • Unit - Kill (Triggering unit)
  • choosehero2
    • Events
      • Unit - A unit enters 地区 001 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Wisp
    • Actions
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
      • Set Playerunit = (Last created unit)
      • Unit - Create 1 (Unit-type of Mountain King 0001 <gen>) for Player 1 (Red) at (Center of 地区 002 <gen>) facing Default building facing degrees
      • Unit - Kill (Triggering unit)
These are my choose hero triggers. They should be fine since they work alright. Its just the revive hero one that doesnt work



Edit: I got it to work. I needed to add "set playerunit = dying unit" under the actions for the herodie trigger.

So will this "playerunit" variable follow me throughout the map whenever i do anything with the hero? I thought i would need to keep making new variables but it seems not.
Thanks for the help btw guys!




  • Herodied
    • Events
    • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
    • ((Triggering unit) is A Hero) Equal to True
    • Actions
    • Set Playerunit = (Dying unit)
    • Countdown Timer - Create a timer window for Timer with title HERO revive
    • Countdown Timer - Start Timer as a One-shot timer that will expire in 5.00 seconds
    • Set timerwindow = (Last created timer window)
 
Last edited:
:)

No, that solution might fix it, but it's not the right way.

Your problem lies here:

  • Set Playerunit = (Last created unit)
  • Unit - Create 1 (Unit-type of Mountain King 0001 <gen>) for Player 1 (Red) at (Center of 地区 002 <gen>) facing Default building facing degrees
These lines won't set the unit variable. Think a bit about it and you might find out. I also mentioned this problem in the first post about "Timer Window". Good luck!
 
Level 28
Joined
Jul 26, 2008
Messages
1,491
:)

No, that solution might fix it, but it's not the right way.

Your problem lies here:

  • Set Playerunit = (Last created unit)
  • Unit - Create 1 (Unit-type of Mountain King 0001 <gen>) for Player 1 (Red) at (Center of 地区 002 <gen>) facing Default building facing degrees
These lines won't set the unit variable. Think a bit about it and you might find out. I also mentioned this problem in the first post about "Timer Window". Good luck!
hi iceman,


i almost overcomplicated things but then i reread your comments and moved the "set player unit" below the create unit line, and it worked, just like you hinted at! Thanks a ton! by the way, can i ask, do these triggers need to be in the initialization part of the trigger folder or can it work anywhere? :) Thanks!
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
It's nitpicking, but you should know that this Special Effect call leaks:
  • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
You create the effect, it will play its animation, and then it just... sits there. Never gets deleted or anything. Do this too many times and your map will start to eat up your RAM, get ridiculously laggy, and eventually crash (if you leak waaaay too many things). To resolve this you can do:
  • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
  • Special Effect - Destroy (last created special effect)
However, this forces the effect to play its death animation which might not work for you (could display nothing at all if the effect has no death animation or could play an animation you don't want). To solve this you can do:
  • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
  • Set MY_SFX_VARIABLE = (last created special effect)
  • Wait 0.50 game-time seconds //This can be whatever duration is necessary to play the animation you want to see, maybe 0.10-2.00 seconds
  • Special Effect - Destroy MY_SFX_VARIABLE
As you've learned, though, variables created in the variable editor are global and can thus be modified by any trigger at any time. So if you were to run a second trigger that used the same MY_SFX_VARIABLE while the Wait X seconds is happening, it would get overwritten and you'd never delete the first sfx (the second would get deleted 'twice'). The only way around this is with local variables, which you can only have in GUI via custom scripts. For most purposes (yours included as I understand it) the fix I posted above will work-- just make sure to add the wait at the end of the trigger if you need it at all (so you don't pause the execution of important parts of code), use a new variable for each trigger, and make sure to set it to (last created special effect) right after you create the effect.

For a more complete solution (one that solves the leak, doesn't involve a new variable for every trigger, and won't overwrite variables when the trigger runs more than one time simultaneously), check out Vexorian's post in this thread. It does involve some custom scripts, but understanding what he's doing and why he's doing it will give you good insight into how to wrangle the WC3 trigger GUI into doing what you want.

______

Everything I said above also applies to locations, like (Center of 地区 002 <gen>) in
  • Unit - Create 1 (Unit-type of Mountain King 0001 <gen>) for Player 1 (Red) at (Center of 地区 002 <gen>) facing Default building facing degrees
The point gets 'made' when you invoke (Center of 地区 002 <gen>) but then never gets removed/recycled. For example, units get automatically recycled when they die/decay/dissipate and thus you don't have to do anything like this for units-- most wc3 data types don't have an automatic recycler, and some don't need them (string, integer, real, boolean). To solve this you actually have to use a custom script:
  • Set TEMP_LOC = (Center of 地区 002 <gen>)
  • Unit - Create 1 (Unit-type of Mountain King 0001 <gen>) for Player 1 (Red) at TEMP_LOC facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_TEMP_LOC)
Note that capitalization matters in the custom script, and inside the () you'll always want to put "udg_+<whatever your variable name is>". udg_ stands for user defined global.

If this seems like a chore it's better to learn to do now than wonder why your map is all laggy for no reason and have to change every trigger in your map.
 
Status
Not open for further replies.
Top