Index: /trunk/src/game/SpellEffects.cpp
===================================================================
--- /trunk/src/game/SpellEffects.cpp (revision 180)
+++ /trunk/src/game/SpellEffects.cpp (revision 186)
@@ -3478,5 +3478,5 @@
         {
             // Reveal action + get attack
-            m_caster->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH);
+            m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH);
             if (((Creature*)unitTarget)->AI())
                 ((Creature*)unitTarget)->AI()->AttackStart(m_caster);
Index: /trunk/src/game/UnitEvents.h
===================================================================
--- /trunk/src/game/UnitEvents.h (revision 102)
+++ /trunk/src/game/UnitEvents.h (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: /trunk/src/game/AggressorAI.cpp
===================================================================
--- /trunk/src/game/AggressorAI.cpp (revision 156)
+++ /trunk/src/game/AggressorAI.cpp (revision 186)
@@ -50,5 +50,5 @@
         return;
     
-    if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() &&
+    if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && i_creature.canAttack(u) &&
         ( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) &&
         u->isInAccessablePlaceFor(&i_creature) )
Index: /trunk/src/game/Unit.h
===================================================================
--- /trunk/src/game/Unit.h (revision 178)
+++ /trunk/src/game/Unit.h (revision 186)
@@ -923,4 +923,6 @@
 
         bool isTargetableForAttack() const;
+        bool isAttackableByAOE() const;
+        bool canAttack(Unit const* target) const;
         virtual bool IsInWater() const;
         virtual bool IsUnderWater() const;
@@ -1032,5 +1034,4 @@
 
         void RemoveSpellsCausingAura(AuraType auraType);
-        void RemoveInterruptableAura(uint32 flag);
         void RemoveRankAurasDueToSpell(uint32 spellId);
         bool RemoveNoStackAurasDueToAura(Aura *Aur);
Index: /trunk/src/game/Spell.h
===================================================================
--- /trunk/src/game/Spell.h (revision 174)
+++ /trunk/src/game/Spell.h (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -579,5 +579,5 @@
                 {
                     case SPELL_TARGETS_FRIENDLY:
-                        if (!itr->getSource()->isTargetableForAttack() || !i_caster->IsFriendlyTo( itr->getSource() ))
+                        if (!itr->getSource()->isAttackableByAOE() || !i_caster->IsFriendlyTo( itr->getSource() ))
                             continue;
                         break;
@@ -586,5 +586,5 @@
                         if(itr->getSource()->GetTypeId()==TYPEID_UNIT && ((Creature*)itr->getSource())->isTotem())
                             continue;
-                        if(!itr->getSource()->isTargetableForAttack())
+                        if(!itr->getSource()->isAttackableByAOE())
                             continue;
 
Index: /trunk/src/game/GlobalEvents.cpp
===================================================================
--- /trunk/src/game/GlobalEvents.cpp (revision 102)
+++ /trunk/src/game/GlobalEvents.cpp (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: /trunk/src/game/OutdoorPvPObjectiveAI.cpp
===================================================================
--- /trunk/src/game/OutdoorPvPObjectiveAI.cpp (revision 178)
+++ /trunk/src/game/OutdoorPvPObjectiveAI.cpp (revision 186)
@@ -35,5 +35,6 @@
     // IsVisible only passes for players in range, so no need to check again
     // leaving/entering distance will be checked based on go range data
-    sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature);
+    if((u->GetTypeId() == TYPEID_PLAYER) && i_creature.IsWithinDistInMap(u, MAX_OUTDOOR_PVP_DISTANCE))
+        sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature);
 }
 
Index: /trunk/src/game/Creature.cpp
===================================================================
--- /trunk/src/game/Creature.cpp (revision 178)
+++ /trunk/src/game/Creature.cpp (revision 186)
@@ -1533,4 +1533,9 @@
 }
 
