mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
[svn] Provide creature dual wield support.
Update glancing damage formula. Do not daze creatures when other creatures attack from the back (need to find a better way). Fix the damage calculation of +damage aura. --HG-- branch : trunk
This commit is contained in:
@@ -666,6 +666,7 @@ bool Creature::UpdateAllStats()
|
||||
{
|
||||
UpdateMaxHealth();
|
||||
UpdateAttackPowerAndDamage();
|
||||
UpdateAttackPowerAndDamage(true);
|
||||
|
||||
for(int i = POWER_MANA; i < MAX_POWERS; ++i)
|
||||
UpdateMaxPower(Powers(i));
|
||||
@@ -709,35 +710,62 @@ void Creature::UpdateMaxPower(Powers power)
|
||||
|
||||
void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
if(ranged)
|
||||
return;
|
||||
|
||||
//automatically update weapon damage after attack power modification
|
||||
UpdateDamagePhysical(BASE_ATTACK);
|
||||
if(ranged)
|
||||
UpdateDamagePhysical(RANGED_ATTACK);
|
||||
else
|
||||
{
|
||||
UpdateDamagePhysical(BASE_ATTACK);
|
||||
UpdateDamagePhysical(OFF_ATTACK);
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::UpdateDamagePhysical(WeaponAttackType attType)
|
||||
{
|
||||
if(attType > BASE_ATTACK)
|
||||
return;
|
||||
UnitMods unitMod;
|
||||
switch(attType)
|
||||
{
|
||||
case BASE_ATTACK:
|
||||
default:
|
||||
unitMod = UNIT_MOD_DAMAGE_MAINHAND;
|
||||
break;
|
||||
case OFF_ATTACK:
|
||||
unitMod = UNIT_MOD_DAMAGE_OFFHAND;
|
||||
break;
|
||||
case RANGED_ATTACK:
|
||||
unitMod = UNIT_MOD_DAMAGE_RANGED;
|
||||
break;
|
||||
}
|
||||
|
||||
UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND;
|
||||
|
||||
float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f;
|
||||
float att_speed = float(GetAttackTime(attType))/1000.0f;
|
||||
|
||||
float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed;
|
||||
float base_pct = GetModifierValue(unitMod, BASE_PCT);
|
||||
float total_value = GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
float total_pct = GetModifierValue(unitMod, TOTAL_PCT);
|
||||
|
||||
float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE);
|
||||
float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE);
|
||||
float weapon_mindamage = GetWeaponDamageRange(attType, MINDAMAGE);
|
||||
float weapon_maxdamage = GetWeaponDamageRange(attType, MAXDAMAGE);
|
||||
|
||||
float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct ;
|
||||
float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct ;
|
||||
|
||||
SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage);
|
||||
switch(attType)
|
||||
{
|
||||
case BASE_ATTACK:
|
||||
default:
|
||||
SetStatFloatValue(UNIT_FIELD_MINDAMAGE,mindamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXDAMAGE,maxdamage);
|
||||
break;
|
||||
case OFF_ATTACK:
|
||||
SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE,mindamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE,maxdamage);
|
||||
break;
|
||||
case RANGED_ATTACK:
|
||||
SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,mindamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,maxdamage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*#######################################
|
||||
|
||||
Reference in New Issue
Block a user