[7263] Fixed AP calculation in some cases
Fixed use AP dynamic mods (bonuses from stats)
Apply ITEM_MOD_ATTACK_POWER for ranged AP
Implement feral AP from weapon dps for druids
Signed-off-by: DiSlord <[email protected]>
--HG--
branch : trunk
This commit is contained in:
@@ -110,6 +110,7 @@ enum ITEM_FLAGS
|
||||
ITEM_FLAGS_WRAPPER = 0x00000200, // used or not used wrapper
|
||||
ITEM_FLAGS_PARTY_LOOT = 0x00000800, // determines if item is party loot or not
|
||||
ITEM_FLAGS_CHARTER = 0x00002000, // arena/guild charter
|
||||
ITEM_FLAGS_PROSPECTABLE = 0x00040000,
|
||||
ITEM_FLAGS_UNIQUE_EQUIPPED = 0x00080000,
|
||||
ITEM_FLAGS_USEABLE_IN_ARENA = 0x00200000,
|
||||
ITEM_FLAGS_THROWABLE = 0x00400000, // not used in game for check trow possibility, only for item in game tooltip
|
||||
|
||||
+15
-1
@@ -6920,6 +6920,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl
|
||||
break;
|
||||
case ITEM_MOD_ATTACK_POWER:
|
||||
HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(val), apply);
|
||||
HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
|
||||
break;
|
||||
case ITEM_MOD_RANGED_ATTACK_POWER:
|
||||
HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply);
|
||||
@@ -6997,7 +6998,19 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl
|
||||
SetBaseWeaponDamage(attType, MAXDAMAGE, damage);
|
||||
}
|
||||
|
||||
if(IsInFeralForm())
|
||||
if (proto->Class == ITEM_CLASS_WEAPON && proto->Delay)
|
||||
{
|
||||
// Druids get feral AP bonus from weapon dps
|
||||
if(getClass() == CLASS_DRUID && (slot==EQUIPMENT_SLOT_MAINHAND || slot==EQUIPMENT_SLOT_OFFHAND))
|
||||
{
|
||||
float dps = (proto->Damage[0].DamageMin + proto->Damage[0].DamageMax)/(2*proto->Delay/1000.0f);
|
||||
int32 feral_bonus = int32(dps*14.0f) - 767;
|
||||
if (feral_bonus > 0)
|
||||
ApplyFeralAPBonus(feral_bonus, apply);
|
||||
}
|
||||
}
|
||||
|
||||
if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND))
|
||||
return;
|
||||
|
||||
if (proto->Delay)
|
||||
@@ -12377,6 +12390,7 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a
|
||||
break;
|
||||
case ITEM_MOD_ATTACK_POWER:
|
||||
HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(enchant_amount), apply);
|
||||
HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply);
|
||||
sLog.outDebug("+ %u ATTACK_POWER", enchant_amount);
|
||||
break;
|
||||
case ITEM_MOD_RANGED_ATTACK_POWER:
|
||||
|
||||
@@ -801,6 +801,27 @@ void Creature::UpdateMaxPower(Powers power)
|
||||
|
||||
void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
|
||||
|
||||
uint16 index = UNIT_FIELD_ATTACK_POWER;
|
||||
uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS;
|
||||
uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;
|
||||
|
||||
if(ranged)
|
||||
{
|
||||
index = UNIT_FIELD_RANGED_ATTACK_POWER;
|
||||
index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
|
||||
index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
|
||||
}
|
||||
|
||||
float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
|
||||
float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;
|
||||
|
||||
SetUInt32Value(index, (uint32)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field
|
||||
SetUInt32Value(index_mod, (uint32)attPowerMod); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
|
||||
SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
|
||||
|
||||
//automatically update weapon damage after attack power modification
|
||||
if(ranged)
|
||||
UpdateDamagePhysical(RANGED_ATTACK);
|
||||
|
||||
+5
-12
@@ -10393,23 +10393,16 @@ Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const
|
||||
|
||||
float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const
|
||||
{
|
||||
//get value from unit field instead of calculating from mods-because mods from stat are not added to unit_mods
|
||||
int32 index, index_mod, index_mult;
|
||||
if (attType == RANGED_ATTACK)
|
||||
{
|
||||
index=UNIT_FIELD_RANGED_ATTACK_POWER;
|
||||
index_mod=UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
|
||||
index_mult=UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
|
||||
uint32 ap = GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS);
|
||||
return ap * (1.0f + GetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER));
|
||||
}
|
||||
else //meele
|
||||
else
|
||||
{
|
||||
index=UNIT_FIELD_ATTACK_POWER;
|
||||
index_mod=UNIT_FIELD_ATTACK_POWER_MODS;
|
||||
index_mult=UNIT_FIELD_ATTACK_POWER_MULTIPLIER;
|
||||
uint32 ap = GetInt32Value(UNIT_FIELD_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS);
|
||||
return ap * (1.0f + GetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER));
|
||||
}
|
||||
|
||||
float val = float(GetUInt32Value(index) + GetUInt32Value(index_mod)) * float(GetFloatValue(index_mult)+1);
|
||||
return (val < 0.0f)? 0.0f : val;
|
||||
}
|
||||
|
||||
float Unit::GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const
|
||||
|
||||
Reference in New Issue
Block a user