• 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.

Inceasing level of ability depending on lost life

Status
Not open for further replies.
Level 3
Joined
Jun 12, 2009
Messages
38
Hey there, excuse me if I'm posting in the wrong section (I believe that I'm not doing it anyway..) and for the dumb question may be, but that thing is becoming too annoying to me for quite a long time already..
So.. the title explains it pretty much, a bit more detailed:
I have a spellbook that's added to a hero after he learns a specific skill. The spellbook has 3 spells at all levels, 2 of the abilities in it have no levels, and one of them has 10 levels. The ability that the hero learns is based on Immolation (so it's turn on/turn off), and I want to make the trigger to work like that:
The hero activates the ability; his current HP is saved to a variable (or at least I think it has to be that way); and for every 2% of missing HP the level of the 10-leveled ability in the spellbook is increased by one level. The problem is that I do not know (.. sad, it's probably pretty simple as most of these things) how to calculate exactly each of the 2% missing HP from the hero's HP at the moment of the activation of the ability (not his maximum HP) and level up the spell in the spellbook according to them as long as the Immolation-based ability is turned on...
So, If I'm doing wrong by posting this question here - I'm sorry, it's my first time asking for help about such stuff..
 
Level 2
Joined
Jul 1, 2010
Messages
14
So you're basically asking for a formula to calculate that?

Something like this should do it:
( ( ( [CURRENT_HP]*100 ) / [STORED_HP] ) - 80 ) / 2 = Level of ability.

Explaination:
( [CURRENT_HP]*100 ) / [STORED_HP] ) = percental of the hp left.
- 80 = to get a number between 0 and 20
/ 2 = to get a number between 0 and 10
 
Level 7
Joined
Jun 14, 2009
Messages
235
TBH im a little confused, I believe you want just a formula to convert % of hp to level...

So you need it to work, when you activate the ability, It will set the level based off of hp missing...

I'll assume you want it to round down.
  • Trigger
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (String((Issued order))) Equal to (String((Order(immolation))))
    • Actions
      • Set MissingHealth = ((Max life of (Triggering unit)) - (Life of (Triggering unit)))
      • Set MissingHealthPercentage = (MissingHealth / (Max life of (Triggering unit)))
      • Set Level = (MissingHealthPercentage / 2.00)
      • Unit - Set level of Spell for (Triggering unit) to (Integer(Level))
Or you could just make it one equation
  • Trigger
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (String((Issued order))) Equal to (String((Order(immolation))))
    • Actions
      • Set Level = ((((Max life of (Triggering unit)) - (Life of (Triggering unit))) / (Max life of (Triggering unit))) / 2.00)
      • Unit - Set level of Spell for (Triggering unit) to (Integer(Level))
If i made a Math mistake, let me know
 
Level 3
Joined
Jun 12, 2009
Messages
38
So you're basically asking for a formula to calculate that?

Something like this should do it:
( ( ( [CURRENT_HP]*100 ) / [STORED_HP] ) - 80 ) / 2 = Level of ability.

Explaination:
( [CURRENT_HP]*100 ) / [STORED_HP] ) = percental of the hp left.
- 80 = to get a number between 0 and 20
/ 2 = to get a number between 0 and 10
Won't that lead to a negative value in some situations?
use a real variable called something like "HP"

set HP = 100 - percent of life (casting unit)
set HP = HP /2
//HP is now the number of 2%s the unit has lost.

And this.. I don't really understand it, but I need this thing in a periodic trigger, so the ability level changes according to HP lost as long as the Immolation-based spell is turned on..

Basically I'm asking for a trigger which will detect every 2% HP lost during the active period of the Immolation, and these 2% must be of the HP at the moment of the activation of the Immolation.
For instance: the hero has 200 max hp, at the moment of activation of the Immolation he has 100hp left, at 98hp I need the level of the ability in the spellbook to be raised by one, at 96 again, and so on until it's level 10..

Edit:
Ah, Killd0zer posted while I was posting..
I can give you an example of a similar spell from a popular map - DotA.
Huskar's skill "Berserker's Blood"

Berserker's Blood
* Ability Type: Passive
* Targeting Type: N/A
* Ability Hotkey: B
Huskar feels each of his wounds and channels the pain, increasing attack speed and damage for each 7% missing health. First bonus starts at full health.
*Source
 
Level 7
Joined
Jun 14, 2009
Messages
235
Won't that lead to a negative value in some situations?


And this.. I don't really understand it, but I need this thing in a periodic trigger, so the ability level changes according to HP lost as long as the Immolation-based spell is turned on..

Basically I'm asking for a trigger which will detect every 2% HP lost during the active period of the Immolation, and these 2% must be of the HP at the moment of the activation of the Immolation.
For instance: the hero has 200 max hp, at the moment of activation of the Immolation he has 100hp left, at 98hp I need the level of the ability in the spellbook to be raised by one, at 96 again, and so on until it's level 10..

You could do it with Hashtables or an indexing system
 
Level 3
Joined
Jun 12, 2009
Messages
38
Um.. yeah, but obviously I can't, that's why I'm here, for a hint how to do it ^^

The numbers don't really matter, a rough example would be enough..
 
Level 2
Joined
Jul 1, 2010
Messages
14
Won't that lead to a negative value in some situations?

Sure it will. If the HP of the hero goes below 80% it will give a negative result. You can check for that using an if-else-statement.

