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

[Solved] Setting unit armor not working as intented if the unit has bonus armor

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
This trigger works as should as long as the hero has no extra armor from items/auras, etc.

I tested it several times and noticed something is wrong when I was testing my level up trigger from my previous post and noticed that the bonus armor from items destroys my formula.

  • Unit - Set Armor of HeroUnit[StatsPlayerNumber] to ((Real(Agility[StatsPlayerNumber])) + ((Real(Toughness[StatsPlayerNumber])) / 2.00))
What happens if the unit is carrying an item with 3 bonus armor is:

Agi 2 + Tough 4 = 3 Armor, but the unit has extra 3 armor so the formula changes that the base armor is actually set to 0.

So technically the math is correct, it gives me 0 base armor + 3 bonus armor. So the unit armor is set to 3.

If the unit has 2 bonus armor and the Agi + Tough are the same as above the unit gains 1 base armor + 2 extra armor from the item, so once again the unit armor is technically set to 3.

I am pretty sure this is not working as intented.

All help appreciated. :)

EDIT: Made an empty map for testing, attached here:
 

Attachments

  • UnitArmorTest.w3m
    16.4 KB · Views: 36
Last edited:
Level 5
Joined
Oct 16, 2007
Messages
67
Yes, that is sadly how the function works. However, you can use a variable how much armor the unit should have (without boni/mali as having less armor gives greater bonuses) and get the difference and just add that.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Yes, that is sadly how the function works. However, you can use a variable how much armor the unit should have (without boni/mali as having less armor gives greater bonuses) and get the difference and just add that.

Sad, but thanks :)
 
