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

How to Multiplie and Divide Stats

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Make sure the heroes don't gain stats with level ups. You will need to trigger your heroes stat gains as they level up in order to keep track of them, then recalculate their stats:

base stats (at level 1) + leveled up stats (you should keep track of this stat) / 3
 
Last edited:
Level 16
Joined
Mar 27, 2011
Messages
1,349
I just made a system for a bit of fun. It seems to work. This system also factors tomes into the equation.

If you want the system to work with your heroes, you need to add an if/then/else statement in the index
heroes triggers, setting the stats per level to whatever you want it to be.

You didn't specify when you want the heroes stats to be multiplied or divided by 2 or 3, so I just did the math
whenever a hero levels up or uses a tome for the first time. This could be changed of course with a little coding.
Remember to add the Unit Indexing system.

  • Index Heroes
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set Key = (Custom value of (Picked unit))
          • Set StatsBaseStrength[Key] = (Real((Strength of (Picked unit) (Exclude bonuses))))
          • Set StatsBaseAgility[Key] = (Real((Agility of (Picked unit) (Exclude bonuses))))
          • Set StatsBaseIntelligence[Key] = (Real((Intelligence of (Picked unit) (Exclude bonuses))))
          • -------- --------------- --------
          • -------- Add Heroes Here --------
          • -------- --------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Mountain King
            • Then - Actions
              • Set StatsGainStrength[Key] = 3.25
              • Set StatsGainAgility[Key] = 2.50
              • Set StatsGainIntelligence[Key] = 1.75
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Paladin
            • Then - Actions
              • Set StatsGainStrength[Key] = 4.25
              • Set StatsGainAgility[Key] = 2.00
              • Set StatsGainIntelligence[Key] = 2.00
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Archmage
            • Then - Actions
              • Set StatsGainStrength[Key] = 2.50
              • Set StatsGainAgility[Key] = 2.25
              • Set StatsGainIntelligence[Key] = 3.00
            • Else - Actions
  • Index Heroes 2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set Key = (Custom value of (Triggering unit))
      • Set StatsBaseStrength[Key] = (Real((Strength of (Triggering unit) (Exclude bonuses))))
      • Set StatsBaseAgility[Key] = (Real((Agility of (Triggering unit) (Exclude bonuses))))
      • Set StatsBaseIntelligence[Key] = (Real((Intelligence of (Triggering unit) (Exclude bonuses))))
      • -------- --------------- --------
      • -------- Add Heroes Here --------
      • -------- --------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Mountain King
        • Then - Actions
          • Set StatsGainStrength[Key] = 3.25
          • Set StatsGainAgility[Key] = 2.50
          • Set StatsGainIntelligence[Key] = 1.75
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Paladin
        • Then - Actions
          • Set StatsGainStrength[Key] = 4.25
          • Set StatsGainAgility[Key] = 2.00
          • Set StatsGainIntelligence[Key] = 2.00
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Archmage
        • Then - Actions
          • Set StatsGainStrength[Key] = 2.50
          • Set StatsGainAgility[Key] = 2.25
          • Set StatsGainIntelligence[Key] = 3.00
        • Else - Actions

  • Hero Level Up
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set Key = (Custom value of (Triggering unit))
      • Set StatsLvlStrength[Key] = (((Real((Hero level of (Triggering unit)))) - 1.00) x StatsGainStrength[Key])
      • Set StatsLvlAgility[Key] = (((Real((Hero level of (Triggering unit)))) - 1.00) x StatsGainAgility[Key])
      • Set StatsLvlIntelligence[Key] = (((Real((Hero level of (Triggering unit)))) - 1.00) x StatsGainIntelligence[Key])
      • Hero - Modify Strength of (Triggering unit): Set to ((((Integer(StatsBaseStrength[Key])) + (Integer(StatsLvlStrength[Key]))) + (Integer(StatsTomeStrength[Key]))) / 2)
      • Hero - Modify Agility of (Triggering unit): Set to ((((Integer(StatsBaseAgility[Key])) + (Integer(StatsLvlAgility[Key]))) + (Integer(StatsTomeAgility[Key]))) / 2)
      • Hero - Modify Intelligence of (Triggering unit): Set to ((((Integer(StatsBaseIntelligence[Key])) + (Integer(StatsLvlIntelligence[Key]))) + (Integer(StatsTomeIntelligence[Key]))) / 2)
  • Hero Tomes
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set Key = (Custom value of (Triggering unit))
      • -------- Checks for Strength Tome --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Tome of Strength
        • Then - Actions
          • Set StatsTomeStrength[Key] = (StatsTomeStrength[Key] + 1.00)
          • Hero - Modify Strength of (Triggering unit): Set to ((((Integer(StatsBaseStrength[Key])) + (Integer(StatsLvlStrength[Key]))) + (Integer(StatsTomeStrength[Key]))) / 2)
        • Else - Actions
      • -------- Checks for Agility Tome --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Tome of Agility
        • Then - Actions
          • Set StatsTomeAgility[Key] = (StatsTomeAgility[Key] + 1.00)
          • Hero - Modify Agility of (Triggering unit): Set to ((((Integer(StatsBaseAgility[Key])) + (Integer(StatsLvlAgility[Key]))) + (Integer(StatsTomeAgility[Key]))) / 2)
        • Else - Actions
      • -------- Checks for Intelligence Tome --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Tome of Intelligence
        • Then - Actions
          • Set StatsTomeIntelligence[Key] = (StatsTomeIntelligence[Key] + 1.00)
          • Hero - Modify Intelligence of (Triggering unit): Set to ((((Integer(StatsBaseIntelligence[Key])) + (Integer(StatsLvlIntelligence[Key]))) + (Integer(StatsTomeIntelligence[Key]))) / 2)
        • Else - Actions
      • -------- Checks for Knowledge Tome --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Tome of Knowledge
        • Then - Actions
          • Set StatsTomeStrength[Key] = (StatsTomeStrength[Key] + 1.00)
          • Set StatsTomeAgility[Key] = (StatsTomeAgility[Key] + 1.00)
          • Set StatsTomeIntelligence[Key] = (StatsTomeIntelligence[Key] + 1.00)
          • Hero - Modify Strength of (Triggering unit): Set to ((((Integer(StatsBaseStrength[Key])) + (Integer(StatsLvlStrength[Key]))) + (Integer(StatsTomeStrength[Key]))) / 2)
          • Hero - Modify Agility of (Triggering unit): Set to ((((Integer(StatsBaseAgility[Key])) + (Integer(StatsLvlAgility[Key]))) + (Integer(StatsTomeAgility[Key]))) / 2)
          • Hero - Modify Intelligence of (Triggering unit): Set to ((((Integer(StatsBaseIntelligence[Key])) + (Integer(StatsLvlIntelligence[Key]))) + (Integer(StatsTomeIntelligence[Key]))) / 2)
        • Else - Actions
 

