mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Items: use the min and max damage columns from item.db2 to determine weapon damage
This commit is contained in:
@@ -1987,8 +1987,8 @@ struct ItemEntry
|
||||
int32 ScalingStatValue;
|
||||
std::array<uint8, 5> DamageType;
|
||||
std::array<int16, 7> Resistances;
|
||||
std::array<uint16, 5> MinDamage;
|
||||
std::array<uint16, 5> MaxDamage;
|
||||
std::array<uint16, MAX_ITEM_PROTO_DAMAGES> MinDamage;
|
||||
std::array<uint16, MAX_ITEM_PROTO_DAMAGES> MaxDamage;
|
||||
};
|
||||
|
||||
struct ItemAppearanceEntry
|
||||
|
||||
@@ -949,6 +949,7 @@ enum class GlobalCurve : int32
|
||||
#define MAX_ITEM_PROTO_ZONES 2
|
||||
#define MAX_ITEM_PROTO_SOCKETS 3
|
||||
#define MAX_ITEM_PROTO_STATS 10
|
||||
static constexpr uint8 const MAX_ITEM_PROTO_DAMAGES = 5;
|
||||
|
||||
enum GlyphSlotType
|
||||
{
|
||||
|
||||
@@ -828,6 +828,8 @@ struct TC_GAME_API ItemTemplate
|
||||
int16 GetShieldBlockValue(uint32 itemLevel) const;
|
||||
uint16 GetScalingStatDistributionID() const { return ExtendedData->ScalingStatDistributionID; }
|
||||
int32 GetScalingStatValue() const { return BasicData->ScalingStatValue; }
|
||||
uint16 GetMinDamage(uint8 index) const { return BasicData->MinDamage[index]; }
|
||||
uint16 GetMaxDamage(uint8 index) const { return BasicData->MaxDamage[index]; }
|
||||
|
||||
uint32 MaxDurability;
|
||||
std::vector<ItemEffectEntry const*> Effects;
|
||||
|
||||
@@ -8033,22 +8033,40 @@ void Player::_ApplyWeaponDamage(uint8 slot, Item* item, bool apply)
|
||||
if (!IsInFeralForm() && apply && !CanUseAttackType(attType))
|
||||
return;
|
||||
|
||||
static constexpr uint8 const MAX_ITEM_PROTO_DAMAGES = 5;
|
||||
ScalingStatDistributionEntry const* ssd = sScalingStatDistributionStore.LookupEntry(proto->GetScalingStatDistributionID());
|
||||
ScalingStatValuesEntry const* ssv = (ssd && proto->GetScalingStatValue() != 0) ? sDB2Manager.GetScalingStatValuesForLevel(std::clamp<uint32>(GetLevel(), ssd->MinLevel, ssd->MaxLevel)) : nullptr;
|
||||
|
||||
float damage = 0.0f;
|
||||
float minDamage, maxDamage;
|
||||
proto->GetDamage(minDamage, maxDamage);
|
||||
|
||||
if (minDamage > 0)
|
||||
//for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
|
||||
{
|
||||
damage = apply ? minDamage : BASE_MINDAMAGE;
|
||||
SetBaseWeaponDamage(attType, MINDAMAGE, damage);
|
||||
}
|
||||
float minDamage = proto->GetMinDamage(0);
|
||||
float maxDamage = proto->GetMaxDamage(0);
|
||||
|
||||
if (maxDamage > 0)
|
||||
{
|
||||
damage = apply ? maxDamage : BASE_MAXDAMAGE;
|
||||
SetBaseWeaponDamage(attType, MAXDAMAGE, damage);
|
||||
// If set dpsMod in ScalingStatValue use it for min (70% from average), max (130% from average) damage
|
||||
if (ssv)
|
||||
{
|
||||
int32 extraDPS = ssv->getDPSMod(proto->GetScalingStatValue());
|
||||
if (extraDPS)
|
||||
{
|
||||
float average = extraDPS * proto->GetDelay() / 1000.0f;
|
||||
float mod = ssv->isTwoHand(proto->GetScalingStatValue()) ? 0.2f : 0.3f;
|
||||
|
||||
minDamage = (1.0f - mod) * average;
|
||||
maxDamage = (1.0f + mod) * average;
|
||||
}
|
||||
}
|
||||
|
||||
if (minDamage > 0)
|
||||
{
|
||||
damage = apply ? minDamage : BASE_MINDAMAGE;
|
||||
SetBaseWeaponDamage(attType, MINDAMAGE, damage);
|
||||
}
|
||||
|
||||
if (maxDamage > 0)
|
||||
{
|
||||
damage = apply ? maxDamage : BASE_MAXDAMAGE;
|
||||
SetBaseWeaponDamage(attType, MAXDAMAGE, damage);
|
||||
}
|
||||
}
|
||||
|
||||
SpellShapeshiftFormEntry const* shapeshift = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
|
||||
|
||||
Reference in New Issue
Block a user