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

[General] Trigger to alter hero stats works only once

Level 10
Joined
Jun 13, 2010
Messages
398
I want a hashtable to store all stats and when you equip and item, gets a buff, chooses a passive skill, it will calculate the stats for your hero.

So far I made it work so when you equip an item, it sets the attribute to the stat given - but then from there on out nothing happens. It doesn't change if I equip more items with stats or lose the item.

What am I missing?

  • HSS Key Stats
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Creating Hashtable --------
      • Hashtable - Create a hashtable
      • Set VariableSet HSS_ItemHashtable = (Last created hashtable)
      • -------- Stat Keys --------
      • Set VariableSet HSS_KeyMaxTypes = 0
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeySTR = HSS_KeyMaxTypes
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeyAGI = HSS_KeyMaxTypes
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeyINT = HSS_KeyMaxTypes
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeyREA = HSS_KeyMaxTypes
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeyPOT = HSS_KeyMaxTypes
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeyMUL = HSS_KeyMaxTypes
      • Set VariableSet HSS_KeyMaxTypes = (HSS_KeyMaxTypes + 1)
      • Set VariableSet HSS_KeyMAG = HSS_KeyMaxTypes
  • HSS Item Initial Variables
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Creating Hashtables --------
      • Hashtable - Create a hashtable
      • Set VariableSet HSS_ItemHashtable = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set VariableSet HSS_ItemInvHashtable = (Last created hashtable)
      • -------- Stat Defaults --------
      • Set VariableSet HSS_ItemNewStatsBase = 5
      • Set VariableSet HSS_ItemNewStatsRollRange = 50
      • Set VariableSet HSS_ItemNewStatRollsMin = 2
      • Set VariableSet HSS_ItemNewLvlAdd = 2
      • Set VariableSet HSS_ItemNewStatsFactAdd = 2
      • Set VariableSet HSS_ItemNewRollPerc = 25
      • Set VariableSet HSS_ItemAvailableStatCount = HSS_KeyMaxTypes

  • HSS Item Stat Creator
    • Events
      • Game - HSS_ItemNewRunStatCreator becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- Reset trigger real --------
      • Set VariableSet HSS_ItemNewRunStatCreator = 0.00
      • -------- Count max items in play, add custom value to item --------
      • Set VariableSet HSS_ItemMaxCount = (HSS_ItemMaxCount + 1)
      • Set VariableSet HSS_ItemNewIntCV = HSS_ItemMaxCount
      • Set VariableSet HSS_ItemNew = (Last created item)
      • Item - Set the custom value of HSS_ItemNew to HSS_ItemNewIntCV
      • -------- Calculate how many stat types --------
      • Set VariableSet HSS_ItemNewStatTypeRoll = ((Random integer number between 1 and 100) x HSS_ItemNewLvl)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HSS_ItemNewLvl Greater than or equal to 1
        • Then - Actions
          • Set VariableSet HSS_ItemNewStatRollsMax = 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HSS_ItemNewLvl Greater than or equal to 200
        • Then - Actions
          • Set VariableSet HSS_ItemNewStatRollsMax = 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HSS_ItemNewLvl Greater than or equal to 400
        • Then - Actions
          • Set VariableSet HSS_ItemNewStatRollsMax = 3
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HSS_ItemNewLvl Greater than or equal to 800
        • Then - Actions
          • Set VariableSet HSS_ItemNewStatRollsMax = 4
        • Else - Actions
      • Set VariableSet HSS_ItemNewIntRoll = 1
      • Set VariableSet HSS_ItemNewStatRollsMin = 1
      • For each (Integer HSS_ItemNewIntRoll) from HSS_ItemNewStatRollsMin to HSS_ItemNewStatRollsMax, do (Actions)
        • Loop - Actions
          • -------- Calculate the stats given to the item --------
          • Set VariableSet HSS_ItemNewStat = (HSS_ItemNewStatsBase + ((HSS_ItemNewLvl x HSS_ItemNewLvlAdd) + (HSS_ItemNewStatsFact x HSS_ItemNewStatsFactAdd)))
          • Set VariableSet HSS_ItemNewStatsMin = ((HSS_ItemNewStat x (100 - HSS_ItemNewRollPerc)) / 100)
          • Set VariableSet HSS_ItemNewStatsMax = ((HSS_ItemNewStat x (100 + HSS_ItemNewRollPerc)) / 100)
          • Set VariableSet HSS_ItemNewStatNew = (Random integer number between HSS_ItemNewStatsMin and HSS_ItemNewStatsMax)
          • -------- Choose a random stat between those that exist --------
          • Set VariableSet HSS_ItemNewTempIndex = (Random integer number between 1 and HSS_KeyMaxTypes)
          • -------- Only Add stat if >0 --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HSS_ItemNewStatNew Greater than or equal to 1
            • Then - Actions
              • Set VariableSet HSS_ItemNewStatLoad = (Load HSS_ItemNewTempIndex of HSS_ItemNewIntCV from HSS_ItemHashtable.)
              • Set VariableSet HSS_ItemNewStatSave = (HSS_ItemNewStatNew + HSS_ItemNewStatLoad)
              • Hashtable - Save HSS_ItemNewStatSave as HSS_ItemNewTempIndex of HSS_ItemNewIntCV in HSS_ItemHashtable.
            • Else - Actions
      • Set VariableSet HSS_ItemNewDesc = Stats:
      • Set VariableSet HSS_LoadChildKey = 1
      • For each (Integer HSS_LoadChildKey) from 1 to HSS_KeyMaxTypes, do (Actions)
        • Loop - Actions
          • Set VariableSet HSS_LoadParentKey = HSS_ItemNewIntCV
          • Set VariableSet HSS_LoadValue = (Load HSS_LoadChildKey of HSS_LoadParentKey from HSS_ItemHashtable.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HSS_LoadValue Greater than or equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeySTR
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Strength
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyAGI
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Agility
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyINT
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Intelligence
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyPOT
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Potency
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyREA
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Reach
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyPER
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Persistance
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyMUL
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Multiplicity
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HSS_LoadChildKey Equal to HSS_KeyMAG
                • Then - Actions
                  • Set VariableSet HSS_ItemNewStatString = Magnitude
                  • Set VariableSet HSS_ItemNewDesc = (HSS_ItemNewDesc + ((|n + (HSS_ItemNewStatString + : )) + (String(HSS_LoadValue))))
                • Else - Actions
            • Else - Actions
      • Item - Set Description of HSS_ItemNew to HSS_ItemNewDesc
      • Item - Set Extended Tooltip of HSS_ItemNew to HSS_ItemNewDesc

  • HSS Item Stat Inventory Calculator
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • -------- Reset Item Stat Calculator --------
      • Set VariableSet HSS_ItemIntRoll = 1
      • For each (Integer HSS_ItemIntRoll) from 1 to HSS_KeyMaxTypes, do (Actions)
        • Loop - Actions
          • Set VariableSet HSS_ItemStatInvCalculator[HSS_ItemIntRoll] = 0
      • -------- Checks entire inventory size for items --------
      • Set VariableSet HSS_ItemHero = (Hero manipulating item)
      • Set VariableSet HSS_StatHeroCV = (Custom value of HSS_ItemHero)
      • Set VariableSet HSS_ItemInvMax = (Size of inventory for HSS_ItemHero)
      • Set VariableSet HSS_ItemInvSlot = 1
      • For each (Integer HSS_ItemInvSlot) from 1 to HSS_ItemInvMax, do (Actions)
        • Loop - Actions
          • -------- Checks one item at a time --------
          • Set VariableSet HSS_Item = (Item carried by HSS_ItemHero in slot HSS_ItemInvSlot)
          • Set VariableSet HSS_ItemCV = (Custom value of HSS_Item)
          • Set VariableSet HSS_LoadParentKey = HSS_ItemCV
          • Set VariableSet HSS_LoadChildKey = 1
          • For each (Integer HSS_LoadChildKey) from 1 to HSS_KeyMaxTypes, do (Actions)
            • Loop - Actions
              • -------- Checks one stat at a time for each item. Each individual stat is added for a total stored in an array with the path equal to the given stat key. --------
              • Set VariableSet HSS_LoadValue = (Load HSS_LoadChildKey of HSS_LoadParentKey from HSS_ItemHashtable.)
              • Set VariableSet HSS_ItemStatInvCalculator[HSS_LoadChildKey] = (HSS_ItemStatInvCalculator[HSS_LoadChildKey] + HSS_LoadValue)
      • -------- Save to hashtable for the individual units inventory --------
      • Set VariableSet HSS_SaveParentKey = HSS_StatHeroCV
      • Set VariableSet HSS_SaveChildKey = 1
      • For each (Integer HSS_SaveChildKey) from 1 to HSS_KeyMaxTypes, do (Actions)
        • Loop - Actions
          • Hashtable - Save HSS_ItemStatInvCalculator[HSS_SaveChildKey] as HSS_SaveChildKey of HSS_SaveParentKey in HSS_ItemInvHashtable.
          • Game - Display to (All players) the text: (String(HSS_ItemStatInvCalculator[HSS_SaveChildKey]))
      • -------- Run Calculator --------
      • Set VariableSet HSS_StatHero = HSS_ItemHero
      • Set VariableSet HSS_StatCalculator = 1.00

  • HSS Stat Calculator
    • Events
      • Game - HSS_StatCalculator becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- Reset load values --------
      • Set VariableSet HSS_LoadChildKey = 1
      • For each (Integer HSS_LoadChildKey) from 1 to HSS_KeyMaxTypes, do (Actions)
        • Loop - Actions
          • Set VariableSet HSS_LoadValueTotal[HSS_LoadChildKey] = 0
      • -------- Load values from all stat hashtables in an array --------
      • Set VariableSet HSS_LoadParentKey = (Custom value of HSS_StatHero)
      • Set VariableSet HSS_LoadChildKey = 1
      • For each (Integer HSS_LoadChildKey) from 1 to HSS_KeyMaxTypes, do (Actions)
        • Loop - Actions
          • Set VariableSet HSS_LoadValue = (Load HSS_LoadChildKey of HSS_LoadParentKey from HSS_ItemInvHashtable.)
          • Set VariableSet HSS_LoadValueTotal[HSS_LoadChildKey] = (HSS_LoadValueTotal[HSS_LoadChildKey] + HSS_LoadValue)
      • -------- Set stats equal to the stored values in the array --------
      • Set VariableSet HSS_KeySTRValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeySTR]
      • Set VariableSet HSS_KeyAGIValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeyAGI]
      • Set VariableSet HSS_KeyINTValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeyINT]
      • Set VariableSet HSS_KeyREAValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeyREA]
      • Set VariableSet HSS_KeyPOTValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeyPOT]
      • Set VariableSet HSS_KeyMULValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeyMUL]
      • Set VariableSet HSS_KeyMAGValue[HSS_LoadParentKey] = HSS_LoadValueTotal[HSS_KeyMAG]
      • Hero - Modify Strength of HSS_StatHero: Set to HSS_KeySTRValue[HSS_LoadParentKey].
      • Hero - Modify Agility of HSS_StatHero: Set to HSS_KeyAGIValue[HSS_LoadParentKey].
      • Hero - Modify Intelligence of HSS_StatHero: Set to HSS_KeyINTValue[HSS_LoadParentKey].
 

Attachments

Set the HSS_StatCalculator back to 0 after you set to 1 immediately in HSS Item Stat Inventory Calculator

Set VariableSet HSS_StatCalculator = 1.00
Set VariableSet HSS_StatCalculator = 0.00
Thanks I didn't see your message!

That actually solved it, however when I lose the items, it the stats stay the same. Is it maybe because it cannot give the Hero 0 in stats or what might be the issue?
 
Thanks I didn't see your message!

That actually solved it, however when I lose the items, it the stats stay the same. Is it maybe because it cannot give the Hero 0 in stats or what might be the issue?
I recommend checking the value being loaded for this case, it might fail to get the right stat and get a 0 instead, which prevent stat modification from running, as deferred from the function Doc - SetHeroStat
 
I recommend checking the value being loaded for this case, it might fail to get the right stat and get a 0 instead, which prevent stat modification from running, as deferred from the function Doc - SetHeroStat
Okay, I'm just trying to understand - if it does not recognize the stat being loaded, will it not just ignore loading the stat, which is the issue anyway at this point? :) Or will it do something accordingly?
 
Back
Top