+bool Creature::IsWithinSightDist(Unit const* u) const
+{
+    return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER));
+}
+
 float Creature::GetAttackDistance(Unit const* pl) const
 {
@@ -1867,5 +1872,5 @@
         return true;
 
-    if(!pVictim->isTargetableForAttack())
+    if(!canAttack(pVictim))
         return true;
 
Index: /trunk/src/game/Map.cpp
===================================================================
--- /trunk/src/game/Map.cpp (revision 174)
+++ /trunk/src/game/Map.cpp (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -91,5 +91,5 @@
         if(vmgr->isMapLoadingEnabled())
         {
-                                                            // x and y are swaped !! => fixed now
+                                                            // x and y are swapped !! => fixed now
             bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(),  mapid, x,y);
             if(!exists)
@@ -107,5 +107,5 @@
 void Map::LoadVMap(int x,int y)
 {
-                                                            // x and y are swaped !!
+                                                            // x and y are swapped !!
     int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(),  GetId(), x,y);
     switch(vmapLoadResult)
@@ -145,5 +145,5 @@
     }
 
-    //map already load, delete it before reloading (Is it neccessary? Do we really need the abilty the reload maps during runtime?)
+    //map already load, delete it before reloading (Is it necessary? Do we really need the ability the reload maps during runtime?)
     if(GridMaps[x][y])
     {
@@ -335,5 +335,5 @@
 void Map::DeleteFromWorld(T* obj)
 {
-    // Note: In case resurrectable corpse and pet its removed from gloabal lists in own destructors
+    // Note: In case resurrectable corpse and pet its removed from global lists in own destructor
     delete obj;
 }
@@ -442,5 +442,5 @@
 bool Map::Add(Player *player)
 {
-    player->SetInstanceId(this->GetInstanceId());
+    player->SetInstanceId(GetInstanceId());
 
     // update player state for other player and visa-versa
@@ -671,5 +671,4 @@
 
     obj->RemoveFromWorld();
-
     RemoveFromGrid(obj,grid,cell);
 
@@ -1391,5 +1390,5 @@
             break;
         case TYPEID_UNIT:
-            // in case triggred sequence some spell can continue casting after prev CleanupsBeforeDelete call
+            // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call
             // make sure that like sources auras/etc removed before destructor start
             ((Creature*)obj)->CleanupsBeforeDelete ();
@@ -1470,11 +1469,4 @@
         return false;
     }
-
-    /*if(!player->isGameMaster() && i_data && i_data->IsEncounterInProgress())
-    {
-        sLog.outDebug("InstanceMap::CanEnter - Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName());
-        player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT);
-        return false;
-    }*/
 
     return Map::CanEnter(player);
@@ -1587,8 +1579,8 @@
 void InstanceMap::Update(const uint32& t_diff)
 {
-	Map::Update(t_diff);
-
-	if(i_data)
-		i_data->Update(t_diff);
+    Map::Update(t_diff);
+
+    if(i_data)
+        i_data->Update(t_diff);
 }
 
Index: /trunk/src/game/Creature.h
===================================================================
--- /trunk/src/game/Creature.h (revision 178)
+++ /trunk/src/game/Creature.h (revision 186)
@@ -549,4 +549,5 @@
 
         bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const;
+        bool IsWithinSightDist(Unit const* u) const;
         float GetAttackDistance(Unit const* pl) const;
 
Index: /trunk/src/game/GuardAI.cpp
===================================================================
--- /trunk/src/game/GuardAI.cpp (revision 156)
+++ /trunk/src/game/GuardAI.cpp (revision 186)
@@ -44,5 +44,5 @@
         return;
 
-    if( !i_creature.getVictim() && u->isTargetableForAttack() &&
+    if( !i_creature.getVictim() && i_creature.canAttack(u) &&
         ( u->IsHostileToPlayers() || i_creature.IsHostileTo(u) /*|| u->getVictim() && i_creature.IsFriendlyTo(u->getVictim())*/ ) &&
         u->isInAccessablePlaceFor(&i_creature))
Index: /trunk/src/game/GameEvent.cpp
===================================================================
--- /trunk/src/game/GameEvent.cpp (revision 111)
+++ /trunk/src/game/GameEvent.cpp (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: /trunk/src/game/Unit.cpp
===================================================================
--- /trunk/src/game/Unit.cpp (revision 179)
+++ /trunk/src/game/Unit.cpp (revision 186)
@@ -464,5 +464,5 @@
 }
 
-void Unit::RemoveInterruptableAura(uint32 flag)
+void Unit::RemoveAurasWithInterruptFlags(uint32 flag)
 {
     AuraList::iterator iter, next;
@@ -510,5 +510,5 @@
     if( damagetype != DOT)
     {
-        RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH);
+        RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH);
 
         if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED))
@@ -4101,15 +4101,4 @@
                 ++iter;
         }
