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

[Trigger] Need Help With Health Bonus Scaling

Status
Not open for further replies.
Level 1
Joined
Jan 23, 2015
Messages
160
(Started from this thread and evolved into this, thanks to everyone from first thread who helped get me to this point.)

Hi. I have a map using Bribe's Unit Indexer and Damage System. I am using the Indexer to create mock attributes for non-heroes.

  • Scaling HELP HERE please
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
      • (UDexUnits[UDex] is A Hero) Equal to False
    • Actions
      • -------- ------------------------------------------------------------------- --------
      • -------- \\ Wolf Level 3 --------
      • -------- ------------------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UDexUnits[UDex] is A Hero) Equal to False
          • (Unit-type of UDexUnits[UDex]) Equal to Wolf
        • Then - Actions
          • -------- --------
          • -------- Set Strength Level --------
          • Unit - Remove Non-Hero Stats (Str) from UDexUnits[UDex]
          • -------- Set Agility Level --------
          • Unit - Set level of Non-Hero Stats (Agi) for UDexUnits[UDex] to 1
          • -------- Set Intelligence Level --------
          • Unit - Remove Non-Hero Stats (Int) from UDexUnits[UDex]
          • -------- Set Health Bonus Level --------
          • Unit - Remove Non-Hero Stats (Health Bonus)) from UDexUnits[UDex]
          • -------- Set Mana Bonus Level --------
          • Unit - Remove Non-Hero Stats (Mana Bonus)) from UDexUnits[UDex]
          • -------- --------
          • -------- Non Hero Distributes Stats --------
          • For each (Integer Integer1) from 1 to ((Level of UDexUnits[UDex]) mod 2), do (Actions)
            • Loop - Actions
              • Set NonHeroStatsRollToDistribute = (Random integer number between 1 and 3)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • NonHeroStatsRollToDistribute Equal to 1
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Non-Hero Stats (Str) for UDexUnits[UDex]) Equal to 0
                    • Then - Actions
                      • Unit - Add Non-Hero Stats (Str) to UDexUnits[UDex]
                    • Else - Actions
                      • Unit - Set level of Non-Hero Stats (Str) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Str) for UDexUnits[UDex]) + 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • NonHeroStatsRollToDistribute Equal to 2
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Non-Hero Stats (Agi) for UDexUnits[UDex]) Equal to 0
                        • Then - Actions
                          • Unit - Add Non-Hero Stats (Agi) to UDexUnits[UDex]
                        • Else - Actions
                          • Unit - Set level of Non-Hero Stats (Agi) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Agi) for UDexUnits[UDex]) + 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • NonHeroStatsRollToDistribute Equal to 3
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Non-Hero Stats (Int) for UDexUnits[UDex]) Equal to 0
                            • Then - Actions
                              • Unit - Add Non-Hero Stats (Int) to UDexUnits[UDex]
                            • Else - Actions
                              • Unit - Set level of Non-Hero Stats (Int) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Int) for UDexUnits[UDex]) + 1)
                        • Else - Actions
          • For each (Integer Integer2) from 1 to ((Level of UDexUnits[UDex]) mod 2), do (Actions)
            • Loop - Actions
              • Set NonHeroStatsRollToDistribute = (Random integer number between 4 and 5)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • NonHeroStatsRollToDistribute Equal to 4
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) Equal to 0
                    • Then - Actions
                      • Unit - Add Non-Hero Stats (Health Bonus)) to UDexUnits[UDex]
                    • Else - Actions
                      • Unit - Set level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) + 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • NonHeroStatsRollToDistribute Equal to 5
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Non-Hero Stats (Mana Bonus)) for UDexUnits[UDex]) Equal to 0
                        • Then - Actions
                          • Unit - Add Non-Hero Stats (Mana Bonus)) to UDexUnits[UDex]
                        • Else - Actions
                          • Unit - Set level of Non-Hero Stats (Mana Bonus)) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Mana Bonus)) for UDexUnits[UDex]) + 1)
                    • Else - Actions
          • -------- --------
          • -------- Set Strength Variable --------
          • Set NonHeroStr[UDex] = (Level of Non-Hero Stats (Str) for UDexUnits[UDex])
          • -------- Bonus Damage from Strength --------
          • For each (Integer Integer1) from 1 to NonHeroStr[UDex], do (Hero - Create Tome of Damage and give it to UDexUnits[UDex])
          • -------- Set Agility Variable --------
          • Set NonHeroAgi[UDex] = (Level of Non-Hero Stats (Agi) for UDexUnits[UDex])
          • -------- Bonus Attack Speed from Agility (%) --------
          • Set NonHeroAttackSpeedBonus[UDex] = ((Level of Non-Hero Stats (Agi) for UDexUnits[UDex]) x (Integer(0.01)))
          • Custom script: call CSS_AddBonus(udg_UDexUnits[udg_UDex], udg_NonHeroAttackSpeedBonus[udg_UDex], 1)
          • -------- Bonus Move Speed from Agility --------
          • Set NonHeroMoveBonus[UDex] = ((Real((Level of Non-Hero Stats (Agi) for UDexUnits[UDex]))) x 0.01)
          • Custom script: call UnitAddMoveSpeedBonus(udg_UDexUnits[udg_UDex], udg_NonHeroMoveBonus[udg_UDex], 0.00, 0.00)
          • -------- Set Intelligence Variable --------
          • Set NonHeroInt[UDex] = (Level of Non-Hero Stats (Int) for UDexUnits[UDex])
          • -------- Set Mana Bonus Variable --------
          • Set NonHeroManaBonus[UDex] = ((Level of Non-Hero Stats (Mana Bonus)) for UDexUnits[UDex]) x 10)
          • Custom script: call CSS_AddBonus(udg_UDexUnits[udg_UDex], udg_NonHeroManaBonus[udg_UDex], 9)
          • Unit - Set mana of UDexUnits[UDex] to (Max mana of UDexUnits[UDex])
          • -------- --------
          • -------- Set Health Bonus Variable --------
          • Set NonHeroHealthBonus[UDex] = (5 x (((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) x ((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) + 1)) / 2))
          • Set NonHeroHealthBonus[UDex] = (10 x (Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]))
          • Custom script: call CSS_AddBonus(udg_UDexUnits[udg_UDex], udg_NonHeroHealthBonus[udg_UDex], 8)
        • Else - Actions

