void DespawnSphere() { std::list<Creature*> assistList; GetCreatureListWithEntryInGrid(assistList,m_creature, NPC_ETHEREAL_SPHERE ,150.0f); if (assistList.empty()) return; for(std::list<Creature*>::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) (*iter)->DealDamage((*iter), (*iter)->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); }
void UpdateOrientation() { std::list<Creature*> beamTarList; uint64 tarGuid = 0; GetCreatureListWithEntryInGrid(beamTarList, me, YELLOW_EYE_MOVER, 200.0f); for (auto Beam : beamTarList) tarGuid = Beam->GetGUID(); if (Creature* beamTar = ObjectAccessor::GetCreature(*me, tarGuid)) me->SetFacingToObject(beamTar); }
void DespawnCreatures(uint32 entry, float distance) { std::list<Creature*> creatures; GetCreatureListWithEntryInGrid(creatures, me, entry, distance); if (creatures.empty()) return; for (std::list<Creature*>::iterator iter = creatures.begin(); iter != creatures.end(); ++iter) (*iter)->DespawnOrUnsummon(); }
void SendWaypoint() { std::list<Creature*> lVoidwalkerList; GetCreatureListWithEntryInGrid(lVoidwalkerList, m_creature, NPC_VOIDWALKER, 50.0f); for (std::list<Creature*>::iterator itr = lVoidwalkerList.begin(); itr != lVoidwalkerList.end(); ++itr) { if ((*itr)->isAlive()) if (mob_arugal_voidwalkerAI* pVoidwalkerAI = dynamic_cast<mob_arugal_voidwalkerAI*>((*itr)->AI())) pVoidwalkerAI->ReceiveWaypoint(m_uiCurrentPoint, m_bReverse); } }
void DespawnAdds() { CreatureList pWorshippers; GetCreatureListWithEntryInGrid(pWorshippers, m_creature, NPC_WORSHIPPER, DEFAULT_VISIBILITY_INSTANCE); if (!pWorshippers.empty()) for(CreatureList::iterator itr = pWorshippers.begin(); itr != pWorshippers.end(); ++itr) { (*itr)->ForcedDespawn(); } CreatureList pFollower; GetCreatureListWithEntryInGrid(pFollower, m_creature, NPC_FOLLOWER, DEFAULT_VISIBILITY_INSTANCE); if (!pFollower.empty()) for(CreatureList::iterator iter = pFollower.begin(); iter != pFollower.end(); ++iter) { (*iter)->ForcedDespawn(); } }
void LavaSpoutErrupt() { std::list<Creature*> creatures; GetCreatureListWithEntryInGrid(creatures, me, NPC_LAVA_SPOUT_TRIGGER, 1000.0f); if (creatures.empty()) return; for (std::list<Creature*>::iterator iter = creatures.begin(); iter != creatures.end(); ++iter) (*iter)->CastSpell((*iter),SPELL_LAVA_SPOUT, true); }
void DespawnCreature(uint32 entry) { std::list<Creature*> creatureList; GetCreatureListWithEntryInGrid(creatureList, me, entry, 80.0f); for (auto NowCreature : creatureList) { if (NowCreature->GetEntry() == BLUE_FOG && NowCreature->GetDisplayId() == NowCreature->GetNativeDisplayId()) // if blue fog was been activated not despawn him continue; NowCreature->DespawnOrUnsummon(); } }
bool allStartMobsDead() { std::list<Creature* > lCreatureList; GetCreatureListWithEntryInGrid(lCreatureList, m_creature, NPC_TWILIGHT_INITIATE, 40.); if (!lCreatureList.empty()) for(std::list<Creature*>::iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr) if ((*itr)->isAlive()) return false; return true; }
void RespawnBeams() { std::list<Creature*> creatures; GetCreatureListWithEntryInGrid(creatures, me, NPC_JINARA_BEAM, 100.0f); if (creatures.empty()) return; for (std::list<Creature*>::iterator iter = creatures.begin(); iter != creatures.end(); ++iter) { if ((*iter)->isDead()) (*iter)->Respawn(); } }
void DamageTaken(Unit* pDoneBy, uint32& uiDamage, DamageEffectType /*damagetype*/) override { if (uiDamage > m_creature->GetHealth() || m_creature->GetHealthPercent() < 20.0f) { if (Player* pPlayer = pDoneBy->GetBeneficiaryPlayer()) { if (pPlayer->GetQuestStatus(QUEST_MISSING_DIPLO_PT16) == QUEST_STATUS_INCOMPLETE) guidPlayer = pPlayer->GetObjectGuid(); // Store the player to give quest credit later } uiDamage = 0; DoScriptText(EMOTE_SURRENDER, m_creature); EnterEvadeMode(); // Make the two sentries flee and despawn CreatureList lSentryList; GetCreatureListWithEntryInGrid(lSentryList, m_creature, NPC_SENTRY, 40.0f); for (CreatureList::const_iterator itr = lSentryList.begin(); itr != lSentryList.end(); ++itr) { if ((*itr)->isAlive()) { (*itr)->RemoveAllAurasOnEvade(); (*itr)->CombatStop(true); (*itr)->SetWalk(false); (*itr)->GetMotionMaster()->MovePoint(0, fSentryFleePoint[0], fSentryFleePoint[1], fSentryFleePoint[2]); (*itr)->ForcedDespawn(4000); } } // Summon Jaina Proudmoore, Archmage Tervosh and Pained for (const auto& lOutroSpawn : lOutroSpawns) { Creature* pCreature = m_creature->SummonCreature(lOutroSpawn.uiEntry, lOutroSpawn.fX, lOutroSpawn.fY, lOutroSpawn.fZ, lOutroSpawn.fO, TEMPSPAWN_TIMED_DESPAWN, 3 * MINUTE * IN_MILLISECONDS, false, true); if (pCreature) { pCreature->CastSpell(pCreature, SPELL_TELEPORT_VISUAL, TRIGGERED_NONE); pCreature->GetMotionMaster()->MovePoint(0, lOutroSpawn.fDestX, lOutroSpawn.fDestY, lOutroSpawn.fDestZ); // Exception case for Archmage Tervosh: the outro event is a simple speech with visual spell cast // so it will be handled by a DBScript held by NPC Archmage Tervosh if (pCreature->GetEntry() == NPC_TERVOSH) { // Remove Gossip and Quest Giver flag from now, they will be re-added later to Archmage Tervosh in DBScript pCreature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP); // The DBScript will be done here pCreature->GetMotionMaster()->MoveWaypoint(0); } } } } }
void UpdateAI(const uint32 uiDiff) override { if (m_uiStartTimer) { if (m_uiStartTimer <= uiDiff) { // get all the bats list in range; note: this will compare the 2D distance std::list<Creature*> lBatsList; GetCreatureListWithEntryInGrid(lBatsList, m_creature, NPC_DARKCLAW_BAT, 10.0f); if (lBatsList.empty()) { m_uiStartTimer = 5000; return; } // sort by distance and get only the closest lBatsList.sort(ObjectDistanceOrder(m_creature)); std::list<Creature*>::const_iterator batItr = lBatsList.begin(); Creature* pBat = NULL; do { // check for alive and out of combat only if ((*batItr)->isAlive() && !(*batItr)->getVictim()) pBat = *batItr; ++batItr; } while (!pBat && batItr != lBatsList.end()); if (!pBat) { m_uiStartTimer = 5000; return; } // Move bat to the point float fX, fY, fZ; pBat->SetWalk(false); pBat->GetMotionMaster()->Clear(); m_creature->GetContactPoint(pBat, fX, fY, fZ); pBat->GetMotionMaster()->MovePoint(0, fX, fY, fZ); m_selectedBatGuid = pBat->GetObjectGuid(); m_uiStartTimer = 0; m_bHasValidBat = true; } else m_uiStartTimer -= uiDiff; } }
void ShowMushrooms(bool show = true) { std::list<Creature*> lMushroomsHealthy; GetCreatureListWithEntryInGrid(lMushroomsHealthy, m_creature, NPC_HEALTHY_MUSHROOM, 150.0f); for(std::list<Creature*>::iterator itr1 = lMushroomsHealthy.begin(); itr1 != lMushroomsHealthy.end(); ++itr1) { if(show) (*itr1)->SetVisibility(VISIBILITY_ON); else (*itr1)->SetVisibility(VISIBILITY_OFF); } std::list<Creature*> lMushroomsPoison; GetCreatureListWithEntryInGrid(lMushroomsPoison, m_creature, NPC_POISONOUS_MUSHROOM, 150.0f); for(std::list<Creature*>::iterator itr2 = lMushroomsPoison.begin(); itr2 != lMushroomsPoison.end(); ++itr2) { if(show) (*itr2)->SetVisibility(VISIBILITY_ON); else (*itr2)->SetVisibility(VISIBILITY_OFF); } }
void JustStartedEscort() { m_uiEventTimer = 5000; m_uiEventCount = 0; m_lResearchersList.clear(); GetCreatureListWithEntryInGrid(m_lResearchersList, m_creature, NPC_RESEARCHER, 25.0f); if (!m_lResearchersList.empty()) SetFormation(); }
void DoWorldInFlamesEvent() { std::list<Creature*> munitionList; GetCreatureListWithEntryInGrid(munitionList, me, NPC_STABLE_MUNITION, 100.0f); for (std::list<Creature*>::const_iterator i = munitionList.begin(); i != munitionList.end(); ++i) { (*i)->RemoveAurasDueToSpell(SPELL_MUNITION_STABLE); (*i)->CastSpell((*i), SPELL_MUNITION_EXPLOSION, true); (*i)->DespawnOrUnsummon(2000); } }
void Reset() override { m_creature->SetWalk(true); m_uiDarkOffering = urand(4400, 12500); m_bWPDone = true; Creature* pLeader = m_creature->GetMap()->GetCreature(m_leaderGuid); if (pLeader && pLeader->isAlive()) { m_creature->GetMotionMaster()->MoveFollow(pLeader, 1.0f, M_PI / 2 * m_uiPosition); } else { std::list<Creature*> lVoidwalkerList; Creature* pNewLeader = NULL; uint8 uiHighestPosition = 0; GetCreatureListWithEntryInGrid(lVoidwalkerList, m_creature, NPC_VOIDWALKER, 50.0f); for (std::list<Creature*>::iterator itr = lVoidwalkerList.begin(); itr != lVoidwalkerList.end(); ++itr) { if ((*itr)->isAlive()) { if (mob_arugal_voidwalkerAI* pVoidwalkerAI = dynamic_cast<mob_arugal_voidwalkerAI*>((*itr)->AI())) { uint8 uiPosition = pVoidwalkerAI->GetPosition(); if (uiPosition > uiHighestPosition) { pNewLeader = (*itr); uiHighestPosition = uiPosition; } } } } if (pNewLeader) { m_leaderGuid = pNewLeader->GetObjectGuid(); if (pNewLeader == m_creature) { m_bIsLeader = true; m_bWPDone = true; } else m_creature->GetMotionMaster()->MoveFollow(pNewLeader, 1.0f, M_PI / 2 * m_uiPosition); } else { pNewLeader = m_creature; m_bIsLeader = true; m_bWPDone = true; } } }
void UpdateAI(const uint32 uiDiff) { if (m_uiCheckRangeTimer < uiDiff) { if (m_creature->GetDistance(END_X, END_Y, END_Z) < 30) { if( VehicleKitPtr vehicle = m_creature->GetVehicleKit()) { if (Unit* pPlayer = vehicle->GetPassenger(0)) { if (pPlayer->GetTypeId() == TYPEID_PLAYER) { for (int8 i = 1; i < 4; ++i) { if (Unit* pPrisoner = vehicle->GetPassenger(i)) { pPlayer->DealDamage(pPrisoner, pPrisoner->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } } ((Player*)pPlayer)->KilledMonsterCredit(m_creature->GetEntry(), m_creature->GetObjectGuid()); pPlayer->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } } } } else { if (boarded < 3) { std::list<Creature*> pPrisonerList; GetCreatureListWithEntryInGrid(pPrisonerList, m_creature, NPC_ICE_PRISONER, 30.0f); if (!pPrisonerList.empty()) { for(std::list<Creature*>::iterator iter = pPrisonerList.begin(); iter != pPrisonerList.end(); ++iter) { if (Creature* pPrisoner = (*iter)) { if (pPrisoner->isAlive()) { DoCast(pPrisoner, SPELL_SUMMON_FREE_PRISONER); pPrisoner->ForcedDespawn(); } } } } } } m_uiCheckRangeTimer = 2000; } else m_uiCheckRangeTimer -= uiDiff; }
void WaypointReached(uint32 uiPointId) override { switch (uiPointId) { case 2: DoScriptText(SAY_HANES_FIRE_1, m_creature); break; case 3: DoScriptText(SAY_HANES_FIRE_2, m_creature); break; case 14: case 20: case 21: case 29: { m_creature->HandleEmote(EMOTE_ONESHOT_ATTACK1H); // set all nearby triggers on fire - ToDo: research if done by spell! std::list<Creature*> lTriggersInRange; GetCreatureListWithEntryInGrid(lTriggersInRange, m_creature, NPC_HANES_TRIGGER, 10.0f); for (std::list<Creature*>::const_iterator itr = lTriggersInRange.begin(); itr != lTriggersInRange.end(); ++itr) { (*itr)->CastSpell((*itr), SPELL_LOW_POLY_FIRE, true); (*itr)->ForcedDespawn(30000); } break; } case 15: DoScriptText(SAY_HANES_SUPPLIES_1, m_creature); break; case 22: DoScriptText(SAY_HANES_SUPPLIES_2, m_creature); break; case 30: m_creature->HandleEmote(EMOTE_ONESHOT_LAUGH_NOSHEATHE); break; case 31: DoScriptText(SAY_HANES_SUPPLIES_COMPLETE, m_creature); break; case 32: DoScriptText(SAY_HANES_SUPPLIES_ESCAPE, m_creature); break; case 40: DoScriptText(SAY_HANES_ARRIVE_BASE, m_creature); break; case 44: if (Player* pPlayer = GetPlayerForEscort()) pPlayer->GroupEventHappens(QUEST_ID_TRIAL_OF_FIRE, m_creature); break; } }
void DoRemoveAdds() { for (GuidList::iterator i = m_lSummonedAddsGuids.begin(); i != m_lSummonedAddsGuids.end(); ++i) { if (Creature* pTmp = m_creature->GetMap()->GetCreature(*i)) pTmp->ForcedDespawn(); } std::list<Creature*> lWorms; GetCreatureListWithEntryInGrid(lWorms, m_creature, NPC_ROT_WORM, 100.0f); for (std::list<Creature*>::iterator i = lWorms.begin(); i != lWorms.end(); ++i) (*i)->ForcedDespawn(); }
void JustReachedHome() override { if (m_pInstance) m_pInstance->SetData(TYPE_NETHEKURSE, FAIL); std::list<Creature*> lFelConverts; GetCreatureListWithEntryInGrid(lFelConverts, m_creature, NPC_FEL_ORC_CONVERT, 40.0f); for (std::list<Creature*>::iterator itr = lFelConverts.begin(); itr != lFelConverts.end(); ++itr) { if (!(*itr)->isAlive()) (*itr)->Respawn(); } }
void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); std::list<Creature*> triggers; GetCreatureListWithEntryInGrid(triggers, GetHitUnit(), NPC_BAD_INTENTIONS_TARGET, 100.0f); if (!triggers.empty()) { triggers.sort(Trinity::ObjectDistanceOrderPred(GetHitUnit(), true)); Creature* trigger = triggers.front(); GetHitUnit()->CastSpell(trigger, uint32(GetEffectValue()), true); } }
void CastBunnySpell(Creature* pTarget, uint32 uSpell) { if (!uSpell) return; std::list<Creature*> creatureList; GetCreatureListWithEntryInGrid(creatureList, m_creature, NPC_VIMGOL_VISUAL_BUNNY, 200.0f); for (auto& bunny : creatureList) for (auto it = m_uiBunnyGuids.begin(); it != m_uiBunnyGuids.end(); ++it) if ((*it) == bunny->GetObjectGuid()) if (m_uiActiveCircles[std::distance(m_uiBunnyGuids.begin(), it)]) bunny->CastSpell(pTarget ? pTarget : bunny, uSpell, TRIGGERED_OLD_TRIGGERED); }
void UnSummonAllCreatures() { for (GuidMap::const_iterator i = CurrSummons.begin(); i != CurrSummons.end(); ++i) if (Creature *pSummon = m_creature->GetMap()->GetCreature(i->second)) pSummon->ForcedDespawn(); CurrSummons.clear(); //not summoned by Algalon himself std::list<Creature*> DarkMatter; GetCreatureListWithEntryInGrid(DarkMatter, m_creature, NPC_UNLEASHED_DARK_MATTER, 100.0f); for (std::list<Creature*>::const_iterator i = DarkMatter.begin(); i!= DarkMatter.end(); ++i) (*i)->ForcedDespawn(); }
void DoWorldInFlamesEvent() { Talk(TALK_SPECIAL3); std::list<Creature*> munitionList; GetCreatureListWithEntryInGrid(munitionList, me, NPC_STABLE_MUNITION, 100.0f); for (auto itr: munitionList) { itr->RemoveAurasDueToSpell(SPELL_MUNITION_STABLE); itr->CastSpell(itr, SPELL_MUNITION_EXPLOSION, true); itr->DespawnOrUnsummon(2000); } }
boss_karsh_steelbenderAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); std::list<Creature*> creatures; GetCreatureListWithEntryInGrid(creatures, me, NPC_LAVA_SPOUT_TRIGGER, 1000.0f); if (creatures.empty()) return; for (std::list<Creature*>::iterator iter = creatures.begin(); iter != creatures.end(); ++iter) (*iter)->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_SELECTABLE); }
Creature* SelectRandomCreatureOfEntryInRange(uint32 uiEntry, float fRange) { std::list<Creature* > lCreatureList; GetCreatureListWithEntryInGrid(lCreatureList, m_creature, uiEntry, fRange); if (lCreatureList.empty()) return NULL; std::list<Creature* >::iterator iter = lCreatureList.begin(); advance(iter, urand(0, lCreatureList.size()-1)); return *iter; }
void JustReachedHome() { std::list<Creature*> lChannelers; GetCreatureListWithEntryInGrid(lChannelers, m_creature, NPC_CHANNELER, DEFAULT_VISIBILITY_INSTANCE); if (!lChannelers.empty()) { for(std::list<Creature*>::iterator iter = lChannelers.begin(); iter != lChannelers.end(); ++iter) { if ((*iter) && !(*iter)->isAlive()) (*iter)->Respawn(); } } }
void FindDeathKnight() { std::list<Creature*> DeathKnight; GetCreatureListWithEntryInGrid(DeathKnight, m_creature, NPC_DEATH_KNIGHT_UNDERSTUDY, 50.0f); if (!DeathKnight.empty()) { DeathKnightList.clear(); for(std::list<Creature*>::iterator itr = DeathKnight.begin(); itr != DeathKnight.end(); ++itr) DeathKnightList.push_back((*itr)->GetGUID()); } }
void EnterCombat(Unit* /*who*/) { std::list<Creature*> searcher; GetCreatureListWithEntryInGrid(searcher, me, CREATURE_FOUTAIN_TRIGGER, 50.0f); uint8 tab = 0; for (auto itr : searcher) { if (!itr) continue; itr->RemoveAllAuras(); foutainTrigger[++tab] = itr->GetGUID(); } searcher.clear(); GetCreatureListWithEntryInGrid(searcher, me, CREATURE_CORRUPT_DROPLET, 50.0f); for (auto itr : searcher) { if (!itr) continue; if (itr->isSummon()) itr->ForcedDespawn(); } me->SetInCombatWithZone(); me->CastSpell(me, SPELL_WATER_BUBBLE, true); Talk(TEXT_AGGRO); Talk(TEXT_BOSS_EMOTE_AGGRO); intro = true; phase = 1; hydrolancePhase = HYDROLANCE_BOTTOM; events.ScheduleEvent(EVENT_CALL_WATER, 8000); events.ScheduleEvent(EVENT_HYDROLANCE_START, TIMER_HYDROLANCE_START); _EnterCombat(); }
void UpdateAI(const uint32 uiDiff) { if (!UpdateVictim()) return; if (RipTimer <= uiDiff) { DoCastVictim(SPELL_RIP_FLESH); RipTimer = urand(14000, 18000); } else RipTimer -= uiDiff; if (PounceTimer <= uiDiff) { if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 60, true)) { me->AddThreat(pTarget, 100.0f); me->AI()->AttackStart(pTarget); DoCast(pTarget, SPELL_SAVAGE_POUNCE); } PounceTimer = urand(20000, 30000); } else PounceTimer -= uiDiff; // Increases the damage of all Sanctum Sentries within 10 yards by 30% if (CheckTimer < uiDiff) { uint8 aura = NULL; std::list<Creature*> Sanctum; GetCreatureListWithEntryInGrid(Sanctum, me, NPC_SANCTUM_SENTRY, 10.0f); for(std::list<Creature*>::iterator itr = Sanctum.begin(); itr != Sanctum.end(); ++itr) { Creature *Sentry = *itr; if (!Sentry) continue; if (Sentry->isAlive() && me != Sentry) aura++; } if (aura) me->SetAuraStack(SPELL_STRENGHT_PACK, me, aura); CheckTimer = 2000; } else CheckTimer -= uiDiff; DoMeleeAttackIfReady(); }
bool GOUse_go_scourge_enclosure(Player* pPlayer, GameObject* pGo) { std::list<Creature*> m_lResearchersList; GetCreatureListWithEntryInGrid(m_lResearchersList, pGo, NPC_GYMER_LOCK_DUMMY, 15.0f); if (!m_lResearchersList.empty()) { for(std::list<Creature*>::iterator itr = m_lResearchersList.begin(); itr != m_lResearchersList.end(); ++itr) { (*itr)->CastSpell((*itr),SPELL_GYMER_LOCK_EXPLOSION,true); } } pPlayer->KilledMonsterCredit(NPC_GYMER_LOCK_DUMMY); return true; }