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

[Solved] Get distance with hashtables and saving location handle

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
Hello hivers. I am trying to make a spell that throws a shuriken and when the distance is reached, it will be removed from the game.

I made another skill that creates a shadow clone of the unit that mimics the shuriken. Kinda like Zed from League of Legends. (Just thought the reforged Akama attack animation 1 was way too fitting for a shuriken skill).

Anyways, the dummy unit (shuriken) is not removed when it reaches the desired distance. I am using hashtables. Here are the triggers:

  • Shuriken
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shuriken (text not done)
    • Actions
      • Unit - Create 1 Shuriken for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to ShurikenGroup
      • Set VariableSet Shuriken_Loc = (Target point of ability being cast)
      • Set VariableSet Shurken_Loc2 = (Position of (Last created unit))
      • Set VariableSet Shuriken_Angle = (Angle from Shurken_Loc2 to Shuriken_Loc)
      • Set VariableSet Shuriken_Distance = (Distance between Shurken_Loc2 and Shuriken_Loc)
      • Hashtable - Save Shuriken_Angle as 1 of (Key (Last created unit).) in Shuriken_Hash.
      • Hashtable - Save Shuriken_Distance as 2 of (Key (Last created unit).) in Shuriken_Hash.
      • Hashtable - Save Handle OfShuriken_Loc as 3 of (Key (Last created unit).) in Shuriken_Hash.
      • Hashtable - Save Handle OfShurken_Loc2 as 4 of (Key (Last created unit).) in Shuriken_Hash.
      • Set VariableSet ShurikenShadow_Group = (Units owned by (Owner of (Triggering unit)) of type Shadow Image)
      • Unit Group - Pick every unit in ShurikenShadow_Group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Orc Tauren Chieftain - Shockwave (Target point of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Shuriken Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Shuriken Loop <gen>
        • Else - Actions

  • Shuriken Dummy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shuriken Dummy (Dummy Cast)
    • Actions
      • Unit - Create 1 Shuriken for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to ShurikenGroup
      • Set VariableSet Shuriken_Loc = (Target point of ability being cast)
      • Set VariableSet Shurken_Loc2 = (Position of (Last created unit))
      • Set VariableSet Shuriken_Angle = (Angle from Shurken_Loc2 to Shuriken_Loc)
      • Set VariableSet Shuriken_Distance = (Distance between Shurken_Loc2 and Shuriken_Loc)
      • Hashtable - Save Shuriken_Angle as 1 of (Key (Last created unit).) in Shuriken_Hash.
      • Hashtable - Save Shuriken_Distance as 2 of (Key (Last created unit).) in Shuriken_Hash.
      • Hashtable - Save Handle OfShuriken_Loc as 3 of (Key (Last created unit).) in Shuriken_Hash.
      • Hashtable - Save Handle OfShurken_Loc2 as 4 of (Key (Last created unit).) in Shuriken_Hash.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Shuriken Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Shuriken Loop <gen>
        • Else - Actions

  • Shuriken Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ShurikenGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet Shuriken_Angle = (Load 1 of (Key (Picked unit).) from Shuriken_Hash.)
          • Set VariableSet Shuriken_Distance = (Load 2 of (Key (Picked unit).) from Shuriken_Hash.)
          • Set VariableSet Shuriken_Loc = (Load 3 of (Key (Picked unit).) in Shuriken_Hash.)
          • Set VariableSet Shurken_Loc2 = (Load 4 of (Key (Picked unit).) in Shuriken_Hash.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shuriken_Distance Less than or equal to 25.00
            • Then - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in Shuriken_Hash.
              • Unit Group - Remove (Picked unit) from ShurikenGroup.
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
              • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 24.00 towards Shuriken_Angle degrees.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in ShurikenGroup) Less than or equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Unit Group - Remove all units of ShurikenGroup from ShurikenGroup.
            • Else - Actions

Everything else works, the dummy unit casts the skill, the unit is moved and the angle works as intented. Just think the trigger cannot get the distance so obviously I am storing something wrong here.

It's also currently missing damage, but I'll add it later.

Oh and if someone can help me with the dummy to instantly cast the skill with the Hero, there is like an 0.3-0.6 sec delay before the Shadow Image casts the skill.
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
Level 12
Joined
Feb 5, 2018
Messages
521
Oh yeah right well, I thought that when you save the location handle and distance and load them you don't need to reduce the distance.

X unit point
Y target point

X---Y distance 300
Load hashtables, X unit point, Y target point every 0.03 sec, gets new distance? No?

Anyway on which bracket do I set the save (ex (Shuriken_Distance - 24.00) ->->-> Save Shuriken_Distance as 2 of (Picked Unit))

And do I need to remove some of the Load actions in the loop?
 
Level 12
Joined
Feb 5, 2018
Messages
521
Thanks @Devalut
  • Shuriken Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ShurikenGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet Shuriken_Angle = (Load 1 of (Key (Picked unit).) from Shuriken_Hash.)
          • Set VariableSet Shuriken_Distance = (Load 2 of (Key (Picked unit).) from Shuriken_Hash.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shuriken_Distance Less than or equal to 25.00
            • Then - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in Shuriken_Hash.
              • Unit Group - Remove (Picked unit) from ShurikenGroup.
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
              • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 24.00 towards Shuriken_Angle degrees.)
              • Hashtable - Save (Shuriken_Distance - 24.00) as 2 of (Key (Picked unit).) in Shuriken_Hash.
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in ShurikenGroup) Less than or equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Unit Group - Remove all units of ShurikenGroup from ShurikenGroup.
            • Else - Actions
It works like this now! :)

Do you have any idea how to make the dummy units cast the spell at the exact same time with the hero?
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
I'm so pleased to hear, Ensure that the dummy unit has these fields set to 0.00:
upload_2020-8-21_11-16-57.png
 
Status
Not open for further replies.
Top