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

Need assisstance with a hashtable

Status
Not open for further replies.
Level 6
Joined
May 15, 2009
Messages
191
Hey, I'm in rather a pickle here.

I'm trying to create a spell of sorts that focuses a lightning effect (a drain mana) on a target unit. The caster is unit spawned by a trigger, and it channels for as long as it lives (I actually haven't gotten around to the whole stopping the trigger, but that part should be easy enough.

The problem is, I can get the lightning effect created alright, but still being fairly inexperienced with hashtables, I can't seem to get it moving in my loop trigger. Here are the triggers, help is much appreciated and will be rewarded with sweet, sweet points of admiration, recognition, and reputation.


The first trigger both spawns the unit and saves everything needed in hashtables aswell as creating the initial lightning effect. Atleast that's what it should do...
  • Capacitractors Spawn
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Owner of (Matching unit)) Equal to Player 1 (Red)) or ((Owner of (Matching unit)) Equal to Player 2 (Blue))) or ((( and do (Actions)
        • Loop - Actions
          • -------- Picks a random hero from the player team and saves it, adds it to a unit group and saves it in a hashtable --------
          • Set Tempu1 = (Picked unit)
          • Unit Group - Add (Picked unit) to Capacitractor_group
          • Hashtable - Save Handle OfTempu1 as (Key target) of (Key (Picked unit)) in Sucker_hash
      • Set Tempp1 = (Position of Tempu1)
      • Set Tempp2 = (Tempp1 offset by (Random real number between 300.00 and 350.00) towards (Random angle) degrees)
      • Unit - Create 1 Sucker (Boss Minion Dummy) for Player 4 (Purple) at Tempp2 facing Default building facing degrees
      • Unit - Add a 15.00 second Generic expiration timer to (Last created unit)
      • Hashtable - Save Handle Of(Last created unit) as (Key sucker) of (Key (Picked unit)) in Sucker_hash
      • -------- Creates the Lightning effect and saves it in a hashtable --------
      • Lightning - Create a Drain Mana lightning effect from source Tempp1 to target Tempp2
      • Hashtable - Save Handle Of(Last created lightning effect) as (Key lightning) of (Key (Picked unit)) in Sucker_hash
      • -------- Cleans up the trigger, removing any leaks --------
      • Custom script: call RemoveLocation(udg_Tempp1)
      • Custom script: call RemoveLocation(udg_Tempp2)

The loop trigger tries to select the caster and the target once again, save their locations and then move the lightning effect.
  • Capacitractor Move Beam
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Capacitractor_group and do (Actions)
        • Loop - Actions
          • Set Tempu1 = (Picked unit)
          • Set Tempu2 = (Load (Key sucker) of (Key (Picked unit)) in Sucker_hash)
          • Set Tempp1 = (Position of Tempu1)
          • Set Tempp2 = (Position of Tempu2)
          • Set Templightning = (Load (Key lightning) of (Key (Picked unit)) in Sucker_hash)
          • Lightning - Move Templightning to source Tempp1 and target Tempp2
 
Actually I just noticed this comment:
  • -------- Picks a random hero from the player team and saves it, adds it to a unit group and saves it in a hashtable --------
In this case, you would do this instead:

  • Set TempGroup = (Units in (Playable Map Area) ...)
  • Set TempUnit = (Random unit from TempGroup)
  • Set Tempp1 = (Position of TempUnit)
  • .....and so on.....
 
Status
Not open for further replies.
Top