• 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.

Detecting Explosion Death

Status
Not open for further replies.
Level 2
Joined
Apr 5, 2019
Messages
16
Hey,

Sorry if this was already asked, I tried googling it but couldn't find anything related.
Basically, I have a creep revival trigger which works fine, except for when the creep dies with Incinerate's effect.
The thing is, that a unit which explodes (due to Incinerate death effect) is not acknowledged by the "A unit dies" event.

So my question is, how do you detect such death? I wouldn't mind other solutions, such as making Incinerate not cause an explosion on death (fine with that) etc.

EDIT: Thanks in advance!
 
Level 2
Joined
Apr 5, 2019
Messages
16
  • Creep Spawns
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set creepNum = (creepNum + 1)
          • Unit - Set the custom value of (Picked unit) to creepNum
          • Set getX[creepNum] = (X of (Position of (Picked unit)))
          • Set getY[creepNum] = (Y of (Position of (Picked unit)))
      • Trigger - Turn on Revive Creeps <gen>
      • Trigger - Turn on Creep Drops <gen>
      • Trigger - Turn off (This trigger)
  • Revive Creeps
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
      • ((Triggering unit) is Summoned) Equal to False
    • Actions
      • Wait 30.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at ((Center of (Entire map)) offset by (getX[(Custom value of (Triggering unit))], getY[(Custom value of (Triggering unit))])) facing (Random angle) degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
      • Unit - Remove (Triggering unit) from the game

The thing is I have no issues with this other than the Incinerate case. I also tested where a unit died to the AoE of Incinerate and it revived just fine. The unit which exploded, however, did not.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You're leaking a unit group in your spawn setup trigger, and turning itself off doesn't actually do anything since the trigger has no events and can never be run except by another trigger executing it (which I'm assuming you're doing). In your revive trigger you actually leak two points and a region: Entire Map, Center of (Entire Map), and the point with offset. Use "Playable Map Area" as that's a designated region that doesn't leak when used. You don't need to do the point with an offset, you can just use "Location(x, y)"; make sure to clean up the point after you spawn the creep there. You could also just save the creep locations directly in an array and re-use them (no leak cleaning necessary).

My best guess is that by exploding the unit it doesn't leave a corpse and so it decays before that 30 second wait is over. Then trying to load Triggering Unit will just return null. The solution is to save the creep's custom value and unit type in local shadow variables:

  • Actions
    • Custom script: local integer udg_INT_VAR
    • Custom script: local integer udg_UNIT_TYPE_VAR //yes write integer here but make it a unit-type in the variable editor; unit types are really just integers but GUI 'thinks' they're separate
    • Set INT_VAR = (Custom value of (Triggering Unit))
    • Set UNIT_TYPE_VAR = (Unit type of (Triggering Unit))
    • Wait 30.00 seconds
    • -------- use the above variables, don't have to worry about cleaning them up since integers are primitives that don't leak references --------
Also be aware that if you ever implement a unit indexer into your map (or import a system/spell that requires one, etc.) it will conflict with your custom value usage here. This is an easy fix that just requires you to set creepNum = the creep's custom value (since CV is assigned by the indexer).
 
Level 2
Joined
Apr 5, 2019
Messages
16
Thank you very much for taking the time to help.
Is it possible to clean up a point without a custom script? Just wondering.
Also, what is the meaning of the udg part?
Also why do I need those custom script lines given I already have them declared in the variable editor? Assuming the udg thingy is the answer.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
No, Blizzard did not include any of the leak-cleaning actions in GUI because they’re stupid... or thought they had a good reason not to (but I’ve never read the justification). You will have to use JASS custom script lines, but it’s really not complicated and that tutorial I linked (and the one it mentions at the top) will lay out exactly what you have to do for each type of object and why.

udg_ is a prefix that is automatically added to the beginning of all Variable Editor variables and can’t be changed. User Designated Global. You can’t see that prefix in GUI but it IS there. Again, read the tutorials and they will explain. You need to match your variable names inside the custom script to the name you put in the Variable Editor but always keep the udg_ prefix.

Those two lines are a GUI ‘trick’ that allow a global variable (can be seen and modified by all triggers—all variable editor variables are global) to function AS a local variable (can only be seen and modified in the trigger instance it’s made local in). It’s called local shadowing. The purpose is that if you don’t have those lines the variables will be overwritten during the 30s wait every time a new creep dies. Then when you try to use the variables after the 30s wait they would be the wrong values and you would instead revive the creep that’s most recently died instead of the one that originally died 30s ago. If they are shadowed like this then each time a unit dies a new ‘instance’ of that variable is made that can’t be touched by any other trigger firing and won’t be overwritten during the wait.
 
Status
Not open for further replies.
Top