mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 19:35:42 +00:00
feat(Core/Unit): New helper HasActivePowerType and script hook OnPlayerHasActivePowerType (#18293)
* Create HasActivePower for script intercept * Replace relevant player-related getPowerType() comparators with HasActivePowerType * Change OnPlayerHasActivePowerType to regular bool instead of optional --------- Co-authored-by: NathanHandley <nathanhandley@protonmail.com>
This commit is contained in:
@@ -587,13 +587,13 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
|
||||
InitPrimaryProfessions(); // to max set before any spell added
|
||||
|
||||
// apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods()
|
||||
if (getPowerType() == POWER_MANA)
|
||||
if (HasActivePowerType(POWER_MANA))
|
||||
{
|
||||
UpdateMaxPower(POWER_MANA); // Update max Mana (for add bonus from intellect)
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
}
|
||||
|
||||
if (getPowerType() == POWER_RUNIC_POWER)
|
||||
if (HasActivePowerType(POWER_RUNIC_POWER))
|
||||
{
|
||||
SetPower(POWER_RUNE, 8);
|
||||
SetMaxPower(POWER_RUNE, 8);
|
||||
@@ -2019,22 +2019,21 @@ void Player::RegenerateHealth()
|
||||
void Player::ResetAllPowers()
|
||||
{
|
||||
SetHealth(GetMaxHealth());
|
||||
switch (getPowerType())
|
||||
if (HasActivePowerType(POWER_MANA))
|
||||
{
|
||||
case POWER_MANA:
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
break;
|
||||
case POWER_RAGE:
|
||||
SetPower(POWER_RAGE, 0);
|
||||
break;
|
||||
case POWER_ENERGY:
|
||||
SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
|
||||
break;
|
||||
case POWER_RUNIC_POWER:
|
||||
SetPower(POWER_RUNIC_POWER, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
}
|
||||
if (HasActivePowerType(POWER_RAGE))
|
||||
{
|
||||
SetPower(POWER_RAGE, 0);
|
||||
}
|
||||
if (HasActivePowerType(POWER_ENERGY))
|
||||
{
|
||||
SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
|
||||
}
|
||||
if (HasActivePowerType(POWER_RUNIC_POWER))
|
||||
{
|
||||
SetPower(POWER_RUNIC_POWER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2714,6 +2713,14 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
||||
pet->SynchronizeLevelWithOwner();
|
||||
}
|
||||
|
||||
bool Player::HasActivePowerType(Powers power)
|
||||
{
|
||||
if (sScriptMgr->OnPlayerHasActivePowerType(this, power))
|
||||
return true;
|
||||
else
|
||||
return (getPowerType() == power);
|
||||
}
|
||||
|
||||
void Player::SendInitialSpells()
|
||||
{
|
||||
uint32 curTime = GameTime::GetGameTimeMS().count();
|
||||
|
||||
Reference in New Issue
Block a user