[11510] Implement SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT (288) and related spell 19263.

Original patchs provided by KAPATEJIb and Roshnak.
This commit is contained in:
VladimirMangos 2011-05-19 03:46:28 +04:00
parent b7cc436571
commit 0564b622c2
6 changed files with 48 additions and 22 deletions

View file

@ -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;
}
}
@ -2987,14 +2990,20 @@ 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;
}
@ -3002,13 +3011,14 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
}
// 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)
@ -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;
@ -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;
}