void AttackStart(Unit *who) { if (!who) return; if (m_creature->getVictim() == NULL && who->isTargetableForAttack() && who!= m_creature) { //Begin melee attack if we are within range if (m_creature->IsWithinDist(who, ATTACK_DIST)){ DoStartMeleeAttack(who); InCombat = true; } else DoStartRangedAttack(who); InCombat = true; pTarget = who; } }
void AttackStart(Unit *who) { if (!who) return; if (who->isTargetableForAttack() && who!= m_creature) { //Begin melee attack if we are within range if (m_creature->IsWithinDistInMap(who, ATTACK_DIST)) DoStartMeleeAttack(who); else DoStartRangedAttack(who); //Say our dialog DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); DoPlaySoundToSet(m_creature,SOUND_AGGRO); InCombat = true; } }
//*** HANDLED FUNCTION *** //Move in line of sight is called whenever any unit moves within our sight radius (something like 50 yards) void MoveInLineOfSight(Unit *who) { if (!who || m_creature->getVictim()) return; if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) { float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDist(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE) { if(who->HasStealthAura()) who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); //Begin melee attack if we are within range if (m_creature->IsWithinDist(who, ATTACK_DIST)) DoStartMeleeAttack(who); else DoStartRangedAttack(who); //Say some stuff DoSay(SAY_AGGRO,LANG_UNIVERSAL,NULL); DoPlaySoundToSet(m_creature,8280); } } }