• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] How do I get this spell to only apply ONE debuff on the enemies?

Level 15
Joined
Jun 11, 2018
Messages
271
Hello. This is driving me insane. I'm setting up a spell called Sand Attack that applies 'Drunken Haze' on targets. Each time you hit enemies with Sand Attack, a stronger version of 'Drunken Haze' is applied to the target. To achieve this, I made six 'Drunken Haze' buffs and each time you hit the enemies, it replaces the current 'Drunken Haze' buff with a stronger one.


It works as intended for the first cast. It applies 'Drunken Haze' buff level 1 on the target. However, when I cast Sand Attack on the enemy again, the level 1 'Drunken Haze' gets replaced by a level 2 'Drunken Haze' buff (as intended) HOWEVER it also adds an extra level 1 'Drunken Haze' buff. And it keeps repeating - meaning that each time I cast Sand Attack on the enemies, their 'Drunken Haze' buff does get replaced with a stronger one each time (as intended) but it also keeps adding this extra level 1 'Drunken Haze' buff.

I just can not fathom how to get this system to stop applying the level 1 buff in addition to the intended one.
I hope I managed to explain this properly.

  • SandAttack
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Flamethrower Q
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SandAttack_Integer[1] Equal to 0
        • Then - Actions
          • Trigger - Turn on SandAttackRoll <gen>
        • Else - Actions
      • Set VariableSet SandAttack_Integer[1] = (SandAttack_Integer[1] + 1)
      • Set VariableSet SandAttack_Integer[2] = (SandAttack_Integer[2] + 1)
      • Set VariableSet SandAttack_Caster[SandAttack_Integer[2]] = (Triggering unit)
      • Set VariableSet SandAttack_Location[SandAttack_Integer[2]] = (Position of SandAttack_Caster[SandAttack_Integer[2]])
      • Set VariableSet SandAttack_Location2[SandAttack_Integer[2]] = (Target point of ability being cast)
      • Set VariableSet SandAttack_Angle[SandAttack_Integer[2]] = (Angle from SandAttack_Location[SandAttack_Integer[2]] to SandAttack_Location2[SandAttack_Integer[2]])
      • Set VariableSet SandAttack_Muzzle[SandAttack_Integer[2]] = (SandAttack_Location[SandAttack_Integer[2]] offset by 100.00 towards SandAttack_Angle[SandAttack_Integer[2]] degrees.)
      • Set VariableSet SandAttack_Tick[SandAttack_Integer[2]] = 15
      • Unit Group - Remove all units from SandAttack_DummyGroup[SandAttack_Integer[2]].
      • Unit - Create 1 Wave Spell Dummy for (Owner of SandAttack_Caster[SandAttack_Integer[2]]) at SandAttack_Muzzle[SandAttack_Integer[2]] facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Set VariableSet SandAttack_Dummy[SandAttack_Integer[2]] = (Last created unit)
      • Unit Group - Add (Last created unit) to SandAttack_DummyGroup[SandAttack_Integer[2]]
      • Custom script: call RemoveLocation(udg_SandAttack_Location[udg_SandAttack_Integer[2]])
      • Custom script: call RemoveLocation(udg_SandAttack_Location2[udg_SandAttack_Integer[2]])
      • Custom script: call RemoveLocation(udg_SandAttack_Muzzle[udg_SandAttack_Integer[2]])
      • Set VariableSet SandAttack_Location2[SandAttack_Integer[2]] = (Target point of ability being cast)
      • -------- Floating Text --------
      • Floating Text - Create floating text that reads Sand Attack above SandAttack_Caster[SandAttack_Integer[3]] with Z offset 0.00, using font size 10.00, color (88.00%, 45.00%, 20.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change (Last created floating text): Disable permanence

  • SandAttackRoll
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SandAttack_Integer[3]) from 1 to SandAttack_Integer[2], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SandAttack_Tick[SandAttack_Integer[3]] Greater than 0
            • Then - Actions
              • Set VariableSet SandAttack_DummyPoint[SandAttack_Integer[3]] = (Position of SandAttack_Dummy[SandAttack_Integer[3]])
              • Set VariableSet SandAttack_Location2[SandAttack_Integer[3]] = (SandAttack_DummyPoint[SandAttack_Integer[3]] offset by 45.00 towards SandAttack_Angle[SandAttack_Integer[3]] degrees.)
              • For each (Integer A) from 4 to 5, do (Actions)
                • Loop - Actions
                  • Special Effect - Create a special effect at SandAttack_DummyPoint[SandAttack_Integer[3]] using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
                  • Custom script: call BlzSetSpecialEffectHeight(bj_lastCreatedEffect, 10.0)
                  • Custom script: call BlzSetSpecialEffectScale(bj_lastCreatedEffect, 0.9)
                  • Special Effect - Destroy (Last created special effect)
              • Unit - Move SandAttack_Dummy[SandAttack_Integer[3]] instantly to SandAttack_Location2[SandAttack_Integer[3]]
              • -------- Strike Check --------
              • Set VariableSet SandAttack_Strike[SandAttack_Integer[3]] = (Units within 180.00 of SandAttack_DummyPoint[SandAttack_Integer[3]] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) belongs to an ally of (Owner of SandAttack_Caster[S
              • Unit Group - Pick every unit in SandAttack_Strike[SandAttack_Integer[3]] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in SandAttack_NonStrike[SandAttack_Integer[3]].) Equal to False
                    • Then - Actions
                      • Set VariableSet Current_Level = 0
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Lowered Accuracy 6 ) Equal to True
                        • Then - Actions
                          • Set VariableSet Current_Level = 6
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Picked unit) has buff Lowered Accuracy 5 ) Equal to True
                            • Then - Actions
                              • Set VariableSet Current_Level = 5
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked unit) has buff Lowered Accuracy 4 ) Equal to True
                                • Then - Actions
                                  • Set VariableSet Current_Level = 4
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • ((Picked unit) has buff Lowered Accuracy 3 ) Equal to True
                                    • Then - Actions
                                      • Set VariableSet Current_Level = 3
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • ((Picked unit) has buff Lowered Accuracy 2 ) Equal to True
                                        • Then - Actions
                                          • Set VariableSet Current_Level = 2
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • ((Picked unit) has buff Lowered Accuracy 1 ) Equal to True
                                            • Then - Actions
                                              • Set VariableSet Current_Level = 1
                                            • Else - Actions
                      • Unit - Remove Lowered Accuracy 1 buff from (Picked unit)
                      • Unit - Remove Lowered Accuracy 2 buff from (Picked unit)
                      • Unit - Remove Lowered Accuracy 3 buff from (Picked unit)
                      • Unit - Remove Lowered Accuracy 4 buff from (Picked unit)
                      • Unit - Remove Lowered Accuracy 5 buff from (Picked unit)
                      • Unit - Remove Lowered Accuracy 6 buff from (Picked unit)
                      • Unit - Create 1 Dummy (Casts stat debuff) for (Owner of SandAttack_Caster[SandAttack_Integer[3]]) at SandAttack_DummyPoint[SandAttack_Integer[3]] facing Default building facing degrees
                      • Unit - Add Lowered Accuracy (Drunken Haze) to (Last created unit)
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Current_Level Less than 6
                        • Then - Actions
                          • Unit - Set level of Lowered Accuracy (Drunken Haze) for (Last created unit) to (Current_Level + 1)
                        • Else - Actions
                          • Unit - Set level of Lowered Accuracy (Drunken Haze) for (Last created unit) to 6
                      • Unit - Order (Last created unit) to Neutral Brewmaster - Drunken Haze (Picked unit)
                      • Unit Group - Add (Picked unit) to SandAttack_NonStrike[SandAttack_Integer[3]]
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_SandAttack_DummyPoint[udg_SandAttack_Integer[3]])
              • Custom script: call RemoveLocation(udg_SandAttack_Location2[udg_SandAttack_Integer[3]])
              • Custom script: call DestroyGroup(udg_SandAttack_Strike[udg_SandAttack_Integer[3]])
              • Set VariableSet SandAttack_Tick[SandAttack_Integer[3]] = (SandAttack_Tick[SandAttack_Integer[3]] - 1)
            • Else - Actions
              • Unit - Kill SandAttack_Dummy[SandAttack_Integer[3]]
              • Custom script: call DestroyGroup(udg_SandAttack_NonStrike[udg_SandAttack_Integer[3]])
              • Set VariableSet SandAttack_Caster[SandAttack_Integer[3]] = SandAttack_Caster[SandAttack_Integer[2]]
              • Set VariableSet SandAttack_Dummy[SandAttack_Integer[3]] = SandAttack_Dummy[SandAttack_Integer[2]]
              • Set VariableSet SandAttack_NonStrike[SandAttack_Integer[3]] = SandAttack_NonStrike[SandAttack_Integer[2]]
              • Set VariableSet SandAttack_DummyGroup[SandAttack_Integer[3]] = SandAttack_DummyGroup[SandAttack_Integer[2]]
              • Set VariableSet SandAttack_Tick[SandAttack_Integer[3]] = SandAttack_Tick[SandAttack_Integer[2]]
              • Set VariableSet SandAttack_Angle[SandAttack_Integer[3]] = SandAttack_Angle[SandAttack_Integer[2]]
              • -------- Cleaning --------
              • Unit Group - Remove all units from SandAttack_NonStrike[SandAttack_Integer[2]].
              • Unit Group - Remove all units from SandAttack_DummyGroup[SandAttack_Integer[2]].
              • -------- Subtracting counters --------
              • Set VariableSet SandAttack_Integer[2] = (SandAttack_Integer[2] - 1)
              • Set VariableSet SandAttack_Integer[3] = (SandAttack_Integer[3] - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SandAttack_Integer[2] Equal to 0
                • Then - Actions
                  • Set VariableSet SandAttack_Integer[1] = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
[/poiler]
 

Attachments

Since you specified size [50] when creating the variable SandAttack_NonStrike the game creates 51 groups for the variable at index 0-50. But you are destroying those groups when the trigger SandAttackRoll concludes. That results in null groups that cant be used.
  • Custom script: call DestroyGroup(udg_SandAttack_NonStrike[udg_SandAttack_Integer[3]])
You can just remove the destruction of the group but theres an alternative that allows you to use less groups. You can handle the creation and destruction similarly to how you handle everything else with the dynamic indexing. To do this enter the variable editor (important for changing variable size without disabling variable usage in triggers) and change the size of the group to 1. Add set udg_SandAttack_NonStrike[udg_SandAttack_Integer[2]] = CreateGroup() to your SandAttack trigger. Enable JassHelper if you have not done so already.
  • Custom script: set udg_SandAttack_NonStrike[udg_SandAttack_Integer[2]] = CreateGroup()
I also noticed additional problems. Because the Drunken Haze ability has 50 Area of Effect it can affect units outside the picked units. That leaves them outside of your control and outside the trigger logic. Id change this to 0, since you are already casting Drunken Haze on each affected target and there is no need for it to apply to nearby units.
In conjunction to this, for effectiveness, you could just create a single dummy in SandAttack and add an expiration timer to it or remove it when the spell concludes in SandAttackRoll and use this dummy to cast all Drunken Hazes. For this to work the dummy unit needs to be correctly set up, it seems you are missing having 0 movement speed and 0 Cast Backswing and Cast Point (actually only one of those Cast ones but it doesnt hurt to put both to 0). Theres game-play constants for maximum and minimum movement speed for units which I think most would agree should be set to 0 for minimum and 522 for maximum to allow for the greatest possible scope.
 
Last edited:
Back
Top