• 🏆 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] Getting Rid of Dummies when a Caster Dies During a Loop

Status
Not open for further replies.
Level 37
Joined
Jul 22, 2015
Messages
3,485
So I realized this problem AFTER uploading the spell into the resource section. It's an easy fix, but I'm not entirely sure how the moderators will feel about it.

My current setup is that after the dummy unit is created, I add an expired timer on it directly after.

  • Unit - Create 1 EC_SFXOverhead for EC_Player[EC_MaxIndex] at EC_CasterLoc[EC_MaxIndex] facing Default building facing degrees
  • Set EC_DummyUnit = (Last created unit)
  • Unit - Add a EC_Duration[EC_AbilityLevel[EC_MaxIndex]] second Generic expiration timer to EC_DummyUnit

With this method, the dummy unit will disappear right when the duration ends and all the deindex stuff happens, which is good :) however, after realizing the potential of a caster dying during a channel, I had to add an extra condition in the loop that checks whether or not the caster is dead or if the duration is over.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (EC_Caster[EC_CurrentIndex] is dead) Equal to True
          • EC_DurationCounter[EC_CurrentIndex] Greater than or equal to EC_Duration[EC_AbilityLevel[EC_CurrentIndex]]
    • Then - Actions
      • -------- --------
      • -------- removing location leak and special effect --------
      • Custom script: call RemoveLocation (udg_EC_CasterLoc[udg_EC_CurrentIndex])
      • Special Effect - Destroy EC_SFX[EC_CurrentIndex]
      • -------- --------
      • -------- deindex variables of current instance --------
      • Set EC_Caster[EC_CurrentIndex] = EC_Caster[EC_MaxIndex]
      • Set EC_Player[EC_CurrentIndex] = EC_Player[EC_MaxIndex]
      • Set EC_AbilityLevel[EC_CurrentIndex] = EC_AbilityLevel[EC_MaxIndex]
      • Set EC_CasterLoc[EC_CurrentIndex] = EC_CasterLoc[EC_MaxIndex]
      • Set EC_DurationCounter[EC_CurrentIndex] = EC_Duration[EC_MaxIndex]
      • Set EC_IntervalCounter[EC_CurrentIndex] = EC_IntervalCounter[EC_MaxIndex]
      • Set EC_SFX[EC_CurrentIndex] = EC_SFX[EC_MaxIndex]
      • Set EC_MaxIndex = (EC_MaxIndex - 1)
      • Set EC_CurrentIndex = (EC_CurrentIndex - 1)
      • -------- --------
      • -------- checking if there is a spell instance still running --------
      • -------- if not, turn off loop --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EC_MaxIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • -------- continue with spell --------
    • Else - Actions
      • -------- continue with spell --------

Everything works except the dummy unit. Since I'm adding the the duration right after creation, the dummy won't actually disappear until its expiration timer is over xP again, this is an easy fix... but I'm not sure how the moderators would feel about it.

To get around this dummy unit issue, I was thinking maybe instead of adding the full expiration timer at the start of its creation, I can just add a 0.01 second expiration timer at the end of the spell so that the dummy unit will get removed when either conditions are met (note: DummyUnit has to be changed to an array that needs to be deindexed at the end of the spell like everything else)

  • Unit - Create 1 EC_SFXOverhead for EC_Player[EC_MaxIndex] at EC_CasterLoc[EC_MaxIndex] facing Default building facing degrees
  • Set EC_DummyUnit[EC_MaxIndex] = (Last created unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (EC_Caster[EC_CurrentIndex] is dead) Equal to True
          • EC_DurationCounter[EC_CurrentIndex] Greater than or equal to EC_Duration[EC_AbilityLevel[EC_CurrentIndex]]
    • Then - Actions
      • Unit - Add a 0.01 second Generic expiration timer to EC_DummyUnit[EC_CurrentIndex]
      • -------- --------
      • -------- removing location leak and special effect --------
      • Custom script: call RemoveLocation (udg_EC_CasterLoc[udg_EC_CurrentIndex])
      • Special Effect - Destroy EC_SFX[EC_CurrentIndex]
      • -------- --------
      • -------- deindex variables of current instance --------
      • Set EC_Caster[EC_CurrentIndex] = EC_Caster[EC_MaxIndex]
      • Set EC_Player[EC_CurrentIndex] = EC_Player[EC_MaxIndex]
      • Set EC_AbilityLevel[EC_CurrentIndex] = EC_AbilityLevel[EC_MaxIndex]
      • Set EC_CasterLoc[EC_CurrentIndex] = EC_CasterLoc[EC_MaxIndex]
      • Set EC_DurationCounter[EC_CurrentIndex] = EC_Duration[EC_MaxIndex]
      • Set EC_IntervalCounter[EC_CurrentIndex] = EC_IntervalCounter[EC_MaxIndex]
      • Set EC_SFX[EC_CurrentIndex] = EC_SFX[EC_MaxIndex]
      • Set EC_DummyUnit[EC_CurrentIndex] = EC_DummyUnit[EC_MaxIndex]
      • Set EC_MaxIndex = (EC_MaxIndex - 1)
      • Set EC_CurrentIndex = (EC_CurrentIndex - 1)
      • -------- --------
      • -------- checking if there is a spell instance still running --------
      • -------- if not, turn off loop --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EC_MaxIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • -------- continue with spell --------
    • Else - Actions
      • -------- continue with spell --------
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
What's wrong with doing it the second way?

If I have more than one instance running, all the other dummy units will also disappear when one instance finishes. Unless you're talking about the one where I don't add the expiration timer to the dummy at the end... well the dummy unit with the expiration timer has a visible model. So if the caster dies, the model will still hover around until its expired duration is over.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
So why not add the dummy unit to each index instead? Each index with its own dummy?

I did do that, but then theres the problem I mentioned to you earlier.

If I have more than one instance running, all the other dummy units will also disappear when one instance finishes.

It seems the deindex of the dummy at the end of the spell doesnt transfer properly.
 
Level 5
Joined
Jan 17, 2014
Messages
131
If the ability is a channeling ability, you could make another event - "Unit Stops Casting an Ability", that would detect any interruption of the ability (unit move, unit death, silence).
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
If the ability is a channeling ability, you could make another event - "Unit Stops Casting an Ability", that would detect any interruption of the ability (unit move, unit death, silence).

Oh thank you for those other suggestions! I forgot to check for conditions like that xP

Why does it say DummyUnit_copy in the second trigger? It should just be DummyUnit, right?

Yes. I was playing around with the DummyUni variable and changing it to be an array or not. First setup i had DummyUnit was not an array, but for the second, it is. I forgot to rename it when I pasted the triggers.

EDIT: Issue found. I didn't deindex properly.
  • Set EC_DurationCounter[EC_CurrentIndex] = EC_Duration[EC_MaxIndex]
^^ Lol. I can't believe I ripped my hair for days over this one.
 
Last edited:
Status
Not open for further replies.
Top