Level 12
Joined
Feb 5, 2018
Messages
521
And here is the solution I made, not optimal, but works.

  • XpSystem
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
      • (Owner of (Killing unit)) Not equal to Player 2 (Blue)
    • Actions
      • Set VariableSet AoE = 1000.00
      • Set VariableSet Point = (Position of (Triggering unit))
      • Set VariableSet Group = (Units within AoE of Point.)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 2 (Blue)
              • (Owner of (Picked unit)) Not equal to Neutral Passive
              • (Owner of (Picked unit)) Not equal to Neutral Hostile
            • Then - Actions
              • Set VariableSet StatsPlayerNumber = (Player number of (Owner of (Picked unit)))
              • Set VariableSet HeroUnit[StatsPlayerNumber] = (Picked unit)
              • Set VariableSet CustomXp[StatsPlayerNumber] = (CustomXp[StatsPlayerNumber] + (10.00 x (Real((Level of (Triggering unit))))))
              • Game - Display to (All players) the text: ((String(CustomXp[StatsPlayerNumber])) + ( / + (String(CustomXpRequired[StatsPlayerNumber]))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CustomXp[StatsPlayerNumber] Greater than or equal to CustomXpRequired[StatsPlayerNumber]
                • Then - Actions
                  • Unit - Set Unit: HeroUnit[StatsPlayerNumber]'s Integer Field: Level ('ulev') to Value: ((Level of HeroUnit[StatsPlayerNumber]) + 1)
                  • Game - Display to (All players) the text: ((Name of (Owner of HeroUnit[StatsPlayerNumber])) + ( |cff00ff00has grown in strength and is now level |r + (String((Level of HeroUnit[StatsPlayerNumber])))))
                  • Set VariableSet CustomXp[StatsPlayerNumber] = (CustomXp[StatsPlayerNumber] - CustomXpRequired[StatsPlayerNumber])
                  • Set VariableSet CustomXpRequired[StatsPlayerNumber] = ((Real((Level of HeroUnit[StatsPlayerNumber]))) x 175.00)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of HeroUnit[StatsPlayerNumber]) Equal to |cff0000ffDefender|r (Hero)
                    • Then - Actions
                      • -------- Level up --------
                      • Set VariableSet Agility[StatsPlayerNumber] = (Agility[StatsPlayerNumber] + 1)
                      • Set VariableSet Focus[StatsPlayerNumber] = (Focus[StatsPlayerNumber] + 1)
                      • Set VariableSet Toughness[StatsPlayerNumber] = (Toughness[StatsPlayerNumber] + 2)
                      • -------- --------
                      • Set VariableSet Strength[StatsPlayerNumber] = (Strength[StatsPlayerNumber] + 1)
                      • Set VariableSet Intelligence[StatsPlayerNumber] = (Intelligence[StatsPlayerNumber] + 1)
                      • Set VariableSet Charisma[StatsPlayerNumber] = (Charisma[StatsPlayerNumber] + 1)
                      • -------- HP reg --------
                      • Set VariableSet HpReg[StatsPlayerNumber] = ((Real(Strength[StatsPlayerNumber])) + ((Real(Charisma[StatsPlayerNumber])) + (Real(Toughness[StatsPlayerNumber]))))
                      • Set VariableSet HpReg_Total[StatsPlayerNumber] = (HpReg[StatsPlayerNumber] x 0.03)
                      • -------- Remove items temporarily to set the unit stats correct --------
                      • Hero - Drop (Item carried by HeroUnit[StatsPlayerNumber] in slot 1) from HeroUnit[StatsPlayerNumber].
                      • Set VariableSet ItemInteger = (ItemInteger + 1)
                      • Set VariableSet TempItem[ItemInteger] = (Last dropped item)
                      • -------- --------
                      • Hero - Drop (Item carried by HeroUnit[StatsPlayerNumber] in slot 2) from HeroUnit[StatsPlayerNumber].
                      • Set VariableSet ItemInteger = (ItemInteger + 1)
                      • Set VariableSet TempItem[ItemInteger] = (Last dropped item)
                      • -------- --------
                      • Hero - Drop (Item carried by HeroUnit[StatsPlayerNumber] in slot 3) from HeroUnit[StatsPlayerNumber].
                      • Set VariableSet ItemInteger = (ItemInteger + 1)
                      • Set VariableSet TempItem[ItemInteger] = (Last dropped item)
                      • -------- --------
                      • Hero - Drop (Item carried by HeroUnit[StatsPlayerNumber] in slot 4) from HeroUnit[StatsPlayerNumber].
                      • Set VariableSet ItemInteger = (ItemInteger + 1)
                      • Set VariableSet TempItem[ItemInteger] = (Last dropped item)
                      • -------- --------
                      • Hero - Drop (Item carried by HeroUnit[StatsPlayerNumber] in slot 5) from HeroUnit[StatsPlayerNumber].
                      • Set VariableSet ItemInteger = (ItemInteger + 1)
                      • Set VariableSet TempItem[ItemInteger] = (Last dropped item)
                      • -------- --------
                      • Hero - Drop (Item carried by HeroUnit[StatsPlayerNumber] in slot 6) from HeroUnit[StatsPlayerNumber].
                      • Set VariableSet ItemInteger = (ItemInteger + 1)
                      • Set VariableSet TempItem[ItemInteger] = (Last dropped item)
                      • -------- Adjust stats --------
                      • Unit - Set Max HP of HeroUnit[StatsPlayerNumber] to (10 + (Toughness[StatsPlayerNumber] x 7))
                      • Unit - Set Max Mana of HeroUnit[StatsPlayerNumber] to (Intelligence[StatsPlayerNumber] x (4 + (Focus[StatsPlayerNumber] / 2)))
                      • Unit - Set Armor of HeroUnit[StatsPlayerNumber] to ((Real(Agility[StatsPlayerNumber])) + ((Real(Toughness[StatsPlayerNumber])) / 2.00))
                      • -------- --------
                      • Unit - Set Base Damage of HeroUnit[StatsPlayerNumber] to (Strength[StatsPlayerNumber] + (Focus[StatsPlayerNumber] / 2)) for weapon index: 0
                      • Unit - Set Unit: HeroUnit[StatsPlayerNumber]'s Real Field: Mana Regeneration ('umpr') to Value: ((Real(Focus[StatsPlayerNumber])) / 10.00)
                      • Unit - Set Unit: HeroUnit[StatsPlayerNumber]'s Real Field: Hit Points Regeneration Rate ('uhpr') to Value: HpReg_Total[StatsPlayerNumber]
                      • -------- Update multiboard --------
                      • Multiboard - Set the text for PlayerMultiBoards[StatsPlayerNumber] item in column 2, row 1 to (String(Focus[StatsPlayerNumber]))
                      • Multiboard - Set the text for PlayerMultiBoards[StatsPlayerNumber] item in column 2, row 2 to (String(Agility[StatsPlayerNumber]))
                      • Multiboard - Set the text for PlayerMultiBoards[StatsPlayerNumber] item in column 2, row 3 to (String(Intelligence[StatsPlayerNumber]))
                      • Multiboard - Set the text for PlayerMultiBoards[StatsPlayerNumber] item in column 2, row 4 to (String(Charisma[StatsPlayerNumber]))
                      • Multiboard - Set the text for PlayerMultiBoards[StatsPlayerNumber] item in column 2, row 5 to (String(Toughness[StatsPlayerNumber]))
                      • Multiboard - Set the text for PlayerMultiBoards[StatsPlayerNumber] item in column 2, row 6 to (String(Strength[StatsPlayerNumber]))
                      • Multiboard - Set the text for PlayerMultiBoards[1] item in column 2, row 7 to (String((Level of HeroUnit[StatsPlayerNumber])))
                      • -------- Load Items --------
                      • For each (Integer A) from 1 to ItemInteger, do (Actions)
                        • Loop - Actions
                          • Hero - Give TempItem[(Integer A)] to HeroUnit[StatsPlayerNumber]
                          • Set VariableSet ItemInteger = 0
                          • Set VariableSet LevelUpInteger = 0
                    • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation (udg_Point)
            • Else - Actions
 
Status
Not open for further replies.
Top