Attachments

  • Attributes.w3x
    27.4 KB · Views: 59
Level 10
Joined
Jun 6, 2007
Messages
392
You should be more specific on what you want. I assume that you're making an ability, which increases stats for a duration and then restores old stats. If that's the case, you'll need to

1. Calculate the amount of hero stats to be added and store them into a variable (probably using dynamic indexing)
2. Start a timer and when it expires, remove the added stats.

This way you only calculate the amount of modified stats once: you don't have to divide at any point. I can add example code later, if I have time.

EDIT: Here's an example. You can use any unit indexer, I've used Bribe's. Loop trigger is initially off, and it's activated upon the first cast. Explanation of variables:

Caster: Temporary unit variable, which contains the caster. This variable is only used for having a faster access to caster.
StatGroup: Unit group, which contains all units, which are currently under the effect of this ability.
StatAmount: An integer array variable, which contains the amount of hanged stats. To get the correct index, use a unit indexer.
StatDuration: An integer array, which contains remaining spell duration for all active spell casts. To get the correct index, use a unit indexer.
StatCount: The number of units that are under the effect of this ability. Basically this is the same thing as the number of units in StatGroup.

Triggers:
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Stat Bonus
    • Actions
      • -------- Triggering unit is set to a variable, because it's used often and accessing variables is faster than functions. --------
      • Set Caster = (Triggering unit)
      • -------- Check if unit still has bonus stats from previous casts --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Caster is in StatGroup) Equal to True
        • Then - Actions
          • -------- If it has, remove old bonus and add a new one --------
          • Hero - Modify Strength of Caster: Subtract StatAmount[(Custom value of Caster)]
          • Set StatAmount[(Custom value of Caster)] = ((Strength of Caster (Exclude bonuses)) x 2)
          • Hero - Modify Strength of Caster: Add StatAmount[(Custom value of Caster)]
        • Else - Actions
          • -------- Else just add new bonus. In that case, caster must also be added to the group. --------
          • Set StatAmount[(Custom value of Caster)] = ((Strength of Caster (Exclude bonuses)) x 2)
          • Hero - Modify Strength of Caster: Add StatAmount[(Custom value of Caster)]
          • Unit Group - Add Caster to StatGroup
          • -------- Update the number of units under the effect of this ability. If this is the only active cast, turn on the loop trigger. --------
          • Set StatCount = (StatCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StatCount Equal to 1
            • Then - Actions
              • Trigger - Turn on Loop <gen>
            • Else - Actions
      • -------- Set spell duration --------
      • Set StatDuration[(Custom value of Caster)] = 15
  • Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • -------- For every unit with stat bonuses... --------
      • Unit Group - Pick every unit in StatGroup and do (Actions)
        • Loop - Actions
          • Set Caster = (Picked unit)
          • -------- ..., update the remaining spell duration. --------
          • Set StatDuration[(Custom value of Caster)] = (StatDuration[(Custom value of Caster)] - 1)
          • -------- If duration == 0, spell ends. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StatDuration[(Custom value of Caster)] Equal to 0
            • Then - Actions
              • -------- Remove added bonus --------
              • Hero - Modify Strength of Caster: Subtract StatAmount[(Custom value of Caster)]
              • Unit Group - Remove Caster from StatGroup
              • -------- Update the number of active casts. If there are no active casts, disable loop trigger. --------
              • Set StatCount = (StatCount - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • StatCount Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top