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 | |
| 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
37 files changed, 204 insertions, 203 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index c36db401f59..0d8700fb091 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -372,7 +372,7 @@ bool PowerUsersSelector::operator()(Unit const* target) const if (!_me || !target) return false; - if (target->getPowerType() != _power) + if (target->GetPowerType() != _power) return false; if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) diff --git a/src/server/game/AI/PlayerAI/PlayerAI.cpp b/src/server/game/AI/PlayerAI/PlayerAI.cpp index 69a5bc45f1f..677d39ca322 100644 --- a/src/server/game/AI/PlayerAI/PlayerAI.cpp +++ b/src/server/game/AI/PlayerAI/PlayerAI.cpp @@ -919,7 +919,7 @@ PlayerAI::TargetedSpell SimpleCharmedPlayerAI::SelectAppropriateCastForSpec() VerifyAndPushSpellCast(spells, SPELL_FREEZING_ARROW, TARGET_VICTIM, 2); VerifyAndPushSpellCast(spells, SPELL_RAPID_FIRE, TARGET_NONE, 10); VerifyAndPushSpellCast(spells, SPELL_KILL_SHOT, TARGET_VICTIM, 10); - if (me->GetVictim() && me->GetVictim()->getPowerType() == POWER_MANA && !me->GetVictim()->GetAuraApplicationOfRankedSpell(SPELL_VIPER_STING, me->GetGUID())) + if (me->GetVictim() && me->GetVictim()->GetPowerType() == POWER_MANA && !me->GetVictim()->GetAuraApplicationOfRankedSpell(SPELL_VIPER_STING, me->GetGUID())) VerifyAndPushSpellCast(spells, SPELL_VIPER_STING, TARGET_VICTIM, 5); switch (GetSpec()) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 5aae0f6db05..3a061c816bc 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -825,7 +825,7 @@ void Creature::Update(uint32 diff) if (!IsInEvadeMode() && (!bInCombat || IsPolymorphed() || CanNotReachTarget())) // regenerate health if not in combat or if polymorphed RegenerateHealth(); - if (getPowerType() == POWER_ENERGY) + if (GetPowerType() == POWER_ENERGY) Regenerate(POWER_ENERGY); else Regenerate(POWER_MANA); @@ -1439,18 +1439,22 @@ void Creature::UpdateLevelDependantStats() // mana uint32 mana = stats->GenerateMana(cInfo); - SetCreateMana(mana); - SetMaxPower(POWER_MANA, mana); // MAX Mana - SetPower(POWER_MANA, mana); - /// @todo set UNIT_FIELD_POWER*, for some creature class case (energy, etc) + switch (getClass()) + { + case UNIT_CLASS_PALADIN: + case UNIT_CLASS_MAGE: + SetMaxPower(POWER_MANA, mana); + SetFullPower(POWER_MANA); + break; + default: // We don't set max power here, 0 makes power bar hidden + break; + } SetStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, (float)health); - SetStatFlatModifier(UNIT_MOD_MANA, BASE_VALUE, (float)mana); // damage - float basedamage = stats->GenerateBaseDamage(cInfo); float weaponBaseMinDamage = basedamage; diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index ed09b3304cc..3fa20dbeabc 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -21,6 +21,16 @@ #include "Creature.h" +enum PetEntry : uint32 +{ + // Death Knight pets + PET_GHOUL = 26125, + PET_RISEN_ALLY = 30230, + + // Shaman pet + PET_SPIRIT_WOLF = 29264 +}; + struct SummonPropertiesEntry; class TC_GAME_API TempSummon : public Creature @@ -59,10 +69,15 @@ class TC_GAME_API Minion : public TempSummon Unit* GetOwner() const { return m_owner; } float GetFollowAngle() const override { return m_followAngle; } void SetFollowAngle(float angle) { m_followAngle = angle; } - bool IsPetGhoul() const { return GetEntry() == 26125; } // Ghoul may be guardian or pet - bool IsSpiritWolf() const { return GetEntry() == 29264; } // Spirit wolf from feral spirits + + // Death Knight pets + bool IsPetGhoul() const { return GetEntry() == PET_GHOUL; } // Ghoul may be guardian or pet + bool IsRisenAlly() const { return GetEntry() == PET_RISEN_ALLY; } + + // Shaman pet + bool IsSpiritWolf() const { return GetEntry() == PET_SPIRIT_WOLF; } // Spirit wolf from feral spirits + bool IsGuardianPet() const; - bool IsRisenAlly() const { return GetEntry() == 30230; } protected: Unit* const m_owner; float m_followAngle; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index df32c680c09..cf6f1094dce 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -222,7 +222,6 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c case HUNTER_PET: SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_WARRIOR); SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, GENDER_NONE); - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, POWER_FOCUS); SetSheath(SHEATH_STATE_MELEE); SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, fields[9].GetBool() ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); @@ -592,7 +591,7 @@ void Pet::Update(uint32 diff) m_focusRegenTimer -= diff; else { - switch (getPowerType()) + switch (GetPowerType()) { case POWER_FOCUS: Regenerate(POWER_FOCUS); @@ -773,7 +772,6 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas SetMaxPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS)); SetPower(POWER_HAPPINESS, 166500); - setPowerType(POWER_FOCUS); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(getLevel()+1)*PET_XP_FACTOR)); @@ -783,7 +781,6 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_WARRIOR); SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, GENDER_NONE); - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, POWER_FOCUS); SetSheath(SHEATH_STATE_MELEE); SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); } @@ -854,13 +851,12 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) SetStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i])); - //health, mana, armor and resistance + // Health, Mana or Power, Armor PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel); if (pInfo) // exist in DB { SetCreateHealth(pInfo->health); - if (petType != HUNTER_PET) //hunter pet use focus - SetCreateMana(pInfo->mana); + SetCreateMana(pInfo->mana); if (pInfo->armor > 0) SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor)); @@ -882,6 +878,15 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetCreateStat(STAT_SPIRIT, 27); } + // Power + if (petType == HUNTER_PET) // Hunter pets have focus + SetPowerType(POWER_FOCUS); + else if (IsPetGhoul() || IsRisenAlly()) // DK pets have energy + SetPowerType(POWER_ENERGY); + else + SetPowerType(POWER_MANA); + + // Damage SetBonusDamage(0); switch (petType) { diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index c632c8b7cea..6f5ec8a8f09 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -586,19 +586,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() UpdateMaxHealth(); // Update max Health (for add bonus from stamina) SetFullHealth(); - if (getPowerType() == POWER_MANA) - { - UpdateMaxPower(POWER_MANA); // Update max Mana (for add bonus from intellect) - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - } - - if (getPowerType() == POWER_RUNIC_POWER) - { - SetPower(POWER_RUNE, 8); - SetMaxPower(POWER_RUNE, 8); - SetPower(POWER_RUNIC_POWER, 0); - SetMaxPower(POWER_RUNIC_POWER, 1000); - } + SetFullPower(POWER_MANA); // original spells LearnDefaultSkills(); @@ -2195,17 +2183,17 @@ void Player::RegenerateHealth() void Player::ResetAllPowers() { - SetHealth(GetMaxHealth()); - switch (getPowerType()) + SetFullHealth(); + switch (GetPowerType()) { case POWER_MANA: - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); + SetFullPower(POWER_MANA); break; case POWER_RAGE: SetPower(POWER_RAGE, 0); break; case POWER_ENERGY: - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); + SetFullPower(POWER_ENERGY); break; case POWER_RUNIC_POWER: SetPower(POWER_RUNIC_POWER, 0); @@ -2630,12 +2618,7 @@ void Player::GiveLevel(uint8 level) // set current level health and mana/energy to maximum after applying all mods. SetFullHealth(); - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); - if (GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) - SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); - SetPower(POWER_FOCUS, 0); - SetPower(POWER_HAPPINESS, 0); + SetFullPower(POWER_MANA); // update level to hunter/summon pet if (Pet* pet = GetPet()) @@ -2852,11 +2835,11 @@ void Player::InitStatsForLevel(bool reapplyMods) // set current level health and mana/energy to maximum after applying all mods. SetFullHealth(); - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); + SetFullPower(POWER_MANA); + SetFullPower(POWER_ENERGY); if (GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) - SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); - SetPower(POWER_FOCUS, 0); + SetFullPower(POWER_RAGE); + SetFullPower(POWER_FOCUS); SetPower(POWER_HAPPINESS, 0); SetPower(POWER_RUNIC_POWER, 0); @@ -17534,6 +17517,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) m_activeSpec = 0; } + UpdateDisplayPower(); _LoadTalents(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_TALENTS)); _LoadSpells(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SPELLS)); @@ -17599,11 +17583,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) // restore remembered power/health values (but not more max values) uint32 savedHealth = fields[55].GetUInt32(); - SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth); + SetHealth(savedHealth); for (uint8 i = 0; i < MAX_POWERS; ++i) { uint32 savedPower = fields[56 + i].GetUInt32(); - SetPower(Powers(i), savedPower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower); + SetPower(static_cast<Powers>(i), savedPower); } TC_LOG_DEBUG("entities.player.loading", "Player::LoadFromDB: The value of player '%s' after load item and aura is: ", m_name.c_str()); @@ -21340,30 +21324,7 @@ void Player::InitDataForForm(bool reapplyMods) else SetRegularAttackTime(); - switch (form) - { - case FORM_GHOUL: - case FORM_CAT: - { - if (getPowerType() != POWER_ENERGY) - setPowerType(POWER_ENERGY); - break; - } - case FORM_BEAR: - case FORM_DIREBEAR: - { - if (getPowerType() != POWER_RAGE) - setPowerType(POWER_RAGE); - break; - } - default: // 0, for example - { - ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass()); - if (cEntry && cEntry->powerType < MAX_POWERS && uint32(getPowerType()) != cEntry->powerType) - setPowerType(Powers(cEntry->powerType)); - break; - } - } + UpdateDisplayPower(); // update auras at form change, ignore this at mods reapply (.reset stats/etc) when form not change. if (!reapplyMods) @@ -23732,19 +23693,11 @@ void Player::ResurrectUsingRequestDataImpl() ResurrectPlayer(0.0f, false); - if (GetMaxHealth() > resurrectHealth) - SetHealth(resurrectHealth); - else - SetFullHealth(); - - if (GetMaxPower(POWER_MANA) > resurrectMana) - SetPower(POWER_MANA, resurrectMana); - else - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); + SetHealth(resurrectHealth); + SetPower(POWER_MANA, resurrectMana); SetPower(POWER_RAGE, 0); - - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); + SetFullPower(POWER_ENERGY); SpawnCorpseBones(); } @@ -25914,7 +25867,7 @@ void Player::ActivateSpec(uint8 spec) })); } - Powers pw = getPowerType(); + Powers pw = GetPowerType(); if (pw != POWER_MANA) SetPower(POWER_MANA, 0); // Mana must be 0 even if it isn't the active power type. @@ -26442,7 +26395,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->SetCreatorGUID(GetGUID()); pet->SetFaction(GetFaction()); - pet->setPowerType(POWER_MANA); pet->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pet->InitStatsForLevel(getLevel()); diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 46f1c50c11e..eba057a6c67 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -326,7 +326,7 @@ void Player::UpdateMaxPower(Powers power) value += GetFlatModifierValue(unitMod, TOTAL_VALUE) + bonusPower; value *= GetPctModifierValue(unitMod, TOTAL_PCT); - SetMaxPower(power, uint32(value)); + SetMaxPower(power, uint32(std::lroundf(value))); } void Player::ApplyFeralAPBonus(int32 amount, bool apply) @@ -1029,8 +1029,12 @@ void Creature::UpdateMaxPower(Powers power) { UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); - float value = GetTotalAuraModValue(unitMod); - SetMaxPower(power, uint32(value)); + float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); + value *= GetPctModifierValue(unitMod, BASE_PCT); + value += GetFlatModifierValue(unitMod, TOTAL_VALUE); + value *= GetPctModifierValue(unitMod, TOTAL_PCT); + + SetMaxPower(power, uint32(std::lroundf(value))); } void Creature::UpdateAttackPowerAndDamage(bool ranged) @@ -1237,6 +1241,8 @@ bool Guardian::UpdateStats(Stats stat) bool Guardian::UpdateAllStats() { + UpdateMaxHealth(); + for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) UpdateStats(Stats(i)); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index ce611130ddc..e811a87e227 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -729,7 +729,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons } // Rage from Damage made (only from direct weapon damage) - if (attacker && cleanDamage && damagetype == DIRECT_DAMAGE && attacker != victim && attacker->getPowerType() == POWER_RAGE) + if (attacker && cleanDamage && damagetype == DIRECT_DAMAGE && attacker != victim && attacker->GetPowerType() == POWER_RAGE) { uint32 weaponSpeedHitFactor; @@ -755,7 +755,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons if (!damage) { // Rage from absorbed damage - if (cleanDamage && cleanDamage->absorbed_damage && victim->getPowerType() == POWER_RAGE) + if (cleanDamage && cleanDamage->absorbed_damage && victim->GetPowerType() == POWER_RAGE) victim->RewardRage(cleanDamage->absorbed_damage, 0, false); return 0; @@ -857,7 +857,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons } // Rage from damage received - if (attacker != victim && victim->getPowerType() == POWER_RAGE) + if (attacker != victim && victim->GetPowerType() == POWER_RAGE) { rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0); victim->RewardRage(rage_damage, 0, false); @@ -5541,9 +5541,9 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType SendAttackStateUpdate(&dmgInfo); } -void Unit::setPowerType(Powers new_powertype) +void Unit::SetPowerType(Powers new_powertype) { - if (getPowerType() == new_powertype) + if (GetPowerType() == new_powertype) return; SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, new_powertype); @@ -5563,32 +5563,73 @@ void Unit::setPowerType(Powers new_powertype) } } - float powerMultiplier = 1.0f; - if (!IsPet()) - if (Creature* creature = ToCreature()) - powerMultiplier = creature->GetCreatureTemplate()->ModMana; + // Update max power + UpdateMaxPower(new_powertype); + // Update current power switch (new_powertype) { - default: - case POWER_MANA: + case POWER_MANA: // Keep the same (druid form switching...) + case POWER_ENERGY: break; - case POWER_RAGE: - SetMaxPower(POWER_RAGE, uint32(std::ceil(GetCreatePowers(POWER_RAGE) * powerMultiplier))); + case POWER_RAGE: // Reset to zero SetPower(POWER_RAGE, 0); break; - case POWER_FOCUS: - SetMaxPower(POWER_FOCUS, uint32(std::ceil(GetCreatePowers(POWER_FOCUS) * powerMultiplier))); - SetPower(POWER_FOCUS, uint32(std::ceil(GetCreatePowers(POWER_FOCUS) * powerMultiplier))); + case POWER_FOCUS: // Make it full + SetFullPower(new_powertype); break; - case POWER_ENERGY: - SetMaxPower(POWER_ENERGY, uint32(std::ceil(GetCreatePowers(POWER_ENERGY) * powerMultiplier))); + default: + break; + } +} + +void Unit::UpdateDisplayPower() +{ + Powers displayPower = POWER_MANA; + switch (GetShapeshiftForm()) + { + case FORM_GHOUL: + case FORM_CAT: + displayPower = POWER_ENERGY; + break; + case FORM_BEAR: + case FORM_DIREBEAR: + displayPower = POWER_RAGE; break; - case POWER_HAPPINESS: - SetMaxPower(POWER_HAPPINESS, uint32(std::ceil(GetCreatePowers(POWER_HAPPINESS) * powerMultiplier))); - SetPower(POWER_HAPPINESS, uint32(std::ceil(GetCreatePowers(POWER_HAPPINESS) * powerMultiplier))); + case FORM_TRAVEL: + case FORM_GHOSTWOLF: + displayPower = POWER_MANA; + break; + default: + { + if (GetTypeId() == TYPEID_PLAYER) + { + ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass()); + if (cEntry && cEntry->powerType < MAX_POWERS) + displayPower = Powers(cEntry->powerType); + } + else if (GetTypeId() == TYPEID_UNIT) + { + if (Vehicle* vehicle = GetVehicleKit()) + { + if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->m_powerDisplayId)) + displayPower = Powers(powerDisplay->PowerType); + else if (getClass() == CLASS_ROGUE) + displayPower = POWER_ENERGY; + } + else if (Pet* pet = ToPet()) + { + if (pet->getPetType() == HUNTER_PET) // Hunter pets have focus + displayPower = POWER_FOCUS; + else if (pet->IsPetGhoul() || pet->IsRisenAlly()) // DK pets have energy + displayPower = POWER_ENERGY; + } + } break; + } } + + SetPowerType(displayPower); } FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const @@ -6303,14 +6344,9 @@ void Unit::SetMinion(Minion *minion, bool apply) for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i) minion->SetSpeedRate(UnitMoveType(i), m_speed_rate[i]); - // Ghoul pets have energy instead of mana (is anywhere better place for this code?) - if (minion->IsPetGhoul() || minion->IsRisenAlly()) - minion->setPowerType(POWER_ENERGY); - // Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL)); - - if (spellInfo && (spellInfo->IsCooldownStartedOnEvent())) + if (spellInfo && spellInfo->IsCooldownStartedOnEvent()) GetSpellHistory()->StartCooldown(spellInfo, 0, nullptr, true); } else @@ -9366,7 +9402,7 @@ void Unit::setDeathState(DeathState s) // without this when removing IncreaseMaxHealth aura player may stuck with 1 hp // do not why since in IncreaseMaxHealth currenthealth is checked SetHealth(0); - SetPower(getPowerType(), 0); + SetPower(GetPowerType(), 0); SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); // players in instance don't have ZoneScript, but they have InstanceScript diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index f133013161f..d464861f2ea 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -878,12 +878,14 @@ class TC_GAME_API Unit : public WorldObject int32 ModifyHealth(int32 val); int32 GetHealthGain(int32 dVal); - Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); } - void setPowerType(Powers power); + Powers GetPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); } + void SetPowerType(Powers power); + void UpdateDisplayPower(); uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); } uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); } void SetPower(Powers power, uint32 val); void SetMaxPower(Powers power, uint32 val); + inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); } // returns the change in power int32 ModifyPower(Powers power, int32 val); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index b4fce815cc6..898a7a6e043 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -75,14 +75,6 @@ Vehicle::~Vehicle() void Vehicle::Install() { - if (_me->GetTypeId() == TYPEID_UNIT) - { - if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId)) - _me->setPowerType(Powers(powerDisplay->PowerType)); - else if (_me->getClass() == CLASS_ROGUE) - _me->setPowerType(POWER_ENERGY); - } - _status = STATUS_INSTALLED; if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstall(this); diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index bc2e552b47c..b52386f2778 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -781,7 +781,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_MAX_HP) *data << uint32(player->GetMaxHealth()); - Powers powerType = player->getPowerType(); + Powers powerType = player->GetPowerType(); if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) *data << uint8(powerType); @@ -862,7 +862,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) { if (pet) - *data << uint8(pet->getPowerType()); + *data << uint8(pet->GetPowerType()); else *data << uint8(0); } @@ -870,7 +870,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER) { if (pet) - *data << uint16(pet->GetPower(pet->getPowerType())); + *data << uint16(pet->GetPower(pet->GetPowerType())); else *data << uint16(0); } @@ -878,7 +878,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER) { if (pet) - *data << uint16(pet->GetMaxPower(pet->getPowerType())); + *data << uint16(pet->GetMaxPower(pet->GetPowerType())); else *data << uint16(0); } @@ -932,7 +932,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recvData) } Pet* pet = player->GetPet(); - Powers powerType = player->getPowerType(); + Powers powerType = player->GetPowerType(); WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8); data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related @@ -1016,13 +1016,13 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recvData) data << uint32(pet->GetMaxHealth()); if (updateFlags & GROUP_UPDATE_FLAG_PET_POWER_TYPE) - data << (uint8)pet->getPowerType(); + data << (uint8)pet->GetPowerType(); if (updateFlags & GROUP_UPDATE_FLAG_PET_CUR_POWER) - data << uint16(pet->GetPower(pet->getPowerType())); + data << uint16(pet->GetPower(pet->GetPowerType())); if (updateFlags & GROUP_UPDATE_FLAG_PET_MAX_POWER) - data << uint16(pet->GetMaxPower(pet->getPowerType())); + data << uint16(pet->GetMaxPower(pet->GetPowerType())); uint64 petAuraMask = 0; maskPos = data.wpos(); 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()) diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp index 9374203a731..61730d9815c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_vaelastrasz.cpp @@ -194,7 +194,7 @@ public: { //selects a random target that isn't the current victim and is a mana user (selects mana users) but not pets //it also ignores targets who have the aura. We don't want to place the debuff on the same target twice. - if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 1, [&](Unit* u) { return u && !u->IsPet() && u->getPowerType() == POWER_MANA && !u->HasAura(SPELL_BURNINGADRENALINE); })) + if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 1, [&](Unit* u) { return u && !u->IsPet() && u->GetPowerType() == POWER_MANA && !u->HasAura(SPELL_BURNINGADRENALINE); })) { me->CastSpell(target, SPELL_BURNINGADRENALINE, true); } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 5071eb33ebf..ccf1cd7de26 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -425,7 +425,7 @@ public: if (ManaBurn_Timer <= diff) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - if (target->getPowerType() == POWER_MANA) + if (target->GetPowerType() == POWER_MANA) DoCast(target, SPELL_MANABURN); ManaBurn_Timer = 5000; // 3 sec cast } else ManaBurn_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index 6abc0f80a8e..5cd5d52aada 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -174,7 +174,7 @@ class boss_marli : public CreatureScript while (i++ < 3) // max 3 tries to get a random target with power_mana { target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); // not aggro leader - if (target && target->getPowerType() == POWER_MANA) + if (target && target->GetPowerType() == POWER_MANA) break; } if (target) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp index 352d16fb7a2..3d9471560d4 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp @@ -176,7 +176,7 @@ class MarkTargetFilter bool operator()(WorldObject* target) const { if (Unit* unit = target->ToUnit()) - return unit->getPowerType() != POWER_MANA; + return unit->GetPowerType() != POWER_MANA; return false; } }; diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp index dc89f645d3d..c86432eecd3 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp @@ -149,7 +149,7 @@ class boss_moam : public CreatureScript std::list<Unit*> targetList; { for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) - if (ref->GetVictim()->GetTypeId() == TYPEID_PLAYER && ref->GetVictim()->getPowerType() == POWER_MANA) + if (ref->GetVictim()->GetTypeId() == TYPEID_PLAYER && ref->GetVictim()->GetPowerType() == POWER_MANA) targetList.push_back(ref->GetVictim()); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index 6bc1bdc9e10..15572301b94 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -616,7 +616,7 @@ struct boss_faction_championsAI : public BossAI void UpdatePower() { - if (me->getPowerType() == POWER_MANA) + if (me->GetPowerType() == POWER_MANA) me->ModifyPower(POWER_MANA, me->GetMaxPower(POWER_MANA) / 3); } @@ -675,7 +675,7 @@ struct boss_faction_championsAI : public BossAI { for (auto const& pair : me->GetCombatManager().GetPvECombatRefs()) if (Player* player = pair.second->GetOther(me)->ToPlayer()) - if (player->getPowerType() == POWER_MANA) + if (player->GetPowerType() == POWER_MANA) return player; return nullptr; } @@ -1820,7 +1820,7 @@ class npc_toc_rogue : public CreatureScript events.ScheduleEvent(EVENT_EVISCERATE, urand(20*IN_MILLISECONDS, 40*IN_MILLISECONDS)); events.ScheduleEvent(EVENT_WOUND_POISON, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); SetEquipmentSlots(false, 47422, 49982, EQUIP_NO_CHANGE); - me->setPowerType(POWER_ENERGY); + me->SetPowerType(POWER_ENERGY); me->SetMaxPower(POWER_ENERGY, 100); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index 8ec53102b02..240dbca6fe4 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -508,7 +508,7 @@ class spell_mistress_kiss_area : public SpellScript // get a list of players with mana targets.remove_if([](WorldObject* target) { - return target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->getPowerType() == POWER_MANA; + return target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->GetPowerType() == POWER_MANA; }); if (targets.empty()) diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index d5045c82bfd..d0c3a42f3ed 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -271,7 +271,7 @@ class spell_bronjahm_magic_bane : public SpellScriptLoader void RecalculateDamage(SpellEffIndex /*effIndex*/) { - if (GetHitUnit()->getPowerType() != POWER_MANA) + if (GetHitUnit()->GetPowerType() != POWER_MANA) return; int32 const maxDamage = GetCaster()->GetMap()->IsHeroic() ? 15000 : 10000; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 92251489963..334e3d73775 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -1055,7 +1055,7 @@ class spell_deathbringer_blood_link_aura : public SpellScriptLoader void HandlePeriodicTick(AuraEffect const* /*aurEff*/) { PreventDefaultAction(); - if (GetUnitOwner()->getPowerType() == POWER_ENERGY && GetUnitOwner()->GetPower(POWER_ENERGY) == GetUnitOwner()->GetMaxPower(POWER_ENERGY)) + if (GetUnitOwner()->GetPowerType() == POWER_ENERGY && GetUnitOwner()->GetPower(POWER_ENERGY) == GetUnitOwner()->GetMaxPower(POWER_ENERGY)) if (Creature* saurfang = GetUnitOwner()->ToCreature()) saurfang->AI()->DoAction(ACTION_MARK_OF_THE_FALLEN_CHAMPION); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index e483d960db7..bf9035604a3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -1161,7 +1161,7 @@ class UnchainedMagicTargetSelector bool operator()(WorldObject* object) const { if (Unit* unit = object->ToUnit()) - return unit->getPowerType() != POWER_MANA; + return unit->GetPowerType() != POWER_MANA; return true; } }; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index d5e5dfcb5d7..95360a368ed 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -169,7 +169,7 @@ struct ManaVoidSelector : public std::unary_function<Unit*, bool> bool operator()(Unit* unit) const { - return unit->getPowerType() == POWER_MANA && _source->GetDistance(unit) > 15.0f; + return unit->GetPowerType() == POWER_MANA && _source->GetDistance(unit) > 15.0f; } WorldObject const* _source; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index c514fff54b0..16a44bb54bb 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -201,7 +201,7 @@ struct ManaUserTargetSelector : public std::unary_function<Unit*, bool> { bool operator()(Unit const* target) const { - return target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() == POWER_MANA; + return target->GetTypeId() == TYPEID_PLAYER && target->GetPowerType() == POWER_MANA; } }; diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_anzu.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_anzu.cpp index 92ced2c9c17..fcee93877af 100644 --- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_anzu.cpp +++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_anzu.cpp @@ -145,7 +145,7 @@ class boss_anzu : public CreatureScript case EVENT_SPELL_BOMB: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { - if (target->getPowerType() == POWER_MANA) + if (target->GetPowerType() == POWER_MANA) { DoCast(target, SPELL_SPELL_BOMB); Talk(SAY_SPELL_BOMB, target); diff --git a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp index 1ac243c64b2..e1f83c14440 100644 --- a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp +++ b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp @@ -209,7 +209,7 @@ public: if (ManaBurn_Timer <= diff) { Unit* target = me->GetVictim(); - if (target && target->getPowerType() == POWER_MANA) + if (target && target->GetPowerType() == POWER_MANA) DoCast(target, SPELL_MANA_BURN); ManaBurn_Timer = 8000 + rand32() % 8000; } else ManaBurn_Timer -= diff; diff --git a/src/server/scripts/Outland/zone_zangarmarsh.cpp b/src/server/scripts/Outland/zone_zangarmarsh.cpp index 5f86b8fa987..73c823ac8c9 100644 --- a/src/server/scripts/Outland/zone_zangarmarsh.cpp +++ b/src/server/scripts/Outland/zone_zangarmarsh.cpp @@ -88,7 +88,7 @@ public: ClearGossipMenuFor(player); if (action == GOSSIP_ACTION_INFO_DEF + 1) { - me->setPowerType(POWER_MANA); + me->SetPowerType(POWER_MANA); me->SetMaxPower(POWER_MANA, 200); //set a "fake" mana value, we can't depend on database doing it in this case me->SetPower(POWER_MANA, 200); diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 526157708ad..9f8775e9bb9 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -496,7 +496,7 @@ class spell_dru_frenzied_regeneration : public AuraScript void PeriodicTick(AuraEffect const* aurEff) { // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health. - if (GetTarget()->getPowerType() != POWER_RAGE) + if (GetTarget()->GetPowerType() != POWER_RAGE) return; uint32 rage = GetTarget()->GetPower(POWER_RAGE); @@ -1357,7 +1357,7 @@ class spell_dru_revitalize : public SpellScriptLoader Unit* target = eventInfo.GetProcTarget(); uint32 spellId; - switch (target->getPowerType()) + switch (target->GetPowerType()) { case POWER_MANA: spellId = SPELL_DRUID_REVITALIZE_ENERGIZE_MANA; @@ -1803,7 +1803,7 @@ class spell_dru_t3_2p_bonus : public SpellScriptLoader Unit* target = eventInfo.GetProcTarget(); uint32 spellId; - switch (target->getPowerType()) + switch (target->GetPowerType()) { case POWER_MANA: spellId = SPELL_DRUID_T3_PROC_ENERGIZE_MANA; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 943642b7d85..dbf7d7da256 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -2627,7 +2627,7 @@ class spell_gen_pet_summoned : public SpellScript newPet->setDeathState(ALIVE); newPet->SetFullHealth(); - newPet->SetPower(newPet->getPowerType(), newPet->GetMaxPower(newPet->getPowerType())); + newPet->SetPower(newPet->GetPowerType(), newPet->GetMaxPower(newPet->GetPowerType())); switch (newPet->GetEntry()) { @@ -2830,7 +2830,7 @@ public: bool operator()(WorldObject* obj) const { if (Unit* target = obj->ToUnit()) - return target->getPowerType() != POWER_MANA; + return target->GetPowerType() != POWER_MANA; return true; } @@ -2876,7 +2876,7 @@ class spell_gen_replenishment_aura : public AuraScript bool Load() override { - return GetUnitOwner()->getPowerType() == POWER_MANA; + return GetUnitOwner()->GetPowerType() == POWER_MANA; } void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index b47ad57c781..490f31b55b8 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -1101,7 +1101,7 @@ class spell_item_heartpierce : public SpellScriptLoader Unit* caster = eventInfo.GetActor(); uint32 spellId; - switch (caster->getPowerType()) + switch (caster->GetPowerType()) { case POWER_MANA: spellId = Mana; @@ -3851,7 +3851,7 @@ class spell_item_mad_alchemists_potion : public SpellScript Unit* target = GetCaster(); - if (target->getPowerType() == POWER_MANA) + if (target->GetPowerType() == POWER_MANA) availableElixirs.push_back(28509); // Elixir of Major Mageblood (22840) uint32 chosenElixir = Trinity::Containers::SelectRandomContainerElement(availableElixirs); @@ -3914,7 +3914,7 @@ class spell_item_crazy_alchemists_potion : public SpellScript if (!target->IsInCombat()) availableElixirs.push_back(53753); // Potion of Nightmares (40081) - if (target->getPowerType() == POWER_MANA) + if (target->GetPowerType() == POWER_MANA) availableElixirs.push_back(43186); // Runic Mana Potion(33448) uint32 chosenElixir = Trinity::Containers::SelectRandomContainerElement(availableElixirs); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 4386390d49f..928be5a79a6 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -454,7 +454,7 @@ class spell_pal_blessing_of_sanctuary : public SpellScriptLoader bool CheckProc(ProcEventInfo& /*eventInfo*/) { - return GetTarget()->getPowerType() == POWER_MANA; + return GetTarget()->GetPowerType() == POWER_MANA; } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -1518,7 +1518,7 @@ class spell_pal_judgement_of_wisdom_mana : public SpellScriptLoader bool CheckProc(ProcEventInfo& eventInfo) { - return eventInfo.GetProcTarget()->getPowerType() == POWER_MANA; + return eventInfo.GetProcTarget()->GetPowerType() == POWER_MANA; } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 336b2d54be6..aa8b5a5f91d 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -78,7 +78,7 @@ class PowerCheck bool operator()(WorldObject* obj) const { if (Unit* target = obj->ToUnit()) - return target->getPowerType() != _power; + return target->GetPowerType() != _power; return true; } diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 091e06e82fb..a01be4e24f6 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -1541,7 +1541,7 @@ class spell_sha_mana_spring_totem : public SpellScriptLoader { if (Unit* target = GetHitUnit()) if (Unit* caster = GetCaster()) - if (target->getPowerType() == POWER_MANA) + if (target->GetPowerType() == POWER_MANA) { CastSpellExtraArgs args(GetOriginalCaster()->GetGUID()); args.AddSpellBP0(GetEffectValue()); @@ -1608,7 +1608,7 @@ class spell_sha_mana_tide_totem : public SpellScriptLoader { if (Unit* unitTarget = GetHitUnit()) { - if (unitTarget->getPowerType() == POWER_MANA) + if (unitTarget->GetPowerType() == POWER_MANA) { int32 effValue = GetEffectValue(); // Glyph of Mana Tide diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp index bcbf14f0af0..21c928e9b58 100644 --- a/src/server/scripts/World/duel_reset.cpp +++ b/src/server/scripts/World/duel_reset.cpp @@ -46,24 +46,12 @@ class DuelResetScript : public PlayerScript if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_HEALTH_MANA)) { player1->SaveHealthBeforeDuel(); - player1->SetHealth(player1->GetMaxHealth()); + player1->SaveManaBeforeDuel(); + player1->ResetAllPowers(); player2->SaveHealthBeforeDuel(); - player2->SetHealth(player2->GetMaxHealth()); - - // check if player1 class uses mana - if (player1->getPowerType() == POWER_MANA || player1->getClass() == CLASS_DRUID) - { - player1->SaveManaBeforeDuel(); - player1->SetPower(POWER_MANA, player1->GetMaxPower(POWER_MANA)); - } - - // check if player2 class uses mana - if (player2->getPowerType() == POWER_MANA || player2->getClass() == CLASS_DRUID) - { - player2->SaveManaBeforeDuel(); - player2->SetPower(POWER_MANA, player2->GetMaxPower(POWER_MANA)); - } + player2->SaveManaBeforeDuel(); + player2->ResetAllPowers(); } } @@ -90,11 +78,11 @@ class DuelResetScript : public PlayerScript loser->RestoreHealthAfterDuel(); // check if player1 class uses mana - if (winner->getPowerType() == POWER_MANA || winner->getClass() == CLASS_DRUID) + if (winner->GetPowerType() == POWER_MANA || winner->getClass() == CLASS_DRUID) winner->RestoreManaAfterDuel(); // check if player2 class uses mana - if (loser->getPowerType() == POWER_MANA || loser->getClass() == CLASS_DRUID) + if (loser->GetPowerType() == POWER_MANA || loser->getClass() == CLASS_DRUID) loser->RestoreManaAfterDuel(); } } |
