diff options
-rw-r--r-- | src/game/BattleGround.cpp | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 19 | ||||
-rw-r--r-- | src/game/Player.h | 2 | ||||
-rw-r--r-- | src/game/Spell.cpp | 12 | ||||
-rw-r--r-- | src/game/SpellMgr.h | 4 | ||||
-rw-r--r-- | src/game/Unit.cpp | 52 | ||||
-rw-r--r-- | src/game/Unit.h | 3 | ||||
-rw-r--r-- | src/shared/Database/DBCEnums.h | 10 |
8 files changed, 72 insertions, 32 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 9be5650a16e..695b32fd2df 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -957,7 +957,7 @@ void BattleGround::AddPlayer(Player *plr) { plr->RemoveArenaSpellCooldowns(); plr->RemoveArenaAuras(); - plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT); + plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT, true); if(team == ALLIANCE) // gold { if(plr->GetTeam() == HORDE) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6485355a294..23b5434e1b0 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -7000,7 +7000,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro return; // Can do effect if any damage done to target - if (damageInfo->damage) + if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) { for (int i = 0; i < 5; i++) { @@ -7064,7 +7064,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro else { // Can do effect if any damage done to target - if (!(damageInfo->damage)) + if (!(damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)) continue; } @@ -11539,7 +11539,7 @@ void Player::RemoveEnchantmentDurations(Item *item) } } -void Player::RemoveAllEnchantments(EnchantmentSlot slot) +void Player::RemoveAllEnchantments(EnchantmentSlot slot, bool arena) { // remove enchantments from equipped items first to clean up the m_enchantDuration list for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) @@ -11547,6 +11547,19 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) next = itr; if(itr->slot==slot) { + if(arena && itr->item) + { + uint32 enchant_id = itr->item->GetEnchantmentId(slot); + if(enchant_id) + { + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(pEnchant && pEnchant->aura_id == ITEM_ENCHANTMENT_AURAID_POISON) + { + ++next; + continue; + } + } + } if(itr->item && itr->item->GetEnchantmentId(slot)) { // remove from stats diff --git a/src/game/Player.h b/src/game/Player.h index aff836b33c4..384acf7b760 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1154,7 +1154,7 @@ class TRINITY_DLL_SPEC Player : public Unit void UpdateItemDuration(uint32 time, bool realtimeonly=false); void AddEnchantmentDurations(Item *item); void RemoveEnchantmentDurations(Item *item); - void RemoveAllEnchantments(EnchantmentSlot slot); + void RemoveAllEnchantments(EnchantmentSlot slot, bool arena); void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration); void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false); void ApplyEnchantment(Item *item,bool apply); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 29892fcfde3..2cb78e093eb 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1017,8 +1017,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, crit); // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) - if (m_canTrigger && missInfo != SPELL_MISS_REFLECT) - caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, addhealth, m_attackType, m_spellInfo); + if (missInfo != SPELL_MISS_REFLECT) + caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, addhealth, m_attackType, m_spellInfo, m_canTrigger); int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); @@ -1043,8 +1043,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) - if (m_canTrigger && missInfo != SPELL_MISS_REFLECT) - caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo); + if (missInfo != SPELL_MISS_REFLECT) + caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_canTrigger); caster->DealSpellDamage(&damageInfo, true); @@ -1094,8 +1094,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_spellSchoolMask); procEx = createProcExtendMask(&damageInfo, missInfo); // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) - if (m_canTrigger && missInfo != SPELL_MISS_REFLECT) - caster->ProcDamageAndSpell(unit, procAttacker, procVictim, procEx, 0, m_attackType, m_spellInfo); + if (missInfo != SPELL_MISS_REFLECT) + caster->ProcDamageAndSpell(unit, procAttacker, procVictim, procEx, 0, m_attackType, m_spellInfo, m_canTrigger); } // Call scripted function for AI if this spell is casted upon a creature (except pets) diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 62c46ccf990..ccf16d1c7e8 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -485,7 +485,7 @@ enum ProcFlags PROC_FLAG_KILLED = 0x00000001, // 00 Killed by agressor PROC_FLAG_KILL_AND_GET_XP = 0x00000002, // 01 Kill that yields experience or honor - PROC_FLAG_SUCCESSFUL_MILEE_HIT = 0x00000004, // 02 Successful melee attack + PROC_FLAG_SUCCESSFUL_MELEE_HIT = 0x00000004, // 02 Successful melee attack PROC_FLAG_TAKEN_MELEE_HIT = 0x00000008, // 03 Taken damage from melee strike hit PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT = 0x00000010, // 04 Successful attack by Spell that use melee weapon @@ -519,7 +519,7 @@ enum ProcFlags PROC_FLAG_SUCCESSFUL_OFFHAND_HIT = 0x00800000 // 23 Successful off-hand melee attacks }; -#define MELEE_BASED_TRIGGER_MASK (PROC_FLAG_SUCCESSFUL_MILEE_HIT | \ +#define MELEE_BASED_TRIGGER_MASK (PROC_FLAG_SUCCESSFUL_MELEE_HIT | \ PROC_FLAG_TAKEN_MELEE_HIT | \ PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT | \ PROC_FLAG_TAKEN_MELEE_SPELL_HIT | \ diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index d2a10593a1d..6f248b75161 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1334,12 +1334,12 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da switch (attackType) { case BASE_ATTACK: - damageInfo->procAttacker = PROC_FLAG_SUCCESSFUL_MILEE_HIT; + damageInfo->procAttacker = PROC_FLAG_SUCCESSFUL_MELEE_HIT; damageInfo->procVictim = PROC_FLAG_TAKEN_MELEE_HIT; damageInfo->HitInfo = HITINFO_NORMALSWING2; break; case OFF_ATTACK: - damageInfo->procAttacker = PROC_FLAG_SUCCESSFUL_MILEE_HIT | PROC_FLAG_SUCCESSFUL_OFFHAND_HIT; + damageInfo->procAttacker = PROC_FLAG_SUCCESSFUL_MELEE_HIT | PROC_FLAG_SUCCESSFUL_OFFHAND_HIT; damageInfo->procVictim = PROC_FLAG_TAKEN_MELEE_HIT;//|PROC_FLAG_TAKEN_OFFHAND_HIT // not used damageInfo->HitInfo = HITINFO_LEFTSWING; break; @@ -1659,7 +1659,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) } // Do effect if any damage done to target - if (damageInfo->damage) + if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) { // victim's damage shield std::set<Aura*> alreadyDone; @@ -2804,6 +2804,27 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, return miss_chance; } + +int32 Unit::GetMechanicResistChance(const SpellEntry *spell) +{ + if(!spell) + return 0; + int32 resist_mech = 0; + for(int eff = 0; eff < 3; ++eff) + { + if(spell->Effect[eff] == 0) + break; + int32 effect_mech = GetEffectMechanic(spell, eff); + if (effect_mech) + { + int32 temp = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); + if (resist_mech < temp) + resist_mech = temp; + } + } + return resist_mech; +} + // Melee based spells hit result calculations SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) { @@ -2829,6 +2850,12 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK) return SPELL_MISS_NONE; + // Chance resist mechanic + int32 resist_chance = pVictim->GetMechanicResistChance(spell)*100; + tmp += resist_chance; + if (roll < tmp) + return SPELL_MISS_RESIST; + // Ranged attack can`t miss too if (attType == RANGED_ATTACK) return SPELL_MISS_NONE; @@ -2917,20 +2944,9 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (IsDispelSpell(spell)) modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST); // Chance resist mechanic (select max value from every mechanic spell effect) - int32 resist_mech = 0; - // Get effects mechanic and chance - for(int eff = 0; eff < 3; ++eff) - { - int32 effect_mech = GetEffectMechanic(spell, eff); - if (effect_mech) - { - int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); - if (resist_mech < temp) - resist_mech = temp; - } - } + int32 resist_chance = pVictim->GetMechanicResistChance(spell); // Apply mod - modHitChance-=resist_mech; + modHitChance-=resist_chance; // Chance resist debuff modHitChance-=pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spell->Dispel)); @@ -4709,10 +4725,10 @@ void Unit::SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SendMessageToSet( &data, true ); } -void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procExtra, uint32 amount, WeaponAttackType attType, SpellEntry const *procSpell) +void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procExtra, uint32 amount, WeaponAttackType attType, SpellEntry const *procSpell, bool canTrigger) { // Not much to do if no flags are set. - if (procAttacker) + if (procAttacker && canTrigger) ProcDamageAndSpellFor(false,pVictim,procAttacker, procExtra,attType, procSpell, amount); // Now go on with a victim's events'n'auras // Not much to do if no flags are set or there is no victim diff --git a/src/game/Unit.h b/src/game/Unit.h index 0a8cfc2c444..5eb4530113c 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -946,7 +946,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *spellProto = NULL, bool durabilityLoss = true); void Kill(Unit *pVictim, bool durabilityLoss = true); - void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL); + void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL, bool canTrigger = true); void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage ); void HandleEmoteCommand(uint32 anim_id); @@ -969,6 +969,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject float GetUnitParryChance() const; float GetUnitBlockChance() const; float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const; + int32 GetMechanicResistChance(const SpellEntry *spell); virtual uint32 GetShieldBlockValue() const =0; uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } diff --git a/src/shared/Database/DBCEnums.h b/src/shared/Database/DBCEnums.h index d8699b2c240..fbd87aafbe7 100644 --- a/src/shared/Database/DBCEnums.h +++ b/src/shared/Database/DBCEnums.h @@ -98,6 +98,16 @@ enum ItemEnchantmentType ITEM_ENCHANTMENT_TYPE_TOTEM = 6 }; +enum ItemEnchantmentAuraId +{ + ITEM_ENCHANTMENT_AURAID_POISON = 26, + ITEM_ENCHANTMENT_AURAID_NORMAL = 28, + ITEM_ENCHANTMENT_AURAID_FIRE = 32, + ITEM_ENCHANTMENT_AURAID_FROST = 33, + ITEM_ENCHANTMENT_AURAID_NATURE = 81, + ITEM_ENCHANTMENT_AURAID_SHADOW = 107 +}; + enum TotemCategoryType { TOTEM_CATEGORY_TYPE_KNIFE = 1, |