Core/Units: ported power type updates from master branch

This commit is contained in:
Ovahlord committed 2020-04-22 03:13:02 +02:00
1 parent e67167e8cf
commit b653f2f819
40 files changed
+259 -278

No files matched your search

+1 -1
View File
@@ -373,7 +373,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)
+1 -1
View File
@@ -823,7 +823,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())
+2 -2
View File
@@ -1078,9 +1078,9 @@ CharSectionsEntry const* DBCManager::GetCharSectionEntry(uint8 race, CharSection
return nullptr;
}
uint32 DBCManager::GetPowerIndexByClass(uint32 powerType, uint32 classId)
uint32 DBCManager::GetPowerIndexByClass(Powers power, uint32 classId)
{
return PowersByClass[classId][powerType];
return PowersByClass[classId][power];
}
uint32 ScalingStatValuesEntry::GetStatMultiplier(uint32 inventoryType) const
+1 -1
View File
@@ -239,7 +239,7 @@ public:
PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id);
CharStartOutfitEntry const* GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender);
CharSectionsEntry const* GetCharSectionEntry(uint8 race, CharSectionType genType, uint8 gender, uint8 type, uint8 color);
uint32 GetPowerIndexByClass(uint32 powerType, uint32 classId);
uint32 GetPowerIndexByClass(Powers power, uint32 classId);
static bool IsInArea(uint32 objectAreaId, uint32 areaId);
static LFGDungeonEntry const* GetLFGDungeon(uint32 mapId, Difficulty difficulty);
std::vector<uint32> const* GetPhasesForGroup(uint32 group);
+23 -21
View File
@@ -535,18 +535,25 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
if (updateLevel)
SelectLevel();
UpdateLevelDependantStats();
// Do not update guardian stats here - they are handled in Guardian::InitStatsForLevel()
if (!IsGuardian())
{
uint32 previousHealth = GetHealth();
UpdateLevelDependantStats();
if (previousHealth > 0)
SetHealth(previousHealth);
SetMeleeDamageSchool(SpellSchools(cInfo->dmgschool));
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_HOLY]));
SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FIRE]));
SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_NATURE]));
SetModifierValue(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FROST]));
SetModifierValue(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_SHADOW]));
SetModifierValue(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_ARCANE]));
SetMeleeDamageSchool(SpellSchools(cInfo->dmgschool));
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_HOLY]));
SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FIRE]));
SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_NATURE]));
SetModifierValue(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FROST]));
SetModifierValue(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_SHADOW]));
SetModifierValue(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_ARCANE]));
SetCanModifyStats(true);
UpdateAllStats();
SetCanModifyStats(true);
UpdateAllStats();
}
// checked and error show at loading templates
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction))
@@ -783,7 +790,7 @@ void Creature::Update(uint32 diff)
if (HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER))
{
if (getPowerType() == POWER_ENERGY)
if (GetPowerType() == POWER_ENERGY)
Regenerate(POWER_ENERGY);
else
RegenerateMana();
@@ -1324,23 +1331,18 @@ void Creature::UpdateLevelDependantStats()
switch (getClass())
{
case CLASS_WARRIOR:
setPowerType(POWER_RAGE);
case UNIT_CLASS_PALADIN:
case UNIT_CLASS_MAGE:
SetMaxPower(POWER_MANA, mana);
SetFullPower(POWER_MANA);
break;
case CLASS_ROGUE:
setPowerType(POWER_ENERGY);
break;
default:
SetMaxPower(POWER_MANA, mana); // MAX Mana
SetPower(POWER_MANA, mana);
default: // We don't set max power here, 0 makes power bar hidden
break;
}
SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, (float)mana);
// damage
float basedamage = stats->GenerateBaseDamage(cInfo);
float weaponBaseMinDamage = basedamage;
@@ -143,6 +143,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
uint32 GetPowerIndex(Powers power) const override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
@@ -46,6 +46,7 @@ enum PetEntries
// Death Knight Pet/Minions
ENTRY_GHOUL = 26125,
ENTRY_RISEN_ALLY = 30230,
ENTRY_BLOODWORM = 28017,
ENTRY_RUNIC_WEAPON = 27893,
ENTRY_GARGOYLE = 27829,
@@ -108,6 +109,7 @@ class TC_GAME_API Minion : public TempSummon
float GetFollowAngle() const override { return m_followAngle; }
void SetFollowAngle(float angle) { m_followAngle = angle; }
bool IsPetGhoul() const { return GetEntry() == ENTRY_GHOUL; } // Ghoul may be guardian or pet
bool IsRisenAlly() const { return GetEntry() == ENTRY_RISEN_ALLY; }
bool IsSpiritWolf() const { return GetEntry() == ENTRY_SPIRIT_WOLF; } // Spirit wolf from feral spirits
bool IsGuardianPet() const;
bool IsWarlockMinion() const;
@@ -2144,14 +2144,6 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
summon->SetHealth(health);
}
// Initialize guardian stats
if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN) && summoner)
{
((Guardian*)summon)->UpdateAllStats();
summon->SetPower(POWER_MANA, summon->GetMaxPower(POWER_MANA));
summon->SetFullHealth();
}
AddToMap(summon->ToCreature());
summon->InitSummon();
+42 -8
View File
@@ -218,7 +218,6 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur
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, playerPetData->Renamed ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED);
SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
@@ -599,7 +598,7 @@ void Pet::Update(uint32 diff)
m_petFocusRegenTimer -= diff;
if (m_petFocusRegenTimer <= 0)
{
if (getPowerType() == POWER_FOCUS)
if (GetPowerType() == POWER_FOCUS)
Regenerate(POWER_FOCUS);
m_petFocusRegenTimer += PetFocusRegenInterval;
@@ -779,7 +778,6 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map)
if (!Create(guid, map, cinfo->Entry, petId))
return false;
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));
@@ -790,7 +788,6 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map)
SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100);
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);
}
@@ -866,8 +863,7 @@ bool Guardian::InitStatsForLevel(uint8 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)
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
@@ -877,11 +873,16 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
}
else // not exist in DB, use some default fake data
{
// remove elite bonuses included in DB values
// remove elite bonuses included in DB values
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class);
SetCreateHealth(stats->BaseHealth[cinfo->expansion]);
SetCreateMana(stats->BaseMana);
float healthmod = _GetHealthMod(cinfo->rank);
uint32 basehp = stats->GenerateHealth(cinfo);
uint32 health = uint32(basehp * healthmod);
uint32 mana = stats->GenerateMana(cinfo);
SetCreateHealth(health);
SetCreateMana(mana);
SetCreateStat(STAT_STRENGTH, 22);
SetCreateStat(STAT_AGILITY, 22);
SetCreateStat(STAT_STAMINA, 25);
@@ -892,6 +893,18 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
}
// Power
if (petType == HUNTER_PET) // Hunter pets have focus
SetPowerType(POWER_FOCUS);
else if (IsPetGhoul() || IsRisenAlly()) // DK pets have energy
{
SetPowerType(POWER_ENERGY);
SetFullPower(POWER_ENERGY);
}
else
SetPowerType(POWER_MANA);
// Damage
SetBonusDamage(0);
switch (petType)
{
@@ -1066,10 +1079,31 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
if (!HasAura(62137)) // Avoidance
CastSpell(this, 62137, true);
break;
default:
{
/* ToDo: Check what 5f5d2028 broke/fixed and how much of Creature::UpdateLevelDependantStats()
* should be copied here (or moved to another method or if that function should be called here
* or not just for this default case)
*/
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class);
float basedamage = stats->GenerateBaseDamage(cinfo);
float weaponBaseMinDamage = basedamage;
float weaponBaseMaxDamage = basedamage * 1.5f;
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, weaponBaseMinDamage);
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
break;
}
}
break;
}
}
UpdateAllStats();
SetFullHealth();
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
return true;
}
+24 -66
View File
@@ -558,19 +558,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();
@@ -2051,17 +2039,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);
@@ -2483,11 +2471,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);
SetFullPower(POWER_MANA);
// update level to hunter/summon pet
if (Pet* pet = GetPet())
@@ -2726,11 +2710,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, GetMaxPower(POWER_FOCUS));
SetFullPower(POWER_RAGE);
SetFullPower(POWER_FOCUS);
SetPower(POWER_RUNIC_POWER, 0);
// update level to hunter/summon pet
@@ -17713,6 +17697,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder* holder)
//mails are loaded only when needed ;-) - when player in game click on mailbox.
//_LoadMail();
UpdateDisplayPower();
_LoadTalents(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_TALENTS));
_LoadSpells(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SPELLS));
@@ -17785,11 +17770,11 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder* holder)
UpdateAllStats();
// restore remembered power/health values (but not more max values)
SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth);
SetHealth(savedHealth);
uint32 loadedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndex(i) != MAX_POWERS)
if (GetPowerIndex(Powers(i)) != MAX_POWERS)
{
uint32 savedPower = fields[52 + loadedPowers].GetUInt32();
uint32 maxPower = GetUInt32Value(UNIT_FIELD_MAXPOWER1 + loadedPowers);
@@ -19669,7 +19654,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false
uint32 storedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndex(i) != MAX_POWERS)
if (GetPowerIndex(Powers(i)) != MAX_POWERS)
{
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
if (++storedPowers >= MAX_POWERS_PER_CLASS)
@@ -19809,7 +19794,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false
uint32 storedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndex(i) != MAX_POWERS)
if (GetPowerIndex(Powers(i)) != MAX_POWERS)
{
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
if (++storedPowers >= MAX_POWERS_PER_CLASS)
@@ -22073,29 +22058,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:
{
if (getPowerType() != POWER_RAGE)
setPowerType(POWER_RAGE);
break;
}
default: // 0, for example
{
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass());
if (cEntry && cEntry->DisplayPower < MAX_POWERS && uint32(getPowerType()) != cEntry->DisplayPower)
setPowerType(Powers(cEntry->DisplayPower));
break;
}
}
UpdateDisplayPower();
// update auras at form change, ignore this at mods reapply (.reset stats/etc) when form not change.
if (!reapplyMods)
@@ -24873,21 +24836,17 @@ void Player::ResurrectUsingRequestData()
return;
}
uint32 resurrectHealth = _resurrectionData->Health;
uint32 resurrectMana = _resurrectionData->Mana;
ResurrectPlayer(0.0f, false);
if (GetMaxHealth() > _resurrectionData->Health)
SetHealth(_resurrectionData->Health);
else
SetFullHealth();
if (uint32(GetMaxPower(POWER_MANA)) > _resurrectionData->Mana)
SetPower(POWER_MANA, _resurrectionData->Mana);
else
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
SetHealth(resurrectHealth);
SetPower(POWER_MANA, resurrectMana);
SetPower(POWER_RAGE, 0);
SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
SetPower(POWER_FOCUS, GetMaxPower(POWER_FOCUS));
SetFullPower(POWER_ENERGY);
SetFullPower(POWER_FOCUS);
SetPower(POWER_ECLIPSE, 0);
if (uint32 aura = _resurrectionData->Aura)
@@ -27100,7 +27059,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.
@@ -27838,7 +27797,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
pet->SetCreatorGUID(GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, GetFaction());
pet->setPowerType(POWER_MANA);
pet->SetUInt64Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
pet->InitStatsForLevel(getLevel());
+1
View File
@@ -1798,6 +1798,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
uint32 GetPowerIndex(Powers power) const override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void ApplySpellPowerBonus(int32 amount, bool apply);
void UpdateSpellDamageAndHealingBonus();
+34 -4
View File
@@ -306,8 +306,17 @@ void Player::UpdateMaxHealth()
SetMaxHealth((uint32)value);
}
uint32 Player::GetPowerIndex(Powers power) const
{
return sDBCManager.GetPowerIndexByClass(power, getClass());
}
void Player::UpdateMaxPower(Powers power)
{
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
return;
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
float bonusPower = (power == POWER_MANA && GetCreatePowers(power) > 0) ? GetManaBonusFromIntellect() : 0;
@@ -317,7 +326,7 @@ void Player::UpdateMaxPower(Powers power)
value += GetModifierValue(unitMod, TOTAL_VALUE) + bonusPower;
value *= GetModifierValue(unitMod, TOTAL_PCT);
SetMaxPower(power, uint32(value));
SetMaxPower(power, (int32)std::lroundf(value));
}
void Player::UpdateAttackPowerAndDamage(bool ranged)
@@ -880,12 +889,28 @@ void Creature::UpdateMaxHealth()
SetMaxHealth(uint32(value));
}
uint32 Creature::GetPowerIndex(Powers power) const
{
if (power == GetPowerType())
return 0;
if (power == POWER_ALTERNATE_POWER)
return 1;
return MAX_POWERS;
}
void Creature::UpdateMaxPower(Powers power)
{
if (GetPowerIndex(power) == MAX_POWERS)
return;
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
float value = GetTotalAuraModValue(unitMod);
SetMaxPower(power, uint32(value));
float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
value *= GetModifierValue(unitMod, BASE_PCT);
value += GetModifierValue(unitMod, TOTAL_VALUE);
value *= GetModifierValue(unitMod, TOTAL_PCT);
SetMaxPower(power, uint32(std::lroundf(value)));
}
void Creature::UpdateAttackPowerAndDamage(bool ranged)
@@ -1018,6 +1043,8 @@ bool Guardian::UpdateStats(Stats stat)
bool Guardian::UpdateAllStats()
{
UpdateMaxHealth();
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
UpdateStats(Stats(i));
@@ -1069,6 +1096,9 @@ void Guardian::UpdateMaxHealth()
void Guardian::UpdateMaxPower(Powers power)
{
if (GetPowerIndex(power) == MAX_POWERS)
return;
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f;
@@ -1079,7 +1109,7 @@ void Guardian::UpdateMaxPower(Powers power)
value += GetModifierValue(unitMod, TOTAL_VALUE) + addValue * multiplicator;
value *= GetModifierValue(unitMod, TOTAL_PCT);
SetMaxPower(power, uint32(value));
SetMaxPower(power, int32(value));
}
void Guardian::UpdateAttackPowerAndDamage(bool ranged)
+64 -44
View File
@@ -862,7 +862,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
}
// Rage from Damage made (only from direct weapon damage)
if (cleanDamage && damagetype == DIRECT_DAMAGE && this != victim && getPowerType() == POWER_RAGE)
if (cleanDamage && damagetype == DIRECT_DAMAGE && this != victim && GetPowerType() == POWER_RAGE)
{
uint32 rage = uint32(GetAttackTime(cleanDamage->attackType) / 1000 * 6.5f);
@@ -887,7 +887,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
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, false);
return 0;
@@ -985,7 +985,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
}
// Rage from damage received
if (this != victim && victim->getPowerType() == POWER_RAGE)
if (this != victim && victim->GetPowerType() == POWER_RAGE)
{
uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
victim->RewardRage(rage_damage, false);
@@ -5385,9 +5385,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);
@@ -5407,30 +5407,74 @@ 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:
displayPower = POWER_RAGE;
break;
case FORM_TRAVEL:
case FORM_GHOSTWOLF:
displayPower = POWER_MANA;
break;
default:
{
if (GetTypeId() == TYPEID_PLAYER)
{
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass());
if (cEntry && cEntry->DisplayPower < MAX_POWERS)
displayPower = Powers(cEntry->DisplayPower);
}
else if (GetTypeId() == TYPEID_UNIT)
{
if (Vehicle* vehicle = GetVehicleKit())
{
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->PowerDisplayID[0])) // To-do: 4.x has 3 power display id fields.
displayPower = Powers(powerDisplay->ActualType);
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
{
FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(GetFaction());
@@ -6117,14 +6161,10 @@ void Unit::SetMinion(Minion* minion, bool apply)
// PvP, FFAPvP
minion->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG));
// Ghoul pets have energy instead of mana (is anywhere better place for this code?)
if (minion->IsPetGhoul())
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
@@ -9171,7 +9211,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
@@ -10192,26 +10232,6 @@ void Unit::SetMaxPower(Powers power, int32 val)
SetPower(power, val);
}
uint32 Unit::GetPowerIndex(uint32 powerType) const
{
/// This is here because hunter pets are of the warrior class.
/// With the current implementation, the core only gives them
/// POWER_RAGE, so we enforce the class to hunter so that they
/// effectively get focus power.
/// Also, Death Knight ghouls are of Mage class.
/// this is necessary so they get energy
uint32 classId = getClass();
if (Pet const* pet = ToPet())
{
if (pet->IsHunterPet())
classId = CLASS_HUNTER;
else if (pet->IsPetGhoul())
classId = CLASS_ROGUE;
}
return sDBCManager.GetPowerIndexByClass(powerType, classId);
}
int32 Unit::GetCreatePowers(Powers power) const
{
switch (power)
+5 -3
View File
@@ -1102,8 +1102,9 @@ 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();
int32 GetPower(Powers power) const;
int32 GetMinPower(Powers power) const { return power == POWER_ECLIPSE ? -100 : 0; }
int32 GetMaxPower(Powers power) const;
@@ -1111,6 +1112,7 @@ class TC_GAME_API Unit : public WorldObject
void SetPower(Powers power, int32 val);
void SetMaxPower(Powers power, int32 val);
void SetPowerBarID(uint32 id) { _powerBarId = id; }
inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); }
// returns the change in power
int32 ModifyPower(Powers power, int32 val);
@@ -1575,7 +1577,6 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
uint32 GetPowerIndex(uint32 powerType) const;
int32 GetCreatePowers(Powers power) const;
float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); }
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); }
@@ -1648,6 +1649,7 @@ class TC_GAME_API Unit : public WorldObject
virtual void UpdateArmor() = 0;
virtual void UpdateMaxHealth() = 0;
virtual void UpdateMaxPower(Powers power) = 0;
virtual uint32 GetPowerIndex(Powers power) const = 0;
virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
virtual void UpdateDamagePhysical(WeaponAttackType attType);
float GetTotalAttackPowerValue(WeaponAttackType attType) const;
+1 -51
View File
@@ -76,57 +76,7 @@ Vehicle::~Vehicle()
void Vehicle::Install()
{
if (_me->GetTypeId() == TYPEID_UNIT)
{
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->PowerDisplayID[0]))
_me->setPowerType(Powers(powerDisplay->ActualType));
else if (_me->getClass() == CLASS_ROGUE)
_me->setPowerType(POWER_ENERGY);
}
if (_me->IsCreature())
{
switch (_vehicleInfo->PowerDisplayID[0])
{
case POWER_STEAM:
case POWER_HEAT:
case POWER_BLOOD:
case POWER_OOZE:
case POWER_WRATH:
case POWER_ARCANE_ENERGY:
case POWER_LIFE_ENERGY:
case POWER_SUN_ENERGY:
case POWER_SWING_VELOCITY:
case POWER_SHADOWFLAME_ENERGY:
case POWER_ELECTRICAL_ENERGY:
case POWER_ARCANE_ENERGY_2:
case POWER_FUEL:
case POWER_SUN_POWER:
case POWER_TWILIGHT_ENERGY:
_me->SetMaxPower(POWER_ENERGY, 100);
_me->SetPower(POWER_ENERGY, 100);
break;
case POWER_BLUE_POWER:
case POWER_PURPLE_POWER:
case POWER_GREEN_POWER:
case POWER_ORANGE_POWER:
_me->SetMaxPower(POWER_ENERGY, 100);
_me->SetPower(POWER_ENERGY, 0);
break;
case POWER_PYRITE:
_me->SetMaxPower(POWER_ENERGY, 50);
_me->SetPower(POWER_ENERGY, 50);
break;
case POWER_WIND_POWER_1:
case POWER_WIND_POWER_2:
case POWER_WIND_POWER_3:
_me->SetMaxPower(POWER_MANA, 90);
_me->SetPower(POWER_MANA, 0);
break;
default:
break;
}
}
_me->UpdateDisplayPower();
_status = STATUS_INSTALLED;
if (GetBase()->GetTypeId() == TYPEID_UNIT)
+8 -8
View File
@@ -1030,7 +1030,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
*data << int32(player->GetMaxHealth());
Powers powerType = player->getPowerType();
Powers powerType = player->GetPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
*data << uint8(powerType);
@@ -1135,7 +1135,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);
}
@@ -1143,7 +1143,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER)
{
if (pet)
*data << int16(pet->GetPower(pet->getPowerType()));
*data << int16(pet->GetPower(pet->GetPowerType()));
else
*data << int16(0);
}
@@ -1151,7 +1151,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER)
{
if (pet)
*data << int16(pet->GetMaxPower(pet->getPowerType()));
*data << int16(pet->GetMaxPower(pet->GetPowerType()));
else
*data << int16(0);
}
@@ -1232,7 +1232,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
@@ -1336,13 +1336,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()));
// GROUP_UPDATE_FLAG_PET_AURAS
uint64 petAuraMask = 0;
@@ -1849,8 +1849,8 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
if (PowerType != POWER_MANA)
{
// reset power to default values only at power change
if (target->getPowerType() != PowerType)
target->setPowerType(PowerType);
if (target->GetPowerType() != PowerType)
target->SetPowerType(PowerType);
if (form == FORM_CAT)
target->SetPower(POWER_ENERGY, 0);
@@ -1881,7 +1881,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->RemoveMovementImpairingAuras();
}
@@ -1945,6 +1944,8 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
target->ToPlayer()->InitDataForForm();
target->ToPlayer()->UpdateArmorSpecialization();
}
else
target->UpdateDisplayPower();
if (target->getClass() == CLASS_DRUID)
{
@@ -5938,7 +5939,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()))
@@ -6002,7 +6003,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());
@@ -6037,7 +6038,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))
@@ -6072,7 +6073,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()))
+3 -3
View File
@@ -5807,7 +5807,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;
}
@@ -6191,9 +6191,9 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem)
break;
if (m_targets.GetUnitTarget() && m_targets.GetUnitTarget()->getPowerType() != POWER_MANA)
if (m_targets.GetUnitTarget() && m_targets.GetUnitTarget()->GetPowerType() != POWER_MANA)
return SPELL_FAILED_BAD_TARGETS;
else if (!m_targets.GetUnitTarget() && m_caster->getPowerType() != POWER_MANA)
else if (!m_targets.GetUnitTarget() && m_caster->GetPowerType() != POWER_MANA)
return SPELL_FAILED_BAD_TARGETS;
break;
+6 -6
View File
@@ -935,7 +935,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
@@ -1011,7 +1011,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)
@@ -1433,7 +1433,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;
@@ -1497,7 +1497,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);
@@ -2514,8 +2514,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())
@@ -32,6 +32,7 @@
enum Spells
{
// Omnotron
SPELL_COUNCIL_ENERGY_DRAIN = 78725,
SPELL_CONTROLLER_RECHARGE = 78696,
SPELL_RECHARGING_ELECTRON = 78697,
SPELL_RECHARGING_MAGMATRON = 78698,
@@ -217,7 +218,6 @@ enum FailedAchievementCriteriaMask
FAILED_CRITERIA_FLAMETHROWER = 0x8
};
struct GolemInfo
{
uint8 ActivateTextId;
@@ -193,7 +193,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);
}
@@ -124,7 +124,7 @@ class boss_foe_reaper_5000 : public CreatureScript
{
boss_foe_reaper_5000AI(Creature* creature) : BossAI(creature, DATA_FOE_REAPER_5000)
{
me->setPowerType(POWER_ENERGY);
me->SetPowerType(POWER_ENERGY);
me->SetMaxPower(POWER_ENERGY, 100);
Initialize();
}
@@ -269,7 +269,7 @@ class instance_deadmines : public InstanceMapScript
_ripsnarlNightareGuidSet.insert(creature->GetGUID());
break;
case NPC_DEFIAS_SHADOWGUARD:
creature->setPowerType(POWER_ENERGY);
creature->SetPowerType(POWER_ENERGY);
creature->SetMaxPower(POWER_ENERGY, 100);
creature->SetPower(POWER_ENERGY, 100);
break;
@@ -422,7 +422,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;
@@ -175,7 +175,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;
}
};
@@ -150,7 +150,7 @@ class boss_moam : public CreatureScript
{
const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList();
for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->getPowerType() == POWER_MANA)
if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->GetPowerType() == POWER_MANA)
targetList.push_back((*itr)->getTarget());
}
@@ -628,7 +628,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);
}
@@ -697,7 +697,7 @@ struct boss_faction_championsAI : public BossAI
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
Unit* target = ObjectAccessor::GetUnit(*me, (*iter)->getUnitGuid());
if (target && target->getPowerType() == POWER_MANA)
if (target && target->GetPowerType() == POWER_MANA)
return target;
}
return nullptr;
@@ -1849,7 +1849,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);
}
@@ -536,7 +536,7 @@ class MistressKissTargetSelector
bool operator()(WorldObject* unit) const
{
if (unit->GetTypeId() == TYPEID_PLAYER)
if (unit->ToPlayer()->getPowerType() == POWER_MANA)
if (unit->ToPlayer()->GetPowerType() == POWER_MANA)
return false;
return true;
@@ -271,7 +271,7 @@ class spell_bronjahm_magic_bane : public SpellScriptLoader
void RecalculateDamage()
{
if (GetHitUnit()->getPowerType() != POWER_MANA)
if (GetHitUnit()->GetPowerType() != POWER_MANA)
return;
int32 const maxDamage = GetCaster()->GetMap()->IsHeroic() ? 15000 : 10000;
@@ -1078,7 +1078,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);
}
@@ -1152,7 +1152,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;
}
};
@@ -168,7 +168,7 @@ struct ManaVoidSelector
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;
@@ -200,7 +200,7 @@ struct ManaUserTargetSelector
{
bool operator()(Unit const* target) const
{
return target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() == POWER_MANA;
return target->GetTypeId() == TYPEID_PLAYER && target->GetPowerType() == POWER_MANA;
}
};
@@ -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);
@@ -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;
@@ -87,7 +87,7 @@ class npcs_ashyen_and_keleth : public CreatureScript
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);
+3 -3
View File
@@ -2783,7 +2783,7 @@ class spell_gen_pet_summoned : public SpellScriptLoader
newPet->setDeathState(ALIVE);
newPet->SetFullHealth();
newPet->SetPower(newPet->getPowerType(), newPet->GetMaxPower(newPet->getPowerType()));
newPet->SetPower(newPet->GetPowerType(), newPet->GetMaxPower(newPet->GetPowerType()));
switch (newPet->GetEntry())
{
@@ -2904,7 +2904,7 @@ public:
bool operator()(WorldObject* obj) const
{
if (Unit* target = obj->ToUnit())
return target->getPowerType() != POWER_MANA;
return target->GetPowerType() != POWER_MANA;
return true;
}
@@ -2960,7 +2960,7 @@ class spell_gen_replenishment : public SpellScriptLoader
bool Load() override
{
return GetUnitOwner()->getPowerType() == POWER_MANA;
return GetUnitOwner()->GetPowerType() == POWER_MANA;
}
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
+3 -3
View File
@@ -1203,7 +1203,7 @@ class spell_item_heartpierce : public SpellScriptLoader
Unit* caster = eventInfo.GetActor();
uint32 spellId;
switch (caster->getPowerType())
switch (caster->GetPowerType())
{
case POWER_MANA:
spellId = Mana;
@@ -4253,7 +4253,7 @@ public:
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);
@@ -4328,7 +4328,7 @@ public:
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);
+1 -1
View File
@@ -128,7 +128,7 @@ class PowerCheck
bool operator()(WorldObject* obj) const
{
if (Unit* target = obj->ToUnit())
return target->getPowerType() != _power;
return target->GetPowerType() != _power;
return true;
}
+6 -18
View File
@@ -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();
}
}