mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 16:10:49 +01:00
*Merge.
--HG-- branch : trunk
This commit is contained in:
@@ -3803,7 +3803,7 @@ bool ChatHandler::HandleDamageCommand(const char * args)
|
||||
SpellSchoolMask schoolmask = SpellSchoolMask(1 << school);
|
||||
|
||||
if ( schoolmask & SPELL_SCHOOL_MASK_NORMAL )
|
||||
damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage);
|
||||
damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage, NULL, BASE_ATTACK);
|
||||
|
||||
char* spellStr = strtok((char*)NULL, " ");
|
||||
|
||||
|
||||
@@ -3242,6 +3242,12 @@ void Spell::TakePower()
|
||||
{
|
||||
if(ihit->missCondition != SPELL_MISS_NONE && ihit->missCondition != SPELL_MISS_MISS/* && ihit->targetGUID!=m_caster->GetGUID()*/)
|
||||
hit = false;
|
||||
if (ihit->missCondition != SPELL_MISS_NONE)
|
||||
{
|
||||
//lower spell cost on fail (by talent aura)
|
||||
if(Player *modOwner = ((Player*)m_caster)->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_SPELL_COST_REFUND_ON_FAIL, m_powerCost);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(hit && NeedsComboPoints(m_spellInfo))
|
||||
|
||||
@@ -324,7 +324,7 @@ enum AuraType
|
||||
SPELL_AURA_MOD_MAX_AFFECTED_TARGETS = 277,
|
||||
SPELL_AURA_MOD_DISARM_RANGED = 278,
|
||||
SPELL_AURA_279 = 279,
|
||||
SPELL_AURA_MOD_TARGET_ARMOR_PCT = 280,
|
||||
SPELL_AURA_MOD_WEAPONTYPE_IGNORE_TARGET_RESISTANCE = 280,
|
||||
SPELL_AURA_MOD_HONOR_GAIN_PCT = 281,
|
||||
SPELL_AURA_MOD_BASE_HEALTH_PCT = 282,
|
||||
SPELL_AURA_MOD_HEALING_RECEIVED = 283, // Possibly only for some spell family class spells
|
||||
|
||||
@@ -5453,7 +5453,7 @@ void Aura::PeriodicTick()
|
||||
if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL &&
|
||||
GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
|
||||
{
|
||||
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
|
||||
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto());
|
||||
cleanDamage.damage += pdamage - pdamageReductedArmor;
|
||||
pdamage = pdamageReductedArmor;
|
||||
}
|
||||
@@ -5539,7 +5539,7 @@ void Aura::PeriodicTick()
|
||||
//Calculate armor mitigation if it is a physical spell
|
||||
if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
|
||||
{
|
||||
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
|
||||
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto());
|
||||
cleanDamage.damage += pdamage - pdamageReductedArmor;
|
||||
pdamage = pdamageReductedArmor;
|
||||
}
|
||||
|
||||
@@ -1262,7 +1262,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
||||
}
|
||||
|
||||
if( damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL )
|
||||
damage = CalcArmorReducedDamage(pVictim, damage);
|
||||
damage = CalcArmorReducedDamage(pVictim, damage, spellInfo, attackType);
|
||||
|
||||
// Calculate absorb resist
|
||||
if(damage > 0)
|
||||
@@ -1288,6 +1288,37 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
||||
damageInfo->damage = damage;
|
||||
}
|
||||
|
||||
int32 Unit::GetIgnoredArmorMultiplier(SpellEntry const *spellInfo, WeaponAttackType attackType)
|
||||
{
|
||||
if (GetTypeId() != TYPEID_PLAYER)
|
||||
return 0;
|
||||
//check if spell uses weapon
|
||||
if (spellInfo && spellInfo->EquippedItemClass!=ITEM_CLASS_WEAPON)
|
||||
return 0;
|
||||
Item *item = NULL;
|
||||
if(attackType == BASE_ATTACK)
|
||||
item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
|
||||
else if (attackType == OFF_ATTACK)
|
||||
item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
||||
else if (attackType == RANGED_ATTACK)
|
||||
item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED);
|
||||
if (!item)
|
||||
return 0;
|
||||
|
||||
AuraList const& armAuras = GetAurasByType(SPELL_AURA_MOD_WEAPONTYPE_IGNORE_TARGET_RESISTANCE);
|
||||
int32 armorIgnored = 0;
|
||||
for(AuraList::const_iterator i = armAuras.begin();i != armAuras.end(); ++i)
|
||||
{
|
||||
if (!((*i)->GetSpellProto()->EquippedItemClass==item->GetProto()->Class
|
||||
&& (*i)->GetSpellProto()->EquippedItemSubClassMask & (1<<item->GetProto()->SubClass)))
|
||||
continue;
|
||||
|
||||
if((*i)->GetModifier()->m_amount)
|
||||
armorIgnored += (*i)->GetModifier()->m_amount;
|
||||
}
|
||||
return (-armorIgnored);
|
||||
}
|
||||
|
||||
void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
|
||||
{
|
||||
if (damageInfo==0)
|
||||
@@ -1384,7 +1415,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
|
||||
// Add melee damage bonus
|
||||
MeleeDamageBonus(damageInfo->target, &damage, damageInfo->attackType);
|
||||
// Calculate armor reduction
|
||||
damageInfo->damage = CalcArmorReducedDamage(damageInfo->target, damage);
|
||||
damageInfo->damage = CalcArmorReducedDamage(damageInfo->target, damage, NULL , damageInfo->attackType);
|
||||
damageInfo->cleanDamage += damage - damageInfo->damage;
|
||||
|
||||
damageInfo->hitOutCome = RollMeleeOutcomeAgainst(damageInfo->target, damageInfo->attackType);
|
||||
@@ -1679,13 +1710,18 @@ void Unit::HandleEmoteCommand(uint32 anim_id)
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
|
||||
uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType)
|
||||
{
|
||||
uint32 newdamage = 0;
|
||||
float armor = pVictim->GetArmor();
|
||||
// Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura
|
||||
armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL);
|
||||
|
||||
armor *= float((GetIgnoredArmorMultiplier(spellInfo, attackType)+100.0f)/100.0f);
|
||||
if(spellInfo)
|
||||
if(Player *modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor);
|
||||
|
||||
// Apply Player CR_ARMOR_PENETRATION rating
|
||||
if (GetTypeId()==TYPEID_PLAYER)
|
||||
armor *= 1.0f - ((Player*)this)->GetRatingBonusValue(CR_ARMOR_PENETRATION) / 100.0f;
|
||||
@@ -11678,7 +11714,10 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry con
|
||||
}
|
||||
// Apply chance modifer aura
|
||||
if(Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance);
|
||||
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_PROC_CHANCE,chance);
|
||||
}
|
||||
|
||||
return roll_chance_f(chance);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ enum SpellModOp
|
||||
SPELLMOD_CASTING_TIME = 10,
|
||||
SPELLMOD_COOLDOWN = 11,
|
||||
SPELLMOD_EFFECT2 = 12,
|
||||
// spellmod 13 unused
|
||||
SPELLMOD_IGNORE_ARMOR = 13,
|
||||
SPELLMOD_COST = 14,
|
||||
SPELLMOD_CRIT_DAMAGE_BONUS = 15,
|
||||
SPELLMOD_RESIST_MISS_CHANCE = 16,
|
||||
@@ -110,13 +110,16 @@ enum SpellModOp
|
||||
SPELLMOD_CHANCE_OF_SUCCESS = 18,
|
||||
SPELLMOD_ACTIVATION_TIME = 19,
|
||||
SPELLMOD_EFFECT_PAST_FIRST = 20,
|
||||
SPELLMOD_CASTING_TIME_OLD = 21,
|
||||
SPELLMOD_GLOBAL_COOLDOWN = 21, //TODO: GCD is not checked by server currently
|
||||
SPELLMOD_DOT = 22,
|
||||
SPELLMOD_EFFECT3 = 23,
|
||||
SPELLMOD_SPELL_BONUS_DAMAGE = 24,
|
||||
// spellmod 25, 26 unused
|
||||
// spellmod 25
|
||||
SPELLMOD_PROC_CHANCE = 26,
|
||||
SPELLMOD_MULTIPLE_VALUE = 27,
|
||||
SPELLMOD_RESIST_DISPEL_CHANCE = 28
|
||||
SPELLMOD_RESIST_DISPEL_CHANCE = 28,
|
||||
SPELLMOD_CRIT_DAMAGE_BONUS_2 = 29, //one not used spell
|
||||
SPELLMOD_SPELL_COST_REFUND_ON_FAIL = 30
|
||||
};
|
||||
|
||||
#define MAX_SPELLMOD 32
|
||||
@@ -442,11 +445,10 @@ enum WeaponAttackType
|
||||
{
|
||||
BASE_ATTACK = 0,
|
||||
OFF_ATTACK = 1,
|
||||
RANGED_ATTACK = 2
|
||||
RANGED_ATTACK = 2,
|
||||
MAX_ATTACK
|
||||
};
|
||||
|
||||
#define MAX_ATTACK 3
|
||||
|
||||
enum CombatRating
|
||||
{
|
||||
CR_WEAPON_SKILL = 0,
|
||||
@@ -991,6 +993,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss);
|
||||
|
||||
void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
|
||||
int32 GetIgnoredArmorMultiplier(SpellEntry const *spellInfo, WeaponAttackType attackType);
|
||||
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
|
||||
|
||||
float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const;
|
||||
@@ -1410,7 +1413,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
virtual bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
|
||||
// redefined in Creature
|
||||
|
||||
uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage);
|
||||
uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType=MAX_ATTACK);
|
||||
void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist);
|
||||
|
||||
void UpdateSpeed(UnitMoveType mtype, bool forced);
|
||||
|
||||
Reference in New Issue
Block a user