• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

% of hp/mana based buff

Status
Not open for further replies.
Level 3
Joined
Oct 31, 2014
Messages
55
I want to make a passive that increase the unit attack damage equal to a % of his maximum health or mana. does anybody knows how to do it?
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,658
Here you go lad.
If you have problems importing it into your map then just tell me. It is not that hard.

EDIT:
You can change the "UNIT_STATE_MAX_MANA" into "UNIT_STATE_MAX_LIFE" to make it scale with max hp.
You can change the percentage into whatever you want.
 

Attachments

  • DamageBonusByMana.w3x
    18.6 KB · Views: 51
Level 3
Joined
Oct 31, 2014
Messages
55
Thx :D, but i have a question, i want to make that a hero ability with 7 levels, can i set that with this? or you have to make a new code?
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Thx :D, but i have a question, i want to make that a hero ability with 7 levels, can i set that with this? or you have to make a new code?

You didn't quite specified anything about what it was so I made a very basic one... Have seen a similar question coming up :D

The code that I sent to you is very dynamic.
All you have to change is this simple code:

JASS:
local integer level = GetUnitAbilityLevel(u, 'A004')
You have to add it next to the other local stuff and at least under the local unit u.
Then you remove the local percentage thingy and make a new one:
JASS:
local real percentage = 10 + 5*level
Put it at least under the local integer level

The 10 + 5 * level is a simple example of what you can do.
In this case the increased damage is this:
Level 1 = 10 + 5 = 15%
Level 2 = 10 + 5 + 5 = 20%
Level 3 = 10 + 5 + 5 + 5 = 25%
etc. etc. etc.

Optimalization:
You can replace the "if (GetUnitAbilityLevel(u, 'A004') == 0)" with "if (level == 0)" as those are the same thing.
 
Level 3
Joined
Oct 31, 2014
Messages
55
i got some issues with the code, i got +1300 and +7400 more dmg o_O wayyy more than intended, can you post how the whole code has to look like? i believe i am doing something wrong :S.
whoops i was messing with the order of these abilites A000, A001, A002, A003, i believe i fixed it :p
 
Status
Not open for further replies.
Top