The idea was, for every level of the non-hero unit, they get to randomly distribute a point to Str, Agi, Int, Bonus Health, or Bonus Mana.

I was using Health Bonus level X 10 added to max health.

I changed my mind

@Tasyen provided me with a helpful summation equation
  • ( (level * (level + 1) ) / 2 ) x multi
For my map, I did this
    • Set NonHeroHealthBonus[UDex] = (10 x (((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) x ((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) + 1)) / 2))
So, for non-heroes, each point invested in Health Bonus makes the Bonus that much better. I will replicate this for Heroes, because when a player is leveling up, they can choose to invest in upping Health or Mana, the more they invest in just one of these the better it will be.

--
-edit1

@KILLCIDE gave me this helpful little table in the original thread, forgot to mention.

The equation from @Tasyen is the same thing I think? And this is when I was doing +20 health instead of +10.

If the ability level is 1, then a1 = 5((1)^2 + 1) = 5(1 + 1) = 5(2) = 10
If the ability level is 2, then a2 = 5((2)^2 + 2) = 5(4 + 2) = 5(6) = 30
a3 = 5((3)^2 + 3) = 5(9 + 3) = 5(12) = 60
a4 = 5((4)^2 + 4) = 5(16 + 4) = 5(20) = 100
a5 = 5((5)^2 + 5) = 5(25 + 5) = 5(30) = 150
and sooo on and so forth...​

--

What I'm trying to do:

I only want ODD levels to distribute a random point to either Str, Agi, or Int.

I only want EVEN levels to distribute a random point to either Health Bonus or Mana Bonus,

  • For each (Integer Integer1) from 1 to ((Level of UDexUnits[UDex]) mod 2), do (Actions)
    • Loop - Actions
      • Set NonHeroStatsRollToDistribute = (Random integer number between 1 and 3)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • NonHeroStatsRollToDistribute Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Non-Hero Stats (Str) for UDexUnits[UDex]) Equal to 0
            • Then - Actions
              • Unit - Add Non-Hero Stats (Str) to UDexUnits[UDex]
            • Else - Actions
              • Unit - Set level of Non-Hero Stats (Str) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Str) for UDexUnits[UDex]) + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • NonHeroStatsRollToDistribute Equal to 2
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Non-Hero Stats (Agi) for UDexUnits[UDex]) Equal to 0
                • Then - Actions
                  • Unit - Add Non-Hero Stats (Agi) to UDexUnits[UDex]
                • Else - Actions
                  • Unit - Set level of Non-Hero Stats (Agi) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Agi) for UDexUnits[UDex]) + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • NonHeroStatsRollToDistribute Equal to 3
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Non-Hero Stats (Int) for UDexUnits[UDex]) Equal to 0
                    • Then - Actions
                      • Unit - Add Non-Hero Stats (Int) to UDexUnits[UDex]
                    • Else - Actions
                      • Unit - Set level of Non-Hero Stats (Int) for UDexUnits[UDex] to ((Level of Non-Hero Stats (Int) for UDexUnits[UDex]) + 1)
                • Else - Actions

I am just so bad at thinking of the math I need. I am trying to use modulo to determine each even and odd occurrence from level 1 to the units level, so it will distribute a point to the available ability accordingly.

Does that make sense? The trigger I'm using was working, I thought, but then wouldn't add a bonus at all after level 3.

In my demo map, the wolves are level 3, so should distribute 2 points to either Str, Agi, or Int. They should distribute one to Health Bonus or Mana Bonus. You can move the wolf to the circle to show the scores, but I can't seem to get my "for" loop to the right spot for even/odd unit level.

Thanks for any assistance, really appreciate it, especially people from original thread.
 

Attachments

  • Scaling Health Help.w3x
    2.5 MB · Views: 54
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
  • For each (Integer Integer1) from 1 to ((Level of UDexUnits[UDex]) mod 2), do (Actions)
((Level of UDexUnits[UDex]) mod 2) returns either 0 or 1. So your loop starts from 1 and goes up to 1 or 0. That's why it runs for units with odd levels, and not for even ones.

I also suggest that you use an array for storing those 3 abilities (str, agi, int), so you won't need a bunch of if-statements. For example:
  • Map Loads
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Attribute[1] = Strength
      • Set Attribute[2] = Agility
      • Set Attribute[3] = Intelligence
  • Level up abilities
    • Set Level = (Level of YOUR_UNIT)
    • For each (Integer Loop) from 1 to Level, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Level mod 2) Equal to 0
          • Then - Actions
            • -------- Even --------
            • Set randomNum = (Random integer number between 1 and 3)
            • Set Level = (Level of Attribute[randomNum] for YOUR_UNIT)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Level Equal to 0
              • Then - Actions
                • Unit - Add Attribute[randomNum] to YOUR_UNIT
              • Else - Actions
                • Unit - Set level of Attribute[randomNum] for YOUR_UNIT to (Level + 1)
          • Else - Actions
            • -------- Odd --------
            • -------- Do whatever --------
EDIT: Whoops, I tried to add an existing attribute to a unit, and level up a non-existent one.
 
