mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-20 06:59:46 -04:00
Core/Creatures: Changed the spawn health field in creature table to a percentage (#29801)
This commit is contained in:
@@ -5531,12 +5531,43 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType
|
||||
SendAttackStateUpdate(&dmgInfo);
|
||||
}
|
||||
|
||||
void Unit::SetPowerType(Powers new_powertype, bool sendUpdate/* = true*/)
|
||||
void Unit::SetPowerType(Powers power, bool sendUpdate/* = true*/, bool onInit /*= false*/)
|
||||
{
|
||||
if (GetPowerType() == new_powertype)
|
||||
if (!onInit && GetPowerType() == power)
|
||||
return;
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DisplayPower), new_powertype);
|
||||
PowerTypeEntry const* powerTypeEntry = sDB2Manager.GetPowerTypeEntry(power);
|
||||
if (!powerTypeEntry)
|
||||
return;
|
||||
|
||||
if (IsCreature() && !powerTypeEntry->GetFlags().HasFlag(PowerTypeFlags::IsUsedByNPCs))
|
||||
return;
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DisplayPower), power);
|
||||
|
||||
// Update max power
|
||||
UpdateMaxPower(power);
|
||||
|
||||
// Update current power
|
||||
if (!onInit)
|
||||
{
|
||||
switch (power)
|
||||
{
|
||||
case POWER_MANA: // Keep the same (druid form switching...)
|
||||
case POWER_ENERGY:
|
||||
break;
|
||||
case POWER_RAGE: // Reset to zero
|
||||
SetPower(POWER_RAGE, 0);
|
||||
break;
|
||||
case POWER_FOCUS: // Make it full
|
||||
SetFullPower(power);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
SetInitialPowerValue(power);
|
||||
|
||||
if (!sendUpdate)
|
||||
return;
|
||||
@@ -5551,25 +5582,18 @@ void Unit::SetPowerType(Powers new_powertype, bool sendUpdate/* = true*/)
|
||||
if (pet->isControlled())
|
||||
pet->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE);
|
||||
}*/
|
||||
}
|
||||
|
||||
// Update max power
|
||||
UpdateMaxPower(new_powertype);
|
||||
void Unit::SetInitialPowerValue(Powers powerType)
|
||||
{
|
||||
PowerTypeEntry const* powerTypeEntry = sDB2Manager.GetPowerTypeEntry(powerType);
|
||||
if (!powerTypeEntry)
|
||||
return;
|
||||
|
||||
// Update current power
|
||||
switch (new_powertype)
|
||||
{
|
||||
case POWER_MANA: // Keep the same (druid form switching...)
|
||||
case POWER_ENERGY:
|
||||
break;
|
||||
case POWER_RAGE: // Reset to zero
|
||||
SetPower(POWER_RAGE, 0);
|
||||
break;
|
||||
case POWER_FOCUS: // Make it full
|
||||
SetFullPower(new_powertype);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (powerTypeEntry->GetFlags().HasFlag(PowerTypeFlags::UnitsUseDefaultPowerOnInit))
|
||||
SetPower(powerType, powerTypeEntry->DefaultPower);
|
||||
else
|
||||
SetFullPower(powerType);
|
||||
}
|
||||
|
||||
Powers Unit::CalculateDisplayPowerType() const
|
||||
|
||||
Reference in New Issue
Block a user