• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

How to remove a special effect ? (when the unit with the attachment dies)

Status
Not open for further replies.
Level 14
Joined
Nov 2, 2008
Messages
579
Im using the triggers system to add a special effect to my towers when they finish construction, but when they get destroyed, the special effect remains

eg
Event:
A Unit owned by Player 1 (Red) finishes construction

Condition:
(Unit type of((triggering unit) equal to Advanced Magic Tower

Actions:
Create a special effect attached to overhead or [[Triggering Unit] using Abilities\Spells\Other\Drain\ManaDrain.mdl

Please can anyone help me out here :sad:
 
Level 11
Joined
Apr 13, 2006
Messages
353
This should always come after a special effect creation. For most effects it works fine, i.e. creating and then immediately destroying results in the effect being played once (which is what you probably want, judging from your post).

Actions:

Destroy last created special effect.
 
Level 11
Joined
Aug 16, 2007
Messages
847
Make a custom ability based off of some item ability Damage Bonus should do, then set the bonus to zero and set the "Art - Caster Attachment" to "Abilities\Spells\Other\Drain\ManaDrain.mdl", and set the field right below that one to "overhead"

then go to the object editor and give this ability to that tower

so now any tower of that type will have this effect and it'll be gone when it dies



Also in your original trigger you said you wanted it to attach to the tower, so your trigger action should have been:

"Create a special effect attached to overhead of [Constructed Unit] using Abilities\Spells\Other\Drain\ManaDrain.mdl"
 
Level 12
Joined
Aug 22, 2008
Messages
911
Use a variable of type Special Effect to store the effect right after it is created by using:
Set [Variable_Name] = (Last created special effect)
Just like Day-Eleven said.
Then, create another trigger:
  • YourTrigger
    • Events
      • Unit - A unit finishes construction
      • -------- Note that if you want to do it while upgrading you should use a different event --------
    • Conditions
      • Unit type of (Triggering Unit) equal to [Your_Structure_Type]
    • Actions
      • Special Effect - Destroy [Variable_Name]
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
I like all the random and not making sense answers that have been given. . .

The fact is the special affect does vanish by its self on unit death like you want, once the unit has decayed. However unless you destroy it, it will make a memory leak.

As your TD probably is rather small, I dought there will be 8192 towers built during the course of game play, and if there are then something tells me your TD will not be very good. Basically asign each tower as it is built a unique ID and store it as the tower custom value. You then store the special affect in an array at the index of the tower's custom value. On death you get the custom value of the unit and destroy the affect.

The easiest way to get a unique custom vale would be a counter starting at 0 that adds 1 after each tower is built.
 
Ok, this answer actually makes sense:
  • Tower Build
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Scout Tower
    • Actions
      • Set TempIntA = 0
      • Custom script: loop
      • Custom script: exitwhen udg_Tower_Used[udg_TempIntA] == 0
      • Set TempIntA = (TempIntA + 1)
      • Custom script: endloop
      • Set Tower_Unit[TempIntA] = (Constructed structure)
      • Special Effect - Create a special effect attached to the overhead of Tower_Unit[TempIntA] using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Set Tower_SFX[TempIntA] = (Last created special effect)
      • Set Tower_Used[TempIntA] = 1
  • Tower Die
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Scout Tower
    • Actions
      • Set TempUnitA = (Dying unit)
      • Set TempIntA = 0
      • Custom script: loop
      • Custom script: exitwhen udg_TempUnitA == udg_Tower_Unit[udg_TempIntA]
      • Set TempIntA = (TempIntA + 1)
      • Custom script: endloop
      • Custom script: set udg_Tower_Unit[udg_TempIntA] = null
      • Special Effect - Destroy Tower_SFX[TempIntA]
      • Custom script: set udg_Tower_SFX[udg_TempIntA] = null
      • Custom script: set udg_TempUnitA = null
 
Status
Not open for further replies.
Top