• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Trouble with hashtables

Status
Not open for further replies.
Level 1
Joined
Feb 17, 2019
Messages
2
Hello, first post on here.
I am trying to create a charge/dash ability which when cast moves the unit forward a distance based on its current movement speed.
I have been attempting to trigger it in GUI using hashtables, following these two guides:
Hashtables and MUI
A Complete Beginners Guide to Hashtables

Here are the triggers:

Hashtable creation on initialisation:
  • Charge Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet CRUSADER_Charge_Hashtable = (Last created hashtable)
      • Hashtable - Create a hashtable
Cast:
  • Charge cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge!
    • Actions
      • Set VariableSet CRUSADER_Charge_Distance = ((Current movement speed of (Triggering unit)) x 0.04)
      • Set VariableSet CRUSADER_Charge_Time_Remaining = 2.00
      • Hashtable - Save CRUSADER_Charge_Distance as 0 of (Key (Triggering unit).) in CRUSADER_Charge_Hashtable.
      • Hashtable - Save CRUSADER_Charge_Time_Remaining as 1 of (Key (Triggering unit).) in CRUSADER_Charge_Hashtable.
      • Unit Group - Add (Triggering unit) to CRUSADER_Charge_Group
Hashtable loop every 0.04 seconds
  • Charge loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CRUSADER_Charge_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet CRUSADER_Charge_Distance = (Load 0 of (Key (Picked unit).) from CRUSADER_Charge_Hashtable.)
          • Set VariableSet CRUSADER_Charge_Time_Remaining = (Load 1 of (Key (Picked unit).) from CRUSADER_Charge_Hashtable.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CRUSADER_Charge_Time_Remaining Greater than 0.00
            • Then - Actions
              • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by (CRUSADER_Charge_Distance, 0.00))
              • Hashtable - Save (CRUSADER_Charge_Time_Remaining - 0.04) as 1 of (Key (Picked unit).) in CRUSADER_Charge_Hashtable.
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in CRUSADER_Charge_Hashtable.
              • Unit Group - Remove (Picked unit) from CRUSADER_Charge_Group.
I have tried following the guides to the letter but when I order the ability to use the spell, nothing happens.
I have tried troubleshooting it by having other abilities trigger it, but still nothing happens, which leads me to guess I have made a mistake in the hashtables somewhere along the way.

I'd be grateful for any help you could offer a noob :)

Thanks
 
In your first trigger, the variable should be placed after the hashtable's creation. Otherwise, it might refer to another hashtable created somewhere else or none at all. Then, this:
  • Set VariableSet CRUSADER_Charge_Hashtable = (Last created hashtable)
  • Hashtable - Create a hashtable
Should be:
  • Hashtable - Create a hashtable
  • Set VariableSet CRUSADER_Charge_Hashtable = (Last created hashtable)
The move unit action may return wrong results.
  • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by (CRUSADER_Charge_Distance, 0.00))
Currently, the unit will be moved (a little bit) to the right (positive X - axis). Use "(Point with polar offset)" instead, where it requires a location, distance and angle as info. For example:
  • Set unitPos = (Position of (Picked Unit))
  • Set newPos = (unitPos offset by CRUSADER_Charge_Distance towards (Facing of (Picked Unit)) degrees)
  • Unit - Move (Picked Unit) instantly to newPos
  • -------- Don't forget to destroy points after using them. Else, they'll leak. --------
  • Custom script: call RemoveLocation(udg_unitPos)
  • Custom script: call RemoveLocation(udg_newPos)
You could also turn loop trigger off when the unit group is empty, and turn it back on once a unit casts the spell.
 
Status
Not open for further replies.
Back
Top