[Trigger] How to remove multiple special effects made on a unit group

Status
Not open for further replies.
Level 2
Joined
Apr 24, 2019
Messages
15
Hi! I've been trying to remove the special effects that was created in a unit group (create special effect for (picked unit) ). I used loop(Integer A) but only one effect was removed and the other units still has the special effect. I'm not really sure on how to use loops or something I just thought that it might work and since it doesn't I decided to get help here.

Here is the trigger:

  • SoulBurnactivate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Burn
    • Actions
      • Set Doomguard[1] = (Triggering unit)
      • Set SoulBurnTargetLoc = (Target point of ability being cast)
      • Custom script: call TriggerSleepAction(0.02)
      • Set SoulBurnUnitGroup = (Units within 300.00 of SoulBurnTargetLoc matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of Doomguard[1])) Equal to True) and ((((Matching unit) is A structure) Not equal to True) and (((Matching unit
      • Set SoulBurnUnitCount = (Number of units in SoulBurnUnitGroup)
      • Unit Group - Pick every unit in SoulBurnUnitGroup and do (Actions)
        • Loop - Actions
          • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Other\Doom\DoomTarget.mdl
          • For each (Integer A) from 1 to SoulBurnUnitCount, do (Actions)
            • Loop - Actions
              • Set SoulBurnsfx[(Integer A)] = (Last created special effect)
      • Custom script: call TriggerSleepAction(5.00)
      • For each (Integer A) from 1 to SoulBurnUnitCount, do (Actions)
        • Loop - Actions
          • Special Effect - Destroy SoulBurnsfx[(Integer A)]
          • Custom script: call DestroyGroup(udg_SoulBurnUnitGroup)
      • Custom script: call RemoveLocation(udg_SoulBurnTargetLoc)
There are probably lots of things that are wrong there. I need help please tell me what is wrong and what should I do. :) Thanks
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
It doesn't work because you are using a loop that is overwriting the special effect until the last unit in the group is checked. You need to index it so you can destroy it later. Example :
  • Remove Special Effect Group
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set Temp_Integer = (Temp_Integer + 1)
          • Unit - Set the custom value of (Picked unit) to Temp_Integer
          • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
          • Set Temp_SFX[Temp_Integer] = (Last created special effect)
      • Wait 3.00 seconds
      • For each (Integer A) from 1 to Temp_Integer, do (Special Effect - Destroy Temp_SFX[(Integer A)])
 
Status
Not open for further replies.
Top