• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Mathematical Formula for Ability

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
Hi. Im trying to make a version of League of Legend's Olaf's Berserker Rage ability.
Berserker Rage increases his attack speed by 1% for each 1% health he is missing.

However, my ability has 5 levels, and does NOT need to be MUI.
Level 1: Increases attack speed by 1% for each 5% of health missing.
Level 2: Increases attack speed by 1% for each 4% of health missing.
Level 3: Increases attack speed by 1% for each 3% of health missing.
Level 4: Increases attack speed by 1% for each 2% of health missing.
Level 5: Increases attack speed by 1% for each 1% of health missing.

The unit has 2 abilities. The first ability that has 5 levels with tooltips etc. The other ability (dummy, not visible) has 101 levels and is based on the Item Attack Speed Bonus ability, with level 1 giving 0% attack speed, level 2 giving 1% attack speed, level 51 giving 50%, and level 101 giving 100%. You get the idea.
I do NOT need help with the events that triggers the effect, only the formula to adjust the level of the Item Attack Speed ability based on the unit's missing health.

My current formula is like this:
But it does not give logical results.

  • BerserkerRageAbilityTrigger
  • Actions
    • Set TempRealA = ((((Max Life of "Unit") - (Life of "Unit")) / (Max life of "Unit")) x (0.20 x (Real((Level of "Olaf" - "Berserker Rage" for "Unit")))))
    • Unit - Set level of "Olaf" - "Berserker Rage" (Attack Speed Bonus) for "Unit" to ((Integer(TempRealA)) + 1)
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Attackspeed = Health percentage lost / (5/4/3/2/1)

So basically you make an ability with 101 levels. Each level giving 1% attackspeed more than previous and first giving 0%.

Health percentage lost = (1-Current health/max health) * 100 + 1

Attackspeed = percentage lost / (6-ability level)

I didn't write about how to make the trigger, as I assume you are experienced enough to make them yourself once you know the maths.
 
Level 11
Joined
Dec 19, 2012
Messages
411
(100-((CurrentHp / MaxHp) X 100)) - For calculate Unit's Current lost Hp percentage

(((6-AbilityLv) / 100) X MaxHp) - For calculate Unit's Ability Level Hp percentage

So will be (100-((CurrentHP / MaxHp) X 100)) / (((6-AbilityLv) / 100) X MaxHp)

Example a unit has 100 hp max with current hp 87, ability level with 2.

So will be (100-((87 / 100) X 100)) / (((6-2) / 100) X 100)
= 3.25
So attack speed bonus will add 3%
 
Last edited:
Level 11
Joined
Sep 14, 2009
Messages
284
Attackspeed = Health percentage lost / (5/4/3/2/1)

So basically you make an ability with 101 levels. Each level giving 1% attackspeed more than previous and first giving 0%.

Health percentage lost = (1-Current health/max health) * 100 + 1

Attackspeed = percentage lost / (6-ability level)

I didn't write about how to make the trigger, as I assume you are experienced enough to make them yourself once you know the maths.

This seems to make sense. Did some testing and applied the formula to some instances and it gives correct results. Thanks, + rep
 
Status
Not open for further replies.
Top