Core/Creatures: Changed the spawn health field in creature table to a percentage (#29801)

This commit is contained in:
Meji
2024-03-30 20:21:28 +01:00
committed by GitHub
parent d8a82ab909
commit def601b4ff
13 changed files with 185 additions and 95 deletions
+44 -20
View File
@@ -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