mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[9430] Implement preservation of current health percent at UpdateEntry use
Updated creature will now have the same amount of health (in percent) as the original creature after update. For cases where full restoration of health is expected, function have option to disable preservation. Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
9e5e0cf3b4
commit
7eeaed6d10
3 changed files with 22 additions and 10 deletions
|
|
@ -277,9 +277,9 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
||||
bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data, bool preserveHPAndPower)
|
||||
{
|
||||
if(!InitEntry(Entry, team, data))
|
||||
if (!InitEntry(Entry, team, data))
|
||||
return false;
|
||||
|
||||
m_regenHealth = GetCreatureInfo()->RegenHealth;
|
||||
|
|
@ -287,7 +287,8 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
// creatures always have melee weapon ready if any
|
||||
SetSheath(SHEATH_STATE_MELEE);
|
||||
|
||||
SelectLevel(GetCreatureInfo());
|
||||
SelectLevel(GetCreatureInfo(), preserveHPAndPower ? GetHealthPercent() : 100.0f, 100.0f);
|
||||
|
||||
if (team == HORDE)
|
||||
setFaction(GetCreatureInfo()->faction_H);
|
||||
else
|
||||
|
|
@ -299,7 +300,14 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
SetAttackTime(OFF_ATTACK, GetCreatureInfo()->baseattacktime);
|
||||
SetAttackTime(RANGED_ATTACK,GetCreatureInfo()->rangeattacktime);
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->unit_flags);
|
||||
uint32 unitFlags = GetCreatureInfo()->unit_flags;
|
||||
|
||||
// we may need to append or remove additional flags
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT))
|
||||
unitFlags |= UNIT_FLAG_IN_COMBAT;
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_FLAGS, unitFlags);
|
||||
|
||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
|
||||
|
||||
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor));
|
||||
|
|
@ -932,7 +940,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
WorldDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
void Creature::SelectLevel(const CreatureInfo *cinfo)
|
||||
void Creature::SelectLevel(const CreatureInfo *cinfo, float percentHealth, float percentMana)
|
||||
{
|
||||
uint32 rank = isPet()? 0 : cinfo->rank;
|
||||
|
||||
|
|
@ -953,7 +961,11 @@ void Creature::SelectLevel(const CreatureInfo *cinfo)
|
|||
|
||||
SetCreateHealth(health);
|
||||
SetMaxHealth(health);
|
||||
|
||||
if (percentHealth == 100.0f)
|
||||
SetHealth(health);
|
||||
else
|
||||
SetHealthPercent(percentHealth);
|
||||
|
||||
// mana
|
||||
uint32 minmana = std::min(cinfo->maxmana, cinfo->minmana);
|
||||
|
|
@ -1050,7 +1062,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const
|
|||
|
||||
Object::_Create(guidlow, Entry, HIGHGUID_UNIT);
|
||||
|
||||
if(!UpdateEntry(Entry, team, data))
|
||||
if (!UpdateEntry(Entry, team, data, false))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
|
||||
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL);
|
||||
bool LoadCreaturesAddon(bool reload = false);
|
||||
void SelectLevel(const CreatureInfo *cinfo);
|
||||
void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f);
|
||||
void LoadEquipment(uint32 equip_entry, bool force=false);
|
||||
|
||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||
|
|
@ -484,7 +484,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
|
||||
bool HasSpell(uint32 spellID) const;
|
||||
|
||||
bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL);
|
||||
bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL, bool preserveHPAndPower = true);
|
||||
bool UpdateStats(Stats stat);
|
||||
bool UpdateAllStats();
|
||||
void UpdateResistances(uint32 school);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9429"
|
||||
#define REVISION_NR "9430"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue