• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Respawn Trigger, need help.

Status
Not open for further replies.
Level 2
Joined
Aug 28, 2020
Messages
19
Hello I made a trigger that respawn creeps to their original point using a tutorial online and everything works fine, but they only respawn once then the second time they die they don't.

2021-01-05 (2).png


2021-01-05 (3).png


I have no knowledge in this type of editing, but my triggers are identical to the video he made and his creeps keep respawning over and over and mine doesn't :(

Help
 
Level 9
Joined
Mar 26, 2017
Messages
376
Use Triggering Unit instead of Decaying Unit.

Another thing: because this uses a Wait in combination with 'Dying Unit' it can malfunction if multiple units die in close succession.

It is best to save the 'custom value of Triggering Unit' into a variable at the start of the Actions.
Then use the wait. And then each time you want to refer to the value, you can refer to the integer.

Or you can simply use 'Triggering Unit' all the time, which does work correctly with Waits.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,593
So basicly replace every ''dying unit'' to ''triggering unit''?
Correct. If there's a Wait in your trigger then the only safe Event Response you can use AFTER the Wait is Triggering Unit. The other Event Responses (like Entering unit, Dying unit, etc) work like basic Global Variables and can run into problems. Edit: Actually, this isn't entirely true, some Event Responses are safe and others are not, it's inconsistent unfortunately.

This is because a Global Variable can only be set to one value at a time, and this value will change globally across all of your triggers (hence the name). Triggering Unit, however, is treated like a Local Variable, which has the special property of remaining the same throughout your trigger. In other words, Triggering Unit will NOT change regardless of what you do.

Here's an example of an Event Response being overwritten. Let's say 5.00 seconds after a unit dies it's corpse is removed from the game:
A unit dies -> Wait 5.00 seconds -> Remove Dying unit from the game

This trigger appears to work fine, however, there's a big problem.

What happens when another unit dies before that first 5.00 second Wait is finished?

So a unit dies and the trigger runs:
A unit dies -> Wait 5.00 seconds -> Remove Dying unit from the game

But then 1.00 second later another unit dies:
A unit dies -> Wait 5.00 seconds -> Remove Dying unit from the game

Dying Unit is now set to the most RECENT unit that died. Meaning our first trigger is now going to reference the SECOND Dying unit, not the first one. See the problem?


It's quite annoying that none of this is made clear to the user but that's just the way it is.

Luckily, there are some tricks you can use to make using Waits a viable option, for example: local udg_
There's also Hashtables, Dynamic Indexing, and using Local Variables in Custom Script (or not using GUI at all and writing the code yourself) that can offer ways to get around these issues.
 
Last edited:
Level 2
Joined
Aug 28, 2020
Messages
19
Good lord, I do have a hard time understanding all this, but you did manage to make it simple.

But my respawn works now thanks to you two!
 
Status
Not open for further replies.
Top