[12199] Fix health regeneration.

Author: @NorthStrider

Fix HP scaling from stamina. Author: @Subv
Fix HP regen bonus from items.

Signed-off-by: Yaki Khadafi <elsoldollo@gmail.com>
This commit is contained in:
Yaki Khadafi 2012-09-08 20:47:45 +03:00 committed by Antz
parent 8e84b0ff71
commit f552049968
8 changed files with 39 additions and 44 deletions

View file

@ -107,8 +107,8 @@ DBCStorage <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore(GtChanceToMe
DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt); DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt);
DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt); DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt);
DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore(GtOCTClassCombatRatingScalarfmt); DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore(GtOCTClassCombatRatingScalarfmt);
//DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt);
//DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently //DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently
DBCStorage <GtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore(GtOCTHpPerStaminafmt);
DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt); DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt);
DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore(GtSpellScalingfmt); DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore(GtSpellScalingfmt);
DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt); DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt);
@ -517,7 +517,7 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritStore, dbcPath,"gtChanceToSpellCrit.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritStore, dbcPath,"gtChanceToSpellCrit.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTClassCombatRatingScalarStore,dbcPath,"gtOCTClassCombatRatingScalar.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTClassCombatRatingScalarStore,dbcPath,"gtOCTClassCombatRatingScalar.dbc");
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenHPStore, dbcPath,"gtOCTRegenHP.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTHpPerStaminaStore, dbcPath,"gtOCTHpPerStamina.dbc");
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtSpellScalingStore, dbcPath,"gtSpellScaling.dbc"); // 15595 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtSpellScalingStore, dbcPath,"gtSpellScaling.dbc"); // 15595

View file

@ -143,8 +143,8 @@ extern DBCStorage <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore;
extern DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore; extern DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore;
extern DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore; extern DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore;
extern DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore; extern DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore;
//extern DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore;
//extern DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore; -- not used currently //extern DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore; -- not used currently
extern DBCStorage <GtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore;
extern DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore; extern DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore;
extern DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore; extern DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore;
extern DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore; extern DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore;

View file

@ -1046,22 +1046,11 @@ struct GtOCTClassCombatRatingScalarEntry
float ratio; float ratio;
}; };
/*struct GtOCTRegenHPEntry struct GtOCTHpPerStaminaEntry
{ {
//uint32 level; //uint32 level;
float ratio; float ratio;
};*/ };
//struct GtOCTRegenMPEntry
//{
// float ratio;
//};
/*struct GtRegenHPPerSptEntry
{
//uint32 level;
float ratio;
};*/
struct GtRegenMPPerSptEntry struct GtRegenMPPerSptEntry
{ {

View file

@ -61,8 +61,8 @@ const char GtChanceToMeleeCritfmt[]="xf";
const char GtChanceToSpellCritBasefmt[]="xf"; const char GtChanceToSpellCritBasefmt[]="xf";
const char GtOCTClassCombatRatingScalarfmt[]="df"; const char GtOCTClassCombatRatingScalarfmt[]="df";
const char GtChanceToSpellCritfmt[]="xf"; const char GtChanceToSpellCritfmt[]="xf";
const char GtOCTHpPerStaminafmt[]="df";
const char GtOCTRegenHPfmt[]="xf"; const char GtOCTRegenHPfmt[]="xf";
//const char GtOCTRegenMPfmt[]="f";
const char GtRegenHPPerSptfmt[]="xf"; const char GtRegenHPPerSptfmt[]="xf";
const char GtRegenMPPerSptfmt[]="xf"; const char GtRegenMPPerSptfmt[]="xf";
const char GtSpellScalingfmt[]="df"; const char GtSpellScalingfmt[]="df";

View file

@ -550,6 +550,7 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_baseSpellPower = 0; m_baseSpellPower = 0;
m_baseFeralAP = 0; m_baseFeralAP = 0;
m_baseHealthRegen = 0;
m_baseManaRegen = 0; m_baseManaRegen = 0;
m_armorPenetrationPct = 0.0f; m_armorPenetrationPct = 0.0f;
m_spellPenetrationItemMod = 0; m_spellPenetrationItemMod = 0;
@ -2059,7 +2060,7 @@ void Player::RegenerateAll(uint32 diff)
{ {
// Not in combat or they have regeneration // Not in combat or they have regeneration
if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) || if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) ||
HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed()) HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed() || m_baseHealthRegen)
{ {
RegenerateHealth(diff); RegenerateHealth(diff);
if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN))
@ -2204,23 +2205,32 @@ void Player::RegenerateHealth(uint32 diff)
// normal regen case (maybe partly in combat case) // normal regen case (maybe partly in combat case)
else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT))
{ {
addvalue = OCTRegenHPPerSpirit() * HealthIncreaseRate; addvalue = HealthIncreaseRate;
if (!isInCombat()) if (!isInCombat())
{ {
if (getLevel() < 15)
addvalue = 0.20f * GetMaxHealth() * addvalue / getLevel();
else
addvalue = 0.015f * GetMaxHealth() * addvalue;
AuraList const& mModHealthRegenPct = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT); AuraList const& mModHealthRegenPct = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT);
for (AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i) for (AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i)
addvalue *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; addvalue *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f;
addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_REGEN) * 2.0f / 5.0f;
} }
else if (HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) else if (HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT))
addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f; addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f;
if (!IsStandState()) if (!IsStandState())
addvalue *= 1.5; addvalue *= 1.33f;
} }
// always regeneration bonus (including combat) // always regeneration bonus (including combat)
addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT); addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT);
addvalue += m_baseHealthRegen / 2.5f;
if (addvalue < 0) if (addvalue < 0)
addvalue = 0; addvalue = 0;
@ -5237,27 +5247,6 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
return 0.0f; return 0.0f;
} }
float Player::OCTRegenHPPerSpirit()
{
//uint32 level = getLevel();
//uint32 pclass = getClass();
//if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL;
//GtOCTRegenHPEntry const *baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
//GtRegenHPPerSptEntry const *moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
//if (baseRatio==NULL || moreRatio==NULL)
return 0.0f;
// Formula from PaperDollFrame script
//float spirit = GetStat(STAT_SPIRIT);
//float baseSpirit = spirit;
//if (baseSpirit>50) baseSpirit = 50;
//float moreSpirit = spirit - baseSpirit;
//float regen = baseSpirit * baseRatio->ratio + moreSpirit * moreRatio->ratio;
//return regen;
}
float Player::OCTRegenMPPerSpirit() float Player::OCTRegenMPPerSpirit()
{ {
uint32 level = getLevel(); uint32 level = getLevel();
@ -7103,6 +7092,9 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl
case ITEM_MOD_SPELL_POWER: case ITEM_MOD_SPELL_POWER:
ApplySpellPowerBonus(int32(val), apply); ApplySpellPowerBonus(int32(val), apply);
break; break;
case ITEM_MOD_HEALTH_REGEN:
ApplyHealthRegenBonus(int32(val), apply);
break;
case ITEM_MOD_SPELL_PENETRATION: case ITEM_MOD_SPELL_PENETRATION:
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -int32(val), apply); ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -int32(val), apply);
m_spellPenetrationItemMod += apply ? val : -val; m_spellPenetrationItemMod += apply ? val : -val;
@ -12535,6 +12527,10 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
ApplySpellPowerBonus(enchant_amount, apply); ApplySpellPowerBonus(enchant_amount, apply);
DEBUG_LOG("+ %u SPELL_POWER", enchant_amount); DEBUG_LOG("+ %u SPELL_POWER", enchant_amount);
break; break;
case ITEM_MOD_HEALTH_REGEN:
ApplyHealthRegenBonus(enchant_amount, apply);
DEBUG_LOG("+ %u HEALTH_REGENERATION", enchant_amount);
break;
case ITEM_MOD_SPELL_PENETRATION: case ITEM_MOD_SPELL_PENETRATION:
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -int32(enchant_amount), apply); ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -int32(enchant_amount), apply);
m_spellPenetrationItemMod += apply ? enchant_amount : -int32(enchant_amount); m_spellPenetrationItemMod += apply ? enchant_amount : -int32(enchant_amount);

