mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Creature: Fix health regeneration. Creatures immediately reset to full health upon reaching home, rather than slowly regaining it over multiple seconds, which allows players to re-engage them at less than max health. (#17756)
This commit is contained in:
@@ -1383,26 +1383,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
|
||||
}
|
||||
}
|
||||
|
||||
uint32 curhealth;
|
||||
|
||||
if (!m_regenHealth)
|
||||
{
|
||||
curhealth = data->curhealth;
|
||||
if (curhealth)
|
||||
{
|
||||
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank));
|
||||
if (curhealth < 1)
|
||||
curhealth = 1;
|
||||
}
|
||||
SetPower(POWER_MANA, data->curmana);
|
||||
}
|
||||
else
|
||||
{
|
||||
curhealth = GetMaxHealth();
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
}
|
||||
|
||||
SetHealth(m_deathState == ALIVE ? curhealth : 0);
|
||||
SetSpawnHealth();
|
||||
|
||||
// checked at creature_template loading
|
||||
m_defaultMovementType = MovementGeneratorType(data->movementType);
|
||||
@@ -1443,6 +1424,35 @@ void Creature::LoadEquipment(int8 id, bool force /*= true*/)
|
||||
SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, einfo->ItemEntry[i]);
|
||||
}
|
||||
|
||||
void Creature::SetSpawnHealth()
|
||||
{
|
||||
uint32 curhealth;
|
||||
|
||||
if (!m_regenHealth)
|
||||
{
|
||||
if (m_creatureData)
|
||||
{
|
||||
curhealth = m_creatureData->curhealth;
|
||||
if (curhealth)
|
||||
{
|
||||
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank));
|
||||
if (curhealth < 1)
|
||||
curhealth = 1;
|
||||
}
|
||||
SetPower(POWER_MANA, m_creatureData->curmana);
|
||||
}
|
||||
else
|
||||
curhealth = GetHealth();
|
||||
}
|
||||
else
|
||||
{
|
||||
curhealth = GetMaxHealth();
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
}
|
||||
|
||||
SetHealth(m_deathState == ALIVE ? curhealth : 0);
|
||||
}
|
||||
|
||||
bool Creature::hasQuest(uint32 quest_id) const
|
||||
{
|
||||
QuestRelationBounds qr = sObjectMgr->GetCreatureQuestRelationBounds(GetEntry());
|
||||
@@ -1654,9 +1664,11 @@ void Creature::setDeathState(DeathState s)
|
||||
}
|
||||
else if (s == JUST_RESPAWNED)
|
||||
{
|
||||
//if (IsPet())
|
||||
// setActive(true);
|
||||
SetFullHealth();
|
||||
if (IsPet())
|
||||
SetFullHealth();
|
||||
else
|
||||
SetSpawnHealth();
|
||||
|
||||
SetLootRecipient(nullptr);
|
||||
ResetPlayerDamageReq();
|
||||
|
||||
|
||||
@@ -442,6 +442,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool LoadCreaturesAddon();
|
||||
void SelectLevel();
|
||||
void LoadEquipment(int8 id = 1, bool force = false);
|
||||
void SetSpawnHealth();
|
||||
|
||||
ObjectGuid::LowType GetSpawnId() const { return m_spawnId; }
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
|
||||
owner->ClearUnitState(UNIT_STATE_EVADE);
|
||||
owner->SetWalk(true);
|
||||
owner->LoadCreaturesAddon();
|
||||
owner->SetSpawnHealth();
|
||||
owner->AI()->JustReachedHome();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user