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

Custom Damage System Optimization

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

I made this system to trigger my map damage... But right now it's kinda "big" and I'm having some troubles achieving some stuff..


These is the Hashtable data so far.
0 - Spell Damage - > Override the rest of damage data. Boolean
1 - Physical Damage
2 - Physycal Resistance
3 - Fire Damage
4 - Fire Resistance
5 - Wind Damage
6 - Wind Resistance
7 - Earth Damage
8 - Earth Resistance
9 - Water Damage
10 - Water Resistance
11 - Pure Damage
12 - Critical Chance
13 - Critical Rate
14 - Evasion
15 - Bash Chance
16 - Bash Duration
17- Bashed Time


This is how I set the damage based on the unit type ID.

  • Damage Set
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DamageHash = (Last created hashtable)
      • -------- Footman --------
      • Custom script: set udg_i = 'hfoo'
      • Hashtable - Save 7.00 as 1 of i in DamageHash
      • Hashtable - Save 0.15 as 2 of i in DamageHash
      • Hashtable - Save 1.00 as 12 of i in DamageHash
      • Hashtable - Save 1.20 as 13 of i in DamageHash
      • Hashtable - Save 0.00 as 14 of i in DamageHash
      • Hashtable - Save 1.00 as 15 of i in DamageHash
      • Hashtable - Save 10.00 as 16 of i in DamageHash


This is how I handle the Hero stats. It's "Player" stat, since it's based on Player Number.

All the "iVariable" are for Skills/Items/Etc. bonuses.

  • Heroes Stats
    • Events
      • Unit - A unit enters (Playable map area)
      • Unit - A unit Acquires an item
      • Unit - A unit Uses an item
      • Unit - A unit Loses an item
      • Unit - A unit Learns a skill
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Mountain King
    • Actions
      • -------- Unit / Owner / Number --------
      • Set u = (Triggering unit)
      • Set p = (Owner of u)
      • Set i = (Player number of p)
      • -------- Stats --------
      • Set HeroStr[i] = (Real((Strength of u (Include bonuses))))
      • Set HeroAgi[i] = (Real((Agility of u (Include bonuses))))
      • Set HeroInt[i] = (Real((Intelligence of u (Include bonuses))))
      • -------- Physycal Damage --------
      • Set PD = (iPD[i] + ((HeroAgi[i] x 0.50) + ((HeroInt[i] x 0.25) + (HeroStr[i] x 1.00))))
      • Hashtable - Save PD as 1 of i in DamageHash
      • -------- Physycal Resistance --------
      • Set PR = (iPD[i] + (HeroStr[i] / 500.00))
      • Hashtable - Save PR as 2 of i in DamageHash
      • -------- Fire Damage --------
      • Hashtable - Save iFD[i] as 3 of i in DamageHash
      • -------- Fire Resistance --------
      • Hashtable - Save iFR[i] as 4 of i in DamageHash
      • -------- Wind Damage --------
      • Hashtable - Save iWiD[i] as 5 of i in DamageHash
      • -------- Wind Resistance --------
      • Hashtable - Save iWiR[i] as 6 of i in DamageHash
      • -------- Earth Damage --------
      • Hashtable - Save iED[i] as 7 of i in DamageHash
      • -------- Earth Resistance --------
      • Hashtable - Save iER[i] as 8 of i in DamageHash
      • -------- Water Damage --------
      • Hashtable - Save iWaD[i] as 9 of i in DamageHash
      • -------- Water Resistance --------
      • Hashtable - Save iWaR[i] as 10 of i in DamageHash
      • -------- Pure Damage --------
      • Hashtable - Save iPuD[i] as 11 of i in DamageHash
      • -------- Critical Chance --------
      • Set CritChance[i] = (iCritChance[i] + (HeroInt[i] / 500.00))
      • Hashtable - Save CritChance[i] as 12 of i in DamageHash
      • -------- Critical Damage Rate --------
      • Set CritRate[i] = (iCritRate[i] + (HeroStr[i] / 500.00))
      • Hashtable - Save CritRate[i] as 13 of i in DamageHash
      • -------- Evasion --------
      • Set EvaChance[i] = (iEvaChance[i] + (HeroAgi[i] / 500.00))
      • Hashtable - Save EvaChance[i] as 14 of i in DamageHash
      • -------- Bash Chance --------
      • Set BashChance_Hero[i] = (iBashChance[i] + (HeroStr[i] / 500.00))
      • Hashtable - Save BashChance_Hero[i] as 15 of i in DamageHash
      • -------- Bash Duration --------
      • Set BashDuration_Hero[i] = (iBashDuration[i] + (HeroStr[i] / 500.00))
      • Hashtable - Save BashDuration_Hero[i] as 16 of i in DamageHash


