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

[Trigger] My dash ability damges enemies more than once HELP PLEASE!

Status
Not open for further replies.
Level 6
Joined
Jul 21, 2019
Messages
168
Hello, i have a problem with a triggered ability i'm trying to make, i watched a tutorial on YouTube about how to make a dash ability, everything good, my unit dashes just fine, but then i wanted to make the dash deal damage to units hit, so i modified the trigger with what i thought would work, but it damages enemies multiple times instead of once, this is a huge problem because the ability is massively overpowered and one shots everything under 500 hp.

Here are the triggers:

  • SS Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spinning Slash
    • Actions
      • Set SS_Caster = (Triggering unit)
      • Set SS_Point[0] = (Position of SS_Caster)
      • Set SS_Point[1] = (Target point of ability being cast)
      • Set SS_Distance = (Distance between (Position of SS_Caster) and SS_Point[1])
      • Set SS_Increment = 70.00
      • Set SS_Angle = (Angle from (Position of SS_Caster) to SS_Point[1])
      • Set SS_Damage = (75 x (Level of Spinning Slash for SS_Caster))
      • Sound - Play Spinning_Slash <gen> at 100.00% volume, attached to (Triggering unit)
      • Unit - Pause SS_Caster
      • Animation - Play SS_Caster's spin animation
      • Unit - Turn collision for SS_Caster Off
      • Trigger - Turn on SS Loop <gen>
  • SS Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set SS_Distance = (SS_Distance - SS_Increment)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SS_Distance Greater than 0.00
        • Then - Actions
          • Set SS_Group = (Units within 150.00 of SS_Point[2] matching (((Matching unit) belongs to an enemy of (Owner of SS_Caster)) Equal to True))
          • Set SS_Point[2] = (Position of SS_Caster)
          • Set SS_Point[3] = (SS_Point[2] offset by SS_Increment towards SS_Angle degrees)
          • Unit - Move SS_Caster instantly to SS_Point[3]
          • Unit Group - Pick every unit in SS_Group and do (Actions)
            • Loop - Actions
              • Unit - Cause SS_Caster to damage (Picked unit), dealing (Real(SS_Damage)) damage of attack type Spells and damage type Normal
              • Unit Group - Remove all units from SS_Group
        • Else - Actions
  • SS Stop
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spinning Slash
    • Actions
      • Wait 0.40 game-time seconds
      • Unit - Unpause SS_Caster
      • Animation - Reset SS_Caster's animation
      • Unit - Turn collision for SS_Caster On
*The 0.40 wait is the average time it takes my unit to perform the dash, i wasn't able to add these actions within the loop trigger, but it works*
(I think the problem is that it repeatedly deals the intended damage every 0.05 seconds right?)


And a video:


Please note that i am just learning to make triggered spells, i'm surprised i even managed to make it work!
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
What you want to do is create a unit group of "already damaged units".
First, create the unit group in your SS Cast trigger. IIRC, there is no GUI action for creating empty unit group, so let's say the unit group variable will be called SS_DamagedUnits. Then you will need something like this:
  • Custom script: set udg_SS_DamagedUnits = CreateGroup()
Next, in your loop trigger when you pick a nearby unit, check if the unit is not in the SS_DamagedUnits group using the following boolean condition
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Picked unit) is in SS_DamagedUnits.) Equal to False
If the condition above returns true, then damage the picked unit and add the picked unit into SS_DamagedUnits unit group. That will ensure that in the next loop iteration it won't get damaged again.

Finally, in your SS Stop trigger destroy the group using
  • Custom script: call DestroyGroup(udg_SS_DamagedUnits)
As for the Wait action in your SS Stop trigger, what you want is to actually use a counter variable in your loop trigger.
If you want the spell to last 0.4 seconds and the loop fires every 0.05 seconds, then you could use an integer variable (which has value set to 0 in SS Start) and every iteration of the loop increse the value of the counter by 1. Finally, stop the spell when the counter reaches value 8 (0.05 * 8 = 0.4 sec).

  • SS Start
    • Events
    • Conditions
    • Actions
      • ...
      • Set VariableSet SS_Counter = 0
      • ...

  • SS Loop
    • Events
    • Conditions
    • Actions
      • ...
      • Set VariableSet SS_Counter = (SS_Counter + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SS_Counter Equal to 8
        • Then - Actions
          • ... stop spell...
        • Else - Actions
 
Level 9
Joined
Jul 30, 2018
Messages
445
IIRC, there is no GUI action for creating empty unit group

If you create a global variable of type Unit Group, its default value will be an empty unit group, which is created when the game initializes all global variables. Now, what you are essentially doing, is creating a new unit group for the already declared global variable (most likely leaking the original group). So, either you don't need that set udg_SS_DamagedUnits = CreateGroup() line at all and instead of destroying the group, just remove the one unit from it, or clear the whole unit group. Or you have to destroy the group at the start of the game so you basically just have an empty variable to be used the way it is now used there.
 
Last edited:
Level 6
Joined
Jul 21, 2019
Messages
168
Hello Sabe, and thanks for the reply

Can the current state of the trigger cause lags and/or crashes?, because the ability works as intended, but if it's a problem please tell me how i can fix it, thanks!

EDIT: i know you mentioned some possible solutions, but as im still ignorant at triggering i didn't really understand, if it isn't too much of a hassle, could you please guide me step-by-step?
 
Level 9
Joined
Jul 30, 2018
Messages
445
Well, it's nothing too serious, since it just leaks the one group the game initially creates for the variable, so you don't need sweat about it. If you want, I guess you could make a trigger with event like "Time - Time elapsed becomes 0.00 seconds" (so it runs after all the other initialization events) and there you could use that DestroyGroup(udg_YourGroupVariable), so it destroys the group the game initially created.
 
Status
Not open for further replies.
Top