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

[Trigger] Destroy Special Effect if unit is dead?

Status
Not open for further replies.
There is a spell that triggers special effect.

Any trigger to destroy the effect if the unit is dead before the end of the spell duration?
  • cast Frost Bomb
    • Events
      • Unit - Archmage 0001 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Static Shock
    • Actions
      • Wait 0.10 seconds
      • Special Effect - Create a special effect attached to the origin of (Target unit of ability being cast) using war3mapImported\Frost.mdx
      • Wait 7.00 seconds
      • Special Effect - Destroy (Last created special effect)
The last 'wait' is when the duration of spell expires.
 
This is not MUI. You should learn how to create spells using some form of indexing. Look at my tutorial things a GUIer should know. The chapter how to index shows you how to make MUI spells.

You can use waits to make things MUI but waits are buggy and can be cheated. Look at my tutorial the chapter on waits. They are inaccurate and not good to use.
If using waits use local variables to store the things. Look at my tutorial again on the chapter about local variables.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Any trigger to destroy the effect if the unit is dead before the end of the spell duration?

That's actually pretty easy, start a Timer with a small timeout for example 0.03. On each loop you check if the caster is still alive, if not destroy the effect and stop the timer.
Simultanously sum up a real variable by 0.03 on each loop until it hits in your exmaple 7.10, then destroy the effect and stop the timer. ( If not already stopped.)

I agree with deathismyfriend you should get familiar with indexing and how to make spells MUI ( Multi-Unit Instanceability). His tutorial is well organized and has a lot of important information for beginners.
 
Last edited:
Level 7
Joined
Mar 6, 2006
Messages
282
You could use a custom buff with that effect too, and let the buff expire as needed.

Create a buff, and set:

Art - Target = war3mapImported\Frost.mdx
Art - Target Attachment Point 1 = origin

Create an ability based off Curse, or something easy. Set the "Data - Chance To Miss" to zero so it does nothing, and replace the buff with the one you just made. Set the Duration Hero, and Duration Normal to the length of the effect, like 7 seconds.

Add your new ability to a dummy, and make the trigger like this:

  • Actions
    • Set TempLocation = (Position of (Casting unit))
    • Unit - Create 1 FrostDummy for (Owner of (Casting unit)) at TempLocation facing Default building facing degrees
    • Unit - Order (Last created unit) to Undead Banshee - Curse (Casting unit)
    • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
    • Custom script: call RemoveLocation( udg_TempLocation )
 
This works for me but the unit dies late, so... Then i need to check if the unit hp is 1 and then kill the effect

  • cast Frost Bomb
    • Events
      • Unit - Archmage 0001 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Bomb
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to FBOMBED_UNIT
      • Wait 0.10 seconds
      • Special Effect - Create a special effect attached to the origin of (Target unit of ability being cast) using war3mapImported\Frost.mdx
  • kill effect
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to (Random unit from FBOMBED_UNIT)
    • Actions
      • Special Effect - Destroy (Last created special effect)
      • Wait 0.10 seconds
      • Unit Group - Remove (Triggering unit) from FBOMBED_UNIT
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
What you have is simply wrong, as it is not MUI (MUI means it will not bug when fired/used by multiple units at around the same time).

Your problem is this:
First trigger:
"Target unit of ability being cast" is global, it's not local like "triggering unit". That means that if in the 0,1 second wait window the spell is cast again, "Target unit of ability being cast" will be different unit! In actual game, if you used that spell 2 times at around the same time (within the "wait" time), you would create the special effect on the second target (the later one) 2 times.
I think we'll both agree that's not what you want.

Also, waits are inaccurate. Waits in <0 ; ~0,27> second interval are random. That means that even though you set wait to be 0,1 second, the actual wait time will be different per cast.
Also, waits should be avoided if that map is a multiplayer one (among other disadvantages).

