Skip to content

Commit

Permalink
[12199] Fix health regeneration.
Browse files Browse the repository at this point in the history
Author: @Northstrider

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

Signed-off-by: Yaki Khadafi <elsoldollo@gmail.com>
  • Loading branch information
Zakamurite committed Sep 8, 2012
1 parent 915b773 commit 29d1817
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/game/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ DBCStorage <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore(GtChanceToMe
DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt);
DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt);
DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore(GtOCTClassCombatRatingScalarfmt);
//DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt);
//DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently
DBCStorage <GtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore(GtOCTHpPerStaminafmt);
DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt);
DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore(GtSpellScalingfmt);
DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt);
Expand Down Expand Up @@ -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,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,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtSpellScalingStore, dbcPath,"gtSpellScaling.dbc"); // 15595
Expand Down
2 changes: 1 addition & 1 deletion src/game/DBCStores.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ extern DBCStorage <GtChanceToMeleeCritEntry> sGtChanceToMeleeCritStore;
extern DBCStorage <GtChanceToSpellCritBaseEntry> sGtChanceToSpellCritBaseStore;
extern DBCStorage <GtChanceToSpellCritEntry> sGtChanceToSpellCritStore;
extern DBCStorage <GtOCTClassCombatRatingScalarEntry> sGtOCTClassCombatRatingScalarStore;
//extern DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore;
//extern DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore; -- not used currently
extern DBCStorage <GtOCTHpPerStaminaEntry> sGtOCTHpPerStaminaStore;
extern DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore;
extern DBCStorage <GtSpellScalingEntry> sGtSpellScalingStore;
extern DBCStorage <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore;
Expand Down
15 changes: 2 additions & 13 deletions src/game/DBCStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,22 +1046,11 @@ struct GtOCTClassCombatRatingScalarEntry
float ratio;
};

/*struct GtOCTRegenHPEntry
struct GtOCTHpPerStaminaEntry
{
//uint32 level;
float ratio;
};*/

//struct GtOCTRegenMPEntry
//{
// float ratio;
//};

/*struct GtRegenHPPerSptEntry
{
//uint32 level;
float ratio;
};*/
};

struct GtRegenMPPerSptEntry
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/DBCfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const char GtChanceToMeleeCritfmt[]="xf";
const char GtChanceToSpellCritBasefmt[]="xf";
const char GtOCTClassCombatRatingScalarfmt[]="df";
const char GtChanceToSpellCritfmt[]="xf";
const char GtOCTHpPerStaminafmt[]="df";
const char GtOCTRegenHPfmt[]="xf";
//const char GtOCTRegenMPfmt[]="f";
const char GtRegenHPPerSptfmt[]="xf";
const char GtRegenMPPerSptfmt[]="xf";
const char GtSpellScalingfmt[]="df";
Expand Down
44 changes: 20 additions & 24 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_

m_baseSpellPower = 0;
m_baseFeralAP = 0;
m_baseHealthRegen = 0;
m_baseManaRegen = 0;
m_armorPenetrationPct = 0.0f;
m_spellPenetrationItemMod = 0;
Expand Down Expand Up @@ -2059,7 +2060,7 @@ void Player::RegenerateAll(uint32 diff)
{
// Not in combat or they have regeneration
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);
if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN))
Expand Down Expand Up @@ -2204,23 +2205,32 @@ void Player::RegenerateHealth(uint32 diff)
// normal regen case (maybe partly in combat case)
else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT))
{
addvalue = OCTRegenHPPerSpirit() * HealthIncreaseRate;
addvalue = HealthIncreaseRate;
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);
for (AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i)
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))
addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f;

if (!IsStandState())
addvalue *= 1.5;
addvalue *= 1.33f;
}

// always regeneration bonus (including combat)
addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT);

addvalue += m_baseHealthRegen / 2.5f;

if (addvalue < 0)
addvalue = 0;

Expand Down Expand Up @@ -5237,27 +5247,6 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
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()
{
uint32 level = getLevel();
Expand Down Expand Up @@ -7103,6 +7092,9 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl
case ITEM_MOD_SPELL_POWER:
ApplySpellPowerBonus(int32(val), apply);
break;
case ITEM_MOD_HEALTH_REGEN:
ApplyHealthRegenBonus(int32(val), apply);
break;
case ITEM_MOD_SPELL_PENETRATION:
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -int32(val), apply);
m_spellPenetrationItemMod += apply ? val : -val;
Expand Down Expand Up @@ -12535,6 +12527,10 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
ApplySpellPowerBonus(enchant_amount, apply);
DEBUG_LOG("+ %u SPELL_POWER", enchant_amount);
break;
case ITEM_MOD_HEALTH_REGEN:
ApplyHealthRegenBonus(enchant_amount, apply);
DEBUG_LOG("+ %u HEALTH_REGENERATION", enchant_amount);
break;
case ITEM_MOD_SPELL_PENETRATION:
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -int32(enchant_amount), apply);
m_spellPenetrationItemMod += apply ? enchant_amount : -int32(enchant_amount);
Expand Down
3 changes: 2 additions & 1 deletion src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,6 @@ class MANGOS_DLL_SPEC Player : public Unit
float GetMeleeCritFromAgility();
void GetDodgeFromAgility(float& diminishing, float& nondiminishing);
float GetSpellCritFromIntellect();
float OCTRegenHPPerSpirit();
float OCTRegenMPPerSpirit();
float GetRatingMultiplier(CombatRating cr) const;
float GetRatingBonusValue(CombatRating cr) const;
Expand All @@ -1842,6 +1841,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void UpdateExpertise(WeaponAttackType attType);
void UpdateArmorPenetration();
void ApplyManaRegenBonus(int32 amount, bool apply);
void ApplyHealthRegenBonus(int32 amount, bool apply);
void UpdateManaRegen();
void UpdateMasteryAuras();

Expand Down Expand Up @@ -2534,6 +2534,7 @@ class MANGOS_DLL_SPEC Player : public Unit
uint16 m_baseSpellPower;
uint16 m_baseFeralAP;
uint16 m_baseManaRegen;
uint32 m_baseHealthRegen;
float m_armorPenetrationPct;
int32 m_spellPenetrationItemMod;

Expand Down
11 changes: 10 additions & 1 deletion src/game/StatSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,16 @@ void Player::UpdateArmor()

float Player::GetHealthBonusFromStamina()
{
GtOCTHpPerStaminaEntry const* hpBase = sGtOCTHpPerStaminaStore.LookupEntry((getClass() - 1) * GT_MAX_LEVEL + getLevel() - 1);

float stamina = GetStat(STAT_STAMINA);

float baseStam = stamina < 20 ? stamina : 20;
float moreStam = stamina - baseStam;
if (moreStam < 0.0f)
moreStam = 0.0f;

return baseStam + (moreStam * 10.0f);
return baseStam + moreStam * hpBase->ratio;
}

float Player::GetManaBonusFromIntellect()
Expand Down Expand Up @@ -741,6 +745,11 @@ void Player::ApplyManaRegenBonus(int32 amount, bool apply)
UpdateManaRegen();
}

void Player::ApplyHealthRegenBonus(int32 amount, bool apply)
{
m_baseHealthRegen += apply ? amount : -amount;
}

void Player::UpdateManaRegen()
{
float Intellect = GetStat(STAT_INTELLECT);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12198"
#define REVISION_NR "12199"
#endif // __REVISION_NR_H__

0 comments on commit 29d1817

Please sign in to comment.