1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Get distance with hashtables and saving location handle

Discussion in 'Triggers & Scripts' started by DoomBlade, Aug 21, 2020.

  1. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    365
    Resources:
    0
    Resources:
    0
    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.
     
  2. Devalut

    Devalut

    Joined:
    Feb 9, 2009
    Messages:
    1,490
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
  3. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    365
    Resources:
    0
    Resources:
    0
    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?
     
  4. Devalut

    Devalut

    Joined:
    Feb 9, 2009
    Messages:
    1,490
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    Dunno, distance is set as X upon being set, no more or less than it was when you first set it, Just put it right under the move trigger.

    Might as well nuke the distance setting on dummy cast since you're moving it to the loop trigger.
     
  5. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    365
    Resources:
    0
    Resources:
    0
    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?
     
  6. Devalut

    Devalut

    Joined:
    Feb 9, 2009
    Messages:
    1,490
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    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
     
  7. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    365
    Resources:
    0
    Resources:
    0
    Yeah my dummy units are set correctly :p, thanks anyways!