Last edited:
Level 1
Joined
Jan 23, 2015
Messages
160
  • Scaling HELP HERE please Copy
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
      • (UDexUnits[UDex] is A Hero) Equal to False
    • Actions
      • -------- ------------------------------------------------------------------- --------
      • -------- \\ Wolf Level 3 --------
      • -------- ------------------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UDexUnits[UDex] is A Hero) Equal to False
          • (Unit-type of UDexUnits[UDex]) Equal to Wolf
        • Then - Actions
          • -------- --------
          • -------- Set Strength Level --------
          • Unit - Remove Non-Hero Stats (Str) from UDexUnits[UDex]
          • -------- Set Agility Level --------
          • Unit - Set level of Non-Hero Stats (Agi) for UDexUnits[UDex] to 1
          • -------- Set Intelligence Level --------
          • Unit - Remove Non-Hero Stats (Int) from UDexUnits[UDex]
          • -------- Set Health Bonus Level --------
          • Unit - Remove Non-Hero Stats (Health Bonus)) from UDexUnits[UDex]
          • -------- Set Mana Bonus Level --------
          • Unit - Remove Non-Hero Stats (Mana Bonus)) from UDexUnits[UDex]
          • -------- --------
          • Set NonHeroStatsArray[1] = Non-Hero Stats (Str)
          • Set NonHeroStatsArray[2] = Non-Hero Stats (Agi)
          • Set NonHeroStatsArray[3] = Non-Hero Stats (Int)
          • Set NonHeroStatsArray[4] = Non-Hero Stats (Health Bonus))
          • Set NonHeroStatsArray[5] = Non-Hero Stats (Mana Bonus))
          • Set NonHeroLevel = (Level of UDexUnits[UDex])
          • -------- Non Hero Distributes Stats --------
          • -------- --------
          • For each (Integer Integer1) from 1 to NonHeroLevel, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (NonHeroLevel mod 2) Equal to 1
                • Then - Actions
                  • -------- Odd --------
                  • Set NonHeroStatsRollToDistribute = (Random integer number between 1 and 3)
                  • Set NonHeroStatGetStatLevel = (Level of NonHeroStatsArray[NonHeroStatsRollToDistribute] for UDexUnits[UDex])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • NonHeroStatGetStatLevel Equal to 0
                    • Then - Actions
                      • Unit - Add NonHeroStatsArray[NonHeroStatsRollToDistribute] to UDexUnits[UDex]
                    • Else - Actions
                      • Unit - Set level of NonHeroStatsArray[NonHeroStatsRollToDistribute] for UDexUnits[UDex] to ((Level of NonHeroStatsArray[NonHeroStatsRollToDistribute] for UDexUnits[UDex]) + 1)
                • Else - Actions
                  • -------- Even --------
                  • Set NonHeroStatsRollToDistribute = (Random integer number between 4 and 5)
                  • Set NonHeroStatGetStatLevel = (Level of NonHeroStatsArray[NonHeroStatsRollToDistribute] for UDexUnits[UDex])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • NonHeroStatGetStatLevel Equal to 0
                    • Then - Actions
                      • Unit - Add NonHeroStatsArray[NonHeroStatsRollToDistribute] to UDexUnits[UDex]
                    • Else - Actions
                      • Unit - Set level of NonHeroStatsArray[NonHeroStatsRollToDistribute] for UDexUnits[UDex] to ((Level of NonHeroStatsArray[NonHeroStatsRollToDistribute] for UDexUnits[UDex]) + 1)
          • -------- Set Strength Variable --------
          • Set NonHeroStr[UDex] = (Level of Non-Hero Stats (Str) for UDexUnits[UDex])
          • -------- Bonus Damage from Strength --------
          • For each (Integer Integer1) from 1 to NonHeroStr[UDex], do (Hero - Create Tome of Damage and give it to UDexUnits[UDex])
          • -------- Set Agility Variable --------
          • Set NonHeroAgi[UDex] = (Level of Non-Hero Stats (Agi) for UDexUnits[UDex])
          • -------- Bonus Attack Speed from Agility (%) --------
          • Set NonHeroAttackSpeedBonus[UDex] = ((Level of Non-Hero Stats (Agi) for UDexUnits[UDex]) x (Integer(0.01)))
          • Custom script: call CSS_AddBonus(udg_UDexUnits[udg_UDex], udg_NonHeroAttackSpeedBonus[udg_UDex], 1)
          • -------- Bonus Move Speed from Agility --------
          • Set NonHeroMoveBonus[UDex] = ((Real((Level of Non-Hero Stats (Agi) for UDexUnits[UDex]))) x 0.01)
          • Custom script: call UnitAddMoveSpeedBonus(udg_UDexUnits[udg_UDex], udg_NonHeroMoveBonus[udg_UDex], 0.00, 0.00)
          • -------- Set Intelligence Variable --------
          • Set NonHeroInt[UDex] = (Level of Non-Hero Stats (Int) for UDexUnits[UDex])
          • -------- Set Mana Bonus Variable --------
          • Set NonHeroManaBonus[UDex] = ((Level of Non-Hero Stats (Mana Bonus)) for UDexUnits[UDex]) x 10)
          • Custom script: call CSS_AddBonus(udg_UDexUnits[udg_UDex], udg_NonHeroManaBonus[udg_UDex], 9)
          • Unit - Set mana of UDexUnits[UDex] to (Max mana of UDexUnits[UDex])
          • -------- --------
          • -------- Set Health Bonus Variable --------
          • Set NonHeroHealthBonus[UDex] = (10 x (((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) x ((Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]) + 1)) / 2))
          • Set NonHeroHealthBonus[UDex] = (10 x (Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex]))
          • Custom script: call CSS_AddBonus(udg_UDexUnits[udg_UDex], udg_NonHeroHealthBonus[udg_UDex], 8)
        • Else - Actions

Tried to follow your steps, sorry my variable names are a mess - I'll try to get a cleaner script up here soon. Doing something wrong here, every wolf reads attributes at 1 but they are not getting the bonus.
 
Status
Not open for further replies.
Top