How to get base stats of hero.

Level 4
Joined
May 7, 2020
Messages
24
I want to get either the base stats of the hero (casting unit) or the hero's stats without bonuses (not from items, but from tomes that give +1). I know I can create a new hero (unit) and find out that way, but I would like to avoid it if possible.
 
Level 30
Joined
Aug 29, 2012
Messages
1,382
I assume there are several hero types in your map, otherwise you could simply type the level 1 value to do the math

So make a trigger at map init where you'll store all the data about your heroes

  • Set VariableSet BaseSTR[1] = 22.00
  • Set VariableSet LevelUpSTR[1] = 2.50
  • etc.
Then you decide that the array 1 will be assigned to e.g. Paladin, and then you could retrieve it with Point value for instance. Point value is useful to assign an integer to a given unit type and you do it directly in the unit editor

Finally just retrieve the value like so

  • Set VariableSet HeroStrength = (BaseSTR[(Point-value of (Triggering unit))] + (LevelUpSTR[(Point-value of (Triggering unit))] x (Real((Hero level of (Triggering unit))))))
I'm not sure whether there are more straightforward ways to do that with just a single function
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
The bonus from tomes is considered a base value increase, so it's working as intended. Unfortunately, you don't have access to a "true" base value that excludes tomes. Like Chaosium said, you have to recalculate the true base value yourself using a custom Hero-stat database. This is a nice thing to have in custom maps, as it allows you to store other important data about your Hero's that you can't otherwise access.

Alternatively, you could detect when a Tome is consumed and track the true base value yourself. This could be a pain depending on how many you have:
  • Events
    • Unit - A unit Uses an item
  • Conditions
    • (Item-type of (Item being manipulated)) Equal to Tome of Agility +3
  • Actions
    • Set Variable Hero = (Triggering unit)
    • Set Variable CV = (Custom value of Hero)
    • Set Variable Hero_Tome_AGI[CV] = (Hero_Tome_AGI[CV] + 3)
    • Set Variable Hero_Base_AGI[CV] = (Agility of Hero (Exclude bonuses)) - Hero_Tome_AGI[CV])
^ The variable Hero_Base_AGI should now always contain a hero's true Agility, which excludes bonuses from both tomes and non-tomes.
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Agility Blast
  • Actions
    • Set Variable Hero = (Casting unit)
    • Set Variable Damage = (Hero_Base_AGI[(Custom value of Hero)] x 0.50)
    • Unit - Cause Hero to damage (Target unit of ability being cast), dealing Damage of attack type Spells and damage type Normal
^ The above trigger dealt 50% of the hero's true base Agility as damage.

I'm using a Unit Indexer to save the Agility data directly to our unit. I recommend relying on it instead of (Point-value) if you attempt Chaosium's suggestion. It may be slightly more confusing at first but it's more flexible and doesn't force you to change what a Stat is actually intended for.
 
Last edited:
Level 4
Joined
May 7, 2020
Messages
24
The bonus from tomes is considered a base value increase, so it's working as intended. Unfortunately, you don't have access to a "true" base value that excludes tomes. Like Chaosium said, you have to recalculate the true base value yourself using a custom Hero-stat database. This is a nice thing to have in custom maps, as it allows you to store other important data about your Hero's that you can't otherwise access.

Alternatively, you could detect when a Tome is consumed and track the true base value yourself. This could be a pain depending on how many you have:
  • Events
    • Unit - A unit Uses an item
  • Conditions
    • (Item-type of (Item being manipulated)) Equal to Tome of Agility +3
  • Actions
    • Set Variable Hero = (Triggering unit)
    • Set Variable CV = (Custom value of Hero)
    • Set Variable Hero_Tome_AGI[CV] = (Hero_Tome_AGI[CV] + 3)
    • Set Variable Hero_Base_AGI[CV] = (Agility of Hero (Exclude bonuses)) - Hero_Tome_AGI[CV])
^ The variable Hero_Base_AGI should now always contain a hero's true Agility, which excludes bonuses from both tomes and non-tomes.
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Agility Blast
  • Actions
    • Set Variable Hero = (Casting unit)
    • Set Variable Damage = (Hero_Base_AGI[(Custom value of Hero)] x 0.50)
    • Unit - Cause Hero to damage (Target unit of ability being cast), dealing Damage of attack type Spells and damage type Normal
^ The above trigger dealt 50% of the hero's true base Agility as damage.

I'm using a Unit Indexer to save the Agility data directly to our unit. I recommend relying on it instead of (Point-value) if you attempt Chaosium's suggestion. It may be slightly more confusing at first but it's more flexible and doesn't force you to change what a Stat is actually intended for.
Yeah, I thought about saving the base stats as variables (since I only have two hero types per map that use that certain ability, although across 7 maps). However, one problem with that solution is that if I ever want to change the base stats of the hero, I need to remember to change it in the trigger too. But since there is no way to get base stats directly, it is probably the best solution.
 
Level 14
Joined
Jan 10, 2023
Messages
247
Yeah, I thought about saving the base stats as variables (since I only have two hero types per map that use that certain ability, although across 7 maps). However, one problem with that solution is that if I ever want to change the base stats of the hero, I need to remember to change it in the trigger too. But since there is no way to get base stats directly, it is probably the best solution.
You could make a quick system that creates a hero at initialization and then pull the stats and save them to an indexer and then remove the units.

If many heroes are added this might be a good method, or if somehow a hero could have unique base stats, do this same thing when the hero is made and index the stats to an array.
 
Level 4
Joined
May 7, 2020
Messages
24
You could make a quick system that creates a hero at initialization and then pull the stats and save them to an indexer and then remove the units.

If many heroes are added this might be a good method, or if somehow a hero could have unique base stats, do this same thing when the hero is made and index the stats to an array.
This seems like best solution, removes possibility for human error without creating too many units.
 
Top