-    }
-}
-
-void Unit::RemoveAurasWithInterruptFlags(uint32 flags)
-{
-    for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
-    {
-        if (iter->second->GetSpellProto()->AuraInterruptFlags & flags)
-            RemoveAura(iter);
-        else
-            ++iter;
     }
 }
@@ -8507,7 +8496,29 @@
 }
 
+//TODO: remove this function
 bool Unit::isTargetableForAttack() const
 {
-    if (GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster())
+    return isAttackableByAOE() && !hasUnitState(UNIT_STAT_DIED);
+}
+
+bool Unit::canAttack(Unit const* target) const
+{
+    assert(target);
+
+    if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))
+        return false;
+
+    if((m_invisibilityMask || target->m_invisibilityMask) && !canDetectInvisibilityOf(target))
+        return false;
+
+    if(target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target)))
+        return false;
+
+    return true;
+}
+
+bool Unit::isAttackableByAOE() const
+{
+    if(!isAlive())
         return false;
 
@@ -8515,5 +8526,8 @@
         return false;
 
-    return isAlive() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/;
+    if(GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster())
+        return false;
+
+    return !isInFlight();
 }
 
@@ -9067,5 +9081,5 @@
         for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr)
         {
-            if( (*itr)->IsInMap(this) && (*itr)->isTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this) )
+            if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessablePlaceFor((Creature*)this) )
                 return false;
         }
Index: /trunk/src/game/Player.cpp
===================================================================
--- /trunk/src/game/Player.cpp (revision 183)
+++ /trunk/src/game/Player.cpp (revision 186)
@@ -16547,5 +16547,5 @@
 
     // prevent stealth flight
-    RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH);
+    RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH);
 
     WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4);
Index: /trunk/src/game/GridNotifiersImpl.h
===================================================================
--- /trunk/src/game/GridNotifiersImpl.h (revision 102)
+++ /trunk/src/game/GridNotifiersImpl.h (revision 186)
@@ -75,5 +75,5 @@
     if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
     {
-        if( c->AI() && c->AI()->IsVisible(pl) && !c->IsInEvadeMode() )
+        if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() )
             c->AI()->MoveInLineOfSight(pl);
     }
@@ -84,5 +84,5 @@
     if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
     {
-        if( c1->AI() && c1->AI()->IsVisible(c2) && !c1->IsInEvadeMode() )
+        if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() )
             c1->AI()->MoveInLineOfSight(c2);
     }
@@ -90,5 +90,5 @@
     if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
     {
-        if( c2->AI() && c2->AI()->IsVisible(c1) && !c2->IsInEvadeMode() )
+        if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() )
             c2->AI()->MoveInLineOfSight(c1);
     }
Index: /trunk/src/game/PetAI.cpp
===================================================================
--- /trunk/src/game/PetAI.cpp (revision 156)
+++ /trunk/src/game/PetAI.cpp (revision 186)
@@ -49,5 +49,5 @@
     if( !i_pet.getVictim() && i_pet.GetCharmInfo() &&
         i_pet.GetCharmInfo()->HasReactState(REACT_AGGRESSIVE) &&
-        u->isTargetableForAttack() && i_pet.IsHostileTo( u ) &&
+        i_pet.IsHostileTo( u ) && i_pet.canAttack(u) &&
         u->isInAccessablePlaceFor(&i_pet))
     {
@@ -96,5 +96,5 @@
         return true;
 
-    return !i_pet.getVictim()->isTargetableForAttack();
+    return !i_pet.canAttack(i_pet.getVictim());
 }
 
