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

Spell not working properly

Status
Not open for further replies.
Level 10
Joined
Sep 6, 2008
Messages
423
I've made a dash spell where the caster targets a point and dashes towards that point. The casters collision is turned off while he's dashing and I've made it so that if the point where he's supposed to be going next isn't walkable he won't move and if it is he will continue to move as he should (made this in case someone wants to go outside the map) well the problem is that he never starts the dash :cry: I've done a similar spell before and it worked flawlessly (I didn't implement the check if point is walkable) so I would like you (who knows triggering) to check my 2 triggers and see if there is something wrong with them.

  • Sweeping Strikes
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sweeping Strikes
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spell_Index Equal to 0
        • Then - Actions
          • Trigger - Turn on Spell Loop <gen>
        • Else - Actions
      • Set Spell_Index = (Spell_Index + 1)
      • Unit - Turn collision for (Triggering unit) Off
      • Unit Group - Add (Triggering unit) to Sweeping_Strikes_Group
      • -------- Spell settings --------
      • Set Spell_Damage = (50 x (Level of (Ability being cast) for (Triggering unit)))
      • Set Spell_Distance = (250.00 + (150.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
      • Set Spell_Distance_Traveled = 0.00
      • Set Spell_Effect = Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
      • Set Spell_Speed = (700.00 x 0.05)
      • Set TempLoc[1] = (Position of (Triggering unit))
      • Set TempLoc[2] = (Target point of ability being cast)
      • Set Spell_Degrees = (Angle from TempLoc[1] to TempLoc[2])
      • Custom script: call RemoveLocation(udg_TempLoc[1])
      • Custom script: call RemoveLocation(udg_TempLoc[2])
      • -------- Saving settings --------
      • Hashtable - Save Spell_Damage as 0 of (Key (Triggering unit)) in Spell_Hashtable
      • Hashtable - Save Spell_Distance as 1 of (Key (Triggering unit)) in Spell_Hashtable
      • Hashtable - Save Spell_Distance_Traveled as 2 of (Key (Triggering unit)) in Spell_Hashtable
      • Hashtable - Save Spell_Effect as 3 of (Key (Triggering unit)) in Spell_Hashtable
      • Hashtable - Save Spell_Speed as 4 of (Key (Triggering unit)) in Spell_Hashtable
      • Hashtable - Save Spell_Degrees as 5 of (Key (Triggering unit)) in Spell_Hashtable

  • Spell Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Sweeping_Strikes_Group and do (Actions)
        • Loop - Actions
          • Set Spell_Damage = (Load 0 of (Key (Picked unit)) from Spell_Hashtable)
          • Set Spell_Distance = (Load 1 of (Key (Picked unit)) from Spell_Hashtable)
          • Set Spell_Distance_Traveled = (Load 2 of (Key (Picked unit)) from Spell_Hashtable)
          • Set Spell_Effect = (Load 3 of (Key (Picked unit)) from Spell_Hashtable)
          • Set Spell_Speed = (Load 4 of (Key (Picked unit)) from Spell_Hashtable)
          • Set Spell_Degrees = (Load 5 of (Key (Picked unit)) from Spell_Hashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Spell_Distance Greater than Spell_Distance_Traveled
            • Then - Actions
              • Set Spell_Distance_Traveled = (Spell_Distance_Traveled + Spell_Speed)
              • Set TempLoc[1] = (Position of (Picked unit))
              • Set TempLoc[2] = (TempLoc[1] offset by Spell_Speed towards Spell_Degrees degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at TempLoc[2] of type Walkability is off) Equal to False
                • Then - Actions
                  • Unit - Move (Picked unit) instantly to TempLoc[2], facing Spell_Degrees degrees
                  • Animation - Play (Picked unit)'s Walk animation
                  • Special Effect - Create a special effect at TempLoc[2] using Spell_Effect
                  • Special Effect - Destroy (Last created special effect)
                  • Set TempUnit = (Picked unit)
                  • Set TempGroup = (Units within 50.00 of TempLoc[2] matching (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Equal to True))
                  • Unit Group - Pick every unit in TempGroup and do (Actions)
                    • Loop - Actions
                      • Unit - Cause TempUnit to damage (Picked unit), dealing (Real(Spell_Damage)) damage of attack type Spells and damage type Normal
                  • Set TempUnit = No unit
                • Else - Actions
                  • Unit - Move (Picked unit) instantly to TempLoc[1], facing Spell_Degrees degrees
                  • Animation - Play (Picked unit)'s Walk animation
                  • Special Effect - Create a special effect at TempLoc[1] using Spell_Effect
                  • Special Effect - Destroy (Last created special effect)
                  • Set TempUnit = (Picked unit)
                  • Set TempGroup = (Units within 50.00 of TempLoc[1] matching (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Equal to True))
                  • Unit Group - Pick every unit in TempGroup and do (Actions)
                    • Loop - Actions
                      • Unit - Cause TempUnit to damage (Picked unit), dealing (Real(Spell_Damage)) damage of attack type Spells and damage type Normal
                  • Set TempUnit = No unit
              • Custom script: call RemoveLocation(udg_TempLoc[1])
              • Custom script: call RemoveLocation(udg_TempLoc[2])
              • Hashtable - Save Spell_Damage as 0 of (Key (Picked unit)) in Spell_Hashtable
              • Hashtable - Save Spell_Distance as 1 of (Key (Picked unit)) in Spell_Hashtable
              • Hashtable - Save Spell_Distance_Traveled as 2 of (Key (Picked unit)) in Spell_Hashtable
              • Hashtable - Save Spell_Effect as 3 of (Key (Picked unit)) in Spell_Hashtable
              • Hashtable - Save Spell_Speed as 4 of (Key (Picked unit)) in Spell_Hashtable
              • Hashtable - Save Spell_Degrees as 5 of (Key (Picked unit)) in Spell_Hashtable
            • Else - Actions
              • Set Spell_Index = (Spell_Index - 1)
              • Unit - Turn collision for (Picked unit) On
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Spell_Hashtable
              • Unit Group - Remove (Picked unit) from Sweeping_Strikes_Group
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Spell_Index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions


Don't look for any leaks just a reason why it wouldn't work.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Can't see anything wrong with it (except unit group leaks ;) just by looking at it.

Have you initialized the hashtable?

Try debugging it with the help of Floating Text messages. Check if it goes into the THEN branch where the unit is moved, and if it can load the values (Spell_Distance, Spell_Distance_Traveled).

In the second trigger:

Only load Spell_Distance and Spell_Distance_Traveled. Then do that "greater than" check, and only if it is true, load the other values.

Set Temp_Unit = Picked Unit, and use it rather than Picked Unit. It's faster.

Why do you save the effect, damage, speed, distance and angle with every loop? They don't change.
 
Level 10
Joined
Sep 6, 2008
Messages
423
When I saw
Have you initialized the hashtable?
I though "Ofcourse I initialized it.. it's the first thing you do" then I checked to be on the safe side and I only created it (simple misstakes gives big consequenceses) thanks for this too (I was almost certain that you would answer this one as well) I'll give rep when I've spread around some first.

I'll also fix the other things you pointed out :wink:
 
Status
Not open for further replies.
Top