From b761e2c3f2e076b678dc01f1f5f212eb071c7570 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Tue, 25 Sep 2018 01:27:37 +0200 Subject: [PATCH] Core/Pets: Pet scalings updated to Cataclysm --- .../custom/custom_2018_09_25_00_world.sql | 28 + .../game/Entities/Creature/TemporarySummon.h | 36 +- src/server/game/Entities/Pet/Pet.cpp | 236 +- src/server/game/Entities/Pet/Pet.h | 9 +- src/server/game/Entities/Player/Player.cpp | 7 +- src/server/game/Entities/Unit/StatSystem.cpp | 257 +-- src/server/game/Entities/Unit/Unit.cpp | 68 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 29 +- src/server/game/Spells/SpellEffects.cpp | 48 +- src/server/scripts/Spells/spell_pet.cpp | 2056 ++++++----------- 10 files changed, 1055 insertions(+), 1719 deletions(-) create mode 100644 sql/updates/world/custom/custom_2018_09_25_00_world.sql diff --git a/sql/updates/world/custom/custom_2018_09_25_00_world.sql b/sql/updates/world/custom/custom_2018_09_25_00_world.sql new file mode 100644 index 0000000000..f6a58681e7 --- /dev/null +++ b/sql/updates/world/custom/custom_2018_09_25_00_world.sql @@ -0,0 +1,28 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName` IN +('spell_warl_pet_scaling_06', +'spell_dk_pet_scaling_05', +'spell_dk_rune_weapon_scaling_02', +'spell_mage_water_elemental_scaling_01', +'spell_mage_water_elemental_scaling_02'); + +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(89953, 'spell_warl_pet_scaling_06'), +(110474, 'spell_dk_pet_scaling_05'), +(51906, 'spell_dk_rune_weapon_scaling_02'), +(35657, 'spell_mage_water_elemental_scaling_01'), +(35658, 'spell_mage_water_elemental_scaling_02'); + +DELETE FROM `spell_bonus_data` WHERE `entry` IN (3110, 3716, 54049, 7814, 6360, 30213, 89751, 89753, 31707, 51963, 16827, 17253, 49966, 95714, 95725 ); +INSERT INTO `spell_bonus_data` (`entry`, `direct_bonus`, `dot_bonus`, `ap_bonus`, `ap_dot_bonus`, `comments`) VALUES +(3110, 0.657, 0, 0, 0, 'Warlock - Firebolt (Imp)'), +(3716, 0.512, 0, 0, 0, 'Warlock - Torment (Voidwalker)'), +(54049, 1.228, 0, 0, 0, 'Warlock - Shadow Bite (Felhunter)'), +(7814, 0.612, 0, 0, 0, 'Warlock - Lash of Pain (Succubus)'), +(6360, 0.85, 0, 0, 0, 'Warlock - Whiplash (Succubus)'), +(31707, 0.833, 0, 0, 0, 'Mage - Waterbolt (Water Elemental)'), +(51963, 0.453, 0, 0, 0, 'Death Knight - Gargoyle Strike (Gargoyle)'), +(16827, 0, 0, 0.20, 0, 'Hunter - Claw (Pet)'), +(17253, 0, 0, 0.20, 0, 'Hunter - Bite (Pet)'), +(49966, 0, 0, 0.20, 0, 'Hunter - Smack (Pet)'), +(95714, 0, 0, 0.288, 0, 'Hunter - Burrow Attack (Pet)'), +(95725, 0, 0, 0.288, 0, 'Hunter - Froststorm Breath (Pet)'); diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index 0dfa8635d1..8803981636 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -26,28 +26,36 @@ struct SummonPropertiesEntry; enum PetEntries { // Warlock Pet/Minions - ENTRY_IMP = 416, - ENTRY_VOIDWALKER = 1860, - ENTRY_SUCCUBUS = 1863, - ENTRY_FELHUNTER = 417, - ENTRY_FELGUARD = 17252, + ENTRY_IMP = 416, + ENTRY_VOIDWALKER = 1860, + ENTRY_SUCCUBUS = 1863, + ENTRY_FELHUNTER = 417, + ENTRY_FELGUARD = 17252, + ENTRY_INFERNAL = 89, + ENTRY_EBON_IMP = 50675, // Mage Pet - ENTRY_WATER_ELEMENTAL = 510, + ENTRY_WATER_ELEMENTAL = 510, // Druid Minion - ENTRY_TREANT = 1964, + ENTRY_TREANT = 1964, // Shaman Minions - ENTRY_FIRE_ELEMENTAL = 15438, - ENTRY_SPIRIT_WOLF = 29264, + ENTRY_EARTH_ELEMENTAL = 15352, + ENTRY_FIRE_ELEMENTAL = 15438, + ENTRY_SPIRIT_WOLF = 29264, // Death Knight Pet/Minions - ENTRY_GHOUL = 26125, - ENTRY_BLOODWORM = 28017, - ENTRY_RUNIC_WEAPON = 27893, - ENTRY_GARGOYLE = 27829, - ENTRY_SHADOWFIEND = 19668 + ENTRY_GHOUL = 26125, + ENTRY_BLOODWORM = 28017, + ENTRY_RUNIC_WEAPON = 27893, + ENTRY_GARGOYLE = 27829, + ENTRY_SHADOWFIEND = 19668, + ENTRY_ARMY_OF_THE_DEAD_GHOUL = 24207, + + // Hunter Trap Adds + ENTRY_VENOMOUS_SNAKE = 19833, + ENTRY_VIPER = 19921 }; class TC_GAME_API TempSummon : public Creature diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index a717db56cc..7092f27782 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -201,10 +201,8 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur { case SUMMON_PET: petlevel = owner->getLevel(); - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, uint8(CLASS_MAGE)); SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - // this enables popup window (pet dismiss, cancel) break; case HUNTER_PET: SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_WARRIOR); @@ -212,9 +210,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur 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); - // this enables popup window (pet abandon, cancel) break; default: if (!IsPetGhoul()) @@ -278,7 +274,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur } owner->SetMinion(this, true); - map->AddToMap(this->ToCreature()); + map->AddToMap(ToCreature()); InitTalentForLevel(); // set original talents points before spell loading @@ -299,9 +295,17 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur RemoveArenaAuras(); CastPetAuras(current); + CastPetScalingAuras(); } CleanupActionBar(); // remove unknown spells from action bar after load + UpdateAllStats(); + SetFullHealth(); // Set full health and mana after pet scaling auras has been applied + + if (IsHunterPet()) + CastSpell(this, 99289, true); // Energize + else + SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); TC_LOG_DEBUG("entities.pet", "New Pet has guid %u", GetGUID().GetCounter()); @@ -787,7 +791,6 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map) return true; } -/// @todo Move stat mods code to pet passive auras bool Guardian::InitStatsForLevel(uint8 petlevel) { CreatureTemplate const* cinfo = GetCreatureTemplate(); @@ -823,8 +826,6 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool)); - SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(petlevel*50)); - SetAttackTime(BASE_ATTACK, BASE_ATTACK_TIME); SetAttackTime(OFF_ATTACK, BASE_ATTACK_TIME); SetAttackTime(RANGED_ATTACK, BASE_ATTACK_TIME); @@ -848,62 +849,22 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) } // Resistance - // Hunters pet should not inherit resistances from creature_template, they have separate auras for that + // Hunters pets should not inherit resistances from creature_template, they have separate auras for that if (!IsHunterPet()) for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i])); - //health, mana, armor and resistance - 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); - - if (pInfo->armor > 0) - SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor)); - - for (uint8 stat = 0; stat < MAX_STATS; ++stat) - SetCreateStat(Stats(stat), float(pInfo->stats[stat])); - } - else // not exist in DB, use some default fake data - { - // remove elite bonuses included in DB values - CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class); - SetCreateHealth(stats->BaseHealth[cinfo->expansion]); - SetCreateMana(stats->BaseMana); - - SetCreateStat(STAT_STRENGTH, 22); - SetCreateStat(STAT_AGILITY, 22); - SetCreateStat(STAT_STAMINA, 25); - SetCreateStat(STAT_INTELLECT, 28); - SetCreateStat(STAT_SPIRIT, 27); - } - SetBonusDamage(0); switch (petType) { case SUMMON_PET: { - // the damage bonus used for pets is either fire or shadow damage, whatever is higher - int32 fire = GetOwner()->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE); - int32 shadow = GetOwner()->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW); - int32 val = (fire > shadow) ? fire : shadow; - if (val < 0) - val = 0; - - SetBonusDamage(val * 0.15f); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); - - //SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, float(cinfo->attackpower)); - break; } case HUNTER_PET: { - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(petlevel)*PET_XP_FACTOR)); + SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(petlevel) * PET_XP_FACTOR)); //these formula may not be correct; however, it is designed to be close to what it should be //this makes dps 0.5 of pets level SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); @@ -916,72 +877,60 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) { switch (GetEntry()) { - case 510: // mage Water Elemental + case ENTRY_TREANT: { - SetBonusDamage(int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.33f)); - break; - } - case 1964: //force of nature - { - if (!pInfo) - SetCreateHealth(30 + 30*petlevel); float bonusDmg = GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.15f; SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2) + bonusDmg)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2) + bonusDmg)); + SetCreateHealth(m_owner->CountPctFromMaxHealth(10)); break; } - case 15352: //earth elemental 36213 + case ENTRY_EARTH_ELEMENTAL: { - if (!pInfo) - SetCreateHealth(100 + 120*petlevel); + SetCreateHealth(100 + 120 * petlevel); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); break; } - case 15438: //fire elemental + case ENTRY_FIRE_ELEMENTAL: { - if (!pInfo) - { - SetCreateHealth(40*petlevel); - SetCreateMana(28 + 10*petlevel); - } + SetCreateHealth(m_owner->CountPctFromMaxHealth(75)); + SetCreateMana(28 + 10 * petlevel); SetBonusDamage(int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) * 0.5f)); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); break; } - case 19668: // Shadowfiend + case ENTRY_SHADOWFIEND: { - if (!pInfo) - { - SetCreateMana(28 + 10*petlevel); - SetCreateHealth(28 + 30*petlevel); - } - int32 bonus_dmg = int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW)* 0.3f); + SetCreateMana(28 + 10 * petlevel); + SetCreateHealth(28 + 30 * petlevel); + int32 bonus_dmg = int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW)* 0.375f); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel) + bonus_dmg)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel) + bonus_dmg)); break; } - case 19833: //Snake Trap - Venomous Snake + case ENTRY_VENOMOUS_SNAKE: { SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel / 2) - 25)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel / 2) - 18)); break; } - case 19921: //Snake Trap - Viper + case ENTRY_VIPER: { SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel / 2 - 10)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel / 2)); break; } - case 29264: // Feral Spirit + case ENTRY_SPIRIT_WOLF: { - if (!pInfo) - SetCreateHealth(30 * petlevel); - - int32 ownerAP = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.30f; + SetCreateHealth(30 * petlevel); + float dmg_multiplier = 0.50f; + if (m_owner->GetAuraEffect(63271, 0)) // Glyph of Feral Spirit + dmg_multiplier = 0.80f; + SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier)); // wolf attack speed is 1.5s SetAttackTime(BASE_ATTACK, cinfo->BaseAttackTime); @@ -989,59 +938,89 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel))); - // Feral Spirits should take 30% of AP from owner - if (m_owner) - SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, ownerAP); + // 14AP == 1dps, wolf's strike speed == 1.5s so dmg = AP / 14 * 1.5 + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier / 14); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier / 14); SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetOwner()->GetArmor()) * 0.35f); // Bonus Armor (35% of player armor) SetModifierValue(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(GetOwner()->GetStat(STAT_STAMINA)) * 0.3f); // Bonus Stamina (30% of player stamina) - if (!HasAura(58877))//prevent apply twice for the 2 wolves - AddAura(58877, this);//Spirit Hunt, passive, Spirit Wolves' attacks heal them and their master for 150% of damage done. + if (!HasAura(58877)) // Spirit Hunt + AddAura(58877, this); + if (!HasAura(61783)) // Feral Pet Scaling + AddAura(61783, this); break; } - case 27829: // Ebon Gargoyle + case ENTRY_GARGOYLE: { - if (!pInfo) + SetCreateHealth(m_owner->CountPctFromMaxHealth(70)); + if (Player* owner = m_owner->ToPlayer()) { - SetCreateMana(28 + 10*petlevel); - SetCreateHealth(28 + 30*petlevel); + float bonus = owner->GetRatingBonusValue(CR_HASTE_MELEE); + bonus += owner->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_HASTE_3) + + owner->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_RANGED_HASTE); + ApplyCastTimePercentMod(bonus, true); } + SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f)); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); break; } - case 28017: // Bloodworms + case ENTRY_BLOODWORM: { - SetCreateHealth(4 * petlevel); - SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f)); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - 30 - (petlevel / 4))); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel - 30 + (petlevel / 4))); + SetCreateHealth(m_owner->CountPctFromMaxHealth(18)); + SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f)); + float minDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + float maxDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); + if (!HasAura(50453)) // Blood Siphon + CastSpell(this, 50453, true); } - case 50675: // Ebon Imp - case 89: // Summon Infernal - case 11859: // Summon Doomguard + case ENTRY_INFERNAL: { - if (!pInfo) - { - SetCreateMana(28 + 10 * petlevel); - SetCreateHealth(28 + 30 * petlevel); - } + if (m_owner->GetTypeId() == TYPEID_PLAYER) // Infernal get 100% of owners spell, Immolation has his own coef. + SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SPELL))); - int32 bonus_dmg = (int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_MAGIC)* 0.071429f)); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel) + bonus_dmg)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel) + bonus_dmg)); + float mod = 1; + if (petlevel < 60) + mod = 5 + (petlevel - 50) / 4; + if (petlevel < 70) + mod = 10 + (petlevel - 70) / 4; + else if (petlevel <= 80) + mod = 15 + (petlevel - 80) / 2; + else + mod = 20 + (petlevel - 85) / 2; + if (mod < 0) + mod = 0; + float minDamage = (petlevel - (petlevel / 4)) * mod; + float maxDamage = (petlevel + (petlevel / 4)) * mod; + float attackPower = ((minDamage + maxDamage) /4) * 7; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); + SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, attackPower); + SetCreateHealth(m_owner->CountPctFromMaxHealth(40)); + break; + } + case ENTRY_EBON_IMP: + { + SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE))); + break; + } + case ENTRY_ARMY_OF_THE_DEAD_GHOUL: + { + SetCreateHealth(m_owner->CountPctFromMaxHealth(50)); + SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f)); + float minDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + float maxDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); break; } } break; } } - - UpdateAllStats(); - - SetFullHealth(); - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); return true; } @@ -1399,10 +1378,17 @@ bool Pet::addSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpel } } + // Store pet scaling auras in a own vector to handle the updating more efficient + if (spellInfo->HasAttribute(SPELL_ATTR4_IS_PET_SCALING)) + { + m_petScalingAuras.push_back(spellInfo->Id); + return true; + } + m_spells[spellId] = newspell; // Do not go further if this Attribute exists - if (spellInfo->HasAttribute(SPELL_ATTR4_UNK15)) + if (spellInfo->HasAttribute(SPELL_ATTR4_UNK15) && !IsWarlockMinion()) return true; if (spellInfo->IsPassive() && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState)))) @@ -1561,11 +1547,12 @@ void Pet::InitPetCreateSpells() { m_charmInfo->InitPetActionBar(); m_spells.clear(); + m_petScalingAuras.clear(); LearnPetPassives(); InitLevelupSpellsForLevel(); - CastPetAuras(false); + CastPetScalingAuras(); } bool Pet::resetTalents() @@ -1854,14 +1841,20 @@ void Pet::LearnPetPassives() PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID); if (petStore != sPetFamilySpellsStore.end()) { - // For general hunter pets skill 270 - // Passive 01~10, Passive 00 (20782, not used), Ferocious Inspiration (34457) - // Scale 01~03 (34902~34904, bonus from owner, not used) for (PetFamilySpellsSet::const_iterator petSet = petStore->second.begin(); petSet != petStore->second.end(); ++petSet) addSpell(*petSet, ACT_DECIDE, PETSPELL_NEW, PETSPELL_FAMILY); } } +void Pet::CastPetScalingAuras() +{ + for (uint32 spellId : m_petScalingAuras) + { + if (!HasAura(spellId)) + CastSpell(this, spellId, true); + } +} + void Pet::CastPetAuras(bool current) { Player* owner = GetOwner(); @@ -1961,3 +1954,14 @@ std::string Pet::GenerateActionBarData() const return ss.str(); } + +void Pet::UpdatePetScalingAuras() +{ + for (uint32 spellId : m_petScalingAuras) + { + if (Aura* aura = GetAura(spellId)) + aura->RecalculateAmountOfEffects(); + } + + UpdateAllStats(); +} diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 8396dde595..aff8a5d00d 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -50,6 +50,7 @@ struct PetSpell typedef std::unordered_map PetSpellMap; typedef std::vector AutoSpellList; +typedef std::vector PetScalingAuraList; class Player; class PetAura; @@ -118,6 +119,7 @@ class TC_GAME_API Pet : public Guardian bool HasSpell(uint32 spell) const override; void LearnPetPassives(); + void CastPetScalingAuras(); void CastPetAuras(bool current); void CastPetAura(PetAura const* aura); bool IsPetAura(Aura const* aura); @@ -137,8 +139,9 @@ class TC_GAME_API Pet : public Guardian void CleanupActionBar(); std::string GenerateActionBarData() const; - PetSpellMap m_spells; - AutoSpellList m_autospells; + PetSpellMap m_spells; + AutoSpellList m_autospells; + PetScalingAuraList m_petScalingAuras; void InitPetCreateSpells(); @@ -165,6 +168,8 @@ class TC_GAME_API Pet : public Guardian uint32 GetSlot() { return m_petSlot; } void SetSlot(uint32 newPetSlot) { m_petSlot = newPetSlot; } // use only together with DB update + void UpdatePetScalingAuras(); + protected: PetType m_petType; int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index b3c1714f37..758c129e70 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -27912,8 +27912,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_MAGE); pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); - pet->SetFullHealth(); - pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped in this case break; default: @@ -27933,6 +27931,11 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy default: break; } + + // Update all stats after we have applied pet scaling auras to make sure we have all fields initialized properly + pet->UpdateAllStats(); + pet->SetFullHealth(); + pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); } PhasingHandler::InheritPhaseShift(pet, this); diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index e660146987..d87127a51c 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -103,13 +103,6 @@ bool Player::UpdateStats(Stats stat) SetStat(stat, int32(value)); - if (stat == STAT_STAMINA || stat == STAT_INTELLECT || stat == STAT_STRENGTH) - { - Pet* pet = GetPet(); - if (pet) - pet->UpdateStats(stat); - } - switch (stat) { case STAT_AGILITY: @@ -154,6 +147,7 @@ bool Player::UpdateStats(Stats stat) if (mask & (1 << rating)) ApplyRatingMod(CombatRating(rating), 0, true); } + return true; } @@ -250,10 +244,6 @@ void Player::UpdateResistances(uint32 school) { float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); SetResistance(SpellSchools(school), int32(value)); - - Pet* pet = GetPet(); - if (pet) - pet->UpdateResistances(school); } else UpdateArmor(); @@ -278,11 +268,6 @@ void Player::UpdateArmor() value *= GetModifierValue(unitMod, TOTAL_PCT); SetArmor(int32(value)); - - Pet* pet = GetPet(); - if (pet) - pet->UpdateArmor(); - UpdateAttackPowerAndDamage(); // armor dependent auras update for SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR } @@ -386,15 +371,9 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) SetInt32Value(index_mod_neg, uint32(attPowerMod < 0.f ? -attPowerMod : 0.f)); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MOD_NEG field SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field - Pet* pet = GetPet(); //update pet's AP - Guardian* guardian = GetGuardianPet(); //automatically update weapon damage after attack power modification if (ranged) - { UpdateDamagePhysical(RANGED_ATTACK); - if (pet && pet->IsHunterPet()) // At ranged attack change for hunter pet - pet->UpdateAttackPowerAndDamage(); - } else { UpdateDamagePhysical(BASE_ATTACK); @@ -402,12 +381,6 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) UpdateDamagePhysical(OFF_ATTACK); if (getClass() == CLASS_SHAMAN || getClass() == CLASS_PALADIN) // mental quickness UpdateSpellDamageAndHealingBonus(); - - if (pet && pet->IsPetGhoul()) // At melee attack power change for DK pet - pet->UpdateAttackPowerAndDamage(); - - if (guardian && guardian->IsSpiritWolf()) // At melee attack power change for Shaman feral spirit - guardian->UpdateAttackPowerAndDamage(); } } @@ -985,63 +958,26 @@ bool Guardian::UpdateStats(Stats stat) ApplyStatBuffMod(stat, m_statFromOwner[stat], false); float ownersBonus = 0.0f; - Unit* owner = GetOwner(); - // Handle Death Knight Glyphs and Talents - float mod = 0.75f; - if (IsPetGhoul() && (stat == STAT_STAMINA || stat == STAT_STRENGTH)) - { - if (stat == STAT_STAMINA) - mod = 0.3f; // Default Owner's Stamina scale - else - mod = 0.7f; // Default Owner's Strength scale - - // Check just if owner has Ravenous Dead since it's effect is not an aura - AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0); - if (aurEff) - { - SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value - AddPct(mod, spellInfo->Effects[EFFECT_1].CalcValue(owner)); // Ravenous Dead edits the original scale - } - // Glyph of the Ghoul - aurEff = owner->GetAuraEffect(58686, 0); - if (aurEff) - mod += CalculatePct(1.0f, aurEff->GetAmount()); // Glyph of the Ghoul adds a flat value to the scale mod - ownersBonus = float(owner->GetStat(stat)) * mod; - value += ownersBonus; - } - else if (stat == STAT_STAMINA) - { - ownersBonus = CalculatePct(owner->GetStat(STAT_STAMINA), 30); - value += ownersBonus; - } - //warlock's and mage's pets gain 30% of owner's intellect - else if (stat == STAT_INTELLECT) - { - if (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE) - { - ownersBonus = CalculatePct(owner->GetStat(stat), 30); - value += ownersBonus; - } - } -/* - else if (stat == STAT_STRENGTH) - { - if (IsPetGhoul()) - value += float(owner->GetStat(stat)) * 0.3f; - } -*/ - SetStat(stat, int32(value)); m_statFromOwner[stat] = ownersBonus; ApplyStatBuffMod(stat, m_statFromOwner[stat], true); switch (stat) { - case STAT_STRENGTH: UpdateAttackPowerAndDamage(); break; - case STAT_AGILITY: UpdateArmor(); break; - case STAT_STAMINA: UpdateMaxHealth(); break; - case STAT_INTELLECT: UpdateMaxPower(POWER_MANA); break; + case STAT_STRENGTH: + UpdateAttackPowerAndDamage(); + break; + case STAT_AGILITY: + UpdateArmor(); + break; + case STAT_STAMINA: + UpdateMaxHealth(); + break; + case STAT_INTELLECT: + UpdateMaxPower(POWER_MANA); + break; case STAT_SPIRIT: + break; default: break; } @@ -1067,11 +1003,6 @@ void Guardian::UpdateResistances(uint32 school) if (school > SPELL_SCHOOL_NORMAL) { float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); - - // hunter and warlock pets gain 40% of owner's resistance - if (IsPet()) - value += float(CalculatePct(m_owner->GetResistance(SpellSchools(school)), 40)); - SetResistance(SpellSchools(school), int32(value)); } else @@ -1084,15 +1015,9 @@ void Guardian::UpdateArmor() float bonus_armor = 0.0f; UnitMods unitMod = UNIT_MOD_ARMOR; - // hunter pets gain 35% of owner's armor value, warlock pets gain 100% of owner's armor - if (IsHunterPet()) - bonus_armor = float(CalculatePct(m_owner->GetArmor(), 70)); - else if (IsPet()) - bonus_armor = m_owner->GetArmor(); - value = GetModifierValue(unitMod, BASE_VALUE); value *= GetModifierValue(unitMod, BASE_PCT); - value += GetModifierValue(unitMod, TOTAL_VALUE) + bonus_armor; + value += GetModifierValue(unitMod, TOTAL_VALUE); value *= GetModifierValue(unitMod, TOTAL_PCT); SetArmor(int32(value)); @@ -1101,63 +1026,26 @@ void Guardian::UpdateArmor() void Guardian::UpdateMaxHealth() { UnitMods unitMod = UNIT_MOD_HEALTH; - float stamina = GetStat(STAT_STAMINA) - GetCreateStat(STAT_STAMINA); + float stamina = GetStat(STAT_STAMINA); + float multiplicator = 10.0f; + uint32 healthDamage = GetMaxHealth() - GetHealth(); - float multiplicator; switch (GetEntry()) { - case ENTRY_BLOODWORM: - multiplicator = 1.0f; - break; case ENTRY_WATER_ELEMENTAL: - multiplicator = 7.5; + multiplicator = 7.5f; break; default: - multiplicator = 14.0f; break; } - float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); + float value = GetModifierValue(unitMod, BASE_VALUE); value *= GetModifierValue(unitMod, BASE_PCT); value += GetModifierValue(unitMod, TOTAL_VALUE) + stamina * multiplicator; value *= GetModifierValue(unitMod, TOTAL_PCT); - if (Unit* owner = GetOwner()) - { - switch (GetEntry()) - { - case ENTRY_IMP: - value = (7.7 * getLevel() / 80) * GetOwner()->GetStat(STAT_STAMINA) + GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - break; - case ENTRY_VOIDWALKER: - value = (15.0 * getLevel() / 80) * GetOwner()->GetStat(STAT_STAMINA) + GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - break; - case ENTRY_FELHUNTER: - case ENTRY_FELGUARD: - case ENTRY_SUCCUBUS: - value = (9.1 * getLevel() / 80) * GetOwner()->GetStat(STAT_STAMINA) + GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - break; - case ENTRY_WATER_ELEMENTAL: - value = (7.0 * getLevel() / 80) * GetOwner()->GetStat(STAT_STAMINA) + GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - break; - case ENTRY_SPIRIT_WOLF: - case ENTRY_GARGOYLE: - case ENTRY_SHADOWFIEND: - value = (4.2 * getLevel() / 80) * GetOwner()->GetStat(STAT_STAMINA) + GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - break; - case ENTRY_TREANT: - value = (1.9 * getLevel() / 80) * GetOwner()->GetStat(STAT_STAMINA) + GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - break; - default: - break; - } - } - - // Glyph of Voidwalker - if (GetEntry() == ENTRY_VOIDWALKER && GetOwner() && GetOwner()->HasAura(56247)) - value += value * 0.20f; - SetMaxHealth((uint32)value); + SetHealth(GetMaxHealth() - healthDamage); } void Guardian::UpdateMaxPower(Powers power) @@ -1166,29 +1054,24 @@ void Guardian::UpdateMaxPower(Powers power) float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f; float multiplicator = 15.0f; + uint32 usedPower = GetMaxPower(power) - GetPower(power); - float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); + switch (GetEntry()) + { + case ENTRY_WATER_ELEMENTAL: + multiplicator = 5.0f; + break; + default: + break; + } + + float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); value *= GetModifierValue(unitMod, BASE_PCT); value += GetModifierValue(unitMod, TOTAL_VALUE) + addValue * multiplicator; value *= GetModifierValue(unitMod, TOTAL_PCT); - if (Unit* owner = GetOwner()) - { - switch (GetEntry()) - { - case ENTRY_IMP: - case ENTRY_FELHUNTER: - case ENTRY_FELGUARD: - case ENTRY_SUCCUBUS: - case ENTRY_VOIDWALKER: - value = (7.5 * getLevel() / 80) * GetOwner()->GetStat(STAT_INTELLECT) + GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); - break; - default: - break; - } - } - SetMaxPower(power, uint32(value)); + SetPower(power, GetMaxPower(power) - usedPower); } void Guardian::UpdateAttackPowerAndDamage(bool ranged) @@ -1196,79 +1079,29 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged) if (ranged) return; - float val = 0.0f; - float bonusAP = 0.0f; + float ap_per_strength = 2.0f; + float val = GetStat(STAT_STRENGTH); + val *= ap_per_strength; + UnitMods unitMod = UNIT_MOD_ATTACK_POWER; - if (GetEntry() == ENTRY_IMP) // imp's attack power - val = GetStat(STAT_STRENGTH) - 10.0f; - else - val = 2 * GetStat(STAT_STRENGTH) - 20.0f; + SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val); - Unit* owner = GetOwner(); - if (owner && owner->GetTypeId() == TYPEID_PLAYER) - { - if (IsHunterPet()) //hunter pets benefit from owner's attack power - { - float mod = 0.425f; //Hunter contribution modifier - bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * mod; - SetBonusDamage(int32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.0687f)); - } - else if (IsPetGhoul()) //ghouls benefit from deathknight's attack power (may be summon pet or not) - { - bonusAP = owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.12f; - SetBonusDamage(int32(owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.06287f)); - } - else if (IsSpiritWolf()) //wolf benefit from shaman's attack power - { - float dmg_multiplier = 0.50f; - if (m_owner->GetAuraEffect(63271, 0)) // Glyph of Feral Spirit - dmg_multiplier = 0.80f; - bonusAP += owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier; - SetBonusDamage(int32(owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier)); - } - //demons benefit from warlocks shadow or fire damage - else if (IsPet()) - { - int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) + owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); - int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) + owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); - int32 maximum = (fire > shadow) ? fire : shadow; - if (maximum < 0) - maximum = 0; - SetBonusDamage(int32(maximum * 0.07f)); - bonusAP += maximum * 0.25f; - } - //water elementals benefit from mage's frost damage - else if (GetEntry() == ENTRY_WATER_ELEMENTAL) - { - int32 frost = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST)) + owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST); - if (frost < 0) - frost = 0; - SetBonusDamage(int32(frost * 0.4f)); - } - else if (GetEntry() == ENTRY_RUNIC_WEAPON) - { - bonusAP = owner->GetTotalAttackPowerValue(BASE_ATTACK); - } - } - - SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val + bonusAP); - - //in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB + // in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT); float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE); float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f; - //UNIT_FIELD_(RANGED)_ATTACK_POWER field - SetInt32Value(UNIT_FIELD_ATTACK_POWER, (int32)base_attPower); - //UNIT_FIELD_(RANGED)_ATTACK_POWER_MOD_POS field + // UNIT_FIELD_(RANGED)_ATTACK_POWER field + SetInt32Value(UNIT_FIELD_ATTACK_POWER, int32(base_attPower)); + // UNIT_FIELD_(RANGED)_ATTACK_POWER_MOD_POS field SetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_POS, int32(attPowerMod > 0.f ? attPowerMod : 0.f)); - //UNIT_FIELD_(RANGED)_ATTACK_POWER_MOD_NEG field + // UNIT_FIELD_(RANGED)_ATTACK_POWER_MOD_NEG field SetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_NEG, int32(attPowerMod < 0.f ? -attPowerMod : 0.f)); - //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field + // UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attPowerMultiplier); - //automatically update weapon damage after attack power modification + // automatically update weapon damage after attack power modification UpdateDamagePhysical(BASE_ATTACK); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index aa9b65a907..b299bd5433 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6538,7 +6538,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (spellProto->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) return pdamage; - // For totems get damage bonus from owner + // For totems and pets use owner's bonus data if (GetTypeId() == TYPEID_UNIT && IsTotem()) if (Unit* owner = GetOwner()) return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, effIndex); @@ -6591,9 +6591,9 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin case 49635: case 49636: case 49638: - if (SpellInfo const* proto = sSpellMgr->GetSpellInfo(itr->first)) - AddPct(ApCoeffMod, proto->Effects[EFFECT_0].CalcValue()); - break; + if (SpellInfo const* proto = sSpellMgr->GetSpellInfo(itr->first)) + AddPct(ApCoeffMod, proto->Effects[EFFECT_0].CalcValue()); + break; } } } @@ -6602,10 +6602,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin // Done fixed damage bonus auras int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(spellProto->GetSchoolMask()); - // Pets just add their bonus damage to their spell damage - // note that their spell damage is just gain of their own auras - if (HasUnitTypeMask(UNIT_MASK_GUARDIAN)) - DoneAdvertisedBenefit += static_cast(this)->GetBonusDamage(); // Check for table values float coeff = spellProto->Effects[effIndex].BonusMultiplier; @@ -9776,6 +9772,10 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f break; } + // Do not update pet stats one by one. We will update all stats in one big chunk after updating all scaling auras + if (IsPet()) + return false; + if (!CanModifyStats()) return false; @@ -9785,36 +9785,54 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f case UNIT_MOD_STAT_AGILITY: case UNIT_MOD_STAT_STAMINA: case UNIT_MOD_STAT_INTELLECT: - case UNIT_MOD_STAT_SPIRIT: UpdateStats(GetStatByAuraGroup(unitMod)); break; - - case UNIT_MOD_ARMOR: UpdateArmor(); break; - case UNIT_MOD_HEALTH: UpdateMaxHealth(); break; - + case UNIT_MOD_STAT_SPIRIT: + UpdateStats(GetStatByAuraGroup(unitMod)); + break; + case UNIT_MOD_ARMOR: + UpdateArmor(); + break; + case UNIT_MOD_HEALTH: + UpdateMaxHealth(); + break; case UNIT_MOD_MANA: case UNIT_MOD_RAGE: case UNIT_MOD_FOCUS: case UNIT_MOD_ENERGY: case UNIT_MOD_RUNE: - case UNIT_MOD_RUNIC_POWER: UpdateMaxPower(GetPowerTypeByAuraGroup(unitMod)); break; - + case UNIT_MOD_RUNIC_POWER: + UpdateMaxPower(GetPowerTypeByAuraGroup(unitMod)); + break; case UNIT_MOD_RESISTANCE_HOLY: case UNIT_MOD_RESISTANCE_FIRE: case UNIT_MOD_RESISTANCE_NATURE: case UNIT_MOD_RESISTANCE_FROST: case UNIT_MOD_RESISTANCE_SHADOW: - case UNIT_MOD_RESISTANCE_ARCANE: UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); break; - - case UNIT_MOD_ATTACK_POWER: UpdateAttackPowerAndDamage(); break; - case UNIT_MOD_ATTACK_POWER_RANGED: UpdateAttackPowerAndDamage(true); break; - - case UNIT_MOD_DAMAGE_MAINHAND: UpdateDamagePhysical(BASE_ATTACK); break; - case UNIT_MOD_DAMAGE_OFFHAND: UpdateDamagePhysical(OFF_ATTACK); break; - case UNIT_MOD_DAMAGE_RANGED: UpdateDamagePhysical(RANGED_ATTACK); break; - + case UNIT_MOD_RESISTANCE_ARCANE: + UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); + break; + case UNIT_MOD_ATTACK_POWER: + UpdateAttackPowerAndDamage(); + break; + case UNIT_MOD_ATTACK_POWER_RANGED: + UpdateAttackPowerAndDamage(true); + break; + case UNIT_MOD_DAMAGE_MAINHAND: + UpdateDamagePhysical(BASE_ATTACK); + break; + case UNIT_MOD_DAMAGE_OFFHAND: + UpdateDamagePhysical(OFF_ATTACK); + break; + case UNIT_MOD_DAMAGE_RANGED: + UpdateDamagePhysical(RANGED_ATTACK); + break; default: break; } + if (Player* player = ToPlayer()) + if (Pet* pet = player->GetPet()) + pet->UpdatePetScalingAuras(); + return true; } @@ -11528,7 +11546,9 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id) // this enables pet details window (Shift+P) pet->InitPetCreateSpells(); //pet->InitLevelupSpellsForLevel(); + pet->UpdateAllStats(); pet->SetFullHealth(); + pet->CastSpell(pet, 99289, true); // Energize pet->SetReactState(REACT_ASSIST); return true; } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 0d5f134461..f18ebd41c6 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -3309,14 +3309,8 @@ void AuraEffect::HandleAuraModBaseResistancePCT(AuraApplication const* aurApp, u Unit* target = aurApp->GetTarget(); - // only players have base stats - if (target->GetTypeId() != TYPEID_PLAYER) - { - //pets only have base armor - if (target->IsPet() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) - target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(GetAmount()), apply); - } - else + // only players and pets have base stats + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; x++) { @@ -3366,14 +3360,8 @@ void AuraEffect::HandleModBaseResistance(AuraApplication const* aurApp, uint8 mo Unit* target = aurApp->GetTarget(); - // only players have base stats - if (target->GetTypeId() != TYPEID_PLAYER) - { - //only pets have base stats - if (target->IsPet() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) - target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(GetAmount()), apply); - } - else + // only players and pets have base stats + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) { for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) if (GetMiscValue() & (1<GetTypeId() != TYPEID_PLAYER) + // only players and pets have base stats + if (target->GetTypeId() != TYPEID_PLAYER && !target->IsPet()) return; for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) @@ -4192,6 +4180,11 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode, if (Guardian* pet = target->ToPlayer()->GetGuardianPet()) pet->UpdateAttackPowerAndDamage(); } + else if (target->IsPet()) + { + if (Unit* owner = target->GetOwner()) + owner->ApplyModUInt32Value(PLAYER_PET_SPELL_POWER, GetAmount(), apply); + } } void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8 mode, bool apply) const diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 1dff6161bb..07b34872d7 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -431,12 +431,6 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) damage += damage / 6; } } - - // Warlock Pets deal 50% of the coefficient's spell power bonus as bonus damage - if (m_caster->IsPet()) - if (Unit* owner = m_caster->GetCharmerOrOwner()) - damage += CalculatePct(owner->SpellDamageBonusDone(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE, effIndex), 50); - break; } case SPELLFAMILY_PRIEST: @@ -2682,7 +2676,6 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) m_caster->SetMinion(pet, true); pet->InitTalentForLevel(); - if (m_caster->GetTypeId() == TYPEID_PLAYER) { pet->SavePetToDB(PET_SAVE_NEW_PET); @@ -2697,7 +2690,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) return; } } - // "kill" original creature if everything worked + // despawn tame target creatureTarget->DespawnOrUnsummon(); // visual effect for levelup @@ -2717,10 +2710,11 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); } // SUMMON_PET SummonPet's entries are at MiscValue, HunterPetSlot at BasePoints - uint32 petentry = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? m_spellInfo->Effects[effIndex].BasePoints : m_spellInfo->Effects[effIndex].MiscValue; - - PetType petType = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? HUNTER_PET : SUMMON_PET; + uint32 petentry = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? + m_spellInfo->Effects[effIndex].BasePoints : m_spellInfo->Effects[effIndex].MiscValue; + PetType petType = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? + HUNTER_PET : SUMMON_PET; if (!owner) { @@ -2982,6 +2976,23 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) AddPct(totalDamagePercentMod, mercilessCombat->GetAmount()); break; } + case SPELLFAMILY_WARLOCK: + { + // Felstorm and Legion Strike + if (m_spellInfo->Id == 89753) + { + if (m_caster->IsPet()) + if (Unit* owner = m_caster->GetOwner()) + m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.231f; + } + else if (m_spellInfo->Id == 30213) + { + if (m_caster->IsPet()) + if (Unit* owner = m_caster->GetOwner()) + m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.264f; + } + break; + } } bool normalized = false; @@ -3075,6 +3086,21 @@ void Spell::EffectThreat(SpellEffIndex /*effIndex*/) if (!unitTarget->CanHaveThreatList()) return; + switch (m_spellInfo->SpellFamilyName) + { + case SPELLFAMILY_HUNTER: + // Growl should benefit from pet owner's attack power + if (m_spellInfo->SpellFamilyFlags[1] & 0x10000000) + { + if (m_caster->IsHunterPet()) + if (Player* owner = m_caster->ToPet()->GetOwner()) + damage += uint32(owner->GetTotalAttackPowerValue(BASE_ATTACK)); + } + break; + default: + break; + } + unitTarget->AddThreat(m_caster, float(damage)); } diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index 202ab39cbb..1072ae44bd 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_dk_". */ +#include "DBCStores.h" #include "ScriptMgr.h" #include "ObjectMgr.h" #include "Pet.h" @@ -32,13 +33,17 @@ enum HunterPetCalculate { - SPELL_TAMED_PET_PASSIVE_09 = 34667, - SPELL_TAMED_PET_PASSIVE_10 = 34675, - SPELL_HUNTER_PET_SCALING_01 = 34902, - SPELL_HUNTER_PET_SCALING_02 = 34903, - SPELL_HUNTER_PET_SCALING_03 = 34904, - SPELL_HUNTER_PET_SCALING_04 = 61017, - SPELL_HUNTER_PET_SCALING_05 = 89446, + SPELL_TAMED_PET_PASSIVE_09 = 34667, + SPELL_TAMED_PET_PASSIVE_10 = 34675, + SPELL_HUNTER_PET_SCALING_01 = 34902, + SPELL_HUNTER_PET_SCALING_02 = 34903, + SPELL_HUNTER_PET_SCALING_03 = 34904, + SPELL_HUNTER_PET_SCALING_04 = 61017, + SPELL_HUNTER_PET_SCALING_05 = 89446, + + SPELL_HUNTER_PET_CUNNING_MARKER = 87884, + SPELL_HUNTER_PET_FEROCITY_MARKER = 87887, + SPELL_HUNTER_PET_TENACITY_MARKER = 87891, }; enum WarlockPetCalculate @@ -55,14 +60,14 @@ enum WarlockPetCalculate enum DKPetCalculate { - SPELL_DEATH_KNIGHT_RUNE_WEAPON_02 = 51906, - SPELL_DEATH_KNIGHT_PET_SCALING_01 = 54566, - SPELL_DEATH_KNIGHT_PET_SCALING_02 = 51996, - SPELL_DEATH_KNIGHT_PET_SCALING_03 = 61697, - SPELL_DEATH_KNIGHT_PET_SCALING_05 = 110474, - SPELL_NIGHT_OF_THE_DEAD = 55620, - ENTRY_ARMY_OF_THE_DEAD_GHOUL = 24207, - SPELL_DEATH_KNIGHT_GLYPH_OF_GHOUL = 58686, + SPELL_DEATH_KNIGHT_RUNE_WEAPON_02 = 51906, + SPELL_DEATH_KNIGHT_PET_SCALING_01 = 54566, + SPELL_DEATH_KNIGHT_PET_SCALING_02 = 51996, + SPELL_DEATH_KNIGHT_PET_SCALING_03 = 61697, + SPELL_DEATH_KNIGHT_PET_SCALING_05 = 110474, + SPELL_NIGHT_OF_THE_DEAD = 55620, + SPELL_DEATH_KNIGHT_GLYPH_OF_GHOUL = 58686, + DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD = 221, }; enum ShamanPetCalculate @@ -79,644 +84,350 @@ enum MiscPetCalculate SPELL_PET_HEALTH_SCALING = 61679, }; -class spell_warl_pet_scaling_01 : public SpellScriptLoader +class spell_warl_pet_scaling_01 : public AuraScript { -public: - spell_warl_pet_scaling_01() : SpellScriptLoader("spell_warl_pet_scaling_01") { } + PrepareAuraScript(spell_warl_pet_scaling_01); - class spell_warl_pet_scaling_01_AuraScript : public AuraScript + void CalculateStaminaAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_scaling_01_AuraScript); + canBeRecalculated = true; - public: - spell_warl_pet_scaling_01_AuraScript() + if (Pet* pet = GetUnitOwner()->ToPet()) { - _tempBonus = 0; - } - - private: - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = CalculatePct(owner->GetMaxHealth(), 75); - amount += ownerBonus; - } - } - - void ApplyEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/) - { - if (Unit* pet = GetUnitOwner()) - if (_tempBonus) + if (Player* owner = pet->GetOwner()) + { + float stamina = owner->GetStat(STAT_STAMINA); + float healthBonus = 0.0f; + switch (pet->GetEntry()) { - PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel()); - if (pInfo) - return; - - uint32 healthMod = 0; - uint32 baseHealth = pInfo->health; - switch (pet->GetEntry()) - { - case ENTRY_IMP: - healthMod = uint32(_tempBonus * 8.4f); - break; - case ENTRY_FELGUARD: - case ENTRY_VOIDWALKER: - healthMod = _tempBonus * 11; - break; - case ENTRY_SUCCUBUS: - healthMod = uint32(_tempBonus * 9.1f); - break; - case ENTRY_FELHUNTER: - healthMod = uint32(_tempBonus * 9.5f); - break; - default: - healthMod = 0; - break; - } - if (healthMod) - pet->ToPet()->SetCreateHealth(baseHealth + healthMod); + case ENTRY_IMP: + healthBonus = uint32(stamina * 8.4f); + break; + case ENTRY_FELGUARD: + case ENTRY_VOIDWALKER: + healthBonus = uint32(stamina * 11.0f); + break; + case ENTRY_SUCCUBUS: + healthBonus = uint32(stamina * 9.1f); + break; + case ENTRY_FELHUNTER: + healthBonus = uint32(stamina * 9.5f); + break; + default: + break; } + + float ownerHealth = owner->CountPctFromMaxHealth(75); + amount = int32(ownerHealth + healthBonus); + } } + } - void RemoveEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/) - { - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - { - PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel()); - if (!pInfo) - return; - - pet->ToPet()->SetCreateHealth(pInfo->health); - } - } - - void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - - if (Unit* owner = pet->ToPet()->GetOwner()) - { - int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); - int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); - int32 maximum = (fire > shadow) ? fire : shadow; - if (maximum < 0) - maximum = 0; - float bonusAP = maximum * 0.57f; - - amount += bonusAP; - - // Glyph of felguard - if (pet->GetEntry() == ENTRY_FELGUARD) - { - if (AuraEffect* /* aurEff */ect = owner->GetAuraEffect(56246, EFFECT_0)) - { - float base_attPower = pet->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE) * pet->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_PCT); - amount += CalculatePct(amount + base_attPower, /* aurEff */ect->GetAmount()); - } - } - } - } - - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - //the damage bonus used for pets is either fire or shadow damage, whatever is higher - int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); - int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); - int32 maximum = (fire > shadow) ? fire : shadow; - float bonusDamage = 0.0f; - - if (maximum > 0) - bonusDamage = maximum * 0.15f; - - amount += bonusDamage; - } - } - - void Register() override - { - OnEffectRemove += AuraEffectRemoveFn(spell_warl_pet_scaling_01_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_MOD_MAX_HEALTH, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - AfterEffectApply += AuraEffectApplyFn(spell_warl_pet_scaling_01_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_MOD_MAX_HEALTH, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01_AuraScript::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_MAX_HEALTH); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01_AuraScript::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01_AuraScript::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); - } - - private: - uint32 _tempBonus; - }; - - AuraScript* GetAuraScript() const override + void CalculateAttackPowerAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { - return new spell_warl_pet_scaling_01_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + int32 fire = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE); + int32 shadow = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW); + + amount = std::max(fire, shadow) * 0.57f; + } + } + } + + void CalculateDamageDoneAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + int32 fire = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE); + int32 shadow = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW); + + amount = std::max(fire, shadow) * 0.5f; + } + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_MAX_HEALTH); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); } }; -class spell_warl_pet_scaling_02 : public SpellScriptLoader +class spell_warl_pet_scaling_02 : public AuraScript { -public: - spell_warl_pet_scaling_02() : SpellScriptLoader("spell_warl_pet_scaling_02") { } + PrepareAuraScript(spell_warl_pet_scaling_02); - class spell_warl_pet_scaling_02_AuraScript : public AuraScript + void CalculateIntellectAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_scaling_02_AuraScript); - - public: - spell_warl_pet_scaling_02_AuraScript() + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - _tempBonus = 0; - } - - private: - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateIntellectAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetMaxPower(POWER_MANA), 30); - - amount += ownerBonus; - _tempBonus = ownerBonus; - } - } - - void ApplyEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/) - { - if (Unit* pet = GetUnitOwner()) - if (_tempBonus) + if (Player* owner = pet->GetOwner()) + { + float intellect = owner->GetStat(STAT_INTELLECT); + float manaBonus = 0.0f; + switch (pet->GetEntry()) { - PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel()); - if (!pInfo) - return; - - uint32 manaMod = 0; - uint32 baseMana = pInfo->mana; - switch (pet->GetEntry()) - { case ENTRY_IMP: - manaMod = uint32(_tempBonus * 4.9f); + manaBonus = uint32(intellect * 4.9f); break; + case ENTRY_FELGUARD: case ENTRY_VOIDWALKER: case ENTRY_SUCCUBUS: case ENTRY_FELHUNTER: - case ENTRY_FELGUARD: - manaMod = uint32(_tempBonus * 11.5f); + manaBonus = uint32(intellect * 11.5f); break; default: - manaMod = 0; break; - } - if (manaMod) - pet->ToPet()->SetCreateMana(baseMana + manaMod); } + + float ownerMana = CalculatePct(owner->GetMaxPower(POWER_MANA), 30); + amount = int32(ownerMana + manaBonus); + } } + } - void RemoveEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/) - { - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - { - PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel()); - if (!pInfo) - return; - - pet->ToPet()->SetCreateMana(pInfo->mana); - } - } - - void CalculateArmorAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetArmor(), 35); - amount += ownerBonus; - } - } - - void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40); - amount += ownerBonus; - } - } - - void Register() override - { - OnEffectRemove += AuraEffectRemoveFn(spell_warl_pet_scaling_02_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_MOD_INCREASE_ENERGY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - AfterEffectApply += AuraEffectApplyFn(spell_warl_pet_scaling_02_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_MOD_INCREASE_ENERGY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02_AuraScript::CalculateIntellectAmount, EFFECT_0, SPELL_AURA_MOD_INCREASE_ENERGY); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02_AuraScript::CalculateArmorAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02_AuraScript::CalculateFireResistanceAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE); - } - - private: - uint32 _tempBonus; - }; - - AuraScript* GetAuraScript() const override + void CalculateArmorAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_warl_pet_scaling_02_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float ownerBonus = 0.0f; + ownerBonus = CalculatePct(owner->GetArmor(), 35); + amount = ownerBonus; + } + } + } + + void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float ownerBonus = 0.0f; + ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_MASK_FIRE), 40); + amount = ownerBonus; + } + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02::CalculateIntellectAmount, EFFECT_0, SPELL_AURA_MOD_INCREASE_ENERGY); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02::CalculateArmorAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02::CalculateFireResistanceAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE); } }; -class spell_warl_pet_scaling_03 : public SpellScriptLoader +class spell_warl_pet_scaling_03 : public AuraScript { -public: - spell_warl_pet_scaling_03() : SpellScriptLoader("spell_warl_pet_scaling_03") { } + PrepareAuraScript(spell_warl_pet_scaling_03); - class spell_warl_pet_scaling_03_AuraScript : public AuraScript + void CalculateResistanceAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_scaling_03_AuraScript); + // Formular: owner resistance of targeted school * 0.4 + canBeRecalculated = true; + int32 resistanceSchool = GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue; - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetResistance(SpellSchoolMask(resistanceSchool)) * 0.4); + } - void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40); - amount += ownerBonus; - } - } - - void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40); - amount += ownerBonus; - } - } - - void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40); - amount += ownerBonus; - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03_AuraScript::CalculateFrostResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03_AuraScript::CalculateArcaneResistanceAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03_AuraScript::CalculateNatureResistanceAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_warl_pet_scaling_03_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03::CalculateResistanceAmount, EFFECT_ALL, SPELL_AURA_MOD_RESISTANCE); } }; -class spell_warl_pet_scaling_04 : public SpellScriptLoader +class spell_warl_pet_scaling_04 : public AuraScript { -public: - spell_warl_pet_scaling_04() : SpellScriptLoader("spell_warl_pet_scaling_04") { } + PrepareAuraScript(spell_warl_pet_scaling_04); - class spell_warl_pet_scaling_04_AuraScript : public AuraScript + void CalculateResistanceAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_scaling_04_AuraScript); + // Formular: owner resistance of targeted school * 0.4 + canBeRecalculated = true; + int32 resistanceSchool = GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue; - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetResistance(SpellSchoolMask(resistanceSchool)) * 0.4); + } - void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40); - amount += ownerBonus; - } - } - - void CalculatePowerRegen(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - { - // For others recalculate it from: - float regen = 0.0f; - // Increase regen from new max power - regen += pet->GetMaxPower(POWER_MANA) * 0.02; - - amount += int32(regen); - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_04_AuraScript::CalculateShadowResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_04_AuraScript::CalculatePowerRegen, EFFECT_1, SPELL_AURA_MOD_POWER_REGEN); - } - }; - - AuraScript* GetAuraScript() const override + void CalculatePowerRegen(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_warl_pet_scaling_04_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + // For others recalculate it from: + float regen = 0.0f; + // Increase regen from new max power + regen += pet->GetMaxPower(POWER_MANA) * 0.02; + + amount += int32(regen); + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_04::CalculateResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_04::CalculatePowerRegen, EFFECT_1, SPELL_AURA_MOD_POWER_REGEN); } }; -class spell_warl_pet_scaling_05 : public SpellScriptLoader +class spell_warl_pet_scaling_05 : public AuraScript { -public: - spell_warl_pet_scaling_05() : SpellScriptLoader("spell_warl_pet_scaling_05") { } + PrepareAuraScript(spell_warl_pet_scaling_05); - class spell_warl_pet_scaling_05_AuraScript : public AuraScript + void CalculateMeleeHitChanceBonusAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_scaling_05_AuraScript); - - bool Load() override + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + if (Player* owner = pet->GetOwner()) { - // For others recalculate it from: - float HitMelee = 0.0f; - // Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE - HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); - // Increase hit spell from spell hit ratings - HitMelee += owner->GetRatingBonusValue(CR_HIT_SPELL); - - amount += int32(HitMelee); + float hitChance = 0.0f; + hitChance += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE); + hitChance += owner->GetRatingBonusValue(CR_HIT_MELEE); + amount += int32(hitChance); } } + } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float HitSpell = 0.0f; - // Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE - HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); - // Increase hit spell from spell hit ratings - HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - - amount += int32(HitSpell); - } - } - - void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float Expertise = 0.0f; - // Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE - Expertise += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); - // Increase hit spell from spell hit ratings - Expertise += owner->GetRatingBonusValue(CR_HIT_SPELL); - - amount += int32(Expertise); - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05_AuraScript::CalculateAmountExpertise, EFFECT_2, SPELL_AURA_MOD_EXPERTISE); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateSpellHitChanceBonusAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_warl_pet_scaling_05_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float hitChance = 0.0f; + hitChance += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); + hitChance += owner->GetRatingBonusValue(CR_HIT_SPELL); + amount += int32(hitChance); + } + } + } + + void CalculateExpertiseBonusAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float expertise = 0.0f; + expertise += owner->GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE); + expertise += owner->GetRatingBonusValue(CR_EXPERTISE); + amount += int32(expertise); + } + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05::CalculateMeleeHitChanceBonusAmount, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05::CalculateSpellHitChanceBonusAmount, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05::CalculateExpertiseBonusAmount, EFFECT_2, SPELL_AURA_MOD_EXPERTISE); } }; -class spell_warl_pet_passive : public SpellScriptLoader +class spell_warl_pet_scaling_06 : public AuraScript { -public: - spell_warl_pet_passive() : SpellScriptLoader("spell_warl_pet_passive") { } + PrepareAuraScript(spell_warl_pet_scaling_06); - class spell_warl_pet_passive_AuraScript : public AuraScript + void CalculateCritChanceBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_passive_AuraScript); - - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float CritSpell = 0.0f; - // Crit from Intellect - CritSpell += owner->GetSpellCritFromIntellect(); - // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE - CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); - // Increase crit from SPELL_AURA_MOD_CRIT_PCT - CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); - // Increase crit spell from spell crit ratings - CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL); - - amount += CritSpell; - } - } - - void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float CritMelee = 0.0f; - // Crit from Agility - CritMelee += owner->GetMeleeCritFromAgility(); - // Increase crit from SPELL_AURA_MOD_WEAPON_CRIT_PERCENT - CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); - // Increase crit from SPELL_AURA_MOD_CRIT_PCT - CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); - // Increase crit melee from melee crit ratings - CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE); - - amount += CritMelee; - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_AuraScript::CalculateAmountCritSpell, EFFECT_0, SPELL_AURA_MOD_SPELL_CRIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_AuraScript::CalculateAmountCritMelee, EFFECT_1, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_warl_pet_passive_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE)); } -}; -// this doesnt actually fit in here -class spell_warl_pet_passive_damage_done : public SpellScriptLoader -{ -public: - spell_warl_pet_passive_damage_done() : SpellScriptLoader("spell_warl_pet_passive_damage_done") { } - class spell_warl_pet_passive_damage_done_AuraScript : public AuraScript + void CalculateMeleeHasteAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_warl_pet_passive_damage_done_AuraScript); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + if (float meleeHaste = (1.0f - owner->m_modAttackSpeedPct[BASE_ATTACK]) * 100.0f) + amount += int32(meleeHaste); + } - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (GetCaster()->GetOwner()->ToPlayer()) - { - switch (GetCaster()->GetEntry()) - { - case ENTRY_VOIDWALKER: - amount += -16; - break; - case ENTRY_FELHUNTER: - amount += -20; - break; - case ENTRY_SUCCUBUS: - case ENTRY_FELGUARD: - amount += 5; - break; - } - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_damage_done_AuraScript::CalculateAmountDamageDone, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); - } - }; - - AuraScript* GetAuraScript() const override + void Register() { - return new spell_warl_pet_passive_damage_done_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_06::CalculateMeleeHasteAmount, EFFECT_0, SPELL_AURA_MOD_CRIT_PCT); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_06::CalculateMeleeHasteAmount, EFFECT_1, SPELL_AURA_MELEE_SLOW); } }; -class spell_warl_pet_passive_voidwalker : public SpellScriptLoader +class spell_warl_pet_passive : public AuraScript { -public: - spell_warl_pet_passive_voidwalker() : SpellScriptLoader("spell_warl_pet_passive_voidwalker") { } + PrepareAuraScript(spell_warl_pet_passive); - class spell_warl_pet_passive_voidwalker_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_warl_pet_passive_voidwalker_AuraScript); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - if (AuraEffect* /* aurEff */ect = owner->GetAuraEffect(SPELL_WARLOCK_GLYPH_OF_VOIDWALKER, EFFECT_0)) - amount += /* aurEff */ect->GetAmount(); - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_voidwalker_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_warl_pet_passive_voidwalker_AuraScript(); + canBeRecalculated = true; + if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + { + // For others recalculate it from: + float CritSpell = 0.0f; + // Crit from Intellect + CritSpell += owner->GetSpellCritFromIntellect(); + // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE + CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); + // Increase crit from SPELL_AURA_MOD_CRIT_PCT + CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); + // Increase crit spell from spell crit ratings + CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL); + + amount += CritSpell; + } + } + + void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + { + // For others recalculate it from: + float CritMelee = 0.0f; + // Crit from Agility + CritMelee += owner->GetMeleeCritFromAgility(); + // Increase crit from SPELL_AURA_MOD_WEAPON_CRIT_PERCENT + CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); + // Increase crit from SPELL_AURA_MOD_CRIT_PCT + CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); + // Increase crit melee from melee crit ratings + CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE); + + amount += CritMelee; + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive::CalculateAmountCritSpell, EFFECT_0, SPELL_AURA_MOD_SPELL_CRIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive::CalculateAmountCritMelee, EFFECT_1, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); } }; @@ -781,534 +492,265 @@ public: } }; -class spell_hun_pet_scaling_01 : public SpellScriptLoader +class spell_hun_pet_scaling_01 : public AuraScript { -public: - spell_hun_pet_scaling_01() : SpellScriptLoader("spell_hun_pet_scaling_01") { } + PrepareAuraScript(spell_hun_pet_scaling_01); - class spell_hun_pet_scaling_01_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_hun_pet_scaling_01_AuraScript); - - void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - if (pet->IsPet()) - if (Unit* owner = pet->ToPet()->GetOwner()) - { - float mod = 0.45f; - float ownerBonus = 0.0f; - - PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1 - if (itr == pet->ToPet()->m_spells.end()) - itr = pet->ToPet()->m_spells.find(62762); // Wild Hunt rank 2 - - if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt - { - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value - AddPct(mod, spellInfo->Effects[EFFECT_0].CalcValue()); - } - - ownerBonus = owner->GetMaxHealth() * mod; - - amount += ownerBonus; - } - } - - void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) + return ValidateSpellInfo( { - if (!pet->IsPet()) - return; + SPELL_HUNTER_PET_FEROCITY_MARKER, + SPELL_HUNTER_PET_TENACITY_MARKER, + SPELL_HUNTER_PET_CUNNING_MARKER + }); + } - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; + void CalculateHealthAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + // Base Health value for all pets at level 85 is 32,474 + int32 bonus = int32(owner->GetCreateHealth() * 0.79743633f); - float mod = 1.0f; //Hunter contribution modifier - float bonusAP = 0.0f; + // Apply health scaling bonuses based on pet type + float mod = 0.0f; + if (pet->HasAura(SPELL_HUNTER_PET_FEROCITY_MARKER)) + mod = 0.67f; + else if (pet->HasAura(SPELL_HUNTER_PET_TENACITY_MARKER)) + mod = 0.78f; + else if (pet->HasAura(SPELL_HUNTER_PET_CUNNING_MARKER)) + mod = 0.725f; - PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1 - if (itr == pet->ToPet()->m_spells.end()) - itr = pet->ToPet()->m_spells.find(62762); // Wild Hunt rank 2 - - if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt - { - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value - mod += CalculatePct(1.0f, spellInfo->Effects[EFFECT_1].CalcValue()); - } - - bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.42f * mod; - - amount += bonusAP; + bonus += int32(owner->GetMaxHealth() * mod); + amount = bonus; } } + } - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) + if (Player* owner = pet->GetOwner()) { - if (!pet->IsPet()) - return; + // Base attack power value at level 85 is 932 + int32 bonus = int32((owner->GetCreateStat(STAT_AGILITY) * 2) * 2.24038f) + 1; - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float mod = 1.0f; //Hunter contribution modifier - float bonusDamage = 0.0f; - - PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1 - if (itr == pet->ToPet()->m_spells.end()) - itr = pet->ToPet()->m_spells.find(62762); // Wild Hunt rank 2 - - if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt - { - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value - mod += CalculatePct(1.0f, spellInfo->Effects[EFFECT_1].CalcValue()); - } - - bonusDamage = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1287f * mod; - - amount += bonusDamage; + // All pets gain 42.5% from owners attack power + bonus += owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.425f; + amount = bonus; } } + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01_AuraScript::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_MAX_HEALTH); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01_AuraScript::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01_AuraScript::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); - } - - uint32 _tempHealth = 0; - }; - - AuraScript* GetAuraScript() const override + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_hun_pet_scaling_01_AuraScript(); + // Formular: Owner ranged attack power * 0.4 + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.4f); + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01::CalculateHealthAmount, EFFECT_0, SPELL_AURA_MOD_MAX_HEALTH); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); } }; -class spell_hun_pet_scaling_02 : public SpellScriptLoader +class spell_hun_pet_scaling_02 : public AuraScript { -public: - spell_hun_pet_scaling_02() : SpellScriptLoader("spell_hun_pet_scaling_02") { } + PrepareAuraScript(spell_hun_pet_scaling_02); - class spell_hun_pet_scaling_02_AuraScript : public AuraScript + void CalculateResistanceAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_hun_pet_scaling_02_AuraScript); + // Formular: owner resistance of targeted school * 0.4 + canBeRecalculated = true; + int32 resistanceSchool = GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue; - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetResistance(SpellSchoolMask(resistanceSchool)) * 0.4); + } - void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40); - - amount += ownerBonus; - } - } - - void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40); - - amount += ownerBonus; - } - } - - void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40); - - amount += ownerBonus; - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_02_AuraScript::CalculateFrostResistanceAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_02_AuraScript::CalculateFireResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_02_AuraScript::CalculateNatureResistanceAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_hun_pet_scaling_02_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_02::CalculateResistanceAmount, EFFECT_ALL, SPELL_AURA_MOD_RESISTANCE); } }; -class spell_hun_pet_scaling_03 : public SpellScriptLoader +class spell_hun_pet_scaling_03 : public AuraScript { -public: - spell_hun_pet_scaling_03() : SpellScriptLoader("spell_hun_pet_scaling_03") { } + PrepareAuraScript(spell_hun_pet_scaling_03); - class spell_hun_pet_scaling_03_AuraScript : public AuraScript + void CalculateResistanceAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_hun_pet_scaling_03_AuraScript); + // Formular: owner resistance of targeted school * 0.4 + canBeRecalculated = true; + int32 resistanceSchool = GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue; - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetResistance(SpellSchoolMask(resistanceSchool)) * 0.4); + } - void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40); - - amount += ownerBonus; - } - } - - void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40); - - amount += ownerBonus; - } - } - - void CalculateArmorAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetArmor(), 35); - - amount += ownerBonus; - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_03_AuraScript::CalculateShadowResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_03_AuraScript::CalculateArcaneResistanceAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_03_AuraScript::CalculateArmorAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_hun_pet_scaling_03_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_03::CalculateResistanceAmount, EFFECT_ALL, SPELL_AURA_MOD_RESISTANCE); } }; -class spell_hun_pet_scaling_04 : public SpellScriptLoader +class spell_hun_pet_scaling_04 : public AuraScript { -public: - spell_hun_pet_scaling_04() : SpellScriptLoader("spell_hun_pet_scaling_04") { } + PrepareAuraScript(spell_hun_pet_scaling_04); - class spell_hun_pet_scaling_04_AuraScript : public AuraScript + void CalculateMeleeHitChanceBonusAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_hun_pet_scaling_04_AuraScript); - - bool Load() override + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + if (Player* owner = pet->GetOwner()) { - // For others recalculate it from: - float HitMelee = 0.0f; - // Increase hit from SPELL_AURA_MOD_HIT_CHANCE - HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE); - // Increase hit melee from meele hit ratings - HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); - - amount += int32(HitMelee); + float hitChance = 0.0f; + hitChance += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE); + hitChance += owner->GetRatingBonusValue(CR_HIT_MELEE); + amount += int32(hitChance); } } + } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float HitSpell = 0.0f; - // Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE - HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); - // Increase hit spell from spell hit ratings - HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - - amount += int32(HitSpell); - } - } - - void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float Expertise = 0.0f; - // Increase hit from SPELL_AURA_MOD_EXPERTISE - Expertise += owner->GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE); - // Increase Expertise from Expertise ratings - Expertise += owner->GetRatingBonusValue(CR_EXPERTISE); - - amount += int32(Expertise); - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_04_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_04_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_04_AuraScript::CalculateAmountExpertise, EFFECT_2, SPELL_AURA_MOD_EXPERTISE); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateSpellHitChanceBonusAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_hun_pet_scaling_04_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float hitChance = 0.0f; + hitChance += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); + hitChance += owner->GetRatingBonusValue(CR_HIT_SPELL); + amount += int32(hitChance); + } + } + } + + void CalculateExpertiseBonusAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float expertise = 0.0f; + expertise += owner->GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE); + expertise += owner->GetRatingBonusValue(CR_EXPERTISE); + amount += int32(expertise); + } + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_04::CalculateMeleeHitChanceBonusAmount, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_04::CalculateSpellHitChanceBonusAmount, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_04::CalculateExpertiseBonusAmount, EFFECT_2, SPELL_AURA_MOD_EXPERTISE); } }; -class spell_hun_pet_scaling_05 : public SpellScriptLoader +class spell_hun_pet_scaling_05 : public AuraScript { -public: - spell_hun_pet_scaling_05() : SpellScriptLoader("spell_hun_pet_scaling_05") { } + PrepareAuraScript(spell_hun_pet_scaling_05); - class spell_hun_pet_scaling_05_AuraScript : public AuraScript + void CalculateCritChanceBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_hun_pet_scaling_05_AuraScript); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = uint32(owner->GetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE)); + } - bool Load() - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - float hastePct = owner->GetRatingBonusValue(CR_HASTE_RANGED); - amount = int32(100.0f * (1.0f - hastePct) / hastePct); - } - } - - void Register() - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_05_AuraScript::CalculateAmountMeleeHaste, EFFECT_1, SPELL_AURA_MELEE_SLOW); - } - }; - - AuraScript* GetAuraScript() const + void CalculateMeleeHasteAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_hun_pet_scaling_05_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + if (float meleeHaste = (1.0f - owner->m_modAttackSpeedPct[BASE_ATTACK]) * 100.0f) + amount += int32(meleeHaste); + } + + void Register() + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_05::CalculateMeleeHasteAmount, EFFECT_0, SPELL_AURA_MOD_CRIT_PCT); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_05::CalculateMeleeHasteAmount, EFFECT_1, SPELL_AURA_MELEE_SLOW); } }; -class spell_hun_pet_passive_crit : public SpellScriptLoader +class spell_hun_pet_passive_crit : public AuraScript { -public: - spell_hun_pet_passive_crit() : SpellScriptLoader("spell_hun_pet_passive_crit") { } + PrepareAuraScript(spell_hun_pet_passive_crit); - class spell_hun_pet_passive_crit_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_hun_pet_passive_crit_AuraScript); - - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float CritSpell = 0.0f; - // Crit from Intellect - CritSpell += owner->GetSpellCritFromIntellect(); - // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE - CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); - // Increase crit from SPELL_AURA_MOD_CRIT_PCT - CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); - // Increase crit spell from spell crit ratings - CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL); - - amount += CritSpell; - } - } - - void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player *owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float CritMelee = 0.0f; - // Crit from Agility - CritMelee += owner->GetMeleeCritFromAgility(); - // Increase crit from SPELL_AURA_MOD_WEAPON_CRIT_PERCENT - CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); - // Increase crit from SPELL_AURA_MOD_CRIT_PCT - CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); - // Increase crit melee from melee crit ratings - CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE); - - amount += CritMelee; - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_passive_crit_AuraScript::CalculateAmountCritSpell, EFFECT_1, SPELL_AURA_MOD_SPELL_CRIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_passive_crit_AuraScript::CalculateAmountCritMelee, EFFECT_0, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_hun_pet_passive_crit_AuraScript(); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; } -}; -class spell_hun_pet_passive_damage_done : public SpellScriptLoader -{ -public: - spell_hun_pet_passive_damage_done() : SpellScriptLoader("spell_hun_pet_passive_damage_done") { } - - class spell_hun_pet_passive_damage_done_AuraScript : public AuraScript + void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - PrepareAuraScript(spell_hun_pet_passive_damage_done_AuraScript); - - bool Load() override + canBeRecalculated = true; + if (!GetCaster() || !GetCaster()->GetOwner()) + return; + if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } + // For others recalculate it from: + float CritSpell = 0.0f; + // Crit from Intellect + CritSpell += owner->GetSpellCritFromIntellect(); + // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE + CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); + // Increase crit from SPELL_AURA_MOD_CRIT_PCT + CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); + // Increase crit spell from spell crit ratings + CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL); - void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (GetCaster()->GetOwner()->ToPlayer()) - { - // Cobra Reflexes - if (AuraEffect* cobraReflexes = GetCaster()->GetAuraEffectOfRankedSpell(61682, EFFECT_0)) - amount -= cobraReflexes->GetAmount(); - } + amount += CritSpell; } + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_passive_damage_done_AuraScript::CalculateAmountDamageDone, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_hun_pet_passive_damage_done_AuraScript(); + canBeRecalculated = true; + if (!GetCaster() || !GetCaster()->GetOwner()) + return; + if (Player *owner = GetCaster()->GetOwner()->ToPlayer()) + { + // For others recalculate it from: + float CritMelee = 0.0f; + // Crit from Agility + CritMelee += owner->GetMeleeCritFromAgility(); + // Increase crit from SPELL_AURA_MOD_WEAPON_CRIT_PERCENT + CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); + // Increase crit from SPELL_AURA_MOD_CRIT_PCT + CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); + // Increase crit melee from melee crit ratings + CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE); + + amount += CritMelee; + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_passive_crit::CalculateAmountCritSpell, EFFECT_1, SPELL_AURA_MOD_SPELL_CRIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_passive_crit::CalculateAmountCritMelee, EFFECT_0, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT); } }; @@ -1357,377 +799,351 @@ public: } }; -class spell_dk_pet_scaling_01 : public SpellScriptLoader +class spell_dk_pet_scaling_01 : public AuraScript { -public: - spell_dk_pet_scaling_01() : SpellScriptLoader("spell_dk_pet_scaling_01") { } + PrepareAuraScript(spell_dk_pet_scaling_01); - class spell_dk_pet_scaling_01_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dk_pet_scaling_01_AuraScript); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } - public: - spell_dk_pet_scaling_01_AuraScript() + void CalculateStaminaAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - _tempHealth = 0; - } - - private: - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) + if (Player* owner = pet->GetOwner()) { - if (pet->IsGuardian()) - { - if (Unit* owner = pet->GetOwner()) - { - float mod = 0.3f; + uint8 percentage = 30; - // Ravenous Dead. Check just if owner has Ravenous Dead since it's effect is not an aura - if (AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0)) - mod += aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue()/100; // Ravenous Dead edits the original scale + // Glyph of Raise Dead + if (AuraEffect const* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD, EFFECT_0)) + percentage += aurEff->GetAmount(); - // Glyph of the Ghoul - if (AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_DEATH_KNIGHT_GLYPH_OF_GHOUL, 0)) - mod += aurEff->GetAmount()/100; - - float ownerBonus = float(owner->GetStat(STAT_STAMINA)) * mod; - amount += ownerBonus; - } - } + amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), percentage)); } } + } - /*void ApplyEffect(AuraEffect const* /* aurEff , AuraEffectHandleModes /*mode) + void CalculateStrengthAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - if (Unit* pet = GetUnitOwner()) - if (_tempHealth) - { - pet->SetMaxHealth(_tempHealth); - pet->SetHealth(_tempHealth); - } - } - - void RemoveEffect(AuraEffect const* /* aurEff , AuraEffectHandleModes /*mode) - { - if (Unit* pet = GetUnitOwner()) - _tempHealth = pet->GetHealth(); - }*/ - - void CalculateStrengthAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) + if (Player* owner = pet->GetOwner()) { - if (!pet->IsGuardian()) - return; + uint8 percentage = 70; - Unit* owner = pet->GetOwner(); - if (!owner) - return; + // Glyph of Raise Dead + if (AuraEffect const* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD, EFFECT_0)) + percentage += aurEff->GetAmount(); - float mod = 0.7f; - - // Ravenous Dead - AuraEffect const* aurEff = nullptr; - // Check just if owner has Ravenous Dead since it's effect is not an aura - aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0); - if (aurEff) - { - mod += CalculatePct(mod, aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue()); // Ravenous Dead edits the original scale - } - // Glyph of the Ghoul - aurEff = owner->GetAuraEffect(58686, 0); - if (aurEff) - mod += CalculatePct(1.0f, aurEff->GetAmount()); // Glyph of the Ghoul adds a flat value to the scale mod - float ownerBonus = float(owner->GetStat(STAT_STRENGTH)) * mod; - amount += ownerBonus; + amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), percentage)); } } + } - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) + if (Player* owner = pet->GetOwner()) { - if (!pet->IsPet()) - return; - - Unit* owner = pet->ToPet()->GetOwner(); - if (!owner) - return; - float bonusDamage = owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.11f; - amount += bonusDamage; } } + } - void Register() override - { - //OnEffectRemove += AuraEffectRemoveFn(spell_dk_pet_scaling_01_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - //AfterEffectApply += AuraEffectApplyFn(spell_dk_pet_scaling_01_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_01_AuraScript::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_STAT); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_01_AuraScript::CalculateStrengthAmount, EFFECT_1, SPELL_AURA_MOD_STAT); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_01_AuraScript::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); - } - - private: - uint32 _tempHealth; - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dk_pet_scaling_01_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_01::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_STAT); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_01::CalculateStrengthAmount, EFFECT_1, SPELL_AURA_MOD_STAT); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_01::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); } }; -class spell_dk_pet_scaling_02 : public SpellScriptLoader +class spell_dk_pet_scaling_02 : public AuraScript { -public: - spell_dk_pet_scaling_02() : SpellScriptLoader("spell_dk_pet_scaling_02") { } + PrepareAuraScript(spell_dk_pet_scaling_02); - class spell_dk_pet_scaling_02_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dk_pet_scaling_02_AuraScript); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } - bool Load() override + void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + if (Player* owner = pet->GetOwner()) { // For others recalculate it from: float HasteMelee = 0.0f; // Increase hit from SPELL_AURA_MOD_HIT_CHANCE - HasteMelee += (1-owner->m_modAttackSpeedPct[BASE_ATTACK])*100; + HasteMelee += (1 - owner->m_modAttackSpeedPct[BASE_ATTACK]) * 100; amount += int32(HasteMelee); } } + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_02_AuraScript::CalculateAmountMeleeHaste, EFFECT_1, SPELL_AURA_MELEE_SLOW); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dk_pet_scaling_02_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_02::CalculateAmountMeleeHaste, EFFECT_1, SPELL_AURA_MELEE_SLOW); } }; -class spell_dk_pet_scaling_03 : public SpellScriptLoader +class spell_dk_pet_scaling_03 : public AuraScript { -public: - spell_dk_pet_scaling_03() : SpellScriptLoader("spell_dk_pet_scaling_03") { } + PrepareAuraScript(spell_dk_pet_scaling_03); - class spell_dk_pet_scaling_03_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dk_pet_scaling_03_AuraScript); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } - bool Load() override - { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float HitMelee = 0.0f; - // Increase hit from SPELL_AURA_MOD_HIT_CHANCE - HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE); - // Increase hit melee from meele hit ratings - HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); - - amount += int32(HitMelee); - } - } - - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float HitSpell = 0.0f; - // Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE - HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); - // Increase hit spell from spell hit ratings - HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - - amount += int32(HitSpell); - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_03_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_03_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) { - return new spell_dk_pet_scaling_03_AuraScript(); + canBeRecalculated = true; + if (!GetCaster() || !GetCaster()->GetOwner()) + return; + if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + { + // For others recalculate it from: + float HitMelee = 0.0f; + // Increase hit from SPELL_AURA_MOD_HIT_CHANCE + HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE); + // Increase hit melee from meele hit ratings + HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); + + amount += int32(HitMelee); + } + } + + void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (!GetCaster() || !GetCaster()->GetOwner()) + return; + if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + { + // For others recalculate it from: + float HitSpell = 0.0f; + // Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE + HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); + // Increase hit spell from spell hit ratings + HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); + + amount += int32(HitSpell); + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_03::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_03::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE); } }; -class spell_dk_crit : public SpellScriptLoader +class spell_dk_pet_scaling_05 : public AuraScript { -public: - spell_dk_crit() : SpellScriptLoader("spell_dk_crit") { } + PrepareAuraScript(spell_dk_pet_scaling_05); - class spell_dk_crit_AuraScript : public AuraScript + bool Load() { - PrepareAuraScript(spell_dk_crit_AuraScript); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } - bool Load() + void CalculateAmountCritPct(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + { + if (Pet* pet = GetUnitOwner()->ToPet()) { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) - return; - if (GetCaster()->GetOwner()->ToPlayer()) + if (Player* owner = pet->GetOwner()) { - // For others recalculate it from: - float CritSpell = 0.0f; - // Crit from Intellect - // CritSpell += owner->GetSpellCritFromIntellect(); - // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE - // CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); - // Increase crit from SPELL_AURA_MOD_CRIT_PCT - // CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); - // Increase crit spell from spell crit ratings - // CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL); - - amount += (CritSpell * 0.8f); + float CritSpell = owner->GetMeleeCritFromAgility(); + CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE); + CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); + CritSpell += owner->GetRatingBonusValue(CR_CRIT_MELEE); + amount += int32(CritSpell); } } + } - void Register() - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_crit_AuraScript::CalculateAmountCritSpell, EFFECT_0, SPELL_AURA_MOD_CRIT_PCT); - } - }; - - AuraScript* GetAuraScript() const + void CalculateAmountResistance(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) { - return new spell_dk_crit_AuraScript(); + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount += owner->GetInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE); + } + + void Register() + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_05::CalculateAmountCritPct, EFFECT_0, SPELL_AURA_MOD_CRIT_PCT); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_pet_scaling_05::CalculateAmountResistance, EFFECT_2, SPELL_AURA_MOD_TARGET_RESISTANCE); } }; -class spell_dk_rune_weapon_scaling_02 : public SpellScriptLoader +class spell_dk_rune_weapon_scaling_02 : public AuraScript { -public: - spell_dk_rune_weapon_scaling_02() : SpellScriptLoader("spell_dk_rune_weapon_scaling_02") { } + PrepareAuraScript(spell_dk_rune_weapon_scaling_02); - class spell_dk_rune_weapon_scaling_02_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dk_rune_weapon_scaling_02_AuraScript); + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } - bool Load() override + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Unit* pet = GetUnitOwner()) { - if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) - return false; - return true; - } - - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (Unit* pet = GetUnitOwner()) - { - Unit* owner = pet->GetOwner(); - if (!owner) - return; - - if (pet->IsGuardian()) - ((Guardian*)pet)->SetBonusDamage(owner->GetTotalAttackPowerValue(BASE_ATTACK)); - - amount += owner->CalculateDamage(BASE_ATTACK, true, true); - } - } - - void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - if (!GetCaster() || !GetCaster()->GetOwner()) + Unit* owner = pet->GetOwner(); + if (!owner) return; - if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) - { - // For others recalculate it from: - float HasteMelee = 0.0f; - // Increase hit from SPELL_AURA_MOD_HIT_CHANCE - HasteMelee += (1-owner->m_modAttackSpeedPct[BASE_ATTACK])*100; - amount += int32(HasteMelee); + amount += owner->CalculateDamage(BASE_ATTACK, true, true); + } + } + + void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (!GetCaster() || !GetCaster()->GetOwner()) + return; + if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) + { + // For others recalculate it from: + float HasteMelee = 0.0f; + // Increase hit from SPELL_AURA_MOD_HIT_CHANCE + HasteMelee += (1 - owner->m_modAttackSpeedPct[BASE_ATTACK]) * 100; + + amount += int32(HasteMelee); + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_rune_weapon_scaling_02::CalculateDamageDoneAmount, EFFECT_0, SPELL_AURA_MOD_DAMAGE_DONE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_rune_weapon_scaling_02::CalculateAmountMeleeHaste, EFFECT_1, SPELL_AURA_MELEE_SLOW); + } +}; + +class spell_mage_water_elemental_scaling_01 : public AuraScript +{ + PrepareAuraScript(spell_mage_water_elemental_scaling_01); + + bool Load() override + { + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } + + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float bonusDamage = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.4f; + amount = int32(bonusDamage); } } + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_rune_weapon_scaling_02_AuraScript::CalculateDamageDoneAmount, EFFECT_0, SPELL_AURA_MOD_DAMAGE_DONE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_rune_weapon_scaling_02_AuraScript::CalculateAmountMeleeHaste, EFFECT_1, SPELL_AURA_MELEE_SLOW); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateAttackPowerAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { - return new spell_dk_rune_weapon_scaling_02_AuraScript(); + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + { + if (Player* owner = pet->GetOwner()) + { + float bonusDamage = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.57f; + amount = int32(bonusDamage); + } + } + } + + void CalculateStaminaAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), 30)); + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mage_water_elemental_scaling_01::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_STAT); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mage_water_elemental_scaling_01::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mage_water_elemental_scaling_01::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE); + } +}; + +class spell_mage_water_elemental_scaling_02 : public AuraScript +{ + PrepareAuraScript(spell_mage_water_elemental_scaling_02); + + bool Load() override + { + if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) + return false; + return true; + } + + void CalculateIntellectAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = true; + if (Pet* pet = GetUnitOwner()->ToPet()) + if (Player* owner = pet->GetOwner()) + amount = int32(CalculatePct(owner->GetStat(STAT_INTELLECT), 30)); + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mage_water_elemental_scaling_02::CalculateIntellectAmount, EFFECT_0, SPELL_AURA_MOD_STAT); } }; void AddSC_pet_spell_scripts() { - new spell_warl_pet_scaling_01(); - new spell_warl_pet_scaling_02(); - new spell_warl_pet_scaling_03(); - new spell_warl_pet_scaling_04(); - new spell_warl_pet_scaling_05(); - new spell_warl_pet_passive(); + RegisterAuraScript(spell_warl_pet_scaling_01); + RegisterAuraScript(spell_warl_pet_scaling_02); + RegisterAuraScript(spell_warl_pet_scaling_03); + RegisterAuraScript(spell_warl_pet_scaling_04); + RegisterAuraScript(spell_warl_pet_scaling_05); + RegisterAuraScript(spell_warl_pet_scaling_06); + RegisterAuraScript(spell_warl_pet_passive); - new spell_hun_pet_scaling_01(); - new spell_hun_pet_scaling_02(); - new spell_hun_pet_scaling_03(); - new spell_hun_pet_scaling_04(); - new spell_hun_pet_scaling_05(); - new spell_hun_pet_passive_crit(); + RegisterAuraScript(spell_hun_pet_scaling_01); + RegisterAuraScript(spell_hun_pet_scaling_02); + RegisterAuraScript(spell_hun_pet_scaling_03); + RegisterAuraScript(spell_hun_pet_scaling_04); + RegisterAuraScript(spell_hun_pet_scaling_05); + RegisterAuraScript(spell_hun_pet_passive_crit); - new spell_dk_pet_scaling_01(); - new spell_dk_pet_scaling_02(); - new spell_dk_pet_scaling_03(); - new spell_dk_crit(); + RegisterAuraScript(spell_dk_pet_scaling_01); + RegisterAuraScript(spell_dk_pet_scaling_02); + RegisterAuraScript(spell_dk_pet_scaling_03); + RegisterAuraScript(spell_dk_pet_scaling_05); + + RegisterAuraScript(spell_dk_rune_weapon_scaling_02); + + RegisterAuraScript(spell_mage_water_elemental_scaling_01); + RegisterAuraScript(spell_mage_water_elemental_scaling_02); }