All pastes #920187 Raw Edit

Untitled

public text v1 · immutable
#920187 ·published 2008-02-27 07:33 UTC
rendered paste body
Index: src/game/SpellAuras.cpp
===================================================================
--- src/game/SpellAuras.cpp	(revision 5320)
+++ src/game/SpellAuras.cpp	(working copy)
@@ -210,7 +210,7 @@
     &Aura::HandleNULL,                                      //157 SPELL_AURA_PET_DAMAGE_MULTI
     &Aura::HandleShieldBlockValue,                          //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
     &Aura::HandleNULL,                                      //159 SPELL_AURA_NO_PVP_CREDIT      only for Honorless Target spell
-    &Aura::HandleNULL,                                      //160 SPELL_AURA_MOD_AOE_AVOIDANCE
+    &Aura::HandleNoImmediateEffect,                         //160 SPELL_AURA_MOD_AOE_AVOIDANCE
     &Aura::HandleNoImmediateEffect,                         //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
     &Aura::HandleNULL,                                      //162 SPELL_AURA_POWER_BURN_MANA
     &Aura::HandleNULL,                                      //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
Index: src/game/Unit.cpp
===================================================================
--- src/game/Unit.cpp	(revision 5320)
+++ src/game/Unit.cpp	(working copy)
@@ -1058,8 +1058,27 @@
 
     // TODO this in only generic way, check for exceptions
     DEBUG_LOG("DealDamageBySchool (BEFORE) SCHOOL %u >> DMG:%u", spellInfo->School, *damage);
+	
+	// All area effect attacks can be avoided base on SPELL_AURA_MOD_AOE_AVOIDANCE
+	for ( uint32 i=0; i<3;i++)
+	{
+		switch (spellInfo->EffectImplicitTargetA[i])
+		{
+		case TARGET_ALL_ENEMY_IN_AREA:
+        case TARGET_ALL_ENEMY_IN_AREA_INSTANT:
+		case TARGET_ALL_AROUND_CASTER:
+		case TARGET_ALL_ENEMY_IN_AREA_CHANNELED:
+			    if( AoeAvoidChanceCalc(pVictim) > urand(0,10000) )
+				{
+					cleanDamage->damage = 0;
+					*damage = 0;
+					return;
+				}		
+			break;
+		}
+	}
 
-    // Per-school calc
+	// Per-school calc
     switch (spellInfo->School)
     {
         // Physical damage school
@@ -2730,6 +2749,18 @@
     ((Creature*)victim)->AI().EnterEvadeMode(this);*/
 }
 
+uint32 Unit::AoeAvoidChanceCalc(Unit *pVictim) const
+{
+	if(!pVictim)
+        return 0;
+
+	int32 avoidchance = 0;
+    int32 mod = pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE);
+	avoidchance += mod * 100;
+
+    return avoidchance > 10000 ? 10000 : avoidchance;
+}
+
 uint32 Unit::SpellMissChanceCalc(Unit *pVictim) const
 {
     if(!pVictim)
Index: src/game/Unit.h
===================================================================
--- src/game/Unit.h	(revision 5320)
+++ src/game/Unit.h	(working copy)
@@ -680,7 +680,8 @@
         void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 damage = 0, SpellEntry const *procSpell = NULL, bool isTriggeredSpell = false, WeaponAttackType attType = BASE_ATTACK);
         void HandleEmoteCommand(uint32 anim_id);
         void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool isTriggered = false);
-        uint32 SpellMissChanceCalc(Unit *pVictim) const;
+        uint32 AoeAvoidChanceCalc(Unit *pVictim) const;
+		uint32 SpellMissChanceCalc(Unit *pVictim) const;
         int32 MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const;
         SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false);