I'm trying to get a unit's HP somehow, copy the value into a variable and divide by an amount and converting into an integer. ie:
I need to somehow get a marauders HP data (125) via the trigger editor, then I want to divide that by 50 (2.5) and convert it to an integer and store it (2). I've looked around virtually everywhere in the editor and couldn't find a way to do this. It seems simple enough but I honestly don't know how to go about it.
does. UnitLife is the name of the variable where the unit's life will stored, ((Triggering unit) Life (Current)) can be selected via Unit - Unit Property. This function returns a real value, so you will need to call
Ah thanks for the clarification, but I still had to stumble around a bit to find it lol. I've still got a lot to learn.
My other question is how would I perform the math on it now that I've got 125 in a variable. For example, each new wave that spawns I want every 50hp to be worth 1 mineral reward, so 125 / 50 = 2 minerals without rounding. I know how to set the events and conditions but can't find a way to simply perform calculations as an action.
I have a little problem. So I created a trigger linked to an ability (for testing purposes, I used the normal attack, so every time the unit attacks, it SHOULD initiate the trigger. However it's not working.
EventsUnit-Marine[125.05,128.08]usesAttackatGeneric1-Anystage(Ignoresharedabilities)LocalVariables------- Mana Burn also reduces target's energy, Beta damage isn't factored in with this howeverLossofEnergy=(UnitEnergy-AlphaDamage)<Integer>------- The combined values of both alpha and beta damageTotalDamage=(AlphaDamage+BetaDamage)<Integer>------- Manaburn turns 1 point out of every 5 points of energy in to damageAlphaDamage=(UnitEnergymod5)<Integer>------- This is the "beta" damage, or base damage. Regardless of the amount of energy a target has, manaburn will always do at least 90 damageBetaDamage=90<Integer>------- The enemy heroEnemyTarget=NoUnit<Unit>------- The health and energy of enemy heroUnitEnergy=0<Integer>UnitLife=0<Integer>ConditionsActionsVariable-SetEnemyTarget=(AcquiredTarget)Variable-SetUnitEnergy=(Integer((EnemyTargetEnergy(Current))))Variable-SetUnitLife=(Integer((EnemyTargetLife(Current))))Unit-SetEnemyTargetLifeto((Real(UnitLife))-(Real(TotalDamage)))Unit-SetEnemyTargetEnergyto((Real(UnitEnergy))-(Real(LossofEnergy)))
How do you get the triggering unit part? Only thing that shows up for me is triggering player. Is there any other way to get a unit's health to put into a variable?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm trying to get a unit's HP somehow, copy the value into a variable and divide by an amount and converting into an integer. ie:
I need to somehow get a marauders HP data (125) via the trigger editor, then I want to divide that by 50 (2.5) and convert it to an integer and store it (2). I've looked around virtually everywhere in the editor and couldn't find a way to do this. It seems simple enough but I honestly don't know how to go about it.
The HP of a unit is in Unit Properties called Life.
Variable - Set UnitLife = ((Triggering unit) Life (Current))
I don't need to set the life I need to pull and store it.
That's exactly what
does. UnitLife is the name of the variable where the unit's life will stored, ((Triggering unit) Life (Current)) can be selected via Unit - Unit Property. This function returns a real value, so you will need to call
Ah thanks for the clarification, but I still had to stumble around a bit to find it lol. I've still got a lot to learn.
My other question is how would I perform the math on it now that I've got 125 in a variable. For example, each new wave that spawns I want every 50hp to be worth 1 mineral reward, so 125 / 50 = 2 minerals without rounding. I know how to set the events and conditions but can't find a way to simply perform calculations as an action.
Anyone on the math?
Arithmetic
Ah ty I worked out how to use Arithmetic (Multiple) properly by stacking in in value 2, not 1. D'oh!
I have a little problem. So I created a trigger linked to an ability (for testing purposes, I used the normal attack, so every time the unit attacks, it SHOULD initiate the trigger. However it's not working.
How do you get the triggering unit part? Only thing that shows up for me is triggering player. Is there any other way to get a unit's health to put into a variable?