Trigger not adding/removing ability

Status
Not open for further replies.

LanceDH

L

LanceDH

Hi,

I'm trying to add and remove the ability Ghost to a group of units.
I tried it in some random map before and it worked fine, now I'm trying it in my real map and it's not working as it should.
All that happens is the first special effect on the picked units, they don't turn invisible so they don't get the spell, neither to they get the special affect a 2nd time.
It just ends up doing: 5sec wait, 1x special effect, 5sec wait, effect, ...
  • Spectral Shift
    • Events
    • Conditions
      • EliteSpecial Equal to (Shifting)
    • Actions
      • Wait 5.00 seconds
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Not equal to Summoner
              • ((Picked unit) is A structure) Equal to False
            • Then - Actions
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
              • Wait 0.30 seconds
              • Unit - Add Ghost to (Picked unit)
              • Wait 1.00 seconds
              • Unit - Remove Ghost from (Picked unit)
              • Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 75.00% transparency
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
            • Else - Actions
      • Trigger - Run (This trigger) (checking conditions)
 
do this every time after wait

Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 12 (Brown)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Not equal to Summoner
((Picked unit) is A structure) Equal to False
Then - Actions - your actions
wait X sec
Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 12 (Brown)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Not equal to Summoner
((Picked unit) is A structure) Equal to False
Then - Actions your actions
and so on...

btw waits are very bad,try not to use them,dont use in triggers that can be repeated more times,or in generic unit events

you also need to remove leaks ...
search for some tutorials
 
How does this trigger leak? just wondering.

also, if I shouldn't use waits in a repeating trigger, then how do I make it stop for a few seconds before doing the next thing

Edit: found a good overview of what causes leaks and I see what you mean.
I havn't found a anything about the wait thing yet though
 
Last edited by a moderator:
I changed it to this and it works now, ty.
Could you also tell me if I managed to fix all leaks in this trigger (or at least some of them).
I found a guide about leaks, and so far fixed the basic ones like creep movement

  • Spectral Shift
    • Events
    • Conditions
    • Actions
      • Wait 5.00 seconds
      • Set ShiftingGroup = (Units owned by Player 12 (Brown) matching (((Unit-type of (Matching unit)) Not equal to Summoner) and (((Matching unit) is A structure) Equal to False)))
      • Unit Group - Pick every unit in ShiftingGroup and do (Actions)
        • Loop - Actions
          • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
          • Set TempEffect = (Last created special effect)
      • Set ShiftingGroup = (Units owned by Player 12 (Brown) matching (((Unit-type of (Matching unit)) Not equal to Summoner) and (((Matching unit) is A structure) Equal to False)))
      • Wait 0.50 seconds
      • Unit Group - Pick every unit in ShiftingGroup and do (Actions)
        • Loop - Actions
          • Special Effect - Destroy TempEffect
          • Unit - Add Ghost to (Picked unit)
      • Wait 1.00 seconds
      • Set ShiftingGroup = (Units owned by Player 12 (Brown) matching (((Unit-type of (Matching unit)) Not equal to Summoner) and (((Matching unit) is A structure) Equal to False)))
      • Unit Group - Pick every unit in ShiftingGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Ghost from (Picked unit)
          • Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 75.00% transparency
          • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
          • Set TempEffect = (Last created special effect)
          • Wait 0.50 seconds
          • Special Effect - Destroy TempEffect
      • Trigger - Run (This trigger) (checking conditions)
 
good for using unit group - units owned by player matching condition

well you have to destroy unit group each time you change it using this action

Custom Script: call DestroyGroup(udg_NameOfYourUnitGroupHere)

but there is one problem in waits
if you use the group and you don't need to change it so you set it only once in your trigger and you used it after waits, your all other triggers must not set that unit group until that trigger is finished,if you know that unit group could be set by another trigger than better set the group each time after wait like you did in your trigger



set unit group
use the seted unit group as many times you want
at the and of actions of if you want to change the group,firs use
Custom Script: call DestroyGroup(udg_NameOfYourUnitGroupHere)
now you can set unit group again and destroy it when actions are finished or if you want to set a new group again and do some more actions

-------------------------------
set YourUnitGroup
do actions with YourUnitGroup
Custom Script: call DestroyGroup(udg_NameOfYourUnitGroupHere)
 
Eventually you're going to have to use hashtables for more complex things. For instance, if you're making a spell/ability that requires a repeating timer you're going to need to use hashtables to store the associated handles (or struct) to the timer.

Its best to get in a habit of not using TriggerSleepAction (which is Wait - ) especially since its not even an accurate time lapse. If you use a timer and execute a periodic function every 0.5 seconds, the function will be executed every 0.5 seconds. In the same situation, TriggerSleepAction would have varying pauses, none of which are below 1 second.
 
@ALiEN95:

I thought I had to set the unit group every time as it is possible that units are killed after being added, and that it may cause leaks too or something.
Thanks for the help

@Berbanog:

It isn't such a cemplex thing.
The trigger is just for my TD to make some waves dissapear every 5 orso seconds, for 1 second.
only 3 or 4 waves use the trigger, and after those waves it is turned off again.
 
Status
Not open for further replies.
Back
Top