In the same way, if the heroes HP goes above the store value, the formula will give a result bigger than 10. You can check for that using an if-else-statement too. :)

EDIT: I'm out of this thread. Two ppl trying to help at once isn't working. :p It'll follow the thread and create a trigger for you later, if you guys doesn't find a solution.
 
Level 7
Joined
Jun 14, 2009
Messages
235
Um.. yeah, but obviously I can't, that's why I'm here, for a hint how to do it ^^

The numbers don't really matter, a rough example would be enough..

Actually you might not need Hashtables

  • Spell
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (String((Issued order))) Equal to (String((Order(immolation))))
        • Then - Actions
          • Unit Group - Add (Triggering unit) to ImmolationGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (String((Issued order))) Equal to (String((Order(unimmolation))))
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from ImmolationGroup
        • Else - Actions
  • Level Check
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ImmolationGroup and do (Actions)
        • Loop - Actions
          • Set Level = ((((Max life of (Picked unit)) - (Life of (Picked unit))) / (Max life of (Picked unit))) / 2.00)
          • Unit - Set level of Spell for (Picked unit) to (Integer(Spell))
Again if i made a mistake, point it out
 
Level 3
Joined
Jun 12, 2009
Messages
38
  • Level Check
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ImmolationGroup and do (Actions)
        • Loop - Actions
          • Set Level = ((((Max life of (Picked unit)) - (Life of (Picked unit))) / (Max life of (Picked unit))) / 2.00)
          • Unit - Set level of Spell for (Picked unit) to (Integer(Spell))
Again if i made a mistake, point it out
That way the formula in the Level Check trigger gives a pretty strange value..
Take a look at the example <similar> spell that I've linked few posts above and you will understand better what exactly is my problem.

I'll explain it once again - I am unable to create the periodic check for the lost life while the Immolation is on, I'm able to handle the rest. The problem is how to exactly detect those 2% missing health from the Health at the moment of activating the immolation until it's canceled...
 
Level 7
Joined
Jun 14, 2009
Messages
235
That way the formula in the Level Check trigger gives a pretty strange value..
Take a look at the example <similar> spell that I've linked few posts above and you will understand better what exactly is my problem.

I'll explain it once again - I am unable to create the periodic check for the lost life while the Immolation is on, I'm able to handle the rest. The problem is how to exactly detect those 2% missing health from the Health at the moment of activating the immolation until it's canceled...

Hm, it should work, as it converts the real into an integer ill check it one sec

Oh ok, i made a small mistake, one sec

Ok its a small mistake, instead of dividing by 2 on the last number, divide by .02, and it should work, then set the spell level by Convert real to integer
 

Attachments

  • Test.w3x
    17.4 KB · Views: 108
Level 3
Joined
Jun 12, 2009
Messages
38
Mm.. that looks pretty strange to me. If the unit have 200 max hp and currently has 100, the end value is 2.5.
Ok, let's look at this from another point of view. Forget about the immolation and the spell book and the levels of the spell and anything...

I would be able to do it if I just have something that detects every 2% lost HP of a target unit, and then calls a function. That's all.

And btw thank you for being patient with me, I know that I'm like a pest ;d
 
Level 7
Joined
Jun 14, 2009
Messages
235
Mm.. that looks pretty strange to me. If the unit have 200 max hp and currently has 100, the end value is 2.5.
Ok, let's look at this from another point of view. Forget about the immolation and the spell book and the levels of the spell and anything...

I would be able to do it if I just have something that detects every 2% lost HP of a target unit, and then calls a function. That's all.

And btw thank you for being patient with me, I know that I'm like a pest ;d

The map i uploaded does that, here i made go by 10% to show it better'

It should also have much less clutter

OOHHH do you want an event to trigger everytime a unit loses 2% of its health, like say everytime a unit loses 2% of its health, it does aoe damage or some event?
 

Attachments

  • Test.w3x
    17.4 KB · Views: 76
Level 3
Joined
Jun 12, 2009
Messages
38
Hm, okay then, I'll try it and I'll tell you the result as soon as I can <3
Thank you again ^^

Edit:
OOHHH do you want an event to trigger everytime a unit loses 2% of its health, like say everytime a unit loses 2% of its health, it does aoe damage or some event?

Well.. yes, at every 2% loss if that health there are few actions happening. I can explain you the whole ability if you want me to. There are few other triggers associated with it.

Second edit:
Oh holy cow... I've just reached the conclusion how dumb I am. While I was typing this I've figured it out... I can't believe I couldn't do it few... well an hour ago . . .
I'm sorry for wasting your time, still I'm thankful for your help, I really appreciate it <3
 
Level 7
Joined
Jun 14, 2009
Messages
235
Hm, okay then, I'll try it and I'll tell you the result as soon as I can <3
Thank you again ^^

Edit:


Well.. yes, at every 2% loss if that health there are few actions happening. I can explain you the whole ability if you want me to. There are few other triggers associated with it.

ok i understand what you want now (i think), give me a sec
 
Level 3
Joined
Jun 12, 2009
Messages
38
Nevermind... just done it with a single variable..

Second edit:
Oh holy cow... I've just reached the conclusion how dumb I am. While I was typing this I've figured it out... I can't believe I couldn't do it few... well an hour ago . . .
I'm sorry for wasting your time, still I'm thankful for your help, I really appreciate it <3
 
Status
Not open for further replies.
Top