• 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.

[Trigger] Hashtable Problems!

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2012
Messages
159
Hello Hives.
I'm having trouble with hashtables.
It is a trigger that counts everytime a Deaht Knight kills an enemy unit. Whenever he reaches 10/8/6 stacks of kills, he will regain 25% health and gain 1 strength.
However, the trigger keeps saying that the RandomBladeHungers_i = 1, thus showing that the value haven't been saved in the hashtable.
  • Random Sword Hungers Initial Hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set RandomSwordHungers_hash = (Last created hashtable)
      • Set RandomSwordHungers_UG = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Death Knight))
      • Set RandomSwordHungers_i = 1
      • Unit Group - Pick every unit in RandomSwordHungers_UG and do (Actions)
        • Loop - Actions
          • Hashtable - Save RandomSwordHungers_i as (Key (Picked unit)) of 1 in RandomSwordHungers_hash
  • Random Sword Hungers Kill
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is in RandomSwordHungers_UG) Equal to True
      • (Level of Random Blade Hungers for (Killing unit)) Greater than 0
    • Actions
      • Set RandomSwordHungers_caster = (Killing unit)
      • Set RandomSwordHungers_i = (Key (Load (Key (Killing unit)) of 1 in RandomSwordHungers_hash))
      • Set RandomSwordHungers_i = (RandomSwordHungers_i + 1)
      • Custom script: call RemoveSavedHandle(udg_RandomSwordHungers_hash, GetHandleId(udg_RandomSwordHungers_caster), 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomSwordHungers_i Equal to (13 - (2 x (Level of Random Blade Hungers for RandomSwordHungers_caster)))
        • Then - Actions
          • Set RandomSwordHungers_p = (Position of RandomSwordHungers_caster)
          • Special Effect - Create a special effect at RandomSwordHungers_p using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Hero - Modify Strength of RandomSwordHungers_caster: Add 1
          • Unit - Set life of RandomSwordHungers_caster to ((Percentage life of RandomSwordHungers_caster) + 25.00)%
          • Set RandomSwordHungers_i = 1
          • Custom script: call RemoveLocation(udg_RandomSwordHungers_p)
        • Else - Actions
          • Floating Text - Create floating text that reads (String(RandomSwordHungers_i)) above RandomSwordHungers_caster with Z offset 100.00, using font size 15.00, color (50.00%, 25.00%, 25.00%), and 0.00% transparency
          • Set TempText_F = (Last created floating text)
          • Trigger - Run Temp Floating Text <gen> (checking conditions)
      • Hashtable - Save RandomSwordHungers_i as 0 of (Key (Killing unit)) in RandomSwordHungers_hash
Btw, and I dealing properly with the leaks of the saved handle in 'Random Sword Hungers Kill'?
Thanks
 
Your loading and saving is off. You are saving it in 0 and loading it in 1.

  • Set RandomSwordHungers_i = (Key (Load (Key (Killing unit)) of 1 in RandomSwordHungers_hash))
  • Hashtable - Save RandomSwordHungers_i as 0 of (Key (Killing unit)) in RandomSwordHungers_hash
Needs to be this.

  • Set RandomSwordHungers_i = (Key (Load 0 of (Key (Killing unit)) in RandomSwordHungers_hash))
  • Hashtable - Save RandomSwordHungers_i as 0 of (Key (Killing unit)) in RandomSwordHungers_hash
You should also store key of killing unit in a variable.

Also if you are looking to count the units kills and then increase stats you can use my system. http://www.hiveworkshop.com/forums/...-a-245075/?prev=d=list&r=20&u=deathismyfriend
 
Status
Not open for further replies.
Top