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

Ah... problem with hashtables...

Status
Not open for further replies.
Level 14
Joined
Aug 8, 2010
Messages
1,022
Hi! I am newbie in heashtables. I have tried to create a MUI trigg. and what?! It don't work, of course. So, here is my problem - i want to make an absorbing shield by adding health equal to the damage caused to the unit with the shield. And the a variable that is set to 500 (the amount of damage absorbed) will decrease with the amount of damage taken, so when the 500 real reaches zero - the shield is gone. And here are my "perfect" triggers :
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HashTblIceBarr = (Last created hashtable)
  • Trig1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ice Barrier
    • Actions
      • Hashtable - Save Handle Of(Casting unit) as 0 of (Key (Triggering unit)) in HashTblIceBarr
      • Unit Group - Add (Load 0 of (Key (Triggering unit)) in HashTblIceBarr) to (Units within 1000000000.00 of (Center of (Playable map area)) matching ((Ability being cast) Equal to Ice Barrier ))
      • Hashtable - Save Handle Of(Last created unit group) as 0 of (Key (Picked unit)) in HashTblIceBarr
      • Hashtable - Save 500.00 as 0 of (Key (Target unit of ability being cast)) in HashTblIceBarr
      • Hashtable - Save ((Load 0 of (Key (Target unit of ability being cast)) from HashTblIceBarr) - (Damage taken)) as 1 of (Key (Target unit of ability being cast)) in HashTblIceBarr
      • Game - Display to (All players) the text: Trig started!
  • Trig2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Load 0 of (Key (Triggering unit)) in HashTblIceBarr) Equal to (Attacked unit)
    • Actions
      • Unit Group - Pick every unit in (Load 0 of (Key (Picked unit)) in HashTblIceBarr) and do (Actions)
        • Loop - Actions
          • Hashtable - Save ((Load 0 of (Key (Target unit of ability being cast)) from HashTblIceBarr) - (Damage taken)) as 1 of (Key (Attacked unit)) in HashTblIceBarr
          • Unit - Set life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr) to ((Life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr)) + (Damage taken))
          • Trigger - Run Trig3 <gen> (checking conditions)
          • Game - Display to (All players) the text: Trig runs
  • Trig3
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 1 of (Key (Attacked unit)) from HashTblIceBarr) Greater than 0.00
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Game - Display to (All players) the text: Trig stopped
          • Unit - Remove Frost Armor buff from (Load 0 of (Key (Casting unit)) in HashTblIceBarr)
          • Trigger - Turn off Trig2 <gen>
. And it don't work... I will upload my map in any case... (the absorbing shield is the 'Ice Barrier' magic of the Lich. And don't worry about the tooltip - i will change it.) Please, help me! :sad:
 
Last edited:
Level 11
Joined
Jun 20, 2009
Messages
880
I'm not very good with hashtables, but i think this is the problem:
  • Unit - Set life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr) to ((Life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr)) + (Damage taken))
You need damage detection trigger, you can't just use the "Damage taken"
 
Level 15
Joined
Oct 16, 2010
Messages
941
  • Unit - Set life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr) to ((Life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr)) + (Damage taken))
"damaged taken" can only be used with the Unit - Unit Takes Damage event, which is under specific unit events.
 
Level 11
Joined
Jun 20, 2009
Messages
880
It's like this:

  • Dmg
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Trig2 <gen> the event (Unit - (Picked unit) Takes damage)
Remember to add this event to your second trigger, "Trig2".
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
  • Unit - Set life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr) to ((Life of (Load 0 of (Key (Triggering unit)) in HashTblIceBarr)) + (Damage taken))
"damaged taken" can only be used with the Unit - Unit Takes Damage event, which is under specific unit events.
Ahh... i find the event, but i can't load my unit from the hashtable ( the unit with the shield ) in it??? I mean i can, but only with a variable, and if it's variable - then it wount be MUI i think?!
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
Am... i have my triggers and they actually work, i've created them with hashtables, but they are still not MUI, i think. Triggers :
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HashTblIceBarr = (Last created hashtable)
  • Trig1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ice Barrier
    • Actions
      • Unit Group - Add (Triggering unit) to IceBarrUnGroup
      • Hashtable - Save 1500.00 as 1 of (Key (Triggering unit)) in HashTblIceBarr
      • Hashtable - Save Handle Of(Casting unit) as 2 of (Key (Triggering unit)) in HashTblIceBarr
      • Trigger - Turn on Trig2 <gen>
      • Game - Display to (All players) the text: Trig started!
      • Trigger - Add to Trig3 <gen> the event (Unit - (Load 2 of (Key (Triggering unit)) in HashTblIceBarr) Takes damage)
      • Trigger - Add to Trig2 <gen> the event (Unit - (Load 2 of (Key (Triggering unit)) in HashTblIceBarr) Takes damage)
  • Trig2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacked unit) Equal to (Load 2 of (Key (Attacked unit)) in HashTblIceBarr)
    • Actions
      • Unit Group - Pick every unit in IceBarrUnGroup and do (Actions)
        • Loop - Actions
          • Hashtable - Save ((Load 1 of (Key (Attacked unit)) from HashTblIceBarr) - (Damage taken)) as 1 of (Key (Attacked unit)) in HashTblIceBarr
          • Unit - Set life of (Load 2 of (Key (Attacked unit)) in HashTblIceBarr) to ((Life of (Load 2 of (Key (Attacked unit)) in HashTblIceBarr)) + (Damage taken))
          • Trigger - Run Trig3 <gen> (checking conditions)
          • Game - Display to (All players) the text: Trig runs
  • Trig3
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacked unit) Equal to (Load 2 of (Key (Attacked unit)) in HashTblIceBarr)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 1 of (Key (Attacked unit)) from HashTblIceBarr) Greater than 0.00
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Game - Display to (All players) the text: Trig stopped
          • Unit - Remove Frost Armor buff from (Load 2 of (Key (Attacked unit)) in HashTblIceBarr)
          • Trigger - Turn off Trig2 <gen>

As you can see - my unit is healed equal to the damage caused, right, but when there are 2 units they begin to heal (when it is one unit the damage caused is healed, so that makes it like absorbation - if i have unit with 500 hp the attacker damages lets say - 50 life and after that the 50 life is healed, so my unit lefts with 500 life at all, but when they are 2 units they gain double life - if i have unit with 500 life again it is the same, but it heals the damage from the one unit and from the other, so my unit lefts with 550 life, so they heal). Other clue that makes my trigger not MUI is that when the damage value (1500) is zero the trigger removes ice barrier only from the one unit, the second lefts with the ice barrier. Why?!?! Please help me! +rep, don't forget!
 
Status
Not open for further replies.
Top