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

hashtable and damage blocking issue

Status
Not open for further replies.
Level 6
Joined
May 15, 2009
Messages
191
Hello Hive

I'm trying to create a spell where an Enchantress Hero periodically shields her allied Heroes for 50 points.
The Shield is applied to all allied Heroes, picked through a unit group. The units have a special effect applied to them (A mana shield) and the shield value assigned in a hashtable.

The shield is supposed to stack, so whenever the trigger runs without the unit having taken 50+ damage since last time, another "stack" of 50 points is added to the shield.
I've gotten the shield part working, and the unit seems to be blocking and stacking properly. However the special effect (the mana shield model) attached to the unit doesn't seem to be removed, it just gets thicker and thicker, not dissappearing along with the shield.
Can anyone give me advice to this?

The trigger is twofold, a periodic trigger for applying shield and saving stuff in hashtables, and the actual damagereduction trigger (Thx for Bribe for this bit).

  • Events
    • Time - Every 15.00 seconds of game time


  • Warden ShieldBlocking
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource belongs to an enemy of Player 1 (Red)) Equal to True
      • (Unit-type of DamageEventTarget) Not equal to Enchantress (Healer)
    • Actions
      • Unit Group - Pick every unit in Ward_Tempug and do (Actions)
        • Loop - Actions
          • -------- Loads the ShieldAmount real from Ward_hash --------
          • Game - Display to (All players) for 2.00 seconds the text: (Shield amount for blocking = + (String(Ward_Tempr1)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DamageEventAmount Greater than or equal to Ward_Tempr1
            • Then - Actions
              • -------- If the Damage is greater than or equal to the shield size, the shield is removed, but damage still reduced by however much was left --------
              • Set Ward_ShieldEffect = (Load (Key ShieldEffect) of (Key (Picked unit)) in Ward_hash)
              • Special Effect - Destroy Ward_ShieldEffect
              • Set DamageEventAmount = (DamageEventAmount - Ward_Tempr1)
              • Set Ward_Tempr1 = 0.00
              • Hashtable - Save Ward_Tempr1 as (Key ShieldAmount) of (Key (Picked unit)) in Ward_hash
              • Game - Display to (All players) for 2.00 seconds the text: ([1]Damage down to = + (String(Ward_Tempr1)))
            • Else - Actions
              • -------- If the shield is greater than the damage dealt, the shield persists and both remaining shield and damage are reduced --------
              • Set Ward_Tempr1 = (Ward_Tempr1 - DamageEventAmount)
              • Set DamageEventAmount = 0.00
              • Hashtable - Save Ward_Tempr1 as (Key ShieldAmount) of (Key (Picked unit)) in Ward_hash
              • Game - Display to (All players) for 2.00 seconds the text: ([2]Damage down to = + (String(Ward_Tempr1)))


Any help is much appreciated.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Hello Hive

I'm trying to create a spell where an Enchantress Hero periodically shields her allied Heroes for 50 points.
The Shield is applied to all allied Heroes, picked through a unit group. The units have a special effect applied to them (A mana shield) and the shield value assigned in a hashtable.

The shield is supposed to stack, so whenever the trigger runs without the unit having taken 50+ damage since last time, another "stack" of 50 points is added to the shield.
I've gotten the shield part working, and the unit seems to be blocking and stacking properly. However the special effect (the mana shield model) attached to the unit doesn't seem to be removed, it just gets thicker and thicker, not dissappearing along with the shield.
Can anyone give me advice to this?

The trigger is twofold, a periodic trigger for applying shield and saving stuff in hashtables, and the actual damagereduction trigger (Thx for Bribe for this bit).

  • Events
    • Time - Every 15.00 seconds of game time


  • Warden ShieldBlocking
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource belongs to an enemy of Player 1 (Red)) Equal to True
      • (Unit-type of DamageEventTarget) Not equal to Enchantress (Healer)
    • Actions
      • Unit Group - Pick every unit in Ward_Tempug and do (Actions)
        • Loop - Actions
          • -------- Loads the ShieldAmount real from Ward_hash --------
          • Game - Display to (All players) for 2.00 seconds the text: (Shield amount for blocking = + (String(Ward_Tempr1)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DamageEventAmount Greater than or equal to Ward_Tempr1
            • Then - Actions
              • -------- If the Damage is greater than or equal to the shield size, the shield is removed, but damage still reduced by however much was left --------
              • Set Ward_ShieldEffect = (Load (Key ShieldEffect) of (Key (Picked unit)) in Ward_hash)
              • Special Effect - Destroy Ward_ShieldEffect
              • Set DamageEventAmount = (DamageEventAmount - Ward_Tempr1)
              • Set Ward_Tempr1 = 0.00
              • Hashtable - Save Ward_Tempr1 as (Key ShieldAmount) of (Key (Picked unit)) in Ward_hash
              • Game - Display to (All players) for 2.00 seconds the text: ([1]Damage down to = + (String(Ward_Tempr1)))
            • Else - Actions
              • -------- If the shield is greater than the damage dealt, the shield persists and both remaining shield and damage are reduced --------
              • Set Ward_Tempr1 = (Ward_Tempr1 - DamageEventAmount)
              • Set DamageEventAmount = 0.00
              • Hashtable - Save Ward_Tempr1 as (Key ShieldAmount) of (Key (Picked unit)) in Ward_hash
              • Game - Display to (All players) for 2.00 seconds the text: ([2]Damage down to = + (String(Ward_Tempr1)))


Any help is much appreciated.

Make a unit group for the special effect only. If the shielded unit is in the group then do nothing, if it isn't add the special effect to the unit and add the unit to the unit group. Upon shield end remove special effect from the unit and remove the unit from the unit group.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I suggest re-organizing the spell.

When you add it, you increase a number in the hashtable saved under the key of the target (the one who gets the shield) and save the effect on it (if it didnt already had one).

Then when a unit takes damage, check if that value in the hashtable is bigger than 0, this means that the target has a shield.
So you can then remove the shield properly.

However, I dont really know how you make the shield bigger... so there might be something that wouldnt work because of how you intent to do that.

Also, I suggest you to use a unit indexer with arrays instead of a hashtable or use Table (but that is JASS only actually).
 
Status
Not open for further replies.
Top