void instance_karazhan::DoPrepareChessEvent() { // Allow all the chess pieces to init start position for (GuidList::const_iterator itr = m_lChessPiecesAlliance.begin(); itr != m_lChessPiecesAlliance.end(); ++itr) { if (Creature* pChessPiece = instance->GetCreature(*itr)) { Creature* pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_BLACK, 2.0f); if (!pSquare) pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_WHITE, 2.0f); if (!pSquare) { script_error_log("Instance Karazhan: ERROR Failed to properly load the Chess square for %s.", pChessPiece->GetGuidStr().c_str()); return; } // send event which will prepare the current square pChessPiece->AI()->SendAIEvent(AI_EVENT_CUSTOM_B, pSquare, pChessPiece); } } for (GuidList::const_iterator itr = m_lChessPiecesHorde.begin(); itr != m_lChessPiecesHorde.end(); ++itr) { if (Creature* pChessPiece = instance->GetCreature(*itr)) { Creature* pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_BLACK, 2.0f); if (!pSquare) pSquare = GetClosestCreatureWithEntry(pChessPiece, NPC_SQUARE_WHITE, 2.0f); if (!pSquare) { script_error_log("Instance Karazhan: ERROR Failed to properly load the Chess square for %s.", pChessPiece->GetGuidStr().c_str()); return; } // send event which will prepare the current square pChessPiece->AI()->SendAIEvent(AI_EVENT_CUSTOM_B, pSquare, pChessPiece); } } // add silence debuff Map::PlayerList const& players = instance->GetPlayers(); for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { if (Player* pPlayer = itr->getSource()) pPlayer->CastSpell(pPlayer, SPELL_GAME_IN_SESSION, true); } m_uiAllianceStalkerCount = 0; m_uiHordeStalkerCount = 0; m_vHordeStalkers.clear(); m_vAllianceStalkers.clear(); // sort stalkers depending on side std::list<Creature*> lStalkers; for (GuidList::const_iterator itr = m_lChessHordeStalkerList.begin(); itr != m_lChessHordeStalkerList.end(); ++itr) { if (Creature* pTemp = instance->GetCreature(*itr)) lStalkers.push_back(pTemp); } if (lStalkers.empty()) { script_error_log("Instance Karazhan: ERROR Failed to properly load the horde side stalkers for the Chess Event."); return; } // get the proper statusBar npc Creature* pStatusBar = instance->GetCreature(m_HordeStatusGuid); if (!pStatusBar) return; lStalkers.sort(ObjectDistanceOrder(pStatusBar)); for (std::list<Creature*>::const_iterator itr = lStalkers.begin(); itr != lStalkers.end(); ++itr) m_vHordeStalkers.push_back((*itr)->GetObjectGuid()); lStalkers.clear(); for (GuidList::const_iterator itr = m_lChessAllianceStalkerList.begin(); itr != m_lChessAllianceStalkerList.end(); ++itr) { if (Creature* pTemp = instance->GetCreature(*itr)) lStalkers.push_back(pTemp); } if (lStalkers.empty()) { script_error_log("Instance Karazhan: ERROR Failed to properly load the alliance side stalkers for the Chess Event."); return; } // get the proper statusBar npc pStatusBar = instance->GetCreature(m_AllianceStatusGuid); if (!pStatusBar) return; lStalkers.sort(ObjectDistanceOrder(pStatusBar)); for (std::list<Creature*>::const_iterator itr = lStalkers.begin(); itr != lStalkers.end(); ++itr) m_vAllianceStalkers.push_back((*itr)->GetObjectGuid()); }
void UpdateAI(uint32 const diff) { events.Update(diff); switch (events.ExecuteEvent()) { case EVENT_SPAWN: { if (Creature* Dalfors = DoSummon(NPC_CRUSADER_LORD_DALFORS, DalforsPos[0])) { guidDalfors = Dalfors->GetGUID(); Dalfors->GetMotionMaster()->MovePoint(0, DalforsPos[1]); } if (Creature* Priest1 = DoSummon(NPC_ARGENT_BATTLE_PRIEST, Priest1Pos[0])) { guidPriest[0] = Priest1->GetGUID(); Priest1->GetMotionMaster()->MovePoint(0, Priest1Pos[1]); } if (Creature* Priest2 = DoSummon(NPC_ARGENT_BATTLE_PRIEST, Priest2Pos[0])) { guidPriest[1] = Priest2->GetGUID(); Priest2->GetMotionMaster()->MovePoint(0, Priest2Pos[1]); } if (Creature* Priest3 = DoSummon(NPC_ARGENT_BATTLE_PRIEST, Priest3Pos[0])) { guidPriest[2] = Priest3->GetGUID(); Priest3->GetMotionMaster()->MovePoint(0, Priest3Pos[1]); } if (Creature* Mason1 = DoSummon(NPC_ARGENT_MASON, Mason1Pos[0])) { guidMason[0] = Mason1->GetGUID(); Mason1->GetMotionMaster()->MovePoint(0, Mason1Pos[1]); } if (Creature* Mason2 = DoSummon(NPC_ARGENT_MASON, Mason2Pos[0])) { guidMason[1] = Mason2->GetGUID(); Mason2->GetMotionMaster()->MovePoint(0, Mason2Pos[1]); } if (Creature* Mason3 = DoSummon(NPC_ARGENT_MASON, Mason3Pos[0])) { guidMason[2] = Mason3->GetGUID(); Mason3->GetMotionMaster()->MovePoint(0, Mason3Pos[1]); } events.ScheduleEvent(EVENT_INTRO_1,15000); } break; case EVENT_INTRO_1: { if (Creature* Dalfors = me->GetCreature(*me,guidDalfors)) Dalfors->AI()->Talk(DALFORS_SAY_PRE_1); events.ScheduleEvent(EVENT_INTRO_2,5000); } break; case EVENT_INTRO_2: { if (Creature* Dalfors = me->GetCreature(*me,guidDalfors)) { Dalfors->SetFacingTo(6.215f); Dalfors->AI()->Talk(DALFORS_SAY_PRE_2); } events.ScheduleEvent(EVENT_INTRO_3,5000); } break; case EVENT_INTRO_3: { if (Creature* Dalfors = me->GetCreature(*me,guidDalfors)) { Dalfors->GetMotionMaster()->MovePoint(0, DalforsPos[2]); Dalfors->SetHomePosition(DalforsPos[2]); } if (Creature* Priest1 = me->GetCreature(*me,guidPriest[0])) { Priest1->SetFacingTo(5.7421f); Priest1->SetHomePosition(Priest1Pos[1]); } if (Creature* Priest2 = me->GetCreature(*me,guidPriest[1])) { Priest2->SetFacingTo(5.7421f); Priest2->SetHomePosition(Priest2Pos[1]); } if (Creature* Priest3 = me->GetCreature(*me,guidPriest[2])) { Priest3->SetFacingTo(5.7421f); Priest3->SetHomePosition(Priest3Pos[1]); } if (Creature* Mason1 = me->GetCreature(*me,guidMason[0])) { Mason1->GetMotionMaster()->MovePoint(0, Mason1Pos[2]); Mason1->SetHomePosition(Mason1Pos[2]); } if (Creature* Mason2 = me->GetCreature(*me,guidMason[1])) { Mason2->GetMotionMaster()->MovePoint(0, Mason2Pos[2]); Mason2->SetHomePosition(Mason2Pos[2]); } if (Creature* Mason3 = me->GetCreature(*me,guidMason[2])) { Mason3->GetMotionMaster()->MovePoint(0, Mason3Pos[2]); Mason3->SetHomePosition(Mason3Pos[2]); } events.ScheduleEvent(EVENT_START_FIGHT,5000); events.ScheduleEvent(EVENT_MASON_ACTION,15000); } break; case EVENT_MASON_ACTION: { if (Creature* Mason1 = me->GetCreature(*me,guidMason[0])) { Mason1->SetFacingTo(2.8972f); Mason1->AI()->SetData(1,1); // triggers SAI actions on npc } if (Creature* Mason2 = me->GetCreature(*me,guidMason[1])) { Mason2->SetFacingTo(3.1241f); Mason2->AI()->SetData(1,1); // triggers SAI actions on npc } if (Creature* Mason3 = me->GetCreature(*me,guidMason[2])) { Mason3->SetFacingTo(3.6651f); Mason3->AI()->SetData(1,1); // triggers SAI actions on npc } } break; case EVENT_START_FIGHT: { if(Creature* LK = GetClosestCreatureWithEntry(me,NPC_LK,100)) LK->AI()->Talk(LK_TALK_1); if (Creature* Dalfors = me->GetCreature(*me,guidDalfors)) Dalfors->AI()->Talk(DALFORS_SAY_START); events.ScheduleEvent(EVENT_WAVE_SPAWN,1000); } break; case EVENT_WAVE_SPAWN: { if (PhaseCount == 3) { if (Creature* LK = GetClosestCreatureWithEntry(me,NPC_LK,100)) LK->AI()->Talk(LK_TALK_2); } else if (PhaseCount == 6) { if (Creature* LK = GetClosestCreatureWithEntry(me,NPC_LK,100)) LK->AI()->Talk(LK_TALK_3); } if (Creature* tempsum = DoSummon(NPC_SCOURGE_DRUDGE,Mason3Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } if (urand(0,1) == 0) { if (Creature* tempsum = DoSummon(NPC_HIDEOUS_PLAGEBRINGER,Mason1Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } if (Creature* tempsum = DoSummon(NPC_HIDEOUS_PLAGEBRINGER,Mason2Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } } else { if (Creature* tempsum = DoSummon(NPC_REANIMATED_CAPTAIN,Mason1Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } if (Creature* tempsum = DoSummon(NPC_REANIMATED_CAPTAIN,Mason2Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } } PhaseCount++; if (PhaseCount < 8) events.ScheduleEvent(EVENT_WAVE_SPAWN,urand(10000,20000)); else events.ScheduleEvent(EVENT_HALOF,urand(10000,20000)); } break; case EVENT_HALOF: { if (Creature* LK = GetClosestCreatureWithEntry(me,NPC_LK,100)) LK->AI()->Talk(LK_TALK_4); if (Creature* tempsum = DoSummon(NPC_SCOURGE_DRUDGE,Mason1Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } if (Creature* tempsum = DoSummon(NPC_SCOURGE_DRUDGE,Mason2Pos[0])) { tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } if (Creature* tempsum = DoSummon(NPC_HALOF_THE_DEATHBRINGER,DalforsPos[0])) { HalofSpawned = true; guidHalof = tempsum->GetGUID(); tempsum->SetHomePosition(DalforsPos[2]); tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me,NPC_BLESSED_BANNER,100)); } } break; case EVENT_ENDED: { Summons.DespawnAll(); me->DespawnOrUnsummon(); } break; } if (PhaseCount == 8) if (Creature* Halof = me->GetCreature(*me,guidHalof)) if (Halof->isDead()) { DoCast(me,SPELL_CRUSADERS_SPIRE_VICTORY,true); Summons.DespawnEntry(NPC_HIDEOUS_PLAGEBRINGER); Summons.DespawnEntry(NPC_REANIMATED_CAPTAIN); Summons.DespawnEntry(NPC_SCOURGE_DRUDGE); Summons.DespawnEntry(NPC_HALOF_THE_DEATHBRINGER); if (Creature* Dalfors = me->GetCreature(*me,guidDalfors)) Dalfors->AI()->Talk(DALFORS_YELL_FINISHED); events.ScheduleEvent(EVENT_ENDED,10000); } }
void JustReachedHome() { pPyro = GetClosestCreatureWithEntry(m_creature, NPC_PYROGUARD_EMBERSEER, DEFAULT_VISIBILITY_INSTANCE); if (pPyro) ((boss_pyroguard_emberseerAI*)pPyro->AI())->Reset(); }
void JustDidDialogueStep(int32 iEntry) override { switch (iEntry) { case NPC_ANACHRONOS_THE_ANCIENT: // Call the other dragons DoSummonDragons(); break; case EMOTE_ONESHOT_SHOUT: // Summon warriors DoSummonWarriors(); m_creature->HandleEmote(EMOTE_ONESHOT_SHOUT); break; case SAY_FANDRAL_INTRO_2: if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->SetFacingToObject(m_creature); break; case EMOTE_MERITHRA_GLANCE: if (Creature* pMerithra = m_creature->GetMap()->GetCreature(m_merithraGuid)) { if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->SetFacingToObject(pMerithra); } break; case NPC_ANACHRONOS_QUEST_TRIGGER: // Move Merithra to attack if (Creature* pTrigger = GetClosestCreatureWithEntry(m_creature, NPC_ANACHRONOS_QUEST_TRIGGER, 35.0f)) { m_triggerGuid = pTrigger->GetObjectGuid(); if (Creature* pMerithra = m_creature->GetMap()->GetCreature(m_merithraGuid)) { pMerithra->SetWalk(false); pMerithra->GetMotionMaster()->MovePoint(POINT_ID_DRAGON_ATTACK, pTrigger->GetPositionX(), pTrigger->GetPositionY(), pTrigger->GetPositionZ()); } } break; case SPELL_GREEN_DRAGON_TRANSFORM: if (Creature* pMerithra = m_creature->GetMap()->GetCreature(m_merithraGuid)) pMerithra->CastSpell(pMerithra, SPELL_GREEN_DRAGON_TRANSFORM, TRIGGERED_NONE); break; case SAY_ARYGOS_ATTACK_2: if (Creature* pMerithra = m_creature->GetMap()->GetCreature(m_merithraGuid)) pMerithra->CastSpell(pMerithra, SPELL_MERITHRA_WAKE, TRIGGERED_NONE); break; case NPC_ARYGOS: // Move Arygos to attack if (Creature* pTrigger = m_creature->GetMap()->GetCreature(m_triggerGuid)) { if (Creature* pArygos = m_creature->GetMap()->GetCreature(m_arygosGuid)) { pArygos->SetWalk(false); pArygos->GetMotionMaster()->MovePoint(POINT_ID_DRAGON_ATTACK, pTrigger->GetPositionX(), pTrigger->GetPositionY(), pTrigger->GetPositionZ()); } } break; case POINT_ID_EXIT: // Move Merithra to the exit point if (Creature* pMerithra = m_creature->GetMap()->GetCreature(m_merithraGuid)) { pMerithra->SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM); pMerithra->SetLevitate(true); pMerithra->GetMotionMaster()->MovePoint(POINT_ID_EXIT, aEternalBoardMovement[0].m_fX, aEternalBoardMovement[0].m_fY, aEternalBoardMovement[0].m_fZ); pMerithra->ForcedDespawn(9000); } break; case SPELL_BLUE_DRAGON_TRANSFORM: if (Creature* pArygos = m_creature->GetMap()->GetCreature(m_arygosGuid)) pArygos->CastSpell(pArygos, SPELL_BLUE_DRAGON_TRANSFORM, TRIGGERED_NONE); break; case SPELL_ARYGOS_VENGEANCE: if (Creature* pArygos = m_creature->GetMap()->GetCreature(m_arygosGuid)) pArygos->CastSpell(pArygos, SPELL_ARYGOS_VENGEANCE, TRIGGERED_NONE); break; case POINT_ID_DRAGON_ATTACK: // Move Arygos to the exit point if (Creature* pArygos = m_creature->GetMap()->GetCreature(m_arygosGuid)) { pArygos->SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM); pArygos->SetLevitate(true); pArygos->GetMotionMaster()->MovePoint(POINT_ID_EXIT, aEternalBoardMovement[0].m_fX, aEternalBoardMovement[0].m_fY, aEternalBoardMovement[0].m_fZ); pArygos->ForcedDespawn(9000); } break; case NPC_CAELESTRASZ: // Move Caelestrasz to attack if (Creature* pTrigger = m_creature->GetMap()->GetCreature(m_triggerGuid)) { if (Creature* pCaelestrasz = m_creature->GetMap()->GetCreature(m_CaelestraszGuid)) { pCaelestrasz->SetWalk(false); pCaelestrasz->GetMotionMaster()->MovePoint(POINT_ID_DRAGON_ATTACK, pTrigger->GetPositionX(), pTrigger->GetPositionY(), pTrigger->GetPositionZ()); } } break; case SPELL_RED_DRAGON_TRANSFORM: if (Creature* pCaelestrasz = m_creature->GetMap()->GetCreature(m_CaelestraszGuid)) pCaelestrasz->CastSpell(pCaelestrasz, SPELL_RED_DRAGON_TRANSFORM, TRIGGERED_NONE); break; case SPELL_CAELESTRASZ_MOLTEN_RAIN: if (Creature* pCaelestrasz = m_creature->GetMap()->GetCreature(m_CaelestraszGuid)) pCaelestrasz->CastSpell(pCaelestrasz, SPELL_CAELESTRASZ_MOLTEN_RAIN, TRIGGERED_NONE); break; case SAY_ANACHRONOS_SEAL_1: // Send Caelestrasz on flight if (Creature* pCaelestrasz = m_creature->GetMap()->GetCreature(m_CaelestraszGuid)) { pCaelestrasz->SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM); pCaelestrasz->SetLevitate(true); pCaelestrasz->GetMotionMaster()->MovePoint(POINT_ID_EXIT, aEternalBoardMovement[0].m_fX, aEternalBoardMovement[0].m_fY, aEternalBoardMovement[0].m_fZ); pCaelestrasz->ForcedDespawn(9000); } if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) m_creature->SetFacingToObject(pFandral); break; case SAY_FANDRAL_SEAL_2: if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->SetFacingToObject(m_creature); break; case POINT_ID_GATE: // Send Anachronos to the gate m_creature->SetWalk(false); m_creature->GetMotionMaster()->MovePoint(POINT_ID_GATE, aEternalBoardMovement[1].m_fX, aEternalBoardMovement[1].m_fY, aEternalBoardMovement[1].m_fZ); break; case NPC_FANDRAL_STAGHELM: // Send Fandral to the gate if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) { pFandral->SetWalk(false); pFandral->GetMotionMaster()->MovePoint(POINT_ID_GATE, aEternalBoardMovement[2].m_fX, aEternalBoardMovement[2].m_fY, aEternalBoardMovement[2].m_fZ); } break; case SPELL_PRISMATIC_BARRIER: DoCastSpellIfCan(m_creature, SPELL_PRISMATIC_BARRIER); break; case SPELL_GLYPH_OF_WARDING: DoCastSpellIfCan(m_creature, SPELL_GLYPH_OF_WARDING); break; case SAY_FANDRAL_SEAL_6: // Here Anachronos should continue to cast something if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->CastSpell(pFandral, SPELL_CALL_ANCIENTS, TRIGGERED_NONE); break; case EMOTE_FANDRAL_EXHAUSTED: if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) { pFandral->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->SetFacingToObject(pFandral); } break; case DATA_HANDLE_SCEPTER: // Give the scepter to Fandral (it should equip it somehow) if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) DoScriptText(EMOTE_ANACHRONOS_SCEPTER, m_creature, pFandral); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); break; case SAY_FANDRAL_EPILOGUE_4: if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->SetStandState(UNIT_STAND_STATE_STAND); break; case POINT_ID_SCEPTER_2: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case EMOTE_FANDRAL_SHATTER: // Shatter the scepter if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->CastSpell(pFandral, SPELL_SHATTER_HAMMER, TRIGGERED_NONE); break; case SAY_ANACHRONOS_EPILOGUE_6: if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) { pFandral->SetWalk(true); pFandral->GetMotionMaster()->MovePoint(POINT_ID_SCEPTER_1, aEternalBoardMovement[3].m_fX, aEternalBoardMovement[3].m_fY, aEternalBoardMovement[3].m_fZ); } break; case POINT_ID_EPILOGUE: // Make Fandral leave if (Creature* pFandral = m_creature->GetMap()->GetCreature(m_fandralGuid)) pFandral->GetMotionMaster()->MovePoint(POINT_ID_EXIT, aEternalBoardMovement[7].m_fX, aEternalBoardMovement[7].m_fY, aEternalBoardMovement[7].m_fZ); break; case POINT_ID_SCEPTER_1: // Anachronos collects the pieces m_creature->SetWalk(true); m_creature->GetMotionMaster()->MovePoint(POINT_ID_SCEPTER_1, aEternalBoardMovement[5].m_fX, aEternalBoardMovement[5].m_fY, aEternalBoardMovement[5].m_fZ); break; } }
void UpdateAI(const uint32 uiDiff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; // Crush if (Crush_Timer < uiDiff) { DoCast(m_creature->getVictim(), SPELL_CRUSH); Crush_Timer = 10000; }else Crush_Timer -= uiDiff; // Infected Wound if (InfectedWound_Timer < uiDiff) { DoCast(m_creature->getVictim(), SPELL_CRUSH); InfectedWound_Timer = 30000; }else InfectedWound_Timer -= uiDiff; // Summon npcs if (Wave_Timer < uiDiff) { SummonWaves(); Wave_Timer = 15000; }else Wave_Timer -= uiDiff; // Consume if (Consume_Timer < uiDiff) { m_creature->CastSpell(m_creature->getVictim(), m_bIsRegularMode ? SPELL_CONSUME : H_SPELL_CONSUME, true); m_creature->CastSpell(m_creature, m_bIsRegularMode ? SPELL_CONSUME_BUFF : H_SPELL_CONSUME_BUFF, true); Consume_Timer = 15000; }else Consume_Timer -= uiDiff; //Corpse Explosion if (CorpseExplode_Timer < uiDiff) { //DoCast(m_creature->getVictim(), m_bIsRegularMode ? SPELL_CORPSE_EXPLODE : H_SPELL_CORPSE_EXPLODE); if (Creature* pCorpse = GetClosestCreatureWithEntry(m_creature, NPC_DRAKKARI_INVADER, 85.0f)) { if (!pCorpse->isAlive()) { Map *map = pCorpse->GetMap(); if (map->IsDungeon()) { Map::PlayerList const &PlayerList = map->GetPlayers(); if (PlayerList.isEmpty()) return; for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { if (i->getSource()->isAlive() && pCorpse->GetDistance2d(i->getSource()->GetPositionX(), i->getSource()->GetPositionY()) <= 5) m_creature->DealDamage(i->getSource(), (m_bIsRegularMode ? urand(3770, 4230) : urand(9425, 10575)), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NATURE, NULL, false); } } } } CorpseExplode_Timer = 15000; }else CorpseExplode_Timer -= uiDiff; DoMeleeAttackIfReady(); }
void MovementInform(uint32 uiType, uint32 uiPointId) override { if (m_playerGuid.IsEmpty() || uiType != WAYPOINT_MOTION_TYPE) return; // No player assigned as quest taker: abort to avoid summoning adds Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid); if (!pPlayer) return; if (pPlayer->GetQuestStatus(QUEST_BODYGUARD_TO_HIRE) == QUEST_STATUS_INCOMPLETE) { switch (uiPointId) { case 77: uiQuestStatus = 1; // First Ambush case 96: DoScriptText(SAY_CORK_AMBUSH1, m_creature); DoAmbush(QUEST_BODYGUARD_TO_HIRE, 1); break; // Second Ambush case 103: DoScriptText(SAY_CORK_AMBUSH2, m_creature); DoAmbush(QUEST_BODYGUARD_TO_HIRE, 2); break; // Third Ambush case 111: DoScriptText(SAY_CORK_AMBUSH3, m_creature); DoAmbush(QUEST_BODYGUARD_TO_HIRE, 3); break; case 116: DoScriptText(SAY_CORK_END, m_creature); // Award quest credit if (pPlayer) pPlayer->RewardPlayerAndGroupAtEventExplored(QUEST_BODYGUARD_TO_HIRE, m_creature); // Remove player to avoid adds being spawned again next turn m_playerGuid.Clear(); uiQuestStatus = 0; break; } } // The second escort quest is also handled by NPC Cork though it is given by NPC Rigger else if (pPlayer->GetQuestStatus(QUEST_GIZELTON_CARAVAN) == QUEST_STATUS_INCOMPLETE) { switch (uiPointId) { case 209: uiQuestStatus = 2; // First Ambush case 218: if (Creature* pRigger = GetClosestCreatureWithEntry(m_creature, NPC_RIGGER_GIZELTON, 100.0f)) DoScriptText(SAY_RIGGER_AMBUSH1, pRigger); DoAmbush(QUEST_GIZELTON_CARAVAN, 1); break; // Second Ambush case 225: if (Creature* pRigger = GetClosestCreatureWithEntry(m_creature, NPC_RIGGER_GIZELTON, 100.0f)) DoScriptText(SAY_RIGGER_AMBUSH2, pRigger); DoAmbush(QUEST_GIZELTON_CARAVAN, 2); break; // Third Ambush case 235: if (Creature* pRigger = GetClosestCreatureWithEntry(m_creature, NPC_RIGGER_GIZELTON, 100.0f)) DoScriptText(SAY_RIGGER_AMBUSH1, pRigger); DoAmbush(QUEST_GIZELTON_CARAVAN, 3); break; case 241: if (Creature* pRigger = GetClosestCreatureWithEntry(m_creature, NPC_RIGGER_GIZELTON, 100.0f)) DoScriptText(SAY_RIGGER_END, pRigger); // Award quest credit if (pPlayer) pPlayer->RewardPlayerAndGroupAtEventExplored(QUEST_GIZELTON_CARAVAN, m_creature); // Remove player to avoid adds being spawned again next turn m_playerGuid.Clear(); uiQuestStatus = 0; break; } } }
void Aggro(Unit* pWho) override { // initialize nearby buddy if (Creature* pKeeper = GetClosestCreatureWithEntry(m_creature, m_creature->GetEntry() == NPC_TEMPERED_KEEPER_1 ? NPC_TEMPERED_KEEPER_2 : NPC_TEMPERED_KEEPER_1, 20)) m_buddyGuid = pKeeper->GetObjectGuid(); }
/// Process queued scripts void Map::ScriptsProcess() { if (m_scriptSchedule.empty()) return; ///- Process overdue queued scripts std::multimap<time_t, ScriptAction>::iterator iter = m_scriptSchedule.begin(); // ok as multimap is a *sorted* associative container while (!m_scriptSchedule.empty() && (iter->first <= sWorld->GetGameTime())) { ScriptAction const& step = iter->second; Object* source = NULL; if (step.sourceGUID) { switch (GUID_HIPART(step.sourceGUID)) { case HIGHGUID_ITEM: // as well as HIGHGUID_CONTAINER if (Player* player = HashMapHolder<Player>::Find(step.ownerGUID)) source = player->GetItemByGuid(step.sourceGUID); break; case HIGHGUID_UNIT: source = HashMapHolder<Creature>::Find(step.sourceGUID); break; case HIGHGUID_PET: source = HashMapHolder<Pet>::Find(step.sourceGUID); break; case HIGHGUID_PLAYER: source = HashMapHolder<Player>::Find(step.sourceGUID); break; case HIGHGUID_GAMEOBJECT: source = HashMapHolder<GameObject>::Find(step.sourceGUID); break; case HIGHGUID_CORPSE: source = HashMapHolder<Corpse>::Find(step.sourceGUID); break; case HIGHGUID_MO_TRANSPORT: for (MapManager::TransportSet::iterator iter = sMapMgr->m_Transports.begin(); iter != sMapMgr->m_Transports.end(); ++iter) { if ((*iter)->GetGUID() == step.sourceGUID) { source = reinterpret_cast<Object*>(*iter); break; } } break; default: sLog->outError("%s source with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).", step.script->GetDebugInfo().c_str(), step.sourceGUID, GUID_HIPART(step.sourceGUID)); break; } } Object* target = NULL; if (step.targetGUID) { switch (GUID_HIPART(step.targetGUID)) { case HIGHGUID_UNIT: target = HashMapHolder<Creature>::Find(step.targetGUID); break; case HIGHGUID_PET: target = HashMapHolder<Pet>::Find(step.targetGUID); break; //case HIGHGUID_VEHICLE: // target = HashMapHolder<Vehicle>::Find(step.targetGUID); // break; case HIGHGUID_PLAYER: // empty GUID case also target = HashMapHolder<Player>::Find(step.targetGUID); break; case HIGHGUID_GAMEOBJECT: target = HashMapHolder<GameObject>::Find(step.targetGUID); break; case HIGHGUID_CORPSE: target = HashMapHolder<Corpse>::Find(step.targetGUID); break; default: sLog->outError("%s target with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).", step.script->GetDebugInfo().c_str(), step.targetGUID, GUID_HIPART(step.targetGUID)); break; } } // Some information for error messages std::string tableName = GetScriptsTableNameByType(step.script->type); std::string commandName = GetScriptCommandName(step.script->command); switch (step.script->command) { case SCRIPT_COMMAND_TALK: if (step.script->Talk.ChatType > CHAT_TYPE_WHISPER && step.script->Talk.ChatType != CHAT_MSG_RAID_BOSS_WHISPER) { sLog->outError("%s invalid chat type (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->Talk.ChatType); break; } if (step.script->Talk.Flags & SF_TALK_USE_PLAYER) { if (Player *pSource = _GetScriptPlayerSourceOrTarget(source, target, step.script)) { LocaleConstant loc_idx = pSource->GetSession()->GetSessionDbLocaleIndex(); std::string text(sObjectMgr->GetDarkCoreString(step.script->Talk.TextID, loc_idx)); switch (step.script->Talk.ChatType) { case CHAT_TYPE_SAY: pSource->Say(text, LANG_UNIVERSAL); break; case CHAT_TYPE_YELL: pSource->Yell(text, LANG_UNIVERSAL); break; case CHAT_TYPE_TEXT_EMOTE: case CHAT_TYPE_BOSS_EMOTE: pSource->TextEmote(text); break; case CHAT_TYPE_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { uint64 targetGUID = target ? target->GetGUID() : 0; if (!targetGUID || !IS_PLAYER_GUID(targetGUID)) sLog->outError("%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str()); else pSource->Whisper(text, LANG_UNIVERSAL, targetGUID); break; } default: break; // must be already checked at load } } } else { // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { uint64 targetGUID = target ? target->GetGUID() : 0; switch (step.script->Talk.ChatType) { case CHAT_TYPE_SAY: cSource->Say(step.script->Talk.TextID, LANG_UNIVERSAL, targetGUID); break; case CHAT_TYPE_YELL: cSource->Yell(step.script->Talk.TextID, LANG_UNIVERSAL, targetGUID); break; case CHAT_TYPE_TEXT_EMOTE: cSource->TextEmote(step.script->Talk.TextID, targetGUID); break; case CHAT_TYPE_BOSS_EMOTE: cSource->MonsterTextEmote(step.script->Talk.TextID, targetGUID, true); break; case CHAT_TYPE_WHISPER: if (!targetGUID || !IS_PLAYER_GUID(targetGUID)) sLog->outError("%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str()); else cSource->Whisper(step.script->Talk.TextID, targetGUID); break; case CHAT_MSG_RAID_BOSS_WHISPER: if (!targetGUID || !IS_PLAYER_GUID(targetGUID)) sLog->outError("%s attempt to raidbosswhisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str()); else cSource->MonsterWhisper(step.script->Talk.TextID, targetGUID, true); break; default: break; // must be already checked at load } } } break; case SCRIPT_COMMAND_EMOTE: // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { if (step.script->Emote.Flags & SF_EMOTE_USE_STATE) cSource->SetUInt32Value(UNIT_NPC_EMOTESTATE, step.script->Emote.EmoteID); else cSource->HandleEmoteCommand(step.script->Emote.EmoteID); } break; case SCRIPT_COMMAND_FIELD_SET: // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { // Validate field number. if (step.script->FieldSet.FieldID <= OBJECT_FIELD_ENTRY || step.script->FieldSet.FieldID >= cSource->GetValuesCount()) sLog->outError("%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID, cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow()); else cSource->SetUInt32Value(step.script->FieldSet.FieldID, step.script->FieldSet.FieldValue); } break; case SCRIPT_COMMAND_MOVE_TO: // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { cSource->SendMonsterMoveWithSpeed(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, step.script->MoveTo.TravelTime); cSource->GetMap()->CreatureRelocation(cSource, step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, 0); } break; case SCRIPT_COMMAND_FLAG_SET: // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { // Validate field number. if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount()) sLog->outError("%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, source->GetValuesCount(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow()); else cSource->SetFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue); } break; case SCRIPT_COMMAND_FLAG_REMOVE: // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { // Validate field number. if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount()) sLog->outError("%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, source->GetValuesCount(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow()); else cSource->RemoveFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue); } break; case SCRIPT_COMMAND_TELEPORT_TO: if (step.script->TeleportTo.Flags & SF_TELEPORT_USE_CREATURE) { // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true)) cSource->NearTeleportTo(step.script->TeleportTo.DestX, step.script->TeleportTo.DestY, step.script->TeleportTo.DestZ, step.script->TeleportTo.Orientation); } else { // Source or target must be Player. if (Player *pSource = _GetScriptPlayerSourceOrTarget(source, target, step.script)) pSource->TeleportTo(step.script->TeleportTo.MapID, step.script->TeleportTo.DestX, step.script->TeleportTo.DestY, step.script->TeleportTo.DestZ, step.script->TeleportTo.Orientation); } break; case SCRIPT_COMMAND_QUEST_EXPLORED: { if (!source) { sLog->outError("%s source object is NULL.", step.script->GetDebugInfo().c_str()); break; } if (!target) { sLog->outError("%s target object is NULL.", step.script->GetDebugInfo().c_str()); break; } // when script called for item spell casting then target == (unit or GO) and source is player WorldObject* worldObject; Player* pTarget = target->ToPlayer(); if (pTarget) { if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) { sLog->outError("%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.", step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow()); break; } worldObject = dynamic_cast<WorldObject*>(source); } else { pTarget = source->ToPlayer(); if (pTarget) { if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) { sLog->outError("%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.", step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); break; } worldObject = dynamic_cast<WorldObject*>(target); } else { sLog->outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", step.script->GetDebugInfo().c_str(), source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); break; } } // quest id and flags checked at script loading if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(pTarget, float(step.script->QuestExplored.Distance)))) pTarget->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID); else pTarget->FailQuest(step.script->QuestExplored.QuestID); break; } case SCRIPT_COMMAND_KILL_CREDIT: // Source or target must be Player. if (Player *pSource = _GetScriptPlayerSourceOrTarget(source, target, step.script)) { if (step.script->KillCredit.Flags & SF_KILLCREDIT_REWARD_GROUP) pSource->RewardPlayerAndGroupAtEvent(step.script->KillCredit.CreatureEntry, pSource); else pSource->KilledMonsterCredit(step.script->KillCredit.CreatureEntry, 0); } break; case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: if (!step.script->RespawnGameobject.GOGuid) { sLog->outError("%s gameobject guid (datalong) is not specified.", step.script->GetDebugInfo().c_str()); break; } // Source or target must be WorldObject. if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script)) { GameObject *pGO = _FindGameObject(pSummoner, step.script->RespawnGameobject.GOGuid); if (!pGO) { sLog->outError("%s gameobject was not found (guid: %u).", step.script->GetDebugInfo().c_str(), step.script->RespawnGameobject.GOGuid); break; } if (pGO->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE || pGO->GetGoType() == GAMEOBJECT_TYPE_DOOR || pGO->GetGoType() == GAMEOBJECT_TYPE_BUTTON || pGO->GetGoType() == GAMEOBJECT_TYPE_TRAP) { sLog->outError("%s can not be used with gameobject of type %u (guid: %u).", step.script->GetDebugInfo().c_str(), uint32(pGO->GetGoType()), step.script->RespawnGameobject.GOGuid); break; } // Check that GO is not spawned if (!pGO->isSpawned()) { int32 nTimeToDespawn = std::max(5, int32(step.script->RespawnGameobject.DespawnDelay)); pGO->SetLootState(GO_READY); pGO->SetRespawnTime(nTimeToDespawn); pGO->GetMap()->Add(pGO); } } break; case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: { // Source must be WorldObject. if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script)) { if (!step.script->TempSummonCreature.CreatureEntry) sLog->outError("%s creature entry (datalong) is not specified.", step.script->GetDebugInfo().c_str()); else { float x = step.script->TempSummonCreature.PosX; float y = step.script->TempSummonCreature.PosY; float z = step.script->TempSummonCreature.PosZ; float o = step.script->TempSummonCreature.Orientation; if (!pSummoner->SummonCreature(step.script->TempSummonCreature.CreatureEntry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->TempSummonCreature.DespawnDelay)) sLog->outError("%s creature was not spawned (entry: %u).", step.script->GetDebugInfo().c_str(), step.script->TempSummonCreature.CreatureEntry); } } break; } case SCRIPT_COMMAND_OPEN_DOOR: case SCRIPT_COMMAND_CLOSE_DOOR: _ScriptProcessDoor(source, target, step.script); break; case SCRIPT_COMMAND_ACTIVATE_OBJECT: // Source must be Unit. if (Unit *pSource = _GetScriptUnit(source, true, step.script)) { // Target must be GameObject. if (!target) { sLog->outError("%s target object is NULL.", step.script->GetDebugInfo().c_str()); break; } if (target->GetTypeId() != TYPEID_GAMEOBJECT) { sLog->outError("%s target object is not gameobject (TypeId: %u, Entry: %u, GUID: %u), skipping.", step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); break; } if (GameObject *pGO = dynamic_cast<GameObject*>(target)) pGO->Use(pSource); } break; case SCRIPT_COMMAND_REMOVE_AURA: { // Source (datalong2 != 0) or target (datalong2 == 0) must be Unit. bool bReverse = step.script->RemoveAura.Flags & SF_REMOVEAURA_REVERSE; if (Unit *pTarget = _GetScriptUnit(bReverse ? source : target, bReverse, step.script)) pTarget->RemoveAurasDueToSpell(step.script->RemoveAura.SpellID); break; } case SCRIPT_COMMAND_CAST_SPELL: { // TODO: Allow gameobjects to be targets and casters if (!source && !target) { sLog->outError("%s source and target objects are NULL.", step.script->GetDebugInfo().c_str()); break; } Unit* uSource = NULL; Unit* uTarget = NULL; // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s switch (step.script->CastSpell.Flags) { case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target uSource = dynamic_cast<Unit*>(source); uTarget = dynamic_cast<Unit*>(target); break; case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source uSource = dynamic_cast<Unit*>(source); uTarget = uSource; break; case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target uSource = dynamic_cast<Unit*>(target); uTarget = uSource; break; case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source uSource = dynamic_cast<Unit*>(target); uTarget = dynamic_cast<Unit*>(source); break; case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry uSource = dynamic_cast<Unit*>(source); uTarget = GetClosestCreatureWithEntry(uSource, abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius); break; } if (!uSource || !uSource->isType(TYPEMASK_UNIT)) { sLog->outError("%s no source unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID); break; } if (!uTarget || !uTarget->isType(TYPEMASK_UNIT)) { sLog->outError("%s no target unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID); break; } bool triggered = (step.script->CastSpell.Flags != 4) ? step.script->CastSpell.CreatureEntry & SF_CASTSPELL_TRIGGERED : step.script->CastSpell.CreatureEntry < 0; uSource->CastSpell(uTarget, step.script->CastSpell.SpellID, triggered); break; } case SCRIPT_COMMAND_PLAY_SOUND: // Source must be WorldObject. if (WorldObject* pSource = _GetScriptWorldObject(source, true, step.script)) { // PlaySound.Flags bitmask: 0/1=anyone/target Player* pTarget = NULL; if (step.script->PlaySound.Flags & SF_PLAYSOUND_TARGET_PLAYER) { // Target must be Player. pTarget = _GetScriptPlayer(target, false, step.script); if (!pTarget) break; } // PlaySound.Flags bitmask: 0/2=without/with distance dependent if (step.script->PlaySound.Flags & SF_PLAYSOUND_DISTANCE_SOUND) pSource->PlayDistanceSound(step.script->PlaySound.SoundID, pTarget); else pSource->PlayDirectSound(step.script->PlaySound.SoundID, pTarget); } break; case SCRIPT_COMMAND_CREATE_ITEM: // Target or source must be Player. if (Player* pReceiver = _GetScriptPlayerSourceOrTarget(source, target, step.script)) { ItemPosCountVec dest; uint8 msg = pReceiver->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, step.script->CreateItem.ItemEntry, step.script->CreateItem.Amount); if (msg == EQUIP_ERR_OK) { if (Item* item = pReceiver->StoreNewItem(dest, step.script->CreateItem.ItemEntry, true)) pReceiver->SendNewItem(item, step.script->CreateItem.Amount, false, true); } else pReceiver->SendEquipError(msg, NULL, NULL, step.script->CreateItem.ItemEntry); } break; case SCRIPT_COMMAND_DESPAWN_SELF: // Target or source must be Creature. if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true)) cSource->DespawnOrUnsummon(step.script->DespawnSelf.DespawnDelay); break; case SCRIPT_COMMAND_LOAD_PATH: // Source must be Unit. if (Unit* pSource = _GetScriptUnit(source, true, step.script)) { if (!sWaypointMgr->GetPath(step.script->LoadPath.PathID)) sLog->outError("%s source object has an invalid path (%u), skipping.", step.script->GetDebugInfo().c_str(), step.script->LoadPath.PathID); else pSource->GetMotionMaster()->MovePath(step.script->LoadPath.PathID, step.script->LoadPath.IsRepeatable); } break; case SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT: { if (!step.script->CallScript.CreatureEntry) { sLog->outError("%s creature entry is not specified, skipping.", step.script->GetDebugInfo().c_str()); break; } if (!step.script->CallScript.ScriptID) { sLog->outError("%s script id is not specified, skipping.", step.script->GetDebugInfo().c_str()); break; } Creature* cTarget = NULL; if (source) //using grid searcher { WorldObject* wSource = dynamic_cast <WorldObject*> (source); CellPair p(DarkCore::ComputeCellPair(wSource->GetPositionX(), wSource->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; DarkCore::CreatureWithDbGUIDCheck target_check(wSource, step.script->CallScript.CreatureEntry); DarkCore::CreatureSearcher<DarkCore::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check); TypeContainerVisitor<DarkCore::CreatureSearcher <DarkCore::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker); cell.Visit(p, unit_checker, *wSource->GetMap()); } else //check hashmap holders { if (CreatureData const* data = sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry)) cTarget = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->CallScript.CreatureEntry, data->id, HIGHGUID_UNIT), cTarget); } if (!cTarget) { sLog->outError("%s target was not found (entry: %u)", step.script->GetDebugInfo().c_str(), step.script->CallScript.CreatureEntry); break; } //Lets choose our ScriptMap map ScriptMapMap *datamap = GetScriptsMapByType(ScriptsType(step.script->CallScript.ScriptType)); //if no scriptmap present... if (!datamap) { sLog->outError("%s unknown scriptmap (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->CallScript.ScriptType); break; } // Insert script into schedule but do not start it ScriptsStart(*datamap, step.script->CallScript.ScriptID, cTarget, NULL); break; } case SCRIPT_COMMAND_KILL: // Source or target must be Creature. if (Creature *cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script)) { if (cSource->isDead()) sLog->outError("%s creature is already dead (Entry: %u, GUID: %u)", step.script->GetDebugInfo().c_str(), cSource->GetEntry(), cSource->GetGUIDLow()); else { cSource->setDeathState(JUST_DIED); if (step.script->Kill.RemoveCorpse == 1) cSource->RemoveCorpse(); } } break; case SCRIPT_COMMAND_ORIENTATION: // Source must be Unit. if (Unit *pSource = _GetScriptUnit(source, true, step.script)) { if (step.script->Orientation.Flags& SF_ORIENTATION_FACE_TARGET) { // Target must be Unit. Unit* pTarget = _GetScriptUnit(target, false, step.script); if (!pTarget) break; pSource->SetInFront(pTarget); } else pSource->SetOrientation(step.script->Orientation.Orientation); pSource->SendMovementFlagUpdate(); } break; case SCRIPT_COMMAND_EQUIP: // Source must be Creature. if (Creature *cSource = _GetScriptCreature(source, true, step.script)) cSource->LoadEquipment(step.script->Equip.EquipmentID); break; case SCRIPT_COMMAND_MODEL: // Source must be Creature. if (Creature *cSource = _GetScriptCreature(source, true, step.script)) cSource->SetDisplayId(step.script->Model.ModelID); break; case SCRIPT_COMMAND_CLOSE_GOSSIP: // Source must be Player. if (Player *pSource = _GetScriptPlayer(source, true, step.script)) pSource->PlayerTalkClass->CloseGossip(); break; case SCRIPT_COMMAND_PLAYMOVIE: // Source must be Player. if (Player *pSource = _GetScriptPlayerSourceOrTarget(source, target, step.script)) pSource->SendMovieStart(step.script->PlayMovie.MovieID); break; default: sLog->outError("Unknown script command %s.", step.script->GetDebugInfo().c_str()); break; } m_scriptSchedule.erase(iter); sWorld->DecreaseScheduledScriptCount(); iter = m_scriptSchedule.begin(); } }
void UpdateAI(const uint32 uiDiff) override { DialogueUpdate(uiDiff); if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; switch (m_uiPhase) { // arena phase abilities case PHASE_ARENA: if (m_uiBerserkTimer) { if (m_uiBerserkTimer <= uiDiff) { if (DoCastSpellIfCan(m_creature, SPELL_BERSERK_1) == CAST_OK) { DoCastSpellIfCan(m_creature, SPELL_SUMMON_LIGHTNING_ORB, CAST_TRIGGERED); DoScriptText(SAY_ARENA_WIPE, m_creature); m_uiBerserkTimer = 0; } } else m_uiBerserkTimer -= uiDiff; } if (m_uiArenaDwarfTimer < uiDiff) { DoSpawnArenaDwarf(); m_uiArenaDwarfTimer = 10000; } else m_uiArenaDwarfTimer -= uiDiff; if (m_uiChargeOrbTimer < uiDiff) { // this spell has AoE target, but we need to be very specific with the selected targets if (Creature* pTarget = m_creature->GetMap()->GetCreature(SelectRandomOrbGuid())) { if (DoCastSpellIfCan(pTarget, SPELL_CHARGE_ORB) == CAST_OK) m_uiChargeOrbTimer = 20000; } } else m_uiChargeOrbTimer -= uiDiff; if (m_uiStormHammerTimer < uiDiff) { if (Unit* pTarget = GetRandomArenaPlayer()) { if (DoCastSpellIfCan(pTarget, SPELL_STORMHAMMER) == CAST_OK) m_uiStormHammerTimer = 15000; } } else m_uiStormHammerTimer -= uiDiff; break; // solo phase abilities case PHASE_SOLO: if (m_uiBerserkTimer) { if (m_uiBerserkTimer <= uiDiff) { if (DoCastSpellIfCan(m_creature, SPELL_BERSERK_2) == CAST_OK) { DoScriptText(SAY_BERSERK, m_creature); m_uiBerserkTimer = 0; } } else m_uiBerserkTimer -= uiDiff; } if (m_uiAttackTimer) { if (m_uiAttackTimer <= uiDiff) { // Add some small delay to combat movement because Jump triggers before it's actually finished DoResetThreat(); SetCombatMovement(true); DoStartMovement(m_creature->getVictim()); m_uiAttackTimer = 0; } else m_uiAttackTimer -= uiDiff; } if (m_uiChargeOrbTimer < uiDiff) { // this spell requires very specific targets if (Creature* pTarget = m_creature->GetMap()->GetCreature(SelectRandomOrbGuid())) { pTarget->CastSpell(pTarget, SPELL_LIGHTNING_ORG_CHARGED, TRIGGERED_OLD_TRIGGERED); // charge the lower orb as well if (Unit* pOrb = GetClosestCreatureWithEntry(pTarget, NPC_THUNDER_ORB, 25.0f, true, false, true)) pTarget->CastSpell(pOrb, SPELL_LIGHTNING_PILLAR, TRIGGERED_OLD_TRIGGERED); m_uiChargeOrbTimer = 20000; } } else m_uiChargeOrbTimer -= uiDiff; if (m_uiChainLightningTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_CHAIN_LIGHTNING : SPELL_CHAIN_LIGHTNING_H) == CAST_OK) m_uiChainLightningTimer = urand(10000, 15000); } } else m_uiChainLightningTimer -= uiDiff; if (m_uiUnbalancingStrikeTimer < uiDiff) { if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_UNBALANCING_STRIKE) == CAST_OK) m_uiUnbalancingStrikeTimer = 25000; } else m_uiUnbalancingStrikeTimer -= uiDiff; DoMeleeAttackIfReady(); break; // transition phase; nothing here, wait for transition to finish case PHASE_TRANSITION: break; } }
void UpdateAI(const uint32 uiDiff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; // Search and devour Zombie if (m_uiSearchZombieTimer < uiDiff) { if (Creature* pZombie = GetClosestCreatureWithEntry(m_creature, NPC_ZOMBIE_CHOW, 10.0f)) { DoScriptText(EMOTE_SPOTED_ZOMBIE, m_creature); m_creature->SetFacingToObject(pZombie); if (DoCastSpellIfCan(pZombie, SPELL_ZOMBIE_CHOW1) == CAST_OK) { m_creature->SetFacingToObject(pZombie); m_creature->SetHealth(m_creature->GetHealthPercent() < 95.0f ? (m_creature->GetHealth() + m_creature->GetMaxHealth() * 0.05f) : m_creature->GetMaxHealth()); DoScriptText(EMOTE_DEVOURED_ZOMBIE, m_creature); lZombies.remove(pZombie->GetObjectGuid()); } } } else m_uiSearchZombieTimer -= uiDiff; // Mortal Wound if (m_uiMortalWoundTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_MORTALWOUND); m_uiMortalWoundTimer = 10000; } else m_uiMortalWoundTimer -= uiDiff; // Decimate if (m_uiDecimateTimer < uiDiff) { DoCastSpellIfCan(m_creature, SPELL_DECIMATE); DoScriptText(EMOTE_DECIMATE, m_creature); for (GUIDList::iterator itr = lZombies.begin(); itr != lZombies.end(); ++itr) { Creature* pZombie = m_creature->GetMap()->GetCreature(*itr); if (pZombie && pZombie->isAlive()) { pZombie->GetMotionMaster()->Clear(); pZombie->GetMotionMaster()->MoveFollow(m_creature, 0.0f, 0.0f); } } m_uiDecimateTimer = 100000; } else m_uiDecimateTimer -= uiDiff; // Periodic Enrage if (m_uiEnrageTimer < uiDiff) { DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_ENRAGE : SPELL_ENRAGE_H); DoScriptText(EMOTE_PERIODIC_ENRAGE, m_creature); m_uiEnrageTimer = urand(15000, 20000); } else m_uiEnrageTimer -= uiDiff; // Summon if (m_uiSummonTimer < uiDiff) { for (uint8 i = 0; i < (m_bIsRegularMode ? 1 : 2); ++i) { uint8 m_uiGate = urand(1, GATES) - 1; m_creature->SummonCreature(NPC_ZOMBIE_CHOW, GatePosition[m_uiGate][0], GatePosition[m_uiGate][1], GatePosition[m_uiGate][2], 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 80000); } m_uiSummonTimer = 10000; } else m_uiSummonTimer -= uiDiff; // Berserk if (m_uiBerserkTimer < uiDiff) { DoCastSpellIfCan(m_creature, SPELL_BERSERK, CAST_TRIGGERED); m_uiBerserkTimer = MINUTE*5*IN_MILLISECONDS; } else m_uiBerserkTimer -= uiDiff; DoMeleeAttackIfReady(); }
bool EffectAuraDummy_spell_aura_dummy_npc(const Aura* pAura, bool bApply) { switch (pAura->GetId()) { case SPELL_HEALING_SALVE: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (bApply) { if (Unit* pCaster = pAura->GetCaster()) pCaster->CastSpell(pAura->GetTarget(), SPELL_HEALING_SALVE_DUMMY, true); } return true; } case SPELL_HEALING_SALVE_DUMMY: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (!bApply) { Creature* pCreature = (Creature*)pAura->GetTarget(); pCreature->UpdateEntry(NPC_MAGHAR_GRUNT); if (pCreature->getStandState() == UNIT_STAND_STATE_KNEEL) pCreature->SetStandState(UNIT_STAND_STATE_STAND); pCreature->ForcedDespawn(60 * IN_MILLISECONDS); } return true; } case SPELL_RECHARGING_BATTERY: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (!bApply) { if (pAura->GetTarget()->HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT)) ((Creature*)pAura->GetTarget())->UpdateEntry(NPC_DRAINED_PHASE_HUNTER); } return true; } case SPELL_TAG_MURLOC: { Creature* pCreature = (Creature*)pAura->GetTarget(); if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (bApply) { if (pCreature->GetEntry() == NPC_BLACKSILT_MURLOC) { if (Unit* pCaster = pAura->GetCaster()) pCaster->CastSpell(pCreature, SPELL_TAG_MURLOC_PROC, true); } } else { if (pCreature->GetEntry() == NPC_TAGGED_MURLOC) pCreature->ForcedDespawn(); } return true; } case SPELL_ENRAGE: { if (!bApply || pAura->GetTarget()->GetTypeId() != TYPEID_UNIT) return false; Creature* pTarget = (Creature*)pAura->GetTarget(); if (Creature* pCreature = GetClosestCreatureWithEntry(pTarget, NPC_DARKSPINE_MYRMIDON, 25.0f)) { pTarget->AI()->AttackStart(pCreature); return true; } if (Creature* pCreature = GetClosestCreatureWithEntry(pTarget, NPC_DARKSPINE_SIREN, 25.0f)) { pTarget->AI()->AttackStart(pCreature); return true; } return false; } case SPELL_SHROUD_OF_DEATH: case SPELL_SPIRIT_PARTICLES: { Creature* pCreature = (Creature*)pAura->GetTarget(); if (!pCreature || (pCreature->GetEntry() != NPC_FRANCLORN_FORGEWRIGHT && pCreature->GetEntry() != NPC_GAERIYAN)) return false; if (bApply) pCreature->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE; else pCreature->m_AuraFlags &= ~UNIT_AURAFLAG_ALIVE_INVISIBLE; return false; } case SPELL_PROTOVOLTAIC_MAGNETO_COLLECTOR: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; Unit* pTarget = pAura->GetTarget(); if (bApply && pTarget->GetTypeId() == TYPEID_UNIT) ((Creature*)pTarget)->UpdateEntry(NPC_ENCASED_ELECTROMENTAL); return true; } } return false; }
void UpdateAI(const uint32 uiDiff){ if(portalLoc != -1) StartMovement(); if (IsWalking && WalkTimer) { if (WalkTimer <= uiDiff) { if (WayPoint != WayPointList.end()) { m_creature->GetMotionMaster()->MovePoint(WayPoint->id, WayPoint->x, WayPoint->y,WayPoint->z); WalkTimer = 0; } }else WalkTimer -= uiDiff; } //Corrupt Seal if(Creature *pDoorSeal2 = GetClosestCreatureWithEntry(m_creature, NPC_DOOR_SEAL, 150.0f)){ if(m_creature->IsWithinDist(pDoorSeal2, 27.0f, false) && !IsInCombat) { IsWalking = false; WayPointList.clear(); m_creature->GetMotionMaster()->Clear(false); m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); DoCast(pDoorSeal2, SPELL_CORRUPT); m_pInstance->SetData(TYPE_DOOR,SPECIAL); } } if(!IsWalking && !IsInCombat) { if (Unit* m_uEmbraceTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) m_creature->GetMotionMaster()->MoveChase(m_uEmbraceTarget); m_creature->SetInCombatWithZone(); IsInCombat = true; } //Return since we have no target if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if(m_creature->getVictim()) if(m_creature->getVictim()->GetEntry() == NPC_DOOR_SEAL) return; switch(creatureEntry) { case NPC_AZURE_CAPTAIN: AzureCaptain_UpdateAI(uiDiff); break; case NPC_AZURE_RAIDER: AzureRaider_UpdateAI(uiDiff); break; case NPC_AZURE_SORCEROR: AzureSorceror_UpdateAI(uiDiff); break; case NPC_AZURE_STALKER: AzureStalker_UpdateAI(uiDiff); break; case NPC_GUARDIAN: case NPC_KEEPER: case NPC_AZURE_BINDER: case NPC_AZURE_INVADER: case NPC_AZURE_MAGE_SLAYER: case NPC_AZURE_SPELLBREAKER: break; default: debug_log("SD2: The Violet Hold: Unhandled dragon entry %u!", m_creature->GetEntry()); break; } DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 diff) { if (PlayerGUID && !me->getVictim() && me->isAlive()) { if (ExecuteSpeech_Timer <= diff) { Player* player = Unit::GetPlayer(*me, PlayerGUID); if (!player) { Reset(); return; } //TODO: simplify text's selection switch (player->getRace()) { case RACE_HUMAN: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_5, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_5, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_7, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_6, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_ORC: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_6, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_7, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_8, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_8, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_DWARF: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_2, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_2, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_3, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_2, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_5, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_2, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_3, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_NIGHTELF: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_5, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_6, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_2, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_7, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_UNDEAD_PLAYER: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_3, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_4, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_3, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_1, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_3, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_4, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_TAUREN: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_5, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_8, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_9, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_9, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_GNOME: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_4, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_4, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_6, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_5, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_TROLL: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_3, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_7, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_2, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_6, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_9, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_10, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_4, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_10, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_GOBLIN: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_4, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_8, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_11, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_12, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_5, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_12, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_BLOODELF: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; //case 5: //unknown case 6: DoScriptText(SAY_EXEC_THINK_3, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_1, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_DRAENEI: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_2, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_1, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_4, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_2, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_WORGEN: switch (ExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; case 5: DoScriptText(SAY_EXEC_NOREM_10, me, player); break; case 6: DoScriptText(SAY_EXEC_THINK_11, me, player); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); break; case 9: DoScriptText(SAY_EXEC_TIME_11, me, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: DoScriptText(SAY_EXEC_WAITING, me, player); break; case 11: DoScriptText(EMOTE_DIES, me); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; } if (ExecuteSpeech_Counter >= 9) ExecuteSpeech_Timer = 15000; else ExecuteSpeech_Timer = 7000; ++ExecuteSpeech_Counter; } else ExecuteSpeech_Timer -= diff; } }
void UpdateAI(uint32 diff) override { if (PlayerGUID && !me->GetVictim() && me->IsAlive()) { if (ExecuteSpeech_Timer <= diff) { Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID); if (!player) { Reset(); return; } /// @todo simplify text's selection switch (player->getRace()) { case RACE_HUMAN: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_5, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_1, player); break; case 5: Talk(SAY_EXEC_NOREM_5, player); break; case 6: Talk(SAY_EXEC_THINK_7, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_6, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_ORC: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_6, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_1, player); break; case 5: Talk(SAY_EXEC_NOREM_7, player); break; case 6: Talk(SAY_EXEC_THINK_8, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_8, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_DWARF: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_2, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_2, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_3, player); break; case 5: Talk(SAY_EXEC_NOREM_2, player); break; case 6: Talk(SAY_EXEC_THINK_5, player); break; case 7: Talk(SAY_EXEC_LISTEN_2, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_3, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_NIGHTELF: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_5, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_1, player); break; case 5: Talk(SAY_EXEC_NOREM_6, player); break; case 6: Talk(SAY_EXEC_THINK_2, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_7, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_UNDEAD_PLAYER: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_3, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_4, player); break; case 5: Talk(SAY_EXEC_NOREM_3, player); break; case 6: Talk(SAY_EXEC_THINK_1, player); break; case 7: Talk(SAY_EXEC_LISTEN_3, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_4, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_TAUREN: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_1, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_5, player); break; case 5: Talk(SAY_EXEC_NOREM_8, player); break; case 6: Talk(SAY_EXEC_THINK_9, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_9, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_GNOME: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_4, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_1, player); break; case 5: Talk(SAY_EXEC_NOREM_4, player); break; case 6: Talk(SAY_EXEC_THINK_6, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_5, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_TROLL: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_3, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_7, player); break; case 3: Talk(SAY_EXEC_NAME_2, player); break; case 4: Talk(SAY_EXEC_RECOG_6, player); break; case 5: Talk(SAY_EXEC_NOREM_9, player); break; case 6: Talk(SAY_EXEC_THINK_10, player); break; case 7: Talk(SAY_EXEC_LISTEN_4, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_10, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_BLOODELF: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_1, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_1, player); break; //case 5: //unknown case 6: Talk(SAY_EXEC_THINK_3, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_1, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; case RACE_DRAENEI: switch (ExecuteSpeech_Counter) { case 0: Talk(SAY_EXEC_START_1, player); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: Talk(SAY_EXEC_PROG_1, player); break; case 3: Talk(SAY_EXEC_NAME_1, player); break; case 4: Talk(SAY_EXEC_RECOG_2, player); break; case 5: Talk(SAY_EXEC_NOREM_1, player); break; case 6: Talk(SAY_EXEC_THINK_4, player); break; case 7: Talk(SAY_EXEC_LISTEN_1, player); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player); break; case 9: Talk(SAY_EXEC_TIME_2, player); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: Talk(SAY_EXEC_WAITING, player); break; case 11: Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; } break; } if (ExecuteSpeech_Counter >= 9) ExecuteSpeech_Timer = 15000; else ExecuteSpeech_Timer = 7000; ++ExecuteSpeech_Counter; } else ExecuteSpeech_Timer -= diff; } }
void UpdateAI(const uint32 uiDiff) override { if (!SelectCustomHostileTarget()) return; if (m_uiBerserkTimer) { if (m_uiBerserkTimer <= uiDiff) { if (DoCastSpellIfCan(m_creature, SPELL_BERSERK) == CAST_OK) m_uiBerserkTimer = 0; } else m_uiBerserkTimer -= uiDiff; } switch (m_uiPhase) { case PHASE_AIR: if (m_uiFireballTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_FIREBALL : SPELL_FIREBALL_H) == CAST_OK) m_uiFireballTimer = 2000; } } else m_uiFireballTimer -= uiDiff; if (m_uiDevouringFlameTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { if (DoCastSpellIfCan(pTarget, SPELL_DEVOURING_FLAME) == CAST_OK) m_uiDevouringFlameTimer = 10000; } } else m_uiDevouringFlameTimer -= uiDiff; // harpoon is repaired; move to next one, or to home position if all are completed if (m_uiRepairHarpoonTimer) { if (m_uiRepairHarpoonTimer <= uiDiff) { // handle fire extinguish after a grounded phase if (!m_uiCurrentHarpoon) { // extinguish fires if (m_pInstance) { if (Creature* pCommander = m_pInstance->GetSingleCreatureFromStorage(NPC_EXPEDITION_COMMANDER)) { if (Creature* pEngineer = GetClosestCreatureWithEntry(pCommander, NPC_EXPEDITION_ENGINEER, 15.0f)) DoScriptText(SAY_EXTINGUISH_FIRE, pEngineer); } } // move engineers to the first harpoon again DoMoveEngineersToHarpoon(); m_uiRepairHarpoonTimer = 20000; } else { DoScriptText(EMOTE_HARPOON_READY, m_creature); // despawn the current broken harpoon and spawn the repaired one if (GameObject* pHarpoon = m_creature->GetMap()->GetGameObject(m_vHarpoonsGuids[m_uiCurrentHarpoon - 1])) { pHarpoon->SetRespawnTime(HOUR); pHarpoon->SetLootState(GO_JUST_DEACTIVATED); DoRepairHarpoon(pHarpoon); } // if all harpoons have been repaired stop if (m_uiCurrentHarpoon == m_uiMaxHarpoons) { for (GuidList::const_iterator itr = m_lEngineersGuids.begin(); itr != m_lEngineersGuids.end(); ++itr) { if (Creature* pEngineer = m_creature->GetMap()->GetCreature(*itr)) pEngineer->GetMotionMaster()->MoveTargetedHome(); } m_uiRepairHarpoonTimer = 0; } // move to next harpoon else { DoMoveEngineersToHarpoon(); m_uiRepairHarpoonTimer = 20000; } } } else m_uiRepairHarpoonTimer -= uiDiff; } // spawn Mole Machines with dwarfes if (m_uiDwarfSpawnTimer < uiDiff) { DoSpawnMoleMachines(); m_uiDwarfSpawnTimer = 40000; } else m_uiDwarfSpawnTimer -= uiDiff; break; case PHASE_TRANSITION: if (m_uiShackleTimer < uiDiff) { // cast trap visual for (GuidList::const_iterator itr = m_lTrappersGuids.begin(); itr != m_lTrappersGuids.end(); ++itr) { if (Creature* pTrapper = m_creature->GetMap()->GetCreature(*itr)) pTrapper->CastSpell(m_creature, SPELL_SHACKLE, false); } // stun Razorscale if (DoCastSpellIfCan(m_creature, SPELL_STUN) == CAST_OK) { m_creature->SetLevitate(false); m_creature->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER); m_uiPhase = PHASE_GROUNDED; m_uiGroundedTimer = 30000; m_uiGroundedStep = 0; m_uiShackleTimer = 5000; } } else m_uiShackleTimer -= uiDiff; break; case PHASE_GROUNDED: if (m_uiGroundedTimer < uiDiff) { switch (m_uiGroundedStep) { case 0: m_creature->RemoveAurasDueToSpell(SPELL_STUN); if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_FLAME_BREATH : SPELL_FLAME_BREATH_H) == CAST_OK) { DoScriptText(EMOTE_BREATH, m_creature); m_uiGroundedTimer = 2500; } break; case 1: if (DoCastSpellIfCan(m_creature, SPELL_WING_BUFFET) == CAST_OK) m_uiGroundedTimer = 1500; break; case 2: if (DoCastSpellIfCan(m_creature, SPELL_FIREBOLT) == CAST_OK) m_uiGroundedTimer = 2000; break; case 3: // if fully grounded then go to ground phase if (m_bIsGrounded) { SetCombatMovement(true); DoResetThreat(); DoStartMovement(m_creature->getVictim()); m_uiPhase = PHASE_ONLY_GROUND; } // resume air phase else { m_creature->SetLevitate(true); m_creature->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER); float fX, fY, fZ; m_creature->GetRespawnCoord(fX, fY, fZ); // use upgraded speed rate for FlyOrLand. This isn't supported by DB but it's confirmed to happen on retail uint32 uiSpeedRate = m_creature->GetSpeedRate(MOVE_RUN); m_creature->SetSpeedRate(MOVE_RUN, SPEED_RATE_RAZORSCALE); m_creature->GetMotionMaster()->MoveFlyOrLand(1, fX, fY, fZ, true); m_creature->SetSpeedRate(MOVE_RUN, uiSpeedRate); // reset timers m_uiPhase = PHASE_AIR; m_uiCurrentHarpoon = 0; m_uiHarpoonsUsed = 0; m_uiRepairHarpoonTimer = 20000; m_uiFireballTimer = 5000; m_uiDevouringFlameTimer = 10000; ++m_uiFlyPhaseCount; // set achiev criteria as failed if (m_uiFlyPhaseCount >= 2 && m_pInstance) m_pInstance->SetSpecialAchievementCriteria(TYPE_ACHIEV_QUICK_SHAVE, false); } // make the Trappers evade or move to home position for (GuidList::const_iterator itr = m_lTrappersGuids.begin(); itr != m_lTrappersGuids.end(); ++itr) { if (Creature* pTrapper = m_creature->GetMap()->GetCreature(*itr)) pTrapper->AI()->EnterEvadeMode(); } break; } ++m_uiGroundedStep; } else m_uiGroundedTimer -= uiDiff; // make boss land at 50% hp if (!m_bIsGrounded && m_creature->GetHealthPercent() < 50.0f) { DoScriptText(EMOTE_GROUNDED, m_creature); m_creature->RemoveAurasDueToSpell(SPELL_STUN); m_uiGroundedStep = 1; m_uiGroundedTimer = 0; m_bIsGrounded = true; } break; case PHASE_ONLY_GROUND: if (m_uiDevouringFlameTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { if (DoCastSpellIfCan(pTarget, SPELL_DEVOURING_FLAME) == CAST_OK) m_uiDevouringFlameTimer = 10000; } } else m_uiDevouringFlameTimer -= uiDiff; if (m_uiFuseArmorTimer < uiDiff) { if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_FUSE_ARMOR) == CAST_OK) m_uiFuseArmorTimer = 13000; } else m_uiFuseArmorTimer -= uiDiff; if (m_uiFlameBuffetTimer < uiDiff) { if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_FLAME_BUFFET : SPELL_FLAME_BUFFET_H) == CAST_OK) m_uiFlameBuffetTimer = 10000; } else m_uiFlameBuffetTimer -= uiDiff; if (m_uiFlameBreathTimer < uiDiff) { if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_FLAME_BREATH : SPELL_FLAME_BREATH_H) == CAST_OK) { DoScriptText(EMOTE_BREATH, m_creature); m_uiFlameBreathTimer = 15000; } } else m_uiFlameBreathTimer -= uiDiff; DoMeleeAttackIfReady(); break; } }
void UpdateAI(const uint32 uiDiff) { if (!UpdateVictim()) return; if (m_bIsStriking) { if (m_uiPause_Timer <= uiDiff) { if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) if (me->getVictim()) me->GetMotionMaster()->MoveChase(me->getVictim()); m_bHasTemper = false; m_bIsStriking = false; m_uiPause_Timer = 3500; } else m_uiPause_Timer -= uiDiff; return; } // When to start shatter? After 60, 40 or 20% hp? if (!m_bHasTemper && m_uiHealthAmountModifier >= 3) { if (m_uiShatteringStomp_Timer <= uiDiff) { // Should he stomp even if he has no brittle golem to shatter? Talk(SAY_STOMP); DoCast(me, SPELL_SHATTERING_STOMP_N); Talk(EMOTE_SHATTER); m_uiShatteringStomp_Timer = 30000; m_bCanShatterGolem = true; } else m_uiShatteringStomp_Timer -= uiDiff; } // Shatter Golems 3 seconds after Shattering Stomp if (m_bCanShatterGolem) { if (m_uiShatter_Timer <= uiDiff) { ShatterGolem(); m_uiShatter_Timer = 3000; m_bCanShatterGolem = false; } else m_uiShatter_Timer -= uiDiff; } // Health check if (!m_bCanShatterGolem && me->HealthBelowPct(100 - 20 * m_uiHealthAmountModifier)) { ++m_uiHealthAmountModifier; if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); Talk(SAY_FORGE); m_bHasTemper = true; m_uiSummonPhase = 1; } switch (m_uiSummonPhase) { case 1: // 1 - Start run to Anvil Talk(EMOTE_TO_ANVIL); me->GetMotionMaster()->MoveTargetedHome(); m_uiSummonPhase = 2; // Set Next Phase break; case 2: // 2 - Check if reached Anvil // This is handled in: void JustReachedHome() break; case 3: // 3 - Cast Temper on the Anvil if (Unit* target = GetClosestCreatureWithEntry(me, NPC_VOLKHAN_ANVIL, 1000.0f, true)) { me->SetOrientation(2.29f); DoCast(target, SPELL_TEMPER, false); DoCast(target, SPELL_TEMPER_DUMMY, false); } m_uiDelay_Timer = 1000; // Delay 2 seconds before next phase can begin m_uiSummonPhase = 4; // Set Next Phase break; case 4: // 4 - Wait for delay to expire if (m_uiDelay_Timer <= uiDiff) { if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0)) { me->SetReactState(REACT_AGGRESSIVE); me->SetInCombatWith(target); me->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f); } m_uiSummonPhase = 5; } else m_uiDelay_Timer -= uiDiff; break; case 5: // 5 - Spawn the Golems if (Creature* creatureTarget = GetClosestCreatureWithEntry(me, NPC_VOLKHAN_ANVIL, 1000.0f, true)) for (uint8 i = 0; i < MAX_GOLEM; ++i) me->CastSpell(creatureTarget, SPELL_SUMMON_MOLTEN_GOLEM, true); m_bIsStriking = true; m_uiSummonPhase = 0; // Reset back to Phase 0 for next time break; } DoMeleeAttackIfReady(); }
bool EffectAuraDummy_spell_aura_dummy_npc(const Aura* pAura, bool bApply) { switch(pAura->GetId()) { case SPELL_BLESSING_OF_PEACE: { Creature* pCreature = (Creature*)pAura->GetTarget(); if (!pCreature || pCreature->GetEntry() != NPC_FALLEN_HERO_SPIRIT) return true; if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (bApply) { switch(urand(0, 4)) { case 0: DoScriptText(SAY_BLESS_1, pCreature); break; case 1: DoScriptText(SAY_BLESS_2, pCreature); break; case 2: DoScriptText(SAY_BLESS_3, pCreature); break; case 3: DoScriptText(SAY_BLESS_4, pCreature); break; case 4: DoScriptText(SAY_BLESS_5, pCreature); break; } } else { if (Player* pPlayer = (Player*)pAura->GetCaster()) { pPlayer->KilledMonsterCredit(NPC_FALLEN_HERO_SPIRIT_PROXY, pCreature->GetGUID()); pCreature->ForcedDespawn(); } } return true; } case SPELL_HEALING_SALVE: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (bApply) { if (Unit* pCaster = pAura->GetCaster()) pCaster->CastSpell(pAura->GetTarget(), SPELL_HEALING_SALVE_DUMMY, true); } return true; } case SPELL_HEALING_SALVE_DUMMY: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (!bApply) { Creature* pCreature = (Creature*)pAura->GetTarget(); pCreature->UpdateEntry(NPC_MAGHAR_GRUNT); if (pCreature->getStandState() == UNIT_STAND_STATE_KNEEL) pCreature->SetStandState(UNIT_STAND_STATE_STAND); pCreature->ForcedDespawn(60*IN_MILLISECONDS); } return true; } case SPELL_RECHARGING_BATTERY: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (!bApply) { if (pAura->GetTarget()->HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT)) ((Creature*)pAura->GetTarget())->UpdateEntry(NPC_DRAINED_PHASE_HUNTER); } return true; } case SPELL_TAG_MURLOC: { Creature* pCreature = (Creature*)pAura->GetTarget(); if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (bApply) { if (pCreature->GetEntry() == NPC_BLACKSILT_MURLOC) { if (Unit* pCaster = pAura->GetCaster()) pCaster->CastSpell(pCreature, SPELL_TAG_MURLOC_PROC, true); } } else { if (pCreature->GetEntry() == NPC_TAGGED_MURLOC) pCreature->ForcedDespawn(); } return true; } case SPELL_RAELORASZ_FIREBALL: { if (pAura->GetEffIndex() != EFFECT_INDEX_0) return true; if (Unit* pCaster = pAura->GetCaster()) DoScriptText(SAY_SPECIMEN, pCaster); Unit* pTarget = pAura->GetTarget(); if (pTarget->GetTypeId() == TYPEID_UNIT) { Creature* pCreature = (Creature*)pTarget; if (pCreature->GetEntry() == NPC_NEXUS_DRAKE_HATCHLING) { pCreature->SetStandState(UNIT_STAND_STATE_SLEEP); pCreature->ForcedDespawn(3000); } } return true; } case SPELL_ENRAGE: { if (!bApply || pAura->GetTarget()->GetTypeId() != TYPEID_UNIT) return false; Creature* pTarget = (Creature*)pAura->GetTarget(); if (Creature* pCreature = GetClosestCreatureWithEntry(pTarget, NPC_DARKSPINE_MYRMIDON, 25.0f)) { pTarget->AI()->AttackStart(pCreature); return true; } if (Creature* pCreature = GetClosestCreatureWithEntry(pTarget, NPC_DARKSPINE_SIREN, 25.0f)) { pTarget->AI()->AttackStart(pCreature); return true; } return false; } } return false; }
void UpdateEscortAI(const uint32 uiDiff) override { if (m_uiRandomTalkCooldown) { if (m_uiRandomTalkCooldown <= uiDiff) { m_uiRandomTalkCooldown = 0; } else { m_uiRandomTalkCooldown -= uiDiff; } } if (HasEscortState(STATE_ESCORT_PAUSED)) { if (m_uiTalkTimer <= uiDiff) { ++m_uiTalkCount; m_uiTalkTimer = 7500; Player* pPlayer = GetPlayerForEscort(); if (!pPlayer) { return; } switch (m_uiPointId) { case 5: // to lower city { switch (m_uiTalkCount) { case 1: DoScriptText(SAY_KHAD_SERV_1, m_creature, pPlayer); break; case 2: DoScriptText(SAY_KHAD_SERV_2, m_creature, pPlayer); break; case 3: DoScriptText(SAY_KHAD_SERV_3, m_creature, pPlayer); break; case 4: DoScriptText(SAY_KHAD_SERV_4, m_creature, pPlayer); SetEscortPaused(false); break; } break; } case 24: // in lower city { switch (m_uiTalkCount) { case 5: if (Creature* pShanir = GetClosestCreatureWithEntry(m_creature, NPC_SHANIR, 15.0f)) { DoScriptText(SAY_KHAD_INJURED, pShanir, pPlayer); } DoScriptText(SAY_KHAD_SERV_5, m_creature, pPlayer); break; case 6: DoScriptText(SAY_KHAD_SERV_6, m_creature, pPlayer); break; case 7: DoScriptText(SAY_KHAD_SERV_7, m_creature, pPlayer); SetEscortPaused(false); break; } break; } case 50: // outside { switch (m_uiTalkCount) { case 8: DoScriptText(SAY_KHAD_SERV_8, m_creature, pPlayer); break; case 9: DoScriptText(SAY_KHAD_SERV_9, m_creature, pPlayer); break; case 10: DoScriptText(SAY_KHAD_SERV_10, m_creature, pPlayer); break; case 11: DoScriptText(SAY_KHAD_SERV_11, m_creature, pPlayer); SetEscortPaused(false); break; } break; } case 63: // scryer { switch (m_uiTalkCount) { case 12: DoScriptText(SAY_KHAD_SERV_12, m_creature, pPlayer); break; case 13: DoScriptText(SAY_KHAD_SERV_13, m_creature, pPlayer); SetEscortPaused(false); break; } break; } case 74: // aldor { switch (m_uiTalkCount) { case 14: DoScriptText(SAY_KHAD_SERV_14, m_creature, pPlayer); break; case 15: DoScriptText(SAY_KHAD_SERV_15, m_creature, pPlayer); break; case 16: DoScriptText(SAY_KHAD_SERV_16, m_creature, pPlayer); break; case 17: DoScriptText(SAY_KHAD_SERV_17, m_creature, pPlayer); SetEscortPaused(false); break; } break; } case 75: // a'dal { switch (m_uiTalkCount) { case 18: DoScriptText(SAY_KHAD_SERV_18, m_creature, pPlayer); break; case 19: DoScriptText(SAY_KHAD_SERV_19, m_creature, pPlayer); break; case 20: DoScriptText(SAY_KHAD_SERV_20, m_creature, pPlayer); break; case 21: DoScriptText(SAY_KHAD_SERV_21, m_creature, pPlayer); pPlayer->AreaExploredOrEventHappens(QUEST_CITY_LIGHT); SetEscortPaused(false); break; } break; } } } else { m_uiTalkTimer -= uiDiff; } } }
bool EffectDummyCreature_spell_dummy_npc(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Creature* pCreatureTarget) { switch(uiSpellId) { case SPELL_ADMINISTER_ANTIDOTE: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->GetEntry() != NPC_HELBOAR) return true; // possible needs check for quest state, to not have any effect when quest really complete pCreatureTarget->UpdateEntry(NPC_DREADTUSK); return true; } return true; } case SPELL_APPLY_SALVE: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() != TYPEID_PLAYER) return true; if (pCreatureTarget->GetEntry() == NPC_SICKLY_DEER && ((Player*)pCaster)->GetTeam() == ALLIANCE) pCreatureTarget->UpdateEntry(NPC_CURED_DEER); if (pCreatureTarget->GetEntry() == NPC_SICKLY_GAZELLE && ((Player*)pCaster)->GetTeam() == HORDE) pCreatureTarget->UpdateEntry(NPC_CURED_GAZELLE); return true; } return true; } case SPELL_DARKMENDER_TINCTURE: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() != TYPEID_PLAYER) return true; // TODO: find/fix visual for effect, no related spells found doing this pCreatureTarget->CastSpell(pCreatureTarget, SPELL_SUMMON_CORRUPTED_SCARLET, true); ((Player*)pCaster)->KilledMonsterCredit(NPC_CORPSES_RISE_CREDIT_BUNNY); pCreatureTarget->ForcedDespawn(); return true; } return true; } case SPELL_DISCIPLINING_ROD: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->getStandState() == UNIT_STAND_STATE_STAND) return true; switch(urand(1,2)) { case 1: { switch(urand(1,3)) { case 1: DoScriptText(SAY_RAND_ATTACK1, pCreatureTarget); break; case 2: DoScriptText(SAY_RAND_ATTACK2, pCreatureTarget); break; case 3: DoScriptText(SAY_RAND_ATTACK3, pCreatureTarget); break; } pCreatureTarget->SetStandState(UNIT_STAND_STATE_STAND); pCreatureTarget->AI()->AttackStart(pCaster); break; } case 2: { switch(urand(1,3)) { case 1: DoScriptText(SAY_RAND_WORK1, pCreatureTarget); break; case 2: DoScriptText(SAY_RAND_WORK2, pCreatureTarget); break; case 3: DoScriptText(SAY_RAND_WORK3, pCreatureTarget); break; } pCreatureTarget->SetStandState(UNIT_STAND_STATE_STAND); pCreatureTarget->HandleEmote(EMOTE_STATE_WORK); break; } } return true; } return true; } case SPELL_INOCULATE_OWLKIN: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->GetEntry() != NPC_OWLKIN) return true; pCreatureTarget->UpdateEntry(NPC_OWLKIN_INOC); //set despawn timer, since we want to remove creature after a short time pCreatureTarget->ForcedDespawn(15000); return true; } return true; } case SPELL_LIQUID_FIRE: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() == TYPEID_PLAYER) { if (pCreatureTarget->HasAura(SPELL_LIQUID_FIRE_AURA)) return true; if (pCreatureTarget->GetEntry() == NPC_ELK) { pCreatureTarget->CastSpell(pCreatureTarget, SPELL_LIQUID_FIRE_AURA, true); ((Player*)pCaster)->KilledMonsterCredit(NPC_ELK_BUNNY); } else if (pCreatureTarget->GetEntry() == NPC_GRIZZLY) { pCreatureTarget->CastSpell(pCreatureTarget, SPELL_LIQUID_FIRE_AURA, true); ((Player*)pCaster)->KilledMonsterCredit(NPC_GRIZZLY_BUNNY); } } return true; } return true; } case SPELL_MODIFIED_MOJO: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->GetEntry() != NPC_PROPHET_OF_SSERATUS) return true; // Apparently done before updateEntry, so need to make a way to handle that // "Mmm, more mojo" // "%s drinks the Mojo" // "NOOOOOOOOOOOOooooooo...............!" pCreatureTarget->UpdateEntry(NPC_WEAK_PROPHET_OF_SSERATUS); return true; } return true; } case SPELL_FEL_SIPHON_DUMMY: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->GetEntry() != NPC_FELBLOOD_INITIATE) return true; pCreatureTarget->UpdateEntry(NPC_EMACIATED_FELBLOOD); return true; } return true; } case SPELL_SACRED_CLEANSING: { if (uiEffIndex == EFFECT_INDEX_1) { if (pCreatureTarget->GetEntry() != NPC_MORBENT) return true; pCreatureTarget->UpdateEntry(NPC_WEAKENED_MORBENT); return true; } return true; } case SPELL_SEEDS_OF_NATURES_WRATH: { if (uiEffIndex == EFFECT_INDEX_0) { uint32 uiNewEntry = 0; switch(pCreatureTarget->GetEntry()) { case NPC_REANIMATED_FROSTWYRM: uiNewEntry = NPC_WEAK_REANIMATED_FROSTWYRM; break; case NPC_TURGID: uiNewEntry = NPC_WEAK_TURGID; break; case NPC_DEATHGAZE: uiNewEntry = NPC_WEAK_DEATHGAZE; break; } if (uiNewEntry) pCreatureTarget->UpdateEntry(uiNewEntry); return true; } return true; } case SPELL_STRENGTH_ANCIENTS: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() == TYPEID_PLAYER) { if (urand(0, 1)) { DoScriptText(EMOTE_AGGRO, pCreatureTarget); pCreatureTarget->setFaction(FACTION_HOSTILE); pCreatureTarget->AI()->AttackStart(pCaster); } else { DoScriptText(EMOTE_CREATE, pCreatureTarget); pCaster->CastSpell(pCaster, SPELL_CREATE_BARK_WALKERS, true); pCreatureTarget->ForcedDespawn(5000); } } return true; } return true; } case SPELL_TAG_MURLOC_PROC: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->GetEntry() == NPC_BLACKSILT_MURLOC) pCreatureTarget->UpdateEntry(NPC_TAGGED_MURLOC); } return true; } case SPELL_THROW_BOULDER: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() != TYPEID_PLAYER) return true; if (pCreatureTarget->GetEntry() != NPC_IRON_RUNESHAPER && pCreatureTarget->GetEntry() != NPC_RUNE_REAVER) return true; pCreatureTarget->CastSpell(pCreatureTarget, SPELL_BOULBER_IMPACT, true); pCaster->CastSpell(pCaster, SPELL_BOULDER_TOSS_CREDIT, true); return true; } return true; } case SPELL_ULTRASONIC_SCREWDRIVER: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCreatureTarget->IsCorpse()) { uint32 newSpellId = 0; switch(pCreatureTarget->GetEntry()) { case NPC_COLLECT_A_TRON: newSpellId = SPELL_SUMMON_COLLECT_A_TRON; break; case NPC_DEFENDO_TANK: newSpellId = SPELL_SUMMON_DEFENDO_TANK; break; case NPC_SCAVENGE_A8: newSpellId = SPELL_SUMMON_SCAVENGE_A8; break; case NPC_SCAVENGE_B6: newSpellId = SPELL_SUMMON_SCAVENGE_B6; break; case NPC_SENTRY_BOT: newSpellId = SPELL_SUMMON_SENTRY_BOT; break; } if (const SpellEntry* pSpell = GetSpellStore()->LookupEntry(newSpellId)) { pCaster->CastSpell(pCreatureTarget, pSpell->Id, true); if (Pet* pPet = pCaster->FindGuardianWithEntry(pSpell->EffectMiscValue[uiEffIndex])) pPet->CastSpell(pCaster, SPELL_REPROGRAM_KILL_CREDIT, true); pCreatureTarget->ForcedDespawn(); } } return true; } return true; } case SPELL_ORB_OF_MURLOC_CONTROL: { pCreatureTarget->CastSpell(pCaster, SPELL_GREENGILL_SLAVE_FREED, true); // Freed Greengill Slave pCreatureTarget->UpdateEntry(NPC_FREED_GREENGILL_SLAVE); pCreatureTarget->CastSpell(pCreatureTarget, SPELL_ENRAGE, true); return true; } case SPELL_FUMPING: { if (uiEffIndex == EFFECT_INDEX_2) { switch(urand(0,2)) { case 0: { pCaster->CastSpell(pCreatureTarget, SPELL_SUMMON_HAISHULUD, true); break; } case 1: { for (int i = 0; i<2; ++i) { if (Creature* pSandGnome = pCaster->SummonCreature(NPC_SAND_GNOME, pCreatureTarget->GetPositionX(), pCreatureTarget->GetPositionY(), pCreatureTarget->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) pSandGnome->AI()->AttackStart(pCaster); } break; } case 2: { for (int i = 0; i<2; ++i) { if (Creature* pMatureBoneSifter = pCaster->SummonCreature(NPC_MATURE_BONE_SIFTER, pCreatureTarget->GetPositionX(), pCreatureTarget->GetPositionY(), pCreatureTarget->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) pMatureBoneSifter->AI()->AttackStart(pCaster); } break; } } pCreatureTarget->ForcedDespawn(); } return true; } case SPELL_AHUNAES_KNIFE: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() != TYPEID_PLAYER) return true; ((Player*)pCaster)->KilledMonsterCredit(NPC_SCALPS_KILL_CREDIT_BUNNY); pCreatureTarget->ForcedDespawn(); return true; } return true; } case SPELL_TAILS_UP_GENDER_MASTER: { if (uiEffIndex == EFFECT_INDEX_0) { bool isMale = urand(0,1); Player* pPlayer = pCreatureTarget->GetLootRecipient(); if (isMale) DoScriptText(SAY_ITS_MALE, pCreatureTarget, pPlayer); else DoScriptText(SAY_ITS_FEMALE, pCreatureTarget, pPlayer); switch(pCreatureTarget->GetEntry()) { case NPC_FROST_LEOPARD: { if (isMale) pCreatureTarget->CastSpell(pCreatureTarget, SPELL_TAILS_UP_AURA, true); else { pPlayer->KilledMonsterCredit(NPC_LEOPARD_KILL_CREDIT, pCreatureTarget->GetObjectGuid()); pCreatureTarget->CastSpell(pPlayer, SPELL_FORCE_LEOPARD_SUMMON, true); pCreatureTarget->ForcedDespawn(); } break; } case NPC_ICEPAW_BEAR: { if (isMale) pCreatureTarget->CastSpell(pCreatureTarget, SPELL_TAILS_UP_AURA, true); else { pPlayer->KilledMonsterCredit(NPC_BEAR_KILL_CREDIT, pCreatureTarget->GetObjectGuid()); pCreatureTarget->CastSpell(pPlayer, SPELL_FORCE_BEAR_SUMMON, true); pCreatureTarget->ForcedDespawn(); } break; } } return true; } return true; } case SPELL_THROW_GORDAWG_BOULDER: { if (uiEffIndex == EFFECT_INDEX_0) { for(int i = 0; i < 3; ++i) { if (irand(i, 2)) // 2-3 summons pCreatureTarget->SummonCreature(NPC_MINION_OF_GUROK, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 5000); } if (pCreatureTarget->getVictim()) { pCaster->DealDamage(pCreatureTarget, pCreatureTarget->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return true; } // If not in combat, no xp or loot pCreatureTarget->SetDeathState(JUST_DIED); pCreatureTarget->SetHealth(0); return true; } return true; } case SPELL_HIT_APPLE: { if (uiEffIndex == EFFECT_INDEX_0) { if (pCaster->GetTypeId() == TYPEID_PLAYER) ((Player*)pCaster)->KilledMonsterCredit(pCreatureTarget->GetEntry(), pCreatureTarget->GetObjectGuid()); pCreatureTarget->CastSpell(pCreatureTarget, SPELL_APPLE_FALLS_TO_GROUND, false); if (Creature* pLuckyWilhelm = GetClosestCreatureWithEntry(pCreatureTarget, NPC_LUCKY_WILHELM, 2*INTERACTION_DISTANCE)) DoScriptText(SAY_LUCKY_HIT_APPLE, pLuckyWilhelm); } return true; } case SPELL_MISS_APPLE: { if (uiEffIndex == EFFECT_INDEX_0) { switch (urand(1, 3)) { case 1: DoScriptText(SAY_LUCKY_HIT_1, pCreatureTarget); break; case 2: DoScriptText(SAY_LUCKY_HIT_2, pCreatureTarget); break; case 3: DoScriptText(SAY_LUCKY_HIT_3, pCreatureTarget); break; } if (Creature* pDrostan = GetClosestCreatureWithEntry(pCreatureTarget, NPC_DROSTAN, 4*INTERACTION_DISTANCE)) DoScriptText(urand(0, 1) ? SAY_DROSTAN_GOT_LUCKY_1 : SAY_DROSTAN_GOT_LUCKY_2, pDrostan); } return true; } case SPELL_MISS_APPLE_HIT_BIRD: { if (uiEffIndex == EFFECT_INDEX_0) { if (Creature* pDrostan = GetClosestCreatureWithEntry(pCreatureTarget, NPC_DROSTAN, 5*INTERACTION_DISTANCE)) DoScriptText(urand(0, 1) ? SAY_DROSTAN_HIT_BIRD_1 : SAY_DROSTAN_HIT_BIRD_2, pDrostan); pCreatureTarget->DealDamage(pCreatureTarget, pCreatureTarget->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } return true; } } return false; }
void UpdateAI(const uint32 uiDiff) { if (m_uiPlayerGUID && !m_creature->getVictim() && m_creature->isAlive()) { if (m_uiExecuteSpeech_Timer < uiDiff) { Player* pPlayer = m_creature->GetMap()->GetPlayer(m_uiPlayerGUID); if (!pPlayer) { Reset(); return; } //TODO: simplify text's selection switch(pPlayer->getRace()) { case RACE_HUMAN: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_5, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_5, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_7, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_6, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_ORC: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_6, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_7, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_8, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_8, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_DWARF: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_2, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_2, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_3, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_2, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_5, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_2, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_3, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_NIGHTELF: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_5, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_6, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_2, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_7, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_UNDEAD: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_3, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_4, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_3, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_1, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_3, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_4, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_TAUREN: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_5, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_8, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_9, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_9, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_GNOME: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_4, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_4, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_6, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_5, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_TROLL: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_3, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_7, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_2, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_6, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_9, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_10, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_4, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_10, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_BLOODELF: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_1, m_creature, pPlayer); break; //case 5: //unknown case 6: DoScriptText(SAY_EXEC_THINK_3, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_1, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; case RACE_DRAENEI: switch(m_uiExecuteSpeech_Counter) { case 0: DoScriptText(SAY_EXEC_START_1, m_creature, pPlayer); break; case 1: m_creature->SetStandState(UNIT_STAND_STATE_STAND); break; case 2: DoScriptText(SAY_EXEC_PROG_1, m_creature, pPlayer); break; case 3: DoScriptText(SAY_EXEC_NAME_1, m_creature, pPlayer); break; case 4: DoScriptText(SAY_EXEC_RECOG_2, m_creature, pPlayer); break; case 5: DoScriptText(SAY_EXEC_NOREM_1, m_creature, pPlayer); break; case 6: DoScriptText(SAY_EXEC_THINK_4, m_creature, pPlayer); break; case 7: DoScriptText(SAY_EXEC_LISTEN_1, m_creature, pPlayer); break; case 8: if (Creature* pPlaguefist = GetClosestCreatureWithEntry(m_creature, NPC_PLAGUEFIST, 85.0f)) DoScriptText(SAY_PLAGUEFIST, pPlaguefist, pPlayer); break; case 9: DoScriptText(SAY_EXEC_TIME_2, m_creature, pPlayer); m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); break; case 10: DoScriptText(SAY_EXEC_WAITING, m_creature, pPlayer); break; case 11: DoScriptText(EMOTE_DIES, m_creature); m_creature->SetDeathState(JUST_DIED); m_creature->SetHealth(0); return; } break; } if (m_uiExecuteSpeech_Counter >= 9) m_uiExecuteSpeech_Timer = 15000; else m_uiExecuteSpeech_Timer = 7000; ++m_uiExecuteSpeech_Counter; } else m_uiExecuteSpeech_Timer -= uiDiff; } }
void WaypointReached(uint32 waypointId) override { Player* player = GetPlayerForEscort(); if (!player) return; switch (waypointId) { case 9: if (Creature* Mrfloppy = GetClosestCreatureWithEntry(me, NPC_MRFLOPPY, 100.0f)) _mrfloppyGUID = Mrfloppy->GetGUID(); break; case 10: if (ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { Talk(SAY_WORGHAGGRO1); me->SummonCreature(NPC_HUNGRY_WORG, me->GetPositionX()+5, me->GetPositionY()+2, me->GetPositionZ()+1, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); } break; case 11: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) Mrfloppy->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); break; case 17: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) Mrfloppy->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); Talk(SAY_WORGRAGGRO3); if (Creature* RWORG = me->SummonCreature(NPC_RAVENOUS_WORG, me->GetPositionX()+10, me->GetPositionY()+8, me->GetPositionZ()+2, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000)) { RWORG->setFaction(35); _RavenousworgGUID = RWORG->GetGUID(); } break; case 18: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); DoCast(Mrfloppy, SPELL_MRFLOPPY); } break; case 19: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { if (Mrfloppy->HasAura(SPELL_MRFLOPPY, 0)) { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) Mrfloppy->EnterVehicle(RWORG); } } break; case 20: if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) RWORG->HandleEmoteCommand(34); break; case 21: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) { RWORG->Kill(Mrfloppy); Mrfloppy->ExitVehicle(); RWORG->setFaction(14); RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10, RWORG->GetPositionY()+80, RWORG->GetPositionZ()); Talk(SAY_VICTORY2); } } break; case 22: if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { if (Mrfloppy->isDead()) { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) RWORG->DisappearAndDie(); me->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); Mrfloppy->setDeathState(ALIVE); Mrfloppy->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); Talk(SAY_VICTORY3); } } break; case 24: if (player) { player->GroupEventHappens(QUEST_PERILOUS_ADVENTURE, me); Talk(SAY_QUEST_COMPLETE, player); } me->SetWalk(false); break; case 25: Talk(SAY_VICTORY4); break; case 27: me->DisappearAndDie(); if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) Mrfloppy->DisappearAndDie(); break; } }
void WaypointReached(uint32 i) { Player* pPlayer = GetPlayerForEscort(); if (!pPlayer) return; switch (i) { case 9: if (Creature *Mrfloppy = GetClosestCreatureWithEntry(me, NPC_MRFLOPPY, 100.0f)) MrfloppyGUID = Mrfloppy->GetGUID(); break; case 10: if (Unit::GetCreature(*me, MrfloppyGUID)) { DoScriptText(SAY_WORGHAGGRO1, me); me->SummonCreature(NPC_HUNGRY_WORG,me->GetPositionX()+5,me->GetPositionY()+2,me->GetPositionZ()+1,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000); } break; case 11: if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) Mrfloppy->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); break; case 17: if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) Mrfloppy->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); DoScriptText(SAY_WORGRAGGRO3, me); if (Creature *RWORG = me->SummonCreature(NPC_RAVENOUS_WORG,me->GetPositionX()+10,me->GetPositionY()+8,me->GetPositionZ()+2,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000)) { RWORG->setFaction(35); RWORGGUID = RWORG->GetGUID(); } break; case 18: if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) { if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID)) RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); DoCast(Mrfloppy,SPELL_MRFLOPPY); } break; case 19: if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) { if (Mrfloppy->HasAura(SPELL_MRFLOPPY, 0)) { if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID)) Mrfloppy->EnterVehicle(RWORG); } } break; case 20: if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID)) RWORG->HandleEmoteCommand(34); break; case 21: if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) { if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID)) { RWORG->Kill(Mrfloppy); Mrfloppy->ExitVehicle(); RWORG->setFaction(14); RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10,RWORG->GetPositionY()+80,RWORG->GetPositionZ()); DoScriptText(SAY_VICTORY2, me); } } break; case 22: if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) { if (Mrfloppy->isDead()) { if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID)) RWORG->DisappearAndDie(); me->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); Mrfloppy->setDeathState(ALIVE); Mrfloppy->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); DoScriptText(SAY_VICTORY3, me); } } break; case 24: if (pPlayer) { Completed = true; pPlayer->GroupEventHappens(QUEST_PERILOUS_ADVENTURE, me); DoScriptText(SAY_QUEST_COMPLETE, me, pPlayer); } me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); break; case 25: DoScriptText(SAY_VICTORY4, me); break; case 27: me->DisappearAndDie(); if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID)) Mrfloppy->DisappearAndDie(); break; } }
void SummonedCreatureJustDied(Creature* pSummoned) override { // Despawn the tentacle portal - this applies to all the summoned tentacles if (Creature* pPortal = GetClosestCreatureWithEntry(pSummoned, NPC_TENTACLE_PORTAL, 5.0f)) pPortal->ForcedDespawn(); }