• 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] Hashtables, oh dear hashtables....

Status
Not open for further replies.
Level 3
Joined
Mar 31, 2013
Messages
47
Hello, i just started to learn Hashtables, pretty interesting. Ok, so let's go straightforward, I'm working on a map, and i tried to do something, a spell, which activate shield on target which will absorb DMG, well, those hashtables are making me problems. I'm going to post here the triggers, btw, i don't want you to make the spell for me, i want you to show me what i did wrong, and how i can make them work, so i can know for the next time. Ok so my problem is, when i cast the spell on one unit, the shield works pretty good, still, idk why sometimes he's taking DMG, but low indeed, idk why the "absorb" effect isn't happening a bit faster, when i use it on two units, it's goes wrong, the value of the shield for one of them is going of like from 2 strikes, maybe this is happening because idk to use hashtables at all(for sure cause of this), and the spell have to be MUI(hashtables are MUI, but if right). I have a bit bigger basic knowledge on GUI, but SUI, not MUI.



Here are the triggers:
  • PWS INIT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Power Word: Shield
    • Actions
      • Set PWSCaster = (Triggering unit)
      • Set PWSTarget = (Target unit of ability being cast)
      • Set PWSShieldValue = (100.00 x (Real((Intelligence of PWSCaster (Include bonuses)))))
      • Set PWSDuration = (8.00 x (Real((Level of Power Word: Shield for PWSCaster))))
      • Unit Group - Add PWSTarget to PWSGroup
      • Hashtable - Save PWSShieldValue as 1 of (Key (Target unit of ability being cast)) in PWSHashtable
      • Hashtable - Save PWSDuration as 2 of (Key (Target unit of ability being cast)) in PWSHashtable
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PWSTakesDamage Equal to False
        • Then - Actions
          • Trigger - Add to PWS Fire <gen> the event (Unit - PWSTarget Takes damage)
          • Set PWSTakesDamage = True
        • Else - Actions
  • PWS Fire
    • Events
    • Conditions
      • (PWSTarget has buff Power Word: Shield ) Equal to True
    • Actions
      • Unit Group - Pick every unit in PWSGroup and do (Actions)
        • Loop - Actions
          • Set PWSShieldValue = (Load 1 of (Key (Picked unit)) from PWSHashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PWSShieldValue Greater than 0.00
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (Damage taken))
              • Hashtable - Save (PWSShieldValue - (Damage taken)) as 1 of (Key (Picked unit)) in PWSHashtable
            • Else - Actions
              • Unit - Remove Power Word: Shield buff from (Picked unit)
              • Unit Group - Remove (Picked unit) from PWSGroup
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in PWSHashtable
 
Last edited:
  • (PWSTarget has buff Power Word: Shield ) Equal to True
It is not mui, because it's always the last target after spell usage.

If ShieldValue is only 1 for example, but damage is 1000, it will still restore all life again.
If you don't want this you can substract the shieldvalue of the damage, and then do further checks/actions.

Where do you use the duration?

Also maybe you can check at cast trigger, if unit alrdy exists in ur daabase, to prevent issues (for example you cast shield on yourself with 1000 mana and high level, and after 1 second your friend casts it on you with 50 mana and low level, then you got trolled^^)
 
Level 3
Joined
Mar 31, 2013
Messages
47
@Iceman, it will be casted just by one hero, i want it just on multiple targets, about duration, did not set yet, i will do it after i can make the shield works as it has to, ok going to change some things
@chaosy, ya, i will try to change this


Edit: I can't found what to put on condition, since i can't find any boolean with "Damaged Unit", and I'm going to a debuff to players who got shield, so they can't be shieled again for an amount of time, like in WoW, when priests use Power World: Shield, the targets get a debuff. But still idk what to put on condition..
 
Level 3
Joined
Mar 31, 2013
Messages
47
  • PWS Fire
    • Events
    • Conditions
      • ((Triggering unit) has buff Power Word: Shield ) Equal to True
    • Actions
      • Unit Group - Pick every unit in PWSGroup and do (Actions)
        • Loop - Actions
          • Set PWSShieldValue = (Load 1 of (Key (Picked unit)) from PWSHashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • PWSShieldValue Greater than 0.00
                  • PWSShieldValue Less than or equal to (100.00 x (Real((Intelligence of PWSCaster (Include bonuses)))))
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (Damage taken))
              • Set PWSShieldValue = (PWSShieldValue - (Damage taken))
              • Hashtable - Save (PWSShieldValue - (Damage taken)) as 1 of (Key (Picked unit)) in PWSHashtable
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PWSShieldValue Equal to 0.00
            • Then - Actions
              • Unit - Remove Power Word: Shield buff from (Picked unit)
              • Unit Group - Remove (Picked unit) from PWSGroup
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in PWSHashtable
            • Else - Actions
