void VoidZoneArc() { ResetTimer(VoidTimer, (RandomUInt(10) + 30) * 1000); std::vector<Player*> TargetTable; set< Object* >::iterator Itr = _unit->GetInRangePlayerSetBegin(); for (; Itr != _unit->GetInRangePlayerSetEnd(); Itr++) { Player* RandomTarget = NULL; if (!(*Itr)->IsPlayer()) continue; RandomTarget = TO< Player* >(*Itr); if (RandomTarget && RandomTarget->isAlive() && isHostile(*Itr, _unit)) TargetTable.push_back(RandomTarget); } if (!TargetTable.size()) return; size_t RandTarget = rand() % TargetTable.size(); Player* RTarget = TargetTable[RandTarget]; if (!RTarget) return; float vzX = RandomUInt(5) * cos(RandomFloat(6.28f)) + RTarget->GetPositionX(); float vzY = RandomUInt(5) * cos(RandomFloat(6.28f)) + RTarget->GetPositionY(); float vzZ = RTarget->GetPositionZ(); MoonScriptCreatureAI* VoidZone = SpawnCreature(CN_VOIDZONEARC, vzX, vzY, vzZ); VoidZone->GetUnit()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); VoidZone->GetUnit()->m_noRespawn = true; if (!VoidZone->GetUnit()->IsInWorld()) { VoidZone->Despawn(); return; } RTarget = NULL; VoidZone->Despawn(60000, 0); }
void AIUpdate() { // Every 25% Halazzi calls on the lynx if(!mLynx && GetHealthPercent() <= (100 - SplitCount * 25)) Split(); // Lynx OR Halazzi is at 20% HP Merge them together again if(mLynx && (mLynx->GetHealthPct() <= 20 || GetHealthPercent() <= 20)) Merge(); // At <25% Phase 3 begins if(GetHealthPercent() < 25 && GetPhase() == 1) { ResetTimer(mTotemTimer, 30000); SetPhase(3); } if(GetPhase() == 2 || GetPhase() == 3) { if(IsTimerFinished(mTotemTimer)) { MoonScriptCreatureAI* Totem = NULL; Totem = SpawnCreature(CN_TOTEM, (_unit->GetPositionX() + RandomFloat(3) - 3), (_unit->GetPositionY() + RandomFloat(3) - 3), _unit->GetPositionZ(), 0, true); if(Totem) { Totem->Despawn(60000); // Despawn in 60 seconds Totem->AggroNearestPlayer(); Totem = NULL; } switch(GetPhase()) { case 2: ResetTimer(mTotemTimer, 60000); break; case 3: ResetTimer(mTotemTimer, 30000); break; // Spawn them faster then phase 2 } } } }