void MoveInLineOfSight(Unit* pWho) override { if (!m_pSpawnAssoc) return; if (pWho->isTargetableForAttack() && m_creature->IsHostileTo(pWho)) { Player* pPlayerTarget = pWho->GetTypeId() == TYPEID_PLAYER ? (Player*)pWho : nullptr; // airforce guards only spawn for players if (!pPlayerTarget) return; Creature* pLastSpawnedGuard = m_spawnedGuid ? GetSummonedGuard() : nullptr; // prevent calling GetCreature at next MoveInLineOfSight call - speedup if (!pLastSpawnedGuard) m_spawnedGuid.Clear(); switch (m_pSpawnAssoc->m_SpawnType) { case SPAWNTYPE_ALARMBOT: { if (!pWho->IsWithinDistInMap(m_creature, RANGE_GUARDS_MARK)) return; Aura* pMarkAura = pWho->GetAura(SPELL_GUARDS_MARK, EFFECT_INDEX_0); if (pMarkAura) { // the target wasn't able to move out of our range within 25 seconds if (!pLastSpawnedGuard) { pLastSpawnedGuard = SummonGuard(); if (!pLastSpawnedGuard) return; } if (pMarkAura->GetAuraDuration() < AURA_DURATION_TIME_LEFT) { if (!pLastSpawnedGuard->getVictim()) pLastSpawnedGuard->AI()->AttackStart(pWho); } } else { if (!pLastSpawnedGuard) pLastSpawnedGuard = SummonGuard(); if (!pLastSpawnedGuard) return; pLastSpawnedGuard->CastSpell(pWho, SPELL_GUARDS_MARK, true); } break; } case SPAWNTYPE_TRIPWIRE_ROOFTOP: { if (!pWho->IsWithinDistInMap(m_creature, RANGE_TRIPWIRE)) return; if (!pLastSpawnedGuard) pLastSpawnedGuard = SummonGuard(); if (!pLastSpawnedGuard) return; // ROOFTOP only triggers if the player is on the ground if (!pPlayerTarget->IsFlying()) { if (!pLastSpawnedGuard->getVictim()) pLastSpawnedGuard->AI()->AttackStart(pWho); } break; } } } }