This is how I display the selected units information.
  • Stat Display
    • Events
      • Player - Player 1 (Red) types a chat message containing -st as An exact match
    • Conditions
    • Actions
      • Set p = (Triggering player)
      • Set TempForce = (Player group(p))
      • Set Temp_Group = (Units currently selected by p)
      • Set Group2 = (Random 1 units from Temp_Group)
      • Custom script: if GetLocalPlayer() == udg_p then
      • Custom script: call ClearTextMessages()
      • Custom script: endif
      • Unit Group - Pick every unit in Group2 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Custom script: set udg_i = GetConvertedPlayerId(udg_p)
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, GetPlayerName(udg_p) + ":")
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
              • Set ii = (Integer((Load 1 of i from DamageHash)))
              • Set iii = (Integer(((Load 2 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffffd700Damage:|r " + (I2S(udg_ii) + (" |cffffd700/|r " + (I2S(udg_iii) + "% |cffffd700Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 3 of i from DamageHash)))
              • Set iii = (Integer(((Load 4 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffff0000Damage:|r " + (I2S(udg_ii) + (" |cffff0000/|r " + (I2S(udg_iii) + "% |cffff0000Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 5 of i from DamageHash)))
              • Set iii = (Integer(((Load 6 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff999999Damage:|r " + (I2S(udg_ii) + (" |cff999999/|r " + (I2S(udg_iii) + "% |cff999999Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 7 of i from DamageHash)))
              • Set iii = (Integer(((Load 8 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff552200Damage:|r " + (I2S(udg_ii) + (" |cff552200/|r " + (I2S(udg_iii) + "% |cff552200Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 9 of i from DamageHash)))
              • Set iii = (Integer(((Load 10 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff77bbffDamage:|r " + (I2S(udg_ii) + (" |cff77bbff/|r " + (I2S(udg_iii) + "% |cff77bbffResistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 11 of i from DamageHash)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff7F0080Damage:|r " + (I2S(udg_ii))))
              • Custom script: endif
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
              • Set ii = (Integer(((Load 12 of i from DamageHash) x 100.00)))
              • Set Real = (Load 13 of i from DamageHash)
              • Custom script: if udg_ii > 0 or udg_Real > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Critical: " + ((I2S(udg_ii) + "% x"))) + (R2SW(udg_Real, 1, 1)))
              • Custom script: endif
              • Set ii = (Integer(((Load 14 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Evasion: " + ((I2S(udg_ii) + "%"))))
              • Custom script: endif
              • Set ii = (Integer(((Load 15 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Bash Chance: " + ((I2S(udg_ii) + "%"))))
              • Custom script: endif
            • Else - Actions
              • Set u = (Picked unit)
              • Custom script: set udg_i = GetHandleId(udg_u)
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, (GetUnitName(udg_u) + (": |cffffd700Level|r " + I2S(GetUnitLevel(udg_u)))))
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
              • Set ii = (Integer((Load 1 of i from DamageHash)))
              • Set iii = (Integer(((Load 2 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffffd700Damage:|r " + (I2S(udg_ii) + (" |cffffd700/|r " + (I2S(udg_iii) + "% |cffffd700Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 3 of i from DamageHash)))
              • Set iii = (Integer(((Load 4 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffff0000Damage:|r " + (I2S(udg_ii) + (" |cffff0000/|r " + (I2S(udg_iii) + "% |cffff0000Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 5 of i from DamageHash)))
              • Set iii = (Integer(((Load 6 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff999999Damage:|r " + (I2S(udg_ii) + (" |cff999999/|r " + (I2S(udg_iii) + "% |cff999999Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 7 of i from DamageHash)))
              • Set iii = (Integer(((Load 8 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff552200Damage:|r " + (I2S(udg_ii) + (" |cff552200/|r " + (I2S(udg_iii) + "% |cff552200Resistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 9 of i from DamageHash)))
              • Set iii = (Integer(((Load 10 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 or udg_iii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff77bbffDamage:|r " + (I2S(udg_ii) + (" |cff77bbff/|r " + (I2S(udg_iii) + "% |cff77bbffResistance|r" )))))
              • Custom script: endif
              • Set ii = (Integer((Load 11 of i from DamageHash)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff7F0080Damage:|r " + (I2S(udg_ii))))
              • Custom script: endif
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
              • Set ii = (Integer(((Load 12 of i from DamageHash) x 100.00)))
              • Set Real = (Load 13 of i from DamageHash)
              • Custom script: if udg_ii > 0 or udg_Real > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Critical: " + ((I2S(udg_ii) + "% x"))) + (R2SW(udg_Real, 1, 1)))
              • Custom script: endif
              • Set ii = (Integer(((Load 14 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Evasion: " + ((I2S(udg_ii) + "%"))))
              • Custom script: endif
              • Set ii = (Integer(((Load 15 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Bash: " + ((I2S(udg_ii) + "%"))))
              • Custom script: endif
              • Set ii = (Integer(((Load 16 of i from DamageHash) x 100.00)))
              • Custom script: if udg_ii > 0 then
              • Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Bash Duration: " + ((I2S(udg_ii))))
              • Custom script: endif
      • Custom script: call DestroyForce(udg_TempForce)
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call DestroyGroup(udg_Group2)


This is how I handle stunned units.
  • StunGroup
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in StunGroup and do (Actions)
        • Loop - Actions
          • Custom script: set udg_i = GetHandleId(GetEnumUnit())
          • Set BashDur = ((Load 17 of i from DamageHash) - 0.03)
          • Hashtable - Save BashDur as 17 of i in DamageHash
          • Game - Display to (All players) the text: (String(BashDur))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BashDur Less than or equal to 0.00
            • Then - Actions
              • Hashtable - Save 0.00 as 17 of i in DamageHash
              • Unit - Remove Stunned (Pause) buff from (Picked unit)
              • Unit Group - Remove (Picked unit) from StunGroup
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in StunGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions


This is my trigger to deal damage.

  • Damage Itself
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (Unit-type of GDD_DamageSource) Not equal to DUMMY
    • Actions
      • Set FontSize = 8.00
      • -------- DamagedUnit and DamageSource Id's --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (GDD_DamagedUnit is A Hero) Equal to True
        • Then - Actions
          • Set I_DU = (Player number of (Triggering player))
        • Else - Actions
          • Custom script: set udg_I_DU = GetUnitTypeId(udg_GDD_DamagedUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (GDD_DamageSource is A Hero) Equal to True
        • Then - Actions
          • Set I_DS = (Player number of (Owner of GDD_DamageSource))
        • Else - Actions
          • Custom script: set udg_I_DS = GetUnitTypeId(udg_GDD_DamageSource)
      • Custom script: if LoadBooleanBJ(0, udg_I_DS, udg_DamageHash) == true then
      • Custom script: return
      • Custom script: endif
      • -------- Damage Types (Odd) and Resistances (Even) --------
      • Set PD = ((Load 1 of I_DS from DamageHash) x (1.00 - (Load 2 of I_DU from DamageHash)))
      • Set FD = ((Load 3 of I_DS from DamageHash) x (1.00 - (Load 4 of I_DU from DamageHash)))
      • Set WiD = ((Load 5 of I_DS from DamageHash) x (1.00 - (Load 6 of I_DU from DamageHash)))
      • Set ED = ((Load 7 of I_DS from DamageHash) x (1.00 - (Load 8 of I_DU from DamageHash)))
      • Set WaD = ((Load 9 of I_DS from DamageHash) x (1.00 - (Load 10 of I_DU from DamageHash)))
      • Set PuD = (Load 11 of I_DS from DamageHash)
      • Set CritChanc = (Load 12 of I_DS from DamageHash)
      • Set CriticalRate = (Load 13 of I_DS from DamageHash)
      • Set Eva = (Load 14 of I_DU from DamageHash)
      • Set BashChance = (Load 15 of I_DS from DamageHash)
      • Set BashDuration = (Load 16 of I_DS from DamageHash)
      • -------- Total Damage --------
      • Custom script: set udg_Dmg = udg_PD + udg_FD + udg_WiD + udg_ED + udg_WaD + udg_PuD
      • -------- Evasion --------
      • Custom script: if GetRandomReal(0, 1) <= udg_Eva then
      • Floating Text - Create floating text that reads miss above GDD_DamageSource with Z offset 0.00, using font size 9.50, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
      • Custom script: return
      • Custom script: endif
      • -------- Critical Hit --------
      • Custom script: if udg_CritChanc > 0 and GetRandomReal(0,1) <= udg_CritChanc then
      • Custom script: set udg_Dmg = (udg_Dmg * udg_CriticalRate)
      • Set FontSize = 13.00
      • Custom script: endif
      • -------- Bash Chance --------
      • Custom script: if udg_BashChance > 0 and GetRandomReal(0,1) <= udg_BashChance then
      • Custom script: set udg_i = GetHandleId(udg_GDD_DamagedUnit)
      • Set BashDur = ((Load 17 of i from DamageHash) + BashDuration)
      • Custom script: if udg_BashDur > 2.5 then
      • Custom script: set udg_BashDur = 2.5
      • Custom script: endif
      • Hashtable - Save BashDur as 17 of i in DamageHash
      • Set Point = (Position of GDD_DamagedUnit)
      • Unit - Create 1 DUMMY for (Owner of GDD_DamageSource) at Point facing Point
      • Unit - Order (Last created unit) to Attack GDD_DamagedUnit
      • Unit - Add a 0.20 second Generic expiration timer to (Last created unit)
      • Unit Group - Add GDD_DamagedUnit to StunGroup
      • Trigger - Turn on StunGroup <gen>
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: endif
      • -------- Display Red Damage --------
      • Custom script: if (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) < GetWidgetLife(udg_GDD_DamagedUnit) then
      • Floating Text - Create floating text that reads (String((Integer(Dmg)))) above GDD_DamagedUnit with Z offset 0.00, using font size FontSize, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
      • -------- Display Green Heal --------
      • Custom script: elseif (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) > GetWidgetLife(udg_GDD_DamagedUnit) then
      • Custom script: call SetWidgetLife(udg_GDD_DamagedUnit, GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg)
      • Floating Text - Create floating text that reads (+ + (String((Integer((Abs(Dmg))))))) above GDD_DamagedUnit with Z offset -2.00, using font size FontSize, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
      • Custom script: endif
      • -------- Deal Damage if it's > 0 --------
      • Trigger - Turn off (This trigger)
      • Custom script: if udg_Dmg > 0 then
      • Custom script: call UnitDamageTarget(udg_GDD_DamageSource, udg_GDD_DamagedUnit, udg_Dmg, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
      • Custom script: endif
      • Trigger - Turn on (This trigger)
.

I'd like to know how to improve the overall. Now I noticed that, as it is right now, I can't modify specific unit values, since all the data is taken from "Unit Type" and not specific unit ID.

Also, I want to display the data in a Hashtable for triggering player, rather than doing it with Game text.

Another thing is that I'm having too many variables...

I haven't done the trigger that actually sets the Hero/Player values, since i'm using The Witcher equipment system and gets a bit harder.
 
Level 4
Joined
Mar 27, 2008
Messages
112
Well go jass as half of it basicly is jass, so it's just easier and more effecient to do it in jass (yes you might have to learn a few extra things, but once you know it everything will go so much easier;))
 
you really dont need to array the HeroStr and alike, just save it to a hash with a unique childkey...

JASS:
set udg_CHILEKEY = 0x0202 //far away from conflicts
call SaveInteger(HASH, GetHandleId(udg_u), udg_CHILEKEY, GetHeroStr(udg_u, true)) 
call SaveInteger(HASH, GetHandleId(udg_u), udg_CHILEKEY+1, GetHeroAgi(udg_u, true)) 
call SaveInteger(HASH, GetHandleId(udg_u), udg_CHILEKEY+2, GetHeroInt(udg_u, true))

  • --> this
  • Custom script: if LoadBooleanBJ(0, udg_I_DS, udg_DamageHash) == true then
  • --> to this
  • Custom script: if LoadBooleanBJ(0, udg_I_DS, udg_DamageHash) then
others I did not read coz of laziness XD...
 
1)then recreate the data for specific units...
2)what exactly do you mean show data for TP without using Game text?
3)that's normal... else use hashes...
4)You can do it, good luck! But for that, I actually modified his system so that items directly modify the custom hero values instead of using item abilities

Also about the damage text, since the other values are different, just set the text inside the if-then, but set all other data outside of the if-then-else... same result, less lines of code...

@Mckill - it should be
if LoadBoolean(udg_DamageHash, udg_I_DS, 0) then
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I didn't get the
JASS:
set udg_CHILEKEY = 0x0202 //far away from conflicts
call SaveInteger(HASH, GetHandleId(udg_u), udg_CHILEKEY, GetHeroStr(udg_u, true)) 
call SaveInteger(HASH, GetHandleId(udg_u), udg_CHILEKEY+1, GetHeroAgi(udg_u, true)) 
call SaveInteger(HASH, GetHandleId(udg_u), udg_CHILEKEY+2, GetHeroInt(udg_u, true))

1) Recreate the data for specific units, would be...
-A unit enters playable map area-
- Set i = Key(Triggering Unit)
if udg_i = 'hfoo' then
save..
elseif udgi = 'asdf' then..

And save the values that way to each unit?

-> Didn't get this:
Also about the damage text, since the other values are different, just set the text inside the if-then, but set all other data outside of the if-then-else... same result, less lines of code...
<-
 
I got it from Hero Stats
Set i = (Player number of p)

coz instead of putting it in an array which is the player number, just save it with unique
ID's...afterall, hashtables filters specific data, same as arrayed variables...

EDIT:
udg_CHILEKEY (mispelled) is an integer variable set as a childkey of *something*.
0x0202 is also a large integer instead of putting keys like 1,2,3 etc...keys will be in millions,
coz regular keys might conflict/overwrite things when using/saving in the same "DamageHash" hashtable...
 
1)Yup

About the hashes, you don't really need that kind of key if the hashtable is specific to the system... in that case you can just use 0,1,2,3 blahblah... though it won't hurt using it...

  • -------- Display Red Damage --------
  • Custom script: if (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) < GetWidgetLife(udg_GDD_DamagedUnit) then
  • Floating Text - Create floating text that reads (String((Integer(Dmg)))) above GDD_DamagedUnit with Z offset 0.00, using font size FontSize, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
  • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
  • -------- Display Green Heal --------
  • Custom script: elseif (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) > GetWidgetLife(udg_GDD_DamagedUnit) then
  • Custom script: call SetWidgetLife(udg_GDD_DamagedUnit, GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg)
  • Floating Text - Create floating text that reads (+ + (String((Integer((Abs(Dmg))))))) above GDD_DamagedUnit with Z offset -2.00, using font size FontSize, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
  • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
into

  • Display Red Damage --------
  • Custom script: if (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) < GetWidgetLife(udg_GDD_DamagedUnit) then
  • Floating Text - Create floating text that reads (String((Integer(Dmg)))) above GDD_DamagedUnit with Z offset 0.00, using font size FontSize, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
  • -------- Display Green Heal --------
  • Custom script: elseif (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) > GetWidgetLife(udg_GDD_DamagedUnit) then
  • Custom script: call SetWidgetLife(udg_GDD_DamagedUnit, GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg)
  • Floating Text - Create floating text that reads (+ + (String((Integer((Abs(Dmg))))))) above GDD_DamagedUnit with Z offset -2.00, using font size FontSize, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
  • Custom script: endif
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
  • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oh! Good Adiktuz! I'll improve that.

Thanks for the idea of adding the data based on the Unit Type ID; but not only to unit type ID :p
 
Actually, no need for if-then on the unit based... if you keep the one based on the UnitTypeId, you can just load the value for the UnitTypeId of that unit and save it onto the one based on his HandleId (Key(Unit))... so it will just be 1 line per thing to be saved, no need for if-then-elses...

something like
  • Set i = Key(TriggeringUnit)
  • Custom script: Set udg_i2 = GetUnitTypeId(GetTriggerUnit())
  • Hashtable - Save (Load 1 of i2 in Hash) as 1 of i in Hash
Btw, not sure if the syntax is right, but it should give you an idea
 
Status
Not open for further replies.
Top