Index: /trunk/src/game/Spell.cpp
===================================================================
--- /trunk/src/game/Spell.cpp (revision 185)
+++ /trunk/src/game/Spell.cpp (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -1006,5 +1006,5 @@
             {
                 //do not remove feign death
-                unit->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH + AURA_INTERRUPT_FLAG_DAMAGE);
+                unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH + AURA_INTERRUPT_FLAG_DAMAGE);
             }
         }
@@ -2148,5 +2148,5 @@
     if ( !m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo) )
     {
-        m_caster->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH);
+        m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH);
     }
 
@@ -2207,5 +2207,5 @@
 {
     SetExecutedCurrently(true);
-    
+
     uint8 castResult = 0;
 
@@ -2322,5 +2322,5 @@
         handle_immediate();
     }
-    
+
     SetExecutedCurrently(false);
 }
@@ -3083,5 +3083,5 @@
     WorldObject* target = NULL;
 
-    // select first not rsusted target from target list for _0_ effect
+    // select first not resisted target from target list for _0_ effect
     if(!m_UniqueTargetInfo.empty())
     {
@@ -3341,5 +3341,5 @@
     for(TriggerSpells::iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si)
     {
-        Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, this->m_selfContainer);
+        Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, m_selfContainer);
         spell->prepare(&m_targets);                         // use original spell original targets
     }
@@ -3398,5 +3398,4 @@
         if(m_spellInfo->TargetAuraStateNot && target->HasAuraState(AuraState(m_spellInfo->TargetAuraStateNot)))
             return SPELL_FAILED_TARGET_AURASTATE;
-
 
         if(target != m_caster)
@@ -4077,5 +4076,5 @@
         return SPELL_FAILED_CASTER_DEAD;
 
-    if(m_caster->IsNonMeleeSpellCasted(false))              //prevent spellcast interuption by another spellcast
+    if(m_caster->IsNonMeleeSpellCasted(false))              //prevent spellcast interruption by another spellcast
         return SPELL_FAILED_SPELL_IN_PROGRESS;
     if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo))
@@ -4169,5 +4168,5 @@
                 dispel_immune |= GetDispellMask(DispelType(m_spellInfo->EffectMiscValue[i]));
         }
-        //immune movement impairement and loss of control
+        //immune movement impairment and loss of control
         if(m_spellInfo->Id==(uint32)42292)
             mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
@@ -4651,5 +4650,5 @@
 
                 uint32 item_quality = itemProto->Quality;
-                // 2.0.x addon: Check player enchanting level agains the item desenchanting requirements
+                // 2.0.x addon: Check player enchanting level against the item disenchanting requirements
                 uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill;
                 if (item_disenchantskilllevel == uint32(-1))
Index: /trunk/src/game/PossessedAI.cpp
===================================================================
--- /trunk/src/game/PossessedAI.cpp (revision 174)
+++ /trunk/src/game/PossessedAI.cpp (revision 186)
@@ -46,5 +46,5 @@
         return true;
 
-    return !i_pet.getVictim()->isTargetableForAttack();
+    return !i_pet.canAttack(i_pet.getVictim());
 }
 
Index: /trunk/src/game/SpellMgr.cpp
===================================================================
--- /trunk/src/game/SpellMgr.cpp (revision 173)
+++ /trunk/src/game/SpellMgr.cpp (revision 186)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: /trunk/src/bindings/scripts/include/sc_creature.cpp
===================================================================
--- /trunk/src/bindings/scripts/include/sc_creature.cpp (revision 153)
+++ /trunk/src/bindings/scripts/include/sc_creature.cpp (revision 186)
@@ -74,16 +74,16 @@
 void ScriptedAI::MoveInLineOfSight(Unit *who)
 {
-    if (!m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature))
-    {
-        if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
-            return;
-
-        float attackRadius = m_creature->GetAttackDistance(who);
-        if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
-        {
-            who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
-            AttackStart(who);
-        }
-    }
+    if(m_creature->getVictim() || !m_creature->IsHostileTo(who) || !who->isInAccessablePlaceFor(m_creature))
+        return;
+
+    if(!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
+        return;
+
+    if(!m_creature->IsWithinDistInMap(who, m_creature->GetAttackDistance(who)) || !m_creature->IsWithinLOSInMap(who))
+        return;
+    
+    if(m_creature->canAttack(who))
+        //who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
+        AttackStart(who);
 }
 
