• 🏆 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!

SFX removal problem

Status
Not open for further replies.
Level 5
Joined
Nov 21, 2014
Messages
151
Don't look at the names of units or abilities, those don't matter
So here is my problem:
Every one second it should check if the "enforcer" has a buff, if he does, it should display a visual effect at his weapon, if not it should remove it. But it doesn't remove my sfx.. And I don't know what I do wrong.. Could someone please guide me to the right direction, thanks!


(Also, there is this weird splashing animation because I remove it every one second, maybe a solution to that would also be nice, but I can probably find a work-around for this myself)

Thanks in advance as always!
The trigger:

  • Loop1s
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: local unit udg_hasBuff
      • Unit Group - Pick every unit in (Units of type Enforcer) and do (Actions)
        • Loop - Actions
          • Set hasBuff = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (hasBuff has buff Burning Strike ) Equal to True
            • Then - Actions
              • Special Effect - Create a special effect attached to the weapon of hasBuff using Abilities\Weapons\ChimaeraAcidMissile\ChimaeraAcidMissile.mdl
            • Else - Actions
              • Custom script: call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\ChimaeraAcidMissile\\ChimaeraAcidMissile.mdl",udg_hasBuff,"weapon"))
EDIT: Resolved!
trigger for whoever is interested.
  • Loop1s
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Burning Strike
    • Actions
      • Custom script: local unit udg_hasBuff
      • Unit Group - Pick every unit in (Units of type Enforcer) and do (Actions)
        • Loop - Actions
          • Set hasBuff = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Level of Bash (dummy1) for hasBuff) Equal to 1
                  • (Level of Bash (dummy2) for hasBuff) Equal to 1
                  • (Level of Bash (dummy3) for hasBuff) Equal to 1
            • Then - Actions
              • Special Effect - Create a special effect attached to the weapon of hasBuff using Abilities\Weapons\ChimaeraAcidMissile\ChimaeraAcidMissile.mdl
              • Set newSFX[(Player number of (Owner of hasBuff))] = (Last created special effect)
            • Else - Actions
 
Last edited:

Ardenian

A

Ardenian

Using a 1 seconds loop is inaccurate.
Imagine it would lose the buff after 0.10 seconds passed, then the effect will stay until
1.00 seconds passed, 0.90 seconds too much.
In GUI you could use a loop of 0.03 and a counting timer for accuracy.

local unit udg_hasBuff is a local or a global ? You should not add udg in front of it when it is not a global.
If it is a local unit, then you need to null the local unit at the end of the trigger.

My guess would be the desctruction does not find the reference to the unit.
Try using dynamic indexing to save the special effect with the unit and remove the indexed sfx.
 
Level 5
Joined
Nov 21, 2014
Messages
151
Using a 1 seconds loop is inaccurate.
Imagine it would lose the buff after 0.10 seconds passed, then the effect will stay until
1.00 seconds passed, 0.90 seconds too much.
In GUI you could use a loop of 0.03 and a counting timer for accuracy.

local unit udg_hasBuff is a local or a global ? You should not add udg in front of it when it is not a global.
If it is a local unit, then you need to null the local unit at the end of the trigger.

My guess would be the desctruction does not find the reference to the unit.
Try using dynamic indexing to save the special effect with the unit and remove the indexed sfx.

As I said, I fixed the problem already, still thanks though. And also, how do I null a variable? Thanks!:thumbs_up:
 
Level 5
Joined
Nov 21, 2014
Messages
151
Yeah, a new problem arises. (As I am not completely sure how to do this) and yes, I want it to be local. I'm trying to set it to picked unit, but it wants me me to set that before the unit is actually picked.

Here is my trigger:

  • Loop1s
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Burning Strike (1)
    • Actions
      • Unit Group - Pick every unit in (Units of type Enforcer) and do (Actions)
        • Loop - Actions
          • Custom script: local unit hasBuff
          • Custom script: set hasBuff = GetEnumUnit()
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Level of Bash (dummy1) for hasBuff) Equal to 1
                  • (Level of Bash (dummy2) for hasBuff) Equal to 1
                  • (Level of Bash (dummy3) for hasBuff) Equal to 1
            • Then - Actions
              • Special Effect - Create a special effect attached to the weapon of hasBuff using Abilities\Weapons\ChimaeraAcidMissile\ChimaeraAcidMissile.mdl
              • Set newSFX[(Player number of (Owner of hasBuff))] = (Last created special effect)
              • Custom script: set hasBuff = null
            • Else - Actions
              • Custom script: set hasBuff = null
 

Ardenian

A

Ardenian

You assign locals at the very beginning of the trigger, as first actions.
Move
  • Custom script: local unit hasBuff
outside the group pick, at the top of the actions.
 
Level 5
Joined
Nov 21, 2014
Messages
151
You assign locals at the very beginning of the trigger, as first actions.
Move
  • Custom script: local unit hasBuff
outside the group pick, at the top of the actions.

Yeah I tried that.. "Undeclared variable hasBuff" and highlights "set HasBuff = GetEnumUnit()"
 

Ardenian

A

Ardenian

Attach a test map please.
You cannot really trust these highlights.
 
Level 7
Joined
Oct 19, 2015
Messages
286
You don't declare locals at the beginning of the trigger, you declare them at the beginning of the function - he had it in the correct place. Also, since he's using GUI, it must have the "udg_" prefix in order to overwrite an existing global variable, otherwise he can't use it in his GUI actions. So pretty much all suggestions so far have been wrong wrong wrong.

There is actually no need to use a local variable here. You don't use waits and you don't do anything that could cause the event of another trigger to run so there's no way for other code to interrupt what you're doing - you can therefore safely use a global variable. In fact, certain parts of GUI triggers get converted into separate functions so if you use a local variable it will not be accessible in those parts, so using a global variable is actually better than using a local.

Why do you loop through all the units to apply the effect when only one unit uses the ability? That doesn't seem correct, although you didn't explain exactly what your spell is supposed to do so I can't know for sure.
 
Status
Not open for further replies.
Top