• 🏆 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] What's wrong with my Dash spell?

Status
Not open for further replies.
Level 3
Joined
Feb 3, 2016
Messages
43
I created a simple dash spell which pushes the caster 400 units in the direction it is facing, while also damaging all enemy units the caster passes through. One issue that I can't determine the cause of keeps pushing the caster endlessly forward. Can someone help me see where & why?

  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shoulder Charge
    • Actions
      • Set Caster = (Casting unit)
      • Set Cast_Point = (Position of Caster)
      • Set End_Point = (Cast_Point offset by 400.00 towards (Facing of Caster) degrees)
      • Set Distance = (Distance between Cast_Point and End_Point)
      • Unit - Turn collision for Caster Off
      • Special Effect - Create a special effect attached to the weapon of Caster using Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
      • Set Charge_Effect = (Last created special effect)
      • Trigger - Turn on Charge Movement <gen>
  • Charge Movement
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set Distance = (Distance - 16.00)
      • Unit Group - Pick every unit in (Units within 200.00 of (Position of Caster)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of Caster)) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is in Charge_Targets) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to Charge_Targets
              • Unit - Cause Caster to damage (Picked unit), dealing 350.00 damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Weapons\Bolt\BoltImpact.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Distance Equal to 0.00
        • Then - Actions
          • Unit - Turn collision for Caster On
          • Special Effect - Destroy Charge_Effect
          • Unit Group - Remove all units from Charge_Targets
          • Set Distance = 0.00
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit - Move Caster instantly to (Cast_Point offset by (400.00 - Distance) towards (Facing of Caster) degrees)
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
  • Do nothing is useless and never needs to be used anywhere. Just literally do nothing.
  • You're leaking a group and various points point in both triggers (you're doing Charge_Targets correctly though). Learn how to generally avoid/fix them here: Things That Leak
  • 0.01 is unnecessarily fast for this loop. Sure it will run fine but it would look roughly the same at 0.03 which is ~33 fps.
  • Your trigger fails because the Distance you're giving it is 400, which is not a multiple of 16. Your trigger only subtracts 16 from the distance but checks for when it's == 0, which never happens. Instead choose "less than or equal".
  • Not sure entirely what you meant to do in this line: Move Caster instantly to (Cast_Point offset by (400.00 - Distance) towards (Facing of Caster) degrees)
    • It moves the caster by (400-16) the first step then moves it by (384-16) the second step, etc.
    • Keep in mind this happens every 0.01 seconds, so it's effectively moving at 40,000 units/sec. That's very fast.
    • I guess you intended the caster to slow down as it reaches its destination point?
    • If you wanted a constant speed it should just be offset by 16.00.
 
Level 3
Joined
Feb 3, 2016
Messages
43
  • Do nothing is useless and never needs to be used anywhere. Just literally do nothing.
  • You're leaking a group and various points point in both triggers (you're doing Charge_Targets correctly though). Learn how to generally avoid/fix them here: Things That Leak
  • 0.01 is unnecessarily fast for this loop. Sure it will run fine but it would look roughly the same at 0.03 which is ~33 fps.
  • Your trigger fails because the Distance you're giving it is 400, which is not a multiple of 16. Your trigger only subtracts 16 from the distance but checks for when it's == 0, which never happens. Instead choose "less than or equal".
  • Not sure entirely what you meant to do in this line: Move Caster instantly to (Cast_Point offset by (400.00 - Distance) towards (Facing of Caster) degrees)
    • It moves the caster by (400-16) the first step then moves it by (384-16) the second step, etc.
    • Keep in mind this happens every 0.01 seconds, so it's effectively moving at 40,000 units/sec. That's very fast.
    • I guess you intended the caster to slow down as it reaches its destination point?
    • If you wanted a constant speed it should just be offset by 16.00.

1. Alright, I did not know that, thank you!
2. I will look into that.
3. I chose 0.01 because I wanted the travel time to be done in 0.5 seconds total (very fast) since the ability tries to emulate charging someone with a shoulder at a close distance, which is supposed to be very fast.
4. You are definitely right about the condition change, but the problem in execution is it seems to work 80% of the time, i.e. the caster stops at the intended distance, but every once in a while it doesn't - that's the weird part. Maybe your suggestion helps, will test it out!
5. That trigger moves the caster, since the Cast_Point variable is the point at which the caster cast the spell (it's constant) - that is why the offset needs to be adjusted at each trigger interval. And no, I didn't intend for the caster to slow down as it approaches the end point, and doesn't do so in testing. To have the slowing down effect it would require slightly more advanced math, am I correct? And once again, the spell is meant to be done in 0.5 seconds.

P.S. I know it's not MUI compatible, but that is an easy enough fix for me, this "map" is to test out the spell; a proof-of-concept.
 
Level 3
Joined
Feb 3, 2016
Messages
43
  • Do nothing is useless and never needs to be used anywhere. Just literally do nothing.
  • You're leaking a group and various points point in both triggers (you're doing Charge_Targets correctly though). Learn how to generally avoid/fix them here: Things That Leak
  • 0.01 is unnecessarily fast for this loop. Sure it will run fine but it would look roughly the same at 0.03 which is ~33 fps.
  • Your trigger fails because the Distance you're giving it is 400, which is not a multiple of 16. Your trigger only subtracts 16 from the distance but checks for when it's == 0, which never happens. Instead choose "less than or equal".
  • Not sure entirely what you meant to do in this line: Move Caster instantly to (Cast_Point offset by (400.00 - Distance) towards (Facing of Caster) degrees)
    • It moves the caster by (400-16) the first step then moves it by (384-16) the second step, etc.
    • Keep in mind this happens every 0.01 seconds, so it's effectively moving at 40,000 units/sec. That's very fast.
    • I guess you intended the caster to slow down as it reaches its destination point?
    • If you wanted a constant speed it should just be offset by 16.00.
Okay, I updated the Charge Movement trigger, is this alright? I never used Call Custom Script before, hopefully I am doing it right:
  • Charge Movement
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set Distance = (Distance - 16.00)
      • Unit Group - Pick every unit in (Units within 200.00 of (Position of Caster)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of Caster)) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is in Charge_Targets) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to Charge_Targets
              • Unit - Cause Caster to damage (Picked unit), dealing 350.00 damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Weapons\Bolt\BoltImpact.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Distance Less than or equal to 0.00
        • Then - Actions
          • Unit - Turn collision for Caster On
          • Special Effect - Destroy Charge_Effect
          • Unit Group - Remove all units from Charge_Targets
          • Custom script: call DestroyGroup(udg_Charge_Targets)
          • Set Distance = 0.00
          • Custom script: call RemoveLocation(udg_Cast_Point)
          • Custom script: call RemoveLocation(udg_End_Point)
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit - Move Caster instantly to (Cast_Point offset by (400.00 - Distance) towards (Facing of Caster) degrees)
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
Almost. There were also leaks in the cast trigger. You don’t need to destroy Charge_Targets because you are only manually adding/removing units to/from it. This properly reuses the group without ever assigning a new group object to the variable. You are still leaking in this line:

Unit Group - Pick every unit in (Units within 200.00 of (Position of Caster)) and do (Actions)

Also a point in that one and in the line where you move the caster.

Proxym8 said:
I chose 0.01 because I wanted the travel time to be done in 0.5 seconds total (very fast) since the ability tries to emulate charging someone with a shoulder at a close distance, which is supposed to be very fast.
Right but the travel speed is not dependent on the trigger execution frequency. For a given speed V and trigger period P, a unit moving by V*P units per trigger execution will be moving at speed V.
 
Last edited:
Status
Not open for further replies.
Top