@@ -778,5 +778,5 @@
 void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who)
 {
-    if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) )
+    if( !m_creature->getVictim() && m_creature->canAttack(who) && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) )
     {
         if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
Index: /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp (revision 109)
+++ /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp (revision 186)
@@ -1196,6 +1196,5 @@
             return;
 
-
-        if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))
+        if (m_creature->canAttack(who) && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))
         {
             if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
@@ -1205,6 +1204,6 @@
             if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
             {
-                if(who->HasStealthAura())
-                    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
+                //if(who->HasStealthAura())
+                //    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
 
                 //Begin melee attack if we are within range
Index: /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp (revision 180)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp (revision 186)
@@ -414,5 +414,5 @@
             EnterPhase(PHASE_FLIGHT);
         }
-        else 
+        else // handle flight sequence
             Timer[EVENT_FLIGHT_SEQUENCE] = 1000;    
     }
@@ -692,8 +692,8 @@
         for(uint32 i = 1; i <= MaxTimer[Phase]; i++)
         {
-            if(Timer[i])
+            if(Timer[i]) // Event is enabled
                 if(Timer[i] <= diff)
                 {
-                    if(!Event)
+                    if(!Event) // No event with higher priority
                         Event = (EventIllidan)i;
                 }
@@ -709,10 +709,10 @@
 
         case PHASE_NORMAL_2:
-            if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30)
+            if(HPPCT(m_creature) < 30)
                 EnterPhase(PHASE_TALK_SEQUENCE);
             break;
 
         case PHASE_NORMAL_MAIEV:
-            if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 1)
+            if(HPPCT(m_creature) < 1)
                 EnterPhase(PHASE_TALK_SEQUENCE);
             break;
@@ -759,5 +759,5 @@
                         DoPlaySoundToSet(m_creature, soundid);
                 }
-                Timer[EVENT_TAUNT] = 32000;
+                Timer[EVENT_TAUNT] = 25000 + rand()%10000;
                 break;
 
@@ -834,10 +834,7 @@
                 Phase = PHASE_FLIGHT_SEQUENCE;
                 Timer[EVENT_FLIGHT_SEQUENCE] = 0;//do not start Event when changing hover point
-                for (uint8 i = 0; i <= rand()%3; i++)
-                {
-                    HoverPoint++;
-                    if(HoverPoint > 3)
-                        HoverPoint = 0;
-                }
+                HoverPoint += (rand()%3 + 1);
+                if(HoverPoint > 3)
+                    HoverPoint -= 4;
                 m_creature->GetMotionMaster()->MovePoint(0, HoverPosition[HoverPoint].x, HoverPosition[HoverPoint].y, HoverPosition[HoverPoint].z);
                 break;
@@ -2060,25 +2057,15 @@
     final.y = 2 * final.y - initial.y;
 
-    for(uint8 i = 0; i < 2; ++i)//core bug, two buff do not coexist
-    {
-        Creature* Trigger = NULL;
-        Trigger = m_creature->SummonCreature(DEMON_FIRE, initial.x, initial.y, initial.z, 0, TEMPSUMMON_TIMED_DESPAWN, 13000);
-        if(Trigger)
-        {
-            ((demonfireAI*)Trigger->AI())->IsTrigger = true;
-            Trigger->SetSpeed(MOVE_WALK, 3);
-            Trigger->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE);
-            Trigger->GetMotionMaster()->MovePoint(0, final.x, final.y, final.z);
-
-            if(!i)
-                Trigger->CastSpell(Trigger, SPELL_EYE_BLAST_TRIGGER, true);
-            else
-            {
-                Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
-                m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID());
-                DoCast(Trigger, SPELL_EYE_BLAST);
-            }
-        }
-    }
+    Creature* Trigger = m_creature->SummonCreature(DEMON_FIRE, initial.x, initial.y, initial.z, 0, TEMPSUMMON_TIMED_DESPAWN, 13000);
+    if(!Trigger) return;
+
+    ((demonfireAI*)Trigger->AI())->IsTrigger = true;
+    Trigger->SetSpeed(MOVE_WALK, 3);
+    Trigger->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE);
+    Trigger->GetMotionMaster()->MovePoint(0, final.x, final.y, final.z);
+
+    Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+    m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID());
+    DoCast(Trigger, SPELL_EYE_BLAST);
 }
 
