Created
January 10, 2010 21:48
-
-
Save pasdVn/273799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 643e49fa788c43be00e5a3a9495d46bfd5b8f3a7 Mon Sep 17 00:00:00 2001 | |
From: pasdVn <[email protected]> | |
Date: Fri, 2 Oct 2009 20:36:48 +0200 | |
Subject: [PATCH 3/6] fixed hunter pet happiness damage mod | |
* the damage modifier will also be applied to damage from spells now | |
* additionally added the creature-rank based pct bonus damge for | |
not-weapon-based-spells to Unit::MeleeDamageBonus() | |
--- | |
src/game/Pet.cpp | 23 +++++++++++++++++++++++ | |
src/game/Pet.h | 1 + | |
src/game/StatSystem.cpp | 23 +---------------------- | |
src/game/Unit.cpp | 22 +++++++++++++++++++--- | |
4 files changed, 44 insertions(+), 25 deletions(-) | |
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp | |
index d67d9a9..4ad8aca 100644 | |
--- a/src/game/Pet.cpp | |
+++ b/src/game/Pet.cpp | |
@@ -622,6 +622,29 @@ HappinessState Pet::GetHappinessState() | |
return CONTENT; | |
} | |
+float Pet::GetHappinessDamageMod() | |
+{ | |
+ if (getPetType() != HUNTER_PET) | |
+ return 1.0f; | |
+ else | |
+ { | |
+ switch(GetHappinessState()) | |
+ { | |
+ case HAPPY: | |
+ // 125% of normal damage | |
+ return 1.25f; | |
+ case CONTENT: | |
+ // 100% of normal damage | |
+ return 1.0f; | |
+ case UNHAPPY: | |
+ // 75% of normal damage | |
+ return 0.75f; | |
+ default: | |
+ return 1.0f; | |
+ } | |
+ } | |
+} | |
+ | |
bool Pet::CanTakeMoreActiveSpells(uint32 spellid) | |
{ | |
uint8 activecount = 1; | |
diff --git a/src/game/Pet.h b/src/game/Pet.h | |
index b58731b..ff72a38 100644 | |
--- a/src/game/Pet.h | |
+++ b/src/game/Pet.h | |
@@ -180,6 +180,7 @@ class Pet : public Creature | |
int32 GetBonusDamage() { return m_bonusdamage; } | |
void SetBonusDamage(int32 damage) { m_bonusdamage = damage; } | |
+ float GetHappinessDamageMod(); | |
bool UpdateStats(Stats stat); | |
bool UpdateAllStats(); | |
diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp | |
index 8a829cb..b625945 100644 | |
--- a/src/game/StatSystem.cpp | |
+++ b/src/game/StatSystem.cpp | |
@@ -977,7 +977,7 @@ void Pet::UpdateDamagePhysical(WeaponAttackType attType) | |
float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; | |
float base_pct = GetModifierValue(unitMod, BASE_PCT); | |
float total_value = GetModifierValue(unitMod, TOTAL_VALUE); | |
- float total_pct = GetModifierValue(unitMod, TOTAL_PCT); | |
+ float total_pct = GetModifierValue(unitMod, TOTAL_PCT) * GetHappinessDamageMod(); | |
float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); | |
float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); | |
@@ -985,27 +985,6 @@ void Pet::UpdateDamagePhysical(WeaponAttackType attType) | |
float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct; | |
float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct; | |
- // Pet's base damage changes depending on happiness | |
- if (getPetType() == HUNTER_PET && attType == BASE_ATTACK) | |
- { | |
- switch(GetHappinessState()) | |
- { | |
- case HAPPY: | |
- // 125% of normal damage | |
- mindamage = mindamage * 1.25f; | |
- maxdamage = maxdamage * 1.25f; | |
- break; | |
- case CONTENT: | |
- // 100% of normal damage, nothing to modify | |
- break; | |
- case UNHAPPY: | |
- // 75% of normal damage | |
- mindamage = mindamage * 0.75f; | |
- maxdamage = maxdamage * 0.75f; | |
- break; | |
- } | |
- } | |
- | |
SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage); | |
SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage); | |
} | |
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp | |
index e3aedb6..e2e15e1 100644 | |
--- a/src/game/Unit.cpp | |
+++ b/src/game/Unit.cpp | |
@@ -8976,9 +8976,16 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u | |
float DoneTotalMod = 1.0f; | |
int32 DoneTotal = 0; | |
- // Creature damage | |
- if( GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet() ) | |
- DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); | |
+ // ..done | |
+ | |
+ // creature and pet bonus mods | |
+ if (GetTypeId() == TYPEID_UNIT) | |
+ { | |
+ if (!((Creature*)this)->isPet()) | |
+ DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); | |
+ else | |
+ DoneTotalMod *= ((Pet*)this)->GetHappinessDamageMod(); | |
+ } | |
if (!(spellProto->AttributesEx6 & SPELL_ATTR_EX6_NO_DMG_PERCENT_MODS)) | |
{ | |
@@ -10031,6 +10038,15 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType | |
if (attType == OFF_ATTACK) | |
DonePercent *= GetModifierValue(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT); // no school check required | |
+ | |
+ // creature and pet bonus mods | |
+ if (GetTypeId() == TYPEID_UNIT) | |
+ { | |
+ if (!((Creature*)this)->isPet()) | |
+ DonePercent *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); | |
+ else | |
+ DonePercent *= ((Pet*)this)->GetHappinessDamageMod(); | |
+ } | |
} | |
// ..done pct (by creature type mask) | |
-- | |
1.6.5.1.1367.gcd48 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment