Skip to content

Commit

Permalink
Core/Stats: Fixed feral melee damage calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shauren committed Aug 15, 2016
1 parent 59cb674 commit 4a6cf1b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
5 changes: 3 additions & 2 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -7501,7 +7501,8 @@ void Player::_ApplyWeaponDamage(uint8 slot, Item* item, bool apply)
SetBaseWeaponDamage(attType, MAXDAMAGE, damage);
}

if (proto->GetDelay() && !IsInFeralForm())
SpellShapeshiftFormEntry const* shapeshift = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
if (proto->GetDelay() && !(shapeshift && shapeshift->CombatRoundTime))
SetAttackTime(attType, apply ? proto->GetDelay() : BASE_ATTACK_TIME);

if (CanModifyStats() && (damage || proto->GetDelay()))
Expand Down Expand Up @@ -9682,7 +9683,7 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f
if (!useable)
return item;

if (item->IsBroken() || IsInFeralForm())
if (item->IsBroken())
return nullptr;

return item;
Expand Down
30 changes: 6 additions & 24 deletions src/server/game/Entities/Unit/StatSystem.cpp
Expand Up @@ -408,32 +408,21 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
break;
}

float attackSpeedMod = GetAPMultiplier(attType, normalized);
float attackPowerMod = GetAPMultiplier(attType, normalized);

float baseValue = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 3.5f * attackSpeedMod;
float baseValue = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 3.5f * attackPowerMod;
float basePct = GetModifierValue(unitMod, BASE_PCT);
float totalValue = GetModifierValue(unitMod, TOTAL_VALUE);
float totalPct = addTotalPct ? GetModifierValue(unitMod, TOTAL_PCT) : 1.0f;

float weaponMinDamage = GetWeaponDamageRange(attType, MINDAMAGE);
float weaponMaxDamage = GetWeaponDamageRange(attType, MAXDAMAGE);

if (IsInFeralForm()) // check if player is druid and in cat or bear forms
SpellShapeshiftFormEntry const* shapeshift = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
if (shapeshift && shapeshift->CombatRoundTime)
{
float weaponSpeed = BASE_ATTACK_TIME / 1000.f;
if (Item* weapon = GetWeaponForAttack(BASE_ATTACK, true))
weaponSpeed = weapon->GetTemplate()->GetDelay() / 1000;

if (GetShapeshiftForm() == FORM_CAT_FORM)
{
weaponMinDamage = weaponMinDamage / weaponSpeed;
weaponMaxDamage = weaponMaxDamage / weaponSpeed;
}
else if (GetShapeshiftForm() == FORM_BEAR_FORM)
{
weaponMinDamage = weaponMinDamage / weaponSpeed + weaponMinDamage / 2.5;
weaponMaxDamage = weaponMinDamage / weaponSpeed + weaponMaxDamage / 2.5;
}
weaponMinDamage = weaponMinDamage * shapeshift->CombatRoundTime / 1000.0f / attackPowerMod;
weaponMaxDamage = weaponMaxDamage * shapeshift->CombatRoundTime / 1000.0f / attackPowerMod;
}
else if (!CanUseAttackType(attType)) // check if player not in form but still can't use (disarm case)
{
Expand All @@ -447,13 +436,6 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
weaponMinDamage = BASE_MINDAMAGE;
weaponMaxDamage = BASE_MAXDAMAGE;
}
/*
TODO: Is this still needed after ammo has been removed?
else if (attType == RANGED_ATTACK) // add ammo DPS to ranged damage
{
weaponMinDamage += GetAmmoDPS() * attackSpeedMod;
weaponMaxDamage += GetAmmoDPS() * attackSpeedMod;
}*/

minDamage = ((weaponMinDamage + baseValue) * basePct + totalValue) * totalPct;
maxDamage = ((weaponMaxDamage + baseValue) * basePct + totalValue) * totalPct;
Expand Down
17 changes: 10 additions & 7 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -10679,7 +10679,7 @@ void Unit::SetShapeshiftForm(ShapeshiftForm form)
bool Unit::IsInFeralForm() const
{
ShapeshiftForm form = GetShapeshiftForm();
return form == FORM_CAT_FORM || form == FORM_BEAR_FORM;
return form == FORM_CAT_FORM || form == FORM_BEAR_FORM || form == FORM_DIRE_BEAR_FORM || form == FORM_GHOST_WOLF;
}

bool Unit::IsInDisallowedMountForm() const
Expand Down Expand Up @@ -12593,14 +12593,17 @@ float Unit::CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffect

float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
{
if (!normalized || GetTypeId() != TYPEID_PLAYER)
return float(GetAttackTime(attType)) / 1000.0f;
if (GetTypeId() != TYPEID_PLAYER)
return GetAttackTime(attType) / 1000.0f;

Item* weapon = ToPlayer()->GetWeaponForAttack(attType, true);
if (!normalized)
return (weapon ? weapon->GetTemplate()->GetDelay() : BASE_ATTACK_TIME) / 1000.0f;

Item* Weapon = ToPlayer()->GetWeaponForAttack(attType, true);
if (!Weapon)
if (!weapon)
return 2.4f; // fist attack

switch (Weapon->GetTemplate()->GetInventoryType())
switch (weapon->GetTemplate()->GetInventoryType())
{
case INVTYPE_2HWEAPON:
return 3.3f;
Expand All @@ -12612,7 +12615,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
case INVTYPE_WEAPONMAINHAND:
case INVTYPE_WEAPONOFFHAND:
default:
return Weapon->GetTemplate()->GetSubClass() == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f;
return weapon->GetTemplate()->GetSubClass() == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f;
}
}

Expand Down

0 comments on commit 4a6cf1b

Please sign in to comment.