Core/Pets: more updates for pet calculations. feedback would be nice! (nothing is applied to anything yet so this will not reflect ingame atm)

This commit is contained in:
Kandera
2012-06-12 12:18:49 -04:00
parent c6c23b7f7e
commit 76a2d13239
+73 -63
View File
@@ -24,6 +24,9 @@
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "SpellScript.h" #include "SpellScript.h"
#include "SpellAuraEffects.h" #include "SpellAuraEffects.h"
#include "Unit.h"
#include "Player.h"
#include "Pet.h"
enum HunterPetCalculate enum HunterPetCalculate
{ {
@@ -52,6 +55,7 @@ enum WarlockPetCalculate
ENTRY_VOIDWALKER = 1860, ENTRY_VOIDWALKER = 1860,
ENTRY_FELHUNTER = 417, ENTRY_FELHUNTER = 417,
ENTRY_SUCCUBUS = 1863, ENTRY_SUCCUBUS = 1863,
ENTRY_IMP = 416,
}; };
enum DKPetCalculate enum DKPetCalculate
@@ -60,6 +64,9 @@ enum DKPetCalculate
SPELL_DEATH_KNIGHT_PET_SCALING_01 = 54566, SPELL_DEATH_KNIGHT_PET_SCALING_01 = 54566,
SPELL_DEATH_KNIGHT_PET_SCALING_02 = 51996, SPELL_DEATH_KNIGHT_PET_SCALING_02 = 51996,
SPELL_DEATH_KNIGHT_PET_SCALING_03 = 61697, SPELL_DEATH_KNIGHT_PET_SCALING_03 = 61697,
SPELL_NIGHT_OF_THE_DEAD = 55620,
ENTRY_ARMY_OF_THE_DEAD_GHOUL = 24207,
SPELL_DEATH_KNIGHT_GLYPH_OF_GHOUL = 58686,
}; };
enum ShamanPetCalculate enum ShamanPetCalculate
@@ -225,24 +232,17 @@ public:
{ {
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER) if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false; return false;
_tempHealth = 0; _tempBonus = 0;
return true; return true;
} }
void CalculateStaminaAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) void CalculateStaminaAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/)
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{ {
if (!pet->isPet()) float ownerBonus = CalculatePctN(owner->GetStat(STAT_STAMINA), 75);
return;
Unit* owner = pet->ToPet()->GetOwner();
if (!owner)
return;
float ownerBonus = 0.0f;
ownerBonus = CalculatePctN(owner->GetStat(STAT_STAMINA), 75);
amount += ownerBonus; amount += ownerBonus;
} }
@@ -251,27 +251,54 @@ public:
void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
if (_tempHealth) if (_tempBonus)
pet->SetHealth(_tempHealth); {
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel());
uint32 healthMod = 0;
uint32 baseHealth = pInfo->health;
switch (pet->GetEntry())
{
case ENTRY_IMP:
healthMod = uint32(_tempBonus * 8.4f);
break;
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;
case ENTRY_FELGUARD:
healthMod = _tempBonus * 11;
break;
default:
healthMod = 0;
break;
}
if (healthMod)
pet->ToPet()->SetCreateHealth(baseHealth + healthMod);
}
} }
void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
_tempHealth = pet->GetHealth(); if (pet->isPet())
{
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel());
pet->ToPet()->SetCreateHealth(pInfo->health);
}
} }
void CalculateAttackPowerAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) void CalculateAttackPowerAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/)
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{ {
if (!pet->isPet())
return;
Unit* owner = pet->ToPet()->GetOwner();
if (!owner)
return;
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 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 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; int32 maximum = (fire > shadow) ? fire : shadow;
@@ -296,21 +323,17 @@ public:
void CalculateDamageDoneAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) void CalculateDamageDoneAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/)
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{ {
if (!pet->isPet())
return;
Unit* owner = pet->ToPet()->GetOwner();
if (!owner)
return;
//the damage bonus used for pets is either fire or shadow damage, whatever is higher //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 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 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; int32 maximum = (fire > shadow) ? fire : shadow;
if (maximum < 0) float bonusDamage = 0.0f;
maximum = 0;
float bonusDamage = maximum * 0.15f; if (maximum > 0)
bonusDamage = maximum * 0.15f;
amount += bonusDamage; amount += bonusDamage;
} }
@@ -326,7 +349,7 @@ public:
} }
private: private:
uint32 _tempHealth; uint32 _tempBonus;
}; };
AuraScript* GetAuraScript() const AuraScript* GetAuraScript() const
@@ -355,14 +378,9 @@ public:
void CalculateIntellectAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) void CalculateIntellectAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/)
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{ {
if (!pet->isPet())
return;
Unit* owner = pet->ToPet()->GetOwner();
if (!owner)
return;
float ownerBonus = 0.0f; float ownerBonus = 0.0f;
ownerBonus = CalculatePctN(owner->GetStat(STAT_INTELLECT), 30); ownerBonus = CalculatePctN(owner->GetStat(STAT_INTELLECT), 30);
@@ -1470,18 +1488,14 @@ public:
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
{ {
Unit* owner = pet->GetOwner(); if (Unit* owner = pet->GetOwner())
if (!owner)
return;
// Army of the dead ghoul // Army of the dead ghoul
if (pet->GetEntry() == 24207) if (pet->GetEntry() == ENTRY_ARMY_OF_THE_DEAD_GHOUL)
amount = -90; amount = -90;
// Night of the dead // Night of the dead
else if (owner->HasAura(55623)) else if ( Aura * aur = owner->GetAuraOfRankedSpell(SPELL_NIGHT_OF_THE_DEAD))
amount = -90; amount = aur->GetSpellInfo()->Effects[EFFECT_2].CalcValue();
else if (owner->HasAura(55620))
amount = -45;
} }
} }
@@ -1518,31 +1532,27 @@ public:
{ {
if (Unit* pet = GetUnitOwner()) if (Unit* pet = GetUnitOwner())
{ {
if (!pet->isGuardian()) if (pet->isGuardian())
return; {
if (Unit* owner = pet->GetOwner())
Unit* owner = pet->GetOwner(); {
if (!owner)
return;
float mod = 0.3f; float mod = 0.3f;
// Ravenous Dead // Ravenous Dead. Check just if owner has Ravenous Dead since it's effect is not an aura
AuraEffect const* aurEff = NULL; if (AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0))
// 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 += CalculatePctN(mod, aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue()); // Ravenous Dead edits the original scale mod += aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue()/100; // Ravenous Dead edits the original scale
} }
// Glyph of the Ghoul // Glyph of the Ghoul
aurEff = owner->GetAuraEffect(58686, 0); if (AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_DEATH_KNIGHT_GLYPH_OF_GHOUL, 0))
if (aurEff) mod += aurEff->GetAmount()/100;
mod += CalculatePctN(1.0f, aurEff->GetAmount()); // Glyph of the Ghoul adds a flat value to the scale mod
float ownerBonus = float(owner->GetStat(STAT_STAMINA)) * mod; float ownerBonus = float(owner->GetStat(STAT_STAMINA)) * mod;
amount += ownerBonus; amount += ownerBonus;
} }
} }
}
}
void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {