aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-02-15 12:03:51 -0600
committermegamage <none@none>2009-02-15 12:03:51 -0600
commitaffd4d90058606cc95fe37420985c5ce56f81240 (patch)
treeebd601976c04fbf488b15642fc92df17af9ebc33 /src/game/Unit.cpp
parentc261065f2886f60899d2d48a182a1fcb0ddbd8d2 (diff)
[7280] Implement 287 SPELL_AURA_DEFLECT_SPELLS aura Author: DiSlord
--HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index d2ebe0cc575..74d474bf79e 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -2621,9 +2621,19 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)
return SPELL_MISS_NONE;
- // Ranged attack cannot be parry/dodge
+ // Ranged attack cannot be parry/dodge only deflect
if (attType == RANGED_ATTACK)
+ {
+ // only if in front
+ if (pVictim->HasInArc(M_PI,this))
+ {
+ int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
+ tmp+=deflect_chance;
+ if (roll < tmp)
+ return SPELL_MISS_DEFLECT;
+ }
return SPELL_MISS_NONE;
+ }
// Check for attack from behind
if (!pVictim->HasInArc(M_PI,this))
@@ -2756,9 +2766,22 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (HitChance < 100) HitChance = 100;
if (HitChance > 9900) HitChance = 9900;
+ int32 tmp = 10000 - HitChance;
+
uint32 rand = urand(0,10000);
- if (rand > HitChance)
+
+ if (rand < tmp)
return SPELL_MISS_RESIST;
+
+ // cast by caster in front of victim
+ if (pVictim->HasInArc(M_PI,this))
+ {
+ int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
+ tmp+=deflect_chance;
+ if (rand < tmp)
+ return SPELL_MISS_DEFLECT;
+ }
+
return SPELL_MISS_NONE;
}