mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[9427] Add helper functions for Unit::Get/SetHealthPercent
Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
6b0189fed3
commit
67c5e57b0a
3 changed files with 9 additions and 1 deletions
|
|
@ -11649,6 +11649,12 @@ void Unit::SetMaxHealth(uint32 val)
|
||||||
SetHealth(val);
|
SetHealth(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::SetHealthPercent(float percent)
|
||||||
|
{
|
||||||
|
uint32 newHealth = GetMaxHealth() * percent/100.0f;
|
||||||
|
SetHealth(newHealth);
|
||||||
|
}
|
||||||
|
|
||||||
void Unit::SetPower(Powers power, uint32 val)
|
void Unit::SetPower(Powers power, uint32 val)
|
||||||
{
|
{
|
||||||
if(GetPower(power) == val)
|
if(GetPower(power) == val)
|
||||||
|
|
|
||||||
|
|
@ -1160,8 +1160,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
|
|
||||||
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
|
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
|
||||||
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
|
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
|
||||||
|
float GetHealthPercent() const { return (GetHealth()*100.0f) / GetMaxHealth(); }
|
||||||
void SetHealth( uint32 val);
|
void SetHealth( uint32 val);
|
||||||
void SetMaxHealth(uint32 val);
|
void SetMaxHealth(uint32 val);
|
||||||
|
void SetHealthPercent(float percent);
|
||||||
int32 ModifyHealth(int32 val);
|
int32 ModifyHealth(int32 val);
|
||||||
|
|
||||||
Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); }
|
Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9426"
|
#define REVISION_NR "9427"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue