Core/Pets: base implementation for pet aura scaling system. not currently hooked into anything. (thx vincent-michael for the base work)

This commit is contained in:
Kandera
2012-06-08 13:08:38 -04:00
parent 69bf716c1b
commit 69ea6b5d32

View File

@@ -0,0 +1,178 @@
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_DEATHKNIGHT and SPELLFAMILY_GENERIC spells used by deathknight players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_dk_".
*/
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
enum PetCalculate
{
SPELL_HUNTER_PET_CRIT = 19591,
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_WARLOCK_PET_CRIT = 35695,
SPELL_WARLOCK_PET_HIT_EXPERTISE = 61013,
SPELL_DK_PET_HIT = 61697,
SPELL_SHAMAN_PET_HIT = 61783,
};
class spell_gen_pet_calculate : public SpellScriptLoader
{
public:
spell_gen_pet_calculate() : SpellScriptLoader("spell_gen_pet_calculate") { }
class spell_gen_pet_calculate_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_pet_calculate_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmountCritSpell(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
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 += int32(CritSpell);
}
}
void CalculateAmountCritMelee(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
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 += int32(CritMelee);
}
}
void CalculateAmountMeleeHit(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
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*/)
{
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*/)
{
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()
{
switch (m_scriptSpellId)
{
case SPELL_HUNTER_PET_CRIT:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritMelee, EFFECT_0, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritSpell, EFFECT_1, SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
break;
case SPELL_WARLOCK_PET_CRIT:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritSpell, EFFECT_0, SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritMelee, EFFECT_1, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
break;
case SPELL_WARLOCK_PET_HIT_EXPERTISE:
case SPELL_HUNTER_PET_SCALING_04:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountExpertise, EFFECT_2, SPELL_AURA_MOD_EXPERTISE);
break;
case SPELL_DK_PET_HIT:
case SPELL_SHAMAN_PET_HIT:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE);
break;
default:
break;
}
}
};
AuraScript* GetAuraScript() const
{
return new spell_gen_pet_calculate_AuraScript();
}
};
void AddSC_pet_spell_scripts()
{
new spell_gen_pet_calculate();
}