aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-02-11 11:51:17 -0600
committermegamage <none@none>2009-02-11 11:51:17 -0600
commit848af429189fe20fef67cbb09295c3ecd5b9fae6 (patch)
treeb69e91f3471eafefae863733df6dd6854f3be8c1 /src
parent8012f78d00ef29025397d2fe8a18dc1eb8876292 (diff)
[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 <dislord@nomail.com> --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/ItemPrototype.h1
-rw-r--r--src/game/Player.cpp16
-rw-r--r--src/game/StatSystem.cpp21
-rw-r--r--src/game/Unit.cpp17
-rw-r--r--src/shared/revision_nr.h2
5 files changed, 43 insertions, 14 deletions
diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
index 6e490dc2b49..07264f00043 100644
--- a/src/game/ItemPrototype.h
+++ b/src/game/ItemPrototype.h
@@ -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
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 210728eb777..da8e171eb5b 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -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:
diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp
index 3a98e215da7..6e81e8b3de0 100644
--- a/src/game/StatSystem.cpp
+++ b/src/game/StatSystem.cpp
@@ -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);
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index be764eaee3e..b74eec24ae7 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 342b2950b30..27a7f9b933c 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7262"
+ #define REVISION_NR "7263"
#endif // __REVISION_NR_H__