Skip to content

Commit

Permalink
[11510] Implement SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT (288) and …
Browse files Browse the repository at this point in the history
…related spell 19263.

Original patchs provided by KAPATEJIb and Roshnak.
  • Loading branch information
VladimirMangos committed May 18, 2011
1 parent c79f8b2 commit fe23f25
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
5 changes: 4 additions & 1 deletion src/game/Spell.cpp
Expand Up @@ -3037,8 +3037,11 @@ void Spell::cast(bool skipCheck)
break;
case SPELLFAMILY_HUNTER:
{
// Deterrence
if (m_spellInfo->Id == 19263)
AddPrecastSpell(67801);
// Kill Command
if (m_spellInfo->Id == 34026)
else if (m_spellInfo->Id == 34026)
{
if (m_caster->HasAura(37483)) // Improved Kill Command - Item set bonus
m_caster->CastSpell(m_caster, 37482, true);// Exploited Weakness
Expand Down
2 changes: 1 addition & 1 deletion src/game/SpellAuraDefines.h
Expand Up @@ -323,7 +323,7 @@ enum AuraType
SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR = 285,
SPELL_AURA_ABILITY_PERIODIC_CRIT = 286,
SPELL_AURA_DEFLECT_SPELLS = 287,
SPELL_AURA_288 = 288,
SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT = 288,
SPELL_AURA_289 = 289,
SPELL_AURA_MOD_ALL_CRIT_CHANCE = 290,
SPELL_AURA_MOD_QUEST_XP_PCT = 291,
Expand Down
2 changes: 1 addition & 1 deletion src/game/SpellAuras.cpp
Expand Up @@ -338,7 +338,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
&Aura::HandleAuraModAttackPowerOfArmor, //285 SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR implemented in Player::UpdateAttackPowerAndDamage
&Aura::HandleNoImmediateEffect, //286 SPELL_AURA_ABILITY_PERIODIC_CRIT implemented in Aura::IsCritFromAbilityAura called from Aura::PeriodicTick
&Aura::HandleNoImmediateEffect, //287 SPELL_AURA_DEFLECT_SPELLS implemented in Unit::MagicSpellHitResult and Unit::MeleeSpellHitResult
&Aura::HandleNULL, //288 increase parry/deflect, prevent attack (single spell used 67801)
&Aura::HandleNoImmediateEffect, //288 SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT percent from normal parry/deflect applied to from behind attack case (single spell used 67801, also look 4.1.0 spell 97574)
&Aura::HandleUnused, //289 unused (3.2.2a)
&Aura::HandleAuraModAllCritChance, //290 SPELL_AURA_MOD_ALL_CRIT_CHANCE
&Aura::HandleNoImmediateEffect, //291 SPELL_AURA_MOD_QUEST_XP_PCT implemented in Player::GiveXP
Expand Down
4 changes: 4 additions & 0 deletions src/game/SpellMgr.cpp
Expand Up @@ -2210,6 +2210,10 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons
((spellInfo_2->SpellFamilyFlags & UI64LIT(0x4)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x00000004000))))
return false;

// Deterrence
if (spellInfo_1->SpellIconID == 83 && spellInfo_2->SpellIconID == 83)
return false;

// Bestial Wrath
if (spellInfo_1->SpellIconID == 1680 && spellInfo_2->SpellIconID == 1680)
return false;
Expand Down
55 changes: 37 additions & 18 deletions src/game/Unit.cpp
Expand Up @@ -2678,23 +2678,26 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
}

// parry chances
// check if attack comes from behind, nobody can parry or block if attacker is behind
if (!from_behind)
// check if attack comes from behind, nobody can parry or block if attacker is behind if not have
if (!from_behind || pVictim->HasAuraType(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT))
{
// Reduce parry chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
parry_chance-= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100);
parry_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100);
else
parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25;

if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) )
if (parry_chance > 0 && (pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY)))
{
int32 tmp2 = int32(parry_chance);
if ( (tmp2 > 0) // check if unit _can_ parry
&& ((tmp2 -= skillBonus) > 0)
&& (roll < (sum += tmp2)))
parry_chance -= skillBonus;

//if (from_behind) -- only 100% currently and not 100% sure way value apply
// parry_chance = int32(parry_chance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT) - 1);

if (parry_chance > 0 && // check if unit _can_ parry
(roll < (sum += parry_chance)))
{
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum);
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum - parry_chance, sum);
return MELEE_HIT_PARRY;
}
}
Expand Down Expand Up @@ -2987,28 +2990,35 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)
return SPELL_MISS_NONE;

bool from_behind = !pVictim->HasInArc(M_PI_F,this);

// Ranged attack cannot be parry/dodge only deflect
if (attType == RANGED_ATTACK)
{
// only if in front
if (pVictim->HasInArc(M_PI_F,this))
// only if in front or special ability
if (!from_behind || pVictim->HasAuraType(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT))
{
int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
tmp+=deflect_chance;

//if (from_behind) -- only 100% currently and not 100% sure way value apply
// deflect_chance = int32(deflect_chance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT) - 1);

tmp += deflect_chance;
if (roll < tmp)
return SPELL_MISS_DEFLECT;
}
return SPELL_MISS_NONE;
}

// Check for attack from behind
if (!pVictim->HasInArc(M_PI_F,this))
if (from_behind)
{
// Can`t dodge from behind in PvP (but its possible in PvE)
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
canDodge = false;
// Can`t parry
canParry = false;
// Can`t parry without special ability
if (!pVictim->HasAuraType(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT))
canParry = false;
}
// Check creatures flags_extra for disable parry
if(pVictim->GetTypeId()==TYPEID_UNIT)
Expand Down Expand Up @@ -3065,6 +3075,9 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (parryChance < 0)
parryChance = 0;

//if (from_behind) -- only 100% currently and not 100% sure way value apply
// parryChance = int32(parryChance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT) - 1));

tmp += parryChance;
if (roll < tmp)
return SPELL_MISS_PARRY;
Expand Down Expand Up @@ -3142,11 +3155,17 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (rand < tmp)
return SPELL_MISS_MISS;

// cast by caster in front of victim
if (pVictim->HasInArc(M_PI_F,this))
bool from_behind = !pVictim->HasInArc(M_PI_F,this);

// cast by caster in front of victim or behind with special ability
if (!from_behind || pVictim->HasAuraType(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT))
{
int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
tmp+=deflect_chance;

//if (from_behind) -- only 100% currently and not 100% sure way value apply
// deflect_chance = int32(deflect_chance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT)) - 1);

tmp += deflect_chance;
if (rand < tmp)
return SPELL_MISS_DEFLECT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11509"
#define REVISION_NR "11510"
#endif // __REVISION_NR_H__

1 comment on commit fe23f25

@Seehub
Copy link

@Seehub Seehub commented on fe23f25 Jul 5, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's working almost as it was working in wotlk retail, except for Backstab, Shred and that kind of skills that only can be performed from the opponent's back (They should bypass deterrence).

More details: http://www.threadmeters.com/pWsJlL/AmbushBackstab_going_through_deterrence/

Please sign in to comment.