Added some thing, but still doesn't work.
 
Level 3
Joined
Mar 31, 2013
Messages
47
Yes.
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set PWSHashtable = (Last created hashtable)
 
Level 3
Joined
Mar 31, 2013
Messages
47
I'm going to use the one by Bribe, i hope i'll understand something from it, if i won't, i will post here 'bout what i don't understand.
 
Level 3
Joined
Mar 31, 2013
Messages
47
@Chaosy, tried nothing.
@Malhorne, tried, did something, but still isn't really working, it keep taking little dmg, and, it's noi MUI, the values of them are messing up.
  • PWS INIT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Power Word: Shield
    • Actions
      • Set PWSCaster = (Triggering unit)
      • Set PWSTarget = (Target unit of ability being cast)
      • Set PWSShieldValue[(Custom value of PWSCaster)] = (100.00 x (Real((Intelligence of PWSCaster (Include bonuses)))))
      • Set PWSDuration = (8.00 x (Real((Level of Power Word: Shield for PWSCaster))))
      • Unit Group - Add PWSTarget to PWSGroup
  • PWS Fire
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • DamageEventOverride Equal to False
    • Actions
      • Set PWSCustomValue = (Custom value of DamageEventTarget)
      • Unit Group - Pick every unit in PWSGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PWSShieldValue[PWSCustomValue] Greater than or equal to 0.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DamageEventAmount Greater than or equal to PWSShieldValue[PWSCustomValue]
                • Then - Actions
                  • Set DamageEventAmount = (DamageEventAmount - PWSShieldValue[PWSCustomValue])
                  • Set PWSShieldValue[PWSCustomValue] = 0.00
                • Else - Actions
                  • Set PWSShieldValue[PWSCustomValue] = (PWSShieldValue[PWSCustomValue] - DamageEventAmount)
                  • Set DamageEventAmount = 0.00
            • Else - Actions
 
Level 3
Joined
Mar 31, 2013
Messages
47
Thanks, going to check it.

Can't really save the game since your system gave me 233 errors.
 
Last edited by a moderator:
Level 3
Joined
Mar 31, 2013
Messages
47
I still don't really understand what to pull out from that system, i see there some types of DMG, but i don't know how i can set the amount to "absorb" that DMG.
 
Level 3
Joined
Mar 31, 2013
Messages
47
Alright, going to do it and reply what i got.;)