@@ -2163,11 +2150,8 @@
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
         m_creature->GetMotionMaster()->Clear(false);
-        //m_creature->GetMotionMaster()->MoveIdle();
         m_creature->AttackStop();
         break;
     case PHASE_FLIGHT_SEQUENCE:
-        if(Phase == PHASE_FLIGHT) //land
-            Timer[EVENT_FLIGHT_SEQUENCE] = 2000;
-        else //lift off
+        if(Phase == PHASE_NORMAL) //lift off
         {
             FlightCount = 1;
@@ -2177,7 +2161,8 @@
             m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
             m_creature->GetMotionMaster()->Clear(false);
-            //m_creature->GetMotionMaster()->MoveIdle();
             m_creature->AttackStop();
         }
+        else //land
+            Timer[EVENT_FLIGHT_SEQUENCE] = 2000;
         break;
     case PHASE_TRANSFORM_SEQUENCE:
@@ -2192,5 +2177,4 @@
         }
         m_creature->GetMotionMaster()->Clear();
-        //m_creature->GetMotionMaster()->MoveIdle();
         m_creature->AttackStop();
         break;
Index: /trunk/sql/updates/194_world_blacktemple.sql
===================================================================
--- /trunk/sql/updates/194_world_blacktemple.sql (revision 186)
+++ /trunk/sql/updates/194_world_blacktemple.sql (revision 186)
@@ -0,0 +1,19 @@
+DELETE FROM spell_linked_spell WHERE `spell_trigger` IN (39992, 39835, 42052, -41914, 41126, 41376);
+-- INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39992, 39835, 1, 'Needle Spine');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39835, 39968, 1, 'Needle Spine');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41376, 41377, 0, 'Spite');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (41126, 41131, 1, 'Flame Crash');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41914, 41915, 0, 'Summon Parasitic Shadowfiend');
+INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39908, 40017, 1, 'Eye Blast');
+
+
+-- molten_flame
+UPDATE creature_template SET flags_extra = 128, speed = 1.0 WHERE entry = 23095;
+-- volcano
+UPDATE creature_template SET spell1 = 40117, flags_extra = 128, scriptname = '' WHERE entry = 23085;
+-- flame crash
+update creature_template set spell1 = 40836, flags_extra = 128, scriptname = '' where entry = 23336;
+-- blaze
+update creature_template set spell1 = 40610, flags_extra = 128, scriptname = '' where entry = 23259;
+-- glaive
+update creature_template set scriptname = 'mob_blade_of_azzinoth' where entry = 22996;
Index: /unk/sql/updates/163_world.sql
===================================================================
--- /trunk/sql/updates/163_world.sql (revision 178)
+++  (revision )
@@ -1,15 +1,0 @@
-DELETE FROM spell_linked_spell WHERE `spell_trigger` IN (39992, 39835, 42052, -41914, 41126, 41376);
--- INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39992, 39835, 1, 'Needle Spine');
-INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (39835, 39968, 1, 'Needle Spine');
-INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41376, 41377, 0, 'Spite');
-INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-41914, 41915, 0, 'Summon Parasitic Shadowfiend');
-INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (41126, 41131, 1, 'Flame Crash');
-
--- molten_flame
-UPDATE creature_template SET flags_extra = 128, speed = 1.0 WHERE entry = 23095;
--- volcano
-UPDATE creature_template SET spell1 = 40117, flags_extra = 128, scriptname = '' WHERE entry = 23085;
--- flame crash
-update creature_template set spell1 = 40836, flags_extra = 128, scriptname = '' where entry = 23336;
--- blaze
-update creature_template set spell1 = 40610, flags_extra = 128, scriptname = '' where entry = 23259;
