diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2018-03-07 03:32:32 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2018-03-07 03:34:45 -0300 |
| commit | 6e0b9a7916d158981cebe6107710141458d656cc (patch) | |
| tree | 2a44ad4e6049a7ed60b04ffbb8dd7f86d30d44a3 /src/server/game/Spells | |
| parent | 68dde9f8c5467c5983078b190e58105f99dad75c (diff) | |
Core/Creatures: port power type updates from master branch
Core/Misc: Added helper function Unit::SetFullPower
Cherry-picked from 8199eef81cad464bb43f3613ed884a2c8fc3973d
Core/Creatures: Updated power type handling (#20981)
Cherry-picked from 16a7a414abcc93c4514905b871f53c1049261c12
Diffstat (limited to 'src/server/game/Spells')
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 23 | ||||
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 12 |
4 files changed, 21 insertions, 20 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5f7cfe21584..2eb09d0907d 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1703,8 +1703,8 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo { uint32 oldPower = target->GetPower(PowerType); // reset power to default values only at power change - if (target->getPowerType() != PowerType) - target->setPowerType(PowerType); + if (target->GetPowerType() != PowerType) + target->SetPowerType(PowerType); switch (form) { @@ -1713,7 +1713,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo case FORM_DIREBEAR: { // get furor proc chance - uint32 FurorChance = 0; + int32 FurorChance = 0; if (AuraEffect const* dummy = target->GetDummyAuraEffect(SPELLFAMILY_DRUID, 238, 0)) FurorChance = std::max(dummy->GetAmount(), 0); @@ -1722,19 +1722,19 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo case FORM_CAT: { CastSpellExtraArgs args(this); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, std::min(oldPower, FurorChance)); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, std::min<int32>(oldPower, FurorChance)); target->SetPower(POWER_ENERGY, 0); target->CastSpell(target, 17099, args); break; } case FORM_BEAR: case FORM_DIREBEAR: - if (urand(0, 99) < FurorChance) + if (roll_chance_i(FurorChance)) target->CastSpell(target, 17057, true); break; default: { - uint32 newEnergy = std::min(target->GetPower(POWER_ENERGY), FurorChance); + uint32 newEnergy = std::min<int32>(target->GetPower(POWER_ENERGY), FurorChance); target->SetPower(POWER_ENERGY, newEnergy); break; } @@ -1771,7 +1771,6 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo target->SetShapeshiftForm(FORM_NONE); if (target->getClass() == CLASS_DRUID) { - target->setPowerType(POWER_MANA); // Remove movement impairing effects also when shifting out target->RemoveAurasByShapeShift(); } @@ -1833,6 +1832,8 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->InitDataForForm(); + else + target->UpdateDisplayPower(); if (target->getClass() == CLASS_DRUID) { @@ -5437,7 +5438,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con { Powers powerType = Powers(GetMiscValue()); - if (!caster || !caster->IsAlive() || !target->IsAlive() || target->getPowerType() != powerType) + if (!caster || !caster->IsAlive() || !target->IsAlive() || target->GetPowerType() != powerType) return; if (target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsImmunedToDamage(GetSpellInfo())) @@ -5509,7 +5510,7 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const { Powers powerType; if (GetMiscValue() == POWER_ALL) - powerType = target->getPowerType(); + powerType = target->GetPowerType(); else powerType = Powers(GetMiscValue()); @@ -5544,7 +5545,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons { Powers powerType = Powers(GetMiscValue()); - if (target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() != powerType && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) + if (target->GetTypeId() == TYPEID_PLAYER && target->GetPowerType() != powerType && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) return; if (!target->IsAlive() || !target->GetMaxPower(powerType)) @@ -5579,7 +5580,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con { Powers powerType = Powers(GetMiscValue()); - if (!caster || !target->IsAlive() || target->getPowerType() != powerType) + if (!caster || !target->IsAlive() || target->GetPowerType() != powerType) return; if (target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsImmunedToDamage(GetSpellInfo())) diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index b727ded8565..4dc92fd9ac7 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1589,7 +1589,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b break; int32 triggeredSpellId = 0; - switch (target->getPowerType()) + switch (target->GetPowerType()) { case POWER_MANA: { diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index b74453ba138..918887fb131 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5326,7 +5326,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects) if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Unit* target = m_targets.GetUnitTarget()) - if (target != m_caster && target->getPowerType() != Powers(m_spellInfo->Effects[i].MiscValue)) + if (target != m_caster && target->GetPowerType() != Powers(m_spellInfo->Effects[i].MiscValue)) return SPELL_FAILED_BAD_TARGETS; break; } @@ -5753,7 +5753,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem) break; - if (m_targets.GetUnitTarget()->getPowerType() != POWER_MANA) + if (m_targets.GetUnitTarget()->GetPowerType() != POWER_MANA) return SPELL_FAILED_BAD_TARGETS; break; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 9ea2928c423..286e6b8c1fe 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1193,7 +1193,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex) Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue); - if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != powerType || damage < 0) + if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || damage < 0) return; // add spell damage bonus @@ -1272,7 +1272,7 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex) Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue); - if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != powerType || damage < 0) + if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || damage < 0) return; // burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn) @@ -1714,7 +1714,7 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue); - if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->getPowerType() != power && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION + if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetPowerType() != power && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) return; @@ -1784,7 +1784,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex) Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue); - if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->getPowerType() != power && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) + if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetPowerType() != power && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) return; uint32 maxPower = unitTarget->GetMaxPower(power); @@ -2952,8 +2952,8 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) if (OldSummon->getPetType() == SUMMON_PET) { OldSummon->SetHealth(OldSummon->GetMaxHealth()); - OldSummon->SetPower(OldSummon->getPowerType(), - OldSummon->GetMaxPower(OldSummon->getPowerType())); + OldSummon->SetPower(OldSummon->GetPowerType(), + OldSummon->GetMaxPower(OldSummon->GetPowerType())); } if (owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled()) |