Edit: I did something, but it's going really wrong, i mean i can't make the amount to be changed, every attack will be absorbed(healed), but i want that value variable (amount) to get rid of the damage, till it gets to zero. So - means negative, and the damage taken is positive, so i have -2100(just for a matter of time i set this), so again, -2100+DamageTaken, so if the damage taken is 200 for example, we will have -2100+200=-1900, but this ain't happening, idk why, the amount is remaining the initial value. Here are the triggers.
  • PWS Fire
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (target has buff Power Word: Shield ) Equal to True
        • Then - Actions
          • Set amount = (-2100.00 + (Damage taken))
          • Game - Display to (All players) for 10.00 seconds the text: ((Name of source) + ( damages + ((Name of target) + ( with damage: + (|cffff0000 + (String(amount)))))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • amount Equal to 0.00
            • Then - Actions
              • Unit - Remove Power Word: Shield buff from target
            • Else - Actions
        • Else - Actions
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
This should work
  • PWS Fire
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (target has buff Power Word: Shield ) Equal to True
        • Then - Actions
          • Set shield = Load shield value from hashtable
          • set shield = shield - amount
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • shield > 0.00
            • Then - Actions
              • save shield value into hashtable
              • set amount = 0
            • Else - Actions
              • set amount = -shield
              • Unit - Remove Power Word: Shield buff from target
        • Else - Actions
 
Level 3
Joined
Mar 31, 2013
Messages
47
Hmm, i don't know how to set that -shield, tried in this way, but the shield is dying from 1 hit.

  • PWS Fire
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (target has buff Power Word: Shield ) Equal to True
        • Then - Actions
          • Set PWSShieldValue = (Load (Integer(PWSShieldValue)) of (Key (Target unit of ability being cast)) from PWSHashtable)
          • Set PWSShieldValue = (PWSShieldValue - amount)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PWSShieldValue Greater than 0.00
            • Then - Actions
              • Hashtable - Save PWSShieldValue as 1 of (Key (Target unit of ability being cast)) in PWSHashtable
              • Set amount = 0.00
            • Else - Actions
              • Set amount = (0.00 - PWSShieldValue)
              • Unit - Remove Power Word: Shield buff from target
        • Else - Actions
 
Level 3
Joined
Mar 31, 2013
Messages
47
"No variables of this type" when i wanna replace event response target unit of ability being cast with the variable target.
 
Level 3
Joined
Mar 31, 2013
Messages
47
Still, the shield is going off from one hit. The PWSShieldValue is 10xINT, but caster's int is 179, so 1790 DMG, and the mobs are hitting just for 200, + tried to change to 1000 x int and still nothing. I'm posting the init trigger too, maybe it's something wrong there.
  • PWS INIT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Power Word: Shield
    • Actions
      • Set PWSCaster = (Triggering unit)
      • Set PWSTarget = (Target unit of ability being cast)
      • Custom script: set udg_id = GetHandleId(udg_target)
      • Set PWSShieldValue = (10.00 x (Real((Intelligence of PWSCaster (Include bonuses)))))
      • Set PWSDuration = (8.00 x (Real((Level of Power Word: Shield for PWSCaster))))
      • Hashtable - Save PWSShieldValue as 1 of id in PWSHashtable
  • PWS Fire
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (target has buff Power Word: Shield ) Equal to True
        • Then - Actions
          • Set PWSShieldValue = (Load (Integer(PWSShieldValue)) of id from PWSHashtable)
          • Set PWSShieldValue = (PWSShieldValue - amount)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PWSShieldValue Greater than 0.00
            • Then - Actions
              • Hashtable - Save PWSShieldValue as 1 of id in PWSHashtable
              • Set amount = 0.00
            • Else - Actions
              • Set amount = (0.00 - PWSShieldValue)
              • Unit - Remove Power Word: Shield buff from target
        • Else - Actions
 
Level 3
Joined
Mar 31, 2013
Messages
47
Value appears to be -74.825, one single shot, value and shield off. Here's the hashtable creation.
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set PWSHashtable = (Last created hashtable)
 
Level 3
Joined
Mar 31, 2013
Messages
47
Woah, thank you, seems i messed up the GetHandle Target thingy:), now it's working perfect, and it's MUI:X, +rep to you for your great help, and i started to understand Hashtables too, btw, i have a question, the amount, source and target variables, are from the system itself, is there any problem if i use them in more than 1 spell?

Edit: I got an issue with the removal of the buff being MUI, if there are 2 targets, only the second one will get the debuff removed and the first one will have it forever. Maker, can you look over this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Distance between PWSPoint[2] and PWSPoint[3]) Less than or equal to 100.00
    • Then - Actions
      • Set PWSPoint[5] = (Position of PWSTarget)
      • Unit - Create 1 IoLBAntiDebuff for (Owner of PWSCaster) at PWSPoint[5] facing Default building facing degrees
      • Unit - Order (Last created unit) to Orc Shaman - Bloodlust PWSTarget
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 PWSDebuff for (Owner of PWSCaster) at PWSPoint[5] facing Default building facing degrees
      • Unit - Order (Last created unit) to Undead Necromancer - Unholy Frenzy PWSTarget
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 PWSExplo for (Owner of PWSCaster) at PWSPoint[5] facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: set udg_id = GetHandleId(udg_PWSTarget)
      • Unit Group - Add PWSTarget to PWSGroup
      • Set PWSShieldValue = (10.00 x (Real((Intelligence of PWSCaster (Include bonuses)))))
      • Set PWSDuration = 10.00
      • Hashtable - Save PWSShieldValue as 1 of id in PWSHashtable
      • Hashtable - Save PWSDuration as 2 of id in PWSHashtable
      • Hashtable - Save Handle OfPWSTarget as 3 of id in (Last created hashtable)
      • Unit - Remove PWSDummy from the game
      • Custom script: call RemoveLocation(udg_PWSPoint[5])
      • Custom script: call RemoveLocation(udg_PWSPoint[2])
      • Custom script: call RemoveLocation(udg_PWSPoint[3])
      • Custom script: call RemoveLocation(udg_PWSPoint[4])
      • Trigger - Turn off (This trigger)
    • Else - Actions
  • PWS RemoveDebuff
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PWSGroup and do (Actions)
        • Loop - Actions
          • Set PWSDuration = (Load 2 of id from PWSHashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PWSDuration Greater than 0.00
            • Then - Actions
              • Hashtable - Save (PWSDuration - 1.00) as 2 of id in PWSHashtable
            • Else - Actions
              • Unit - Remove Power Word: Shield buff from (Load 3 of id in PWSHashtable)
              • Unit Group - Remove (Load 3 of id in PWSHashtable) from PWSGroup
              • Hashtable - Clear all child hashtables of child id in (Last created hashtable)
 
Last edited:
Level 3
Joined
Mar 31, 2013
Messages
47
Fixed last created hashtabled, but still, the second one overrides the first one, the first one debuff is never going off.


Edit:Fixed it. ;)
 
Last edited:
Status
Not open for further replies.
Top