What bug does the patch fix?
it fix atacks from behind when hunters use deterrence
For which repository revision was the patch created?
I use the branch of kero99 https://github.com/kero99/Stable
Who has been writing this patch?
me
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index b4dc9f9..e9c8455 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -2929,11 +2929,23 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
bool from_behind = !pVictim->HasInArc(M_PI_F,this);
- if (from_behind)
+ if (from_behind) {
+ if(pVictim->HasAura(19263)) {
+ int32 tmp2 = int32(parry_chance);
+ if ( (tmp2 > 0) // check if unit _can_ parry
+ && ((tmp2 -= skillBonus) > 0)
+ && (roll < (sum += tmp2)))
+ {
+ DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum);
+ return MELEE_HIT_PARRY;
+ }
+ }
+ else
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: attack came from behind.");
+ }
// Dodge chance
-
+
// only players can't dodge if attacker is behind
if (pVictim->GetTypeId() != TYPEID_PLAYER || !from_behind)
{
@@ -2976,7 +2988,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum);
return MELEE_HIT_PARRY;
}
- }
+ }
}
// Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon)
@@ -3284,6 +3296,12 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (roll < tmp)
return SPELL_MISS_DEFLECT;
}
+ if(pVictim->HasAura(19263)) {
+ int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
+ tmp+=deflect_chance;
+ if (roll < tmp)
+ return SPELL_MISS_DEFLECT;
+ }
return SPELL_MISS_NONE;
}
@@ -3294,8 +3312,10 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
canDodge = false;
// Can`t parry
- canParry = false;
+ if(!pVictim->HasAura(19263))
+ canParry = false;
}
+
// Check creatures flags_extra for disable parry
if(pVictim->GetTypeId()==TYPEID_UNIT)
{
@@ -3436,7 +3456,12 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (rand < tmp)
return SPELL_MISS_DEFLECT;
}
-
+ if(pVictim->HasAura(19263)) {
+ int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
+ tmp+=deflect_chance;
+ if (rand < tmp)
+ return SPELL_MISS_DEFLECT;
+ }
return SPELL_MISS_NONE;
}