.... mana, kills or whatever... The principle is always the same. For a custom map - I am currently working on - I created a hero that, the more healthpoints it has, the more damage it deals. E.g. my hero's damage is increased by 2 for every 200 healthpoints he has. So having 2000 health, my hero deals 20 bonus damage.
Preparations:
[list=1] [*] Create the unit, that should own this ability with the object editor.[/*:m] [*] When done, still in the object editor, go to abilities -> special -> items.[/*:m] [*] Choose the ability "Item: damage-bonus (+1)" and set "Values - Item-ability" to false[/*:m] [*] Now create 10 copies of it and increase the value of "Data - attack-bonus" for every ability by 1[/*:m] [*] Make sure that you can differentiate those abilities by setting the "Text - editor suffix" value for instance to the value of the attack-bonus given with this ability.[/*:m] [*] You should now have 10 ablilities called "damage-bonus (+1)", "damage-bonus (+2)", .... each increasing the damage of the unit learned this ablity by a value between 1 and 10.[/*:m][/list:o]
Setting the variables:
[list=1] [*] Create a variable of type "ability" called "bonusDamage" for instance. Make this variable an array of size 10[/*:m] [*] Create a trigger, called "setVariables" for instace to put your bonus-damage abilities into your variable-array: Events: Map initialization Conditions: Actions: Set bonusDamage[1] = damage-bonus (+1) Set bonusDamage[2] = damage-bonus (+2) Set bonusDamage[3] = damage-bonus (+3) ... [/*:m] [*] Create a variable of type "ability" called "currentBonusDamage" for instance. Set the start value of this variable to the damage-bonus ability with the lowest bonus value, e.g. damage-bonus (+1) [/*:m] [*] Create a variable of type "unit" and store the unit you want to own your ability in it. (To do this on map-initialization, you need to make this unit already beeing part of the map, so put it somewhere (e.g. a players start location). Else you have to attach the setting of this variable to any event, for instance if the unit is sold or trained. For this tutorial I created a unit called "Windrunner" and stored it in the variable "heroWindrunner". [/*:m][/list:o]
Creating the trigger:
[list=1] [*] Now lets create the trigger, that adds the bonus damage to our unit, depending on its current healthpoints: Events: Time - Every 1.00 seconds of game time Conditions: Actions: Unit - remove currentBonusDamage from heroWindrunner Unit - add bonusDamage[Integer((health of heroWindrunner) / (100))] Set currentBonusDamage = bonusDamage[Integer((health of heroWindrunner) / (100))][/*:m][/list:o]
Well, and that's it. For every 100 health your unit currently has, it will now gain 1 bonus-damage. Note that there is a maximum of 10 bonus damage, because we just created 10 bonus-damage abilities. To increase this maximum, you have to add more abilities of course.
Another maybe easier way to do this, is to create just one bonus-damage ability with multiple levels. Instead of always remove and add the wanted ability, you just set the adapted level for it. For my case the other way was best, because I already needed many ablities of type bonus-damage for other things, that's why I did it this way.
Another point is, that the symbol of our bonus damage ability isn't shown for any unit. To do so, you just have to create a "dummy ability" and give it to your hero. A "dummy ability" does nothing else, than provide icons and tooltips. For our case, you could choose the ability "Evasion" and set "Data - chance for evasion" to 0.