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

Hashtabl0z not working

Status
Not open for further replies.
Level 11
Joined
Feb 14, 2009
Messages
884
Hello everybody!

First of all, I would like you to know that I've read this like a hundred times, and yes, I've tried to make it work myself. The problem is that it cannot load anything from the hashtable (all it prints is "0.000"). What am I doing wrong? Oh, and please don't tell me about leaks etc etc. All I need is some help on hashtables.

Here's the trigger:

  • StalkInit
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Blink
    • Actions
      • Set StalkTotalDistance = (Distance between (Position of (Triggering unit)) and (Target point of ability being cast))
      • Game - Display to (All players) the text: (DEBUG: StalkTotalDistance: + (String(StalkTotalDistance)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StalkTotalDistance Greater than 800.00
        • Then - Actions
          • Set StalkTotalDistance = 800.00
        • Else - Actions
      • Game - Display to (All players) the text: (DEBUG: StalkTotalDistance: + (String(StalkTotalDistance)))
      • Hashtable - Save Handle Of(Target point of ability being cast) as 0 of (Key (Triggering unit)) in Stalk
      • Game - Display to (All players) the text: (DEBUG: + (String((Load 0 of (Key (Triggering unit)) from Stalk))))
      • Hashtable - Save 800 as 1 of (Key (Triggering unit)) in Stalk
      • Hashtable - Save Handle Of(Triggering unit) as 2 of (Key (Triggering unit)) in Stalk
      • Unit Group - Add (Triggering unit) to StalkGroup
Any help appreciated!
 
Level 11
Joined
Feb 14, 2009
Messages
884
I have initialized the hashtable on another trigger, on map initialization. And I know I'm leaking. My problem now is the hashtable, not the leaks. I'll fix them when everything else works correctly.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Damn, you're right. When I wrote it, I thought that it will display the distance. Thanks for pointing out that silly mistake of mine :)

It works now, but I guess you'll be hearing from me again, on another topic. I'm sure I'll make something stupid soon. Thanks again :)

EDIT: Maker, I'm not leaking o_O
Unless you mean the unit group, which is needed because there's a periodic event relying on that group. If I destroy it, won't it screw up the other trigger?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's the trigger without leaks, there was only one leak after all. Remember to clear the target point of ability being cast when you don't need it anymore.

  • StalkInit
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Blink
    • Actions
      • Temp_Loc_1 = Position of (Triggering unit)
      • Temp_Loc_2 = Target point of ability being cast
      • Set StalkTotalDistance = (Distance between Temp_Loc_1 and Temp_Loc_2
      • Game - Display to (All players) the text: (DEBUG: StalkTotalDistance: + (String(StalkTotalDistance)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StalkTotalDistance Greater than 800.00
        • Then - Actions
          • Set StalkTotalDistance = 800.00
        • Else - Actions
      • Game - Display to (All players) the text: (DEBUG: StalkTotalDistance: + (String(StalkTotalDistance)))
      • Hashtable - Save Handle Of(Temp_Loc_2) as 0 of (Key (Triggering unit)) in Stalk
      • Game - Display to (All players) the text: (DEBUG: + (String((Load 0 of (Key (Triggering unit)) from Stalk))))
      • Hashtable - Save 800 as 1 of (Key (Triggering unit)) in Stalk
      • Hashtable - Save Handle Of(Triggering unit) as 2 of (Key (Triggering unit)) in Stalk
      • Unit Group - Add (Triggering unit) to StalkGroup
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
 
Status
Not open for further replies.
Top