View file

@ -1821,7 +1821,6 @@ class MANGOS_DLL_SPEC Player : public Unit
float GetMeleeCritFromAgility(); float GetMeleeCritFromAgility();
void GetDodgeFromAgility(float& diminishing, float& nondiminishing); void GetDodgeFromAgility(float& diminishing, float& nondiminishing);
float GetSpellCritFromIntellect(); float GetSpellCritFromIntellect();
float OCTRegenHPPerSpirit();
float OCTRegenMPPerSpirit(); float OCTRegenMPPerSpirit();
float GetRatingMultiplier(CombatRating cr) const; float GetRatingMultiplier(CombatRating cr) const;
float GetRatingBonusValue(CombatRating cr) const; float GetRatingBonusValue(CombatRating cr) const;
@ -1842,6 +1841,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void UpdateExpertise(WeaponAttackType attType); void UpdateExpertise(WeaponAttackType attType);
void UpdateArmorPenetration(); void UpdateArmorPenetration();
void ApplyManaRegenBonus(int32 amount, bool apply); void ApplyManaRegenBonus(int32 amount, bool apply);
void ApplyHealthRegenBonus(int32 amount, bool apply);
void UpdateManaRegen(); void UpdateManaRegen();
void UpdateMasteryAuras(); void UpdateMasteryAuras();
@ -2534,6 +2534,7 @@ class MANGOS_DLL_SPEC Player : public Unit
uint16 m_baseSpellPower; uint16 m_baseSpellPower;
uint16 m_baseFeralAP; uint16 m_baseFeralAP;
uint16 m_baseManaRegen; uint16 m_baseManaRegen;
uint32 m_baseHealthRegen;
float m_armorPenetrationPct; float m_armorPenetrationPct;
int32 m_spellPenetrationItemMod; int32 m_spellPenetrationItemMod;

View file

@ -194,12 +194,16 @@ void Player::UpdateArmor()
float Player::GetHealthBonusFromStamina() float Player::GetHealthBonusFromStamina()
{ {
GtOCTHpPerStaminaEntry const* hpBase = sGtOCTHpPerStaminaStore.LookupEntry((getClass() - 1) * GT_MAX_LEVEL + getLevel() - 1);
float stamina = GetStat(STAT_STAMINA); float stamina = GetStat(STAT_STAMINA);
float baseStam = stamina < 20 ? stamina : 20; float baseStam = stamina < 20 ? stamina : 20;
float moreStam = stamina - baseStam; float moreStam = stamina - baseStam;
if (moreStam < 0.0f)
moreStam = 0.0f;
return baseStam + (moreStam * 10.0f); return baseStam + moreStam * hpBase->ratio;
} }
float Player::GetManaBonusFromIntellect() float Player::GetManaBonusFromIntellect()
@ -741,6 +745,11 @@ void Player::ApplyManaRegenBonus(int32 amount, bool apply)
UpdateManaRegen(); UpdateManaRegen();
} }
void Player::ApplyHealthRegenBonus(int32 amount, bool apply)
{
m_baseHealthRegen += apply ? amount : -amount;
}
void Player::UpdateManaRegen() void Player::UpdateManaRegen()
{ {
float Intellect = GetStat(STAT_INTELLECT); float Intellect = GetStat(STAT_INTELLECT);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12198" #define REVISION_NR "12199"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__