• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

gui hashtable for my item heal passive

Level 5
Joined
Mar 18, 2023
Messages
63
So when a specific item is picked up, it'll turn on a loop trigger. During this loop trigger, it'll trigger a heal every 18 seconds for the lowest health hero out of all allied players for 25% of their max health. I'm also trying to make this passive stack when other heroes have this item as well. Right now, it kinda works I guess? but turns off after 1 timer loop. The Hashtable saves aren't saving correctly. I'm trying to not use any global variable (except the Unit Group) cause it's getting to the point where I have too much. I'll use it if needed, but I'd prefer not to. I'll also post a SS file of the results I got. Do note that the current GUI coding I'm posting on this thread is slightly different than the way I tested it. But basically, the "if/then/else + turn off trigger" was originally the final action of this trigger. I decided to move it to center and placed the actual healing actions on the "else" since it feels practical. So in its current iteration, it would just turn off instead of healing once.

  • Holy Grail passive
    • Events
      • Time - Every 18.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: local integer i = 1
      • Custom script: local location p
      • Hashtable - Save 0 as (Key hg.) of (Key count.) in Hash.
      • Hashtable - Save 999999.00 as (Key hg.) of (Key lowHP.) in Hash.
      • Set VariableSet HolyGrailUG = (Units in (Playable map area) matching ((((Matching unit) belongs to an ally of Player 7 (Green).) Equal to True) and ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • Unit Group - Pick every unit in HolyGrailUG and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has an item of type The Holy Grail) Equal to True
            • Then - Actions
              • Hashtable - Save ((Load (Key hg.) of (Key count.) from Hash.) + 1) as (Key hg.) of (Key count.) in Hash.
              • Game - Display to (All players) for 3.00 seconds the text: (hg count: + (String((Load (Key hg.) of (Key count.) from Hash.))))
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load (Key hg.) of (Key count.) from Hash.) Equal to 0.00
        • Then - Actions
          • Game - Display to (All players) for 3.00 seconds the text: turn off hg passive
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Custom script: loop
          • Custom script: exitwhen i > LoadIntegerBJ(StringHashBJ("hg"), StringHashBJ("count"), udg_Hash)
          • Unit Group - Pick every unit in HolyGrailUG and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Life of (Picked unit)) Less than (Load (Key hg.) of (Key lowHP.) from Hash.)
                • Then - Actions
                  • Hashtable - Save Handle Of(Picked unit) as (Key hg.) of (Key unit.) in Hash.
                  • Game - Display to (All players) for 3.00 seconds the text: (hg unit: + (String((Load (Key hg.) of (Key unit.) from Hash.))))
                  • Hashtable - Save (Life of (Picked unit)) as (Key hg.) of (Key lowHP.) in Hash.
                  • Hashtable - Save (Life of (Load (Key hg.) of (Key unit.) in Hash.)) as (Key hg.) of (Key lowHP.) in Hash.
                  • Game - Display to (All players) for 3.00 seconds the text: (hg lowHP: + (String((Load (Key hg.) of (Key lowHP.) from Hash.))))
                • Else - Actions
          • Unit - Set life of (Load (Key hg.) of (Key unit.) in Hash.) to ((Load (Key hg.) of (Key lowHP.) from Hash.) + ((Max life of (Load (Key hg.) of (Key unit.) in Hash.)) x 0.25))
          • Hashtable - Save (Life of (Load (Key hg.) of (Key unit.) in Hash.)) as (Key hg.) of (Key lowHP.) in Hash.
          • Game - Display to (All players) for 3.00 seconds the text: (finished healing: + (String((Load (Key hg.) of (Key lowHP.) from Hash.))))
          • Custom script: set p = GetUnitLoc(LoadUnitHandleBJ(StringHashBJ("hg"), StringHashBJ("unit"), udg_Hash))
          • Custom script: call AddSpecialEffectLocBJ( p, "Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl" )
          • Special Effect - Destroy (Last created special effect)
          • Custom script: set i = i + 1
          • Custom script: endloop
      • Custom script: call RemoveLocation(p)
      • Custom script: set p = null
also forgot to add the custom script to destroy unit group. I just added it right now
 

Attachments

  • Screenshot 2026-02-13 084952.png
    Screenshot 2026-02-13 084952.png
    188.6 KB · Views: 28
Last edited:
Not sure if the following will resolve all your troubles, anyway you are doing this:
  • Hashtable - Save 0 as (Key hg.) of (Key count.) in Hash.
  • Hashtable - Save ((Load (Key hg.) of (Key count.) from Hash.) + 1) as (Key hg.) of (Key count.) in Hash.
but then your check is like this:
  • (Load (Key hg.) of (Key count.) from Hash.) Equal to 0.00
In the first two lines you are saving integers, but in condition you are comparing reals. Integer is not real and there is no value of type 'real' stored in the hashtable, so it will return the default real value (0.00).
Try changing your condition to integer comparison.
 
Here's an example without the Hashtable. You can switch from Percentage life to flat values, but Percentages tend to make more sense here:
  • Actions
    • Set Variable BestTarget = No unit
    • Set Variable Lowest = 99999.00
    • Set Variable Targets = (Units that you want to compare...)
    • Unit Group - Pick every unit in Targets and do Actions
      • Loop - Actions
        • Set Variable Current = (Percentage life of (Picked unit))
        • If all conditions are true then do (Actions)
          • If - Conditions
            • Current Less than Lowest
          • Then - Actions
            • Set Variable BestTarget = (Picked unit)
            • Set Variable Lowest = Current
          • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • BestTarget Not equal to No unit
      • Then - Actions
        • Unit - Kill BestTarget <-- just an example, but this will be your lowest health unit
      • Else - Actions
 
Not sure if the following will resolve all your troubles, anyway you are doing this:
  • Hashtable - Save 0 as (Key hg.) of (Key count.) in Hash.
  • Hashtable - Save ((Load (Key hg.) of (Key count.) from Hash.) + 1) as (Key hg.) of (Key count.) in Hash.
but then your check is like this:
  • (Load (Key hg.) of (Key count.) from Hash.) Equal to 0.00
In the first two lines you are saving integers, but in condition you are comparing reals. Integer is not real and there is no value of type 'real' stored in the hashtable, so it will return the default real value (0.00).
Try changing your condition to integer comparison.
oh wow good catch. I was wondering what went wrong

Here's an example without the Hashtable. You can switch from Percentage life to flat values, but Percentages tend to make more sense here:
  • Actions
    • Set Variable BestTarget = No unit
    • Set Variable Lowest = 99999.00
    • Set Variable Targets = (Units that you want to compare...)
    • Unit Group - Pick every unit in Targets and do Actions
      • Loop - Actions
        • Set Variable Current = (Percentage life of (Picked unit))
        • If all conditions are true then do (Actions)
          • If - Conditions
            • Current Less than Lowest
          • Then - Actions
            • Set Variable BestTarget = (Picked unit)
            • Set Variable Lowest = Current
          • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • BestTarget Not equal to No unit
      • Then - Actions
        • Unit - Kill BestTarget <-- just an example, but this will be your lowest health unit
      • Else - Actions
ty uncle. I shall test this later on
 
Back
Top