Second trigger:
Special Effect - Destroy (Last created special effect) -> same problem as with "Target unit of ability being cast" in the first trigger.
You will delete only the last created special effect. That may be any special effect created in the game!
Imagine -> You cast this spell, it creates special effect on the target. Then, some time later, you create another special effect (for example for quest, or whatever, the reason matters not). Then the target of the spell dies and voala, you just removed the special effect for the quest, not from the target.
 

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
Very nice of you to explain, Nichulus, but the spell has 240 sec cooldown and the effect is only one in the game, at all.
do you have another trigger or spell which using this function with different effect?
  • Special Effect - Create a special effect attached to the origin of (Target unit of ability being cast) using war3mapImported\Frost.mdx
 
  • T
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt
    • Actions
      • Set WriteInteger = (WriteInteger + 1)
      • Special Effect - Create a special effect attached to the overhead of (Target unit of ability being cast) using Abilities\Weapons\ZigguratFrostMissile\ZigguratFrostMissile.mdl
      • Set SFX[WriteInteger] = (Last created special effect)
      • Wait 7.00 seconds
      • Set ReadInteger = (ReadInteger + 1)
      • Special Effect - Destroy SFX[ReadInteger]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ReadInteger Equal to WriteInteger
        • Then - Actions
          • Set WriteInteger = 0
          • Set ReadInteger = 0
        • Else - Actions
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Very nice of you to explain, Nichulus, but the spell has 240 sec cooldown and the effect is only one in the game, at all.
If that's the case, then it's alright. But remember - if you decide later in the development to create another effects for some other things, that second trigger will mess things up.
(that's why it's safer to put the efx into variable and then get rid of it, as you may forget after months of development that you even have your second trigger)

Edit: Also, I guessed it's an AoE ability (or a single ability which can be cast often), since you add the target into unit group, that's all.
 
  • T
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt
    • Actions
      • Set WriteInteger = (WriteInteger + 1)
      • Special Effect - Create a special effect attached to the overhead of (Target unit of ability being cast) using Abilities\Weapons\ZigguratFrostMissile\ZigguratFrostMissile.mdl
      • Set SFX[WriteInteger] = (Last created special effect)
      • Wait 7.00 seconds
      • Set ReadInteger = (ReadInteger + 1)
      • Special Effect - Destroy SFX[ReadInteger]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ReadInteger Equal to WriteInteger
        • Then - Actions
          • Set WriteInteger = 0
          • Set ReadInteger = 0
        • Else - Actions

So, what you do here is to destroy the effect with variables?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Use a hashtable or an indexer as someone stated earlier in the thread, when the unit dies (via event), retrieve all the effects attached on the unit and destroy them.
 
  • Sfx
    • Events
      • Unit - Unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Bomb
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Sfx_Mui[0] Equal to 0
        • Then - Actions
          • Trigger - Turn on Sfx Loop <gen>
        • Else - Actions
      • Set Sfx_Mui[0] = Sfx_Mui[0] + 1
      • Set Sfx_Mui[1] = Sfx_Mui[1] + 1
      • Set Sfx_Target[Sfx_Mui[1]] = (Target of unit ability being cast)
      • Special Effect - Create a special effect attached to the origin of Sfx_Target using war3mapImported\Frost.mdx
      • Set Sfx_Var[Sfx_Mui[1]] = (Last created special effect)
      • Set Sfx_Dur[Sfx_Mui[1]] = 1.00
  • Sfx Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Sfx_Mui[2]) from 1 to Sfx_Mui[1], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Sfx_Dur[Sfx_Mui[2]] Greater than 0.00
            • Then - Actions
              • Set Sfx_Dur[Sfx_Mui[2]] = (Sfx_Dur[Sfx_Mui[2]] - 0.02)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Sfx_Dur[Sfx_Mui[2]] Less than or Equal to 0.00
              • Then - Actions
                • Special Effect - Destroy Sfx_Var[Sfx_Mui[2]]
                • Set Sfx_Dur[Sfx_Mui[2]] = 0.00
                • Set Sfx_Mui[0] = Sfx_Mui[0] - 1
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Sfx_Mui[0] Less than or Equal to 0.00
                  • Then - Actions
                    • Trigger - turn off this trigger
                    • Set Sfx_Mui[0] = 0.00
                    • Set Sfx_Mui[1] = 0.00
                    • Else - Actions
                • Else - Actions
            • Else - Actions
 
Status
Not open for further replies.
Top