void Reset() { ArcanagosGUID = 0; if (pInstance && pInstance->GetData64(DATA_IMAGE_OF_MEDIVH) == 0) { pInstance->SetData64(DATA_IMAGE_OF_MEDIVH, me->GetGUID()); (*me).GetMotionMaster()->MovePoint(1, MedivPos[0], MedivPos[1], MedivPos[2]); Step = 0; }else { me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); me->RemoveCorpse(); } }
void JustDied(Unit *victim) { if (!pInstance) return; pInstance->SetData64(DATA_GUNSHIP_ADD_RESPAWN, me->GetGUID()); if (IsPortalMage) pInstance->SetData(DATA_GUNSHIP_PORTAL_MAGES, ACTION_REMOVE_MAGE); else { pInstance->SetData(DATA_GUNSHIP_ICE_CANON_EVENT, DONE); me->RemoveFromWorld(); } }
void Reset() { _Reset(); me->SetReactState(REACT_PASSIVE); me->AddAura(SPELL_IMPERVIOUS_CARAPACE, me); me->CombatStop(); //SetCanSeeEvenInPassiveMode(true); //no need Phase = PHASE_WEAK_SPOT; inFight = false; eventChargeProgress = 0; events.ScheduleEvent(EVENT_RAIGONN_CHARGE, 1000, PHASE_WEAK_SPOT); me->RemoveAurasDueToSpell(SPELL_BROKEN_CARAPACE); me->RemoveAurasDueToSpell(SPELL_BROKEN_CARAPACE_DAMAGE); if (Vehicle* meVehicle = me->GetVehicleKit()) { //meVehicle->SetPassengersSpawnedByAI(true); if (Unit* passenger = meVehicle->GetPassenger(1)) // Check if weak_spot already spawned { passenger->setFaction(35); passenger->SetFullHealth(); passenger->AddUnitState(UNIT_STATE_UNATTACKABLE); pInstance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, passenger); return; } if (Creature* weakSpot = me->SummonCreature(NPC_WEAK_SPOT, 0, 0, 0)) { weakSpot->EnterVehicle(me, 1); //weakSpot->_EnterVehicle(me, 1); if (pInstance) pInstance->SetData64(NPC_WEAK_SPOT, weakSpot->GetGUID()); /*if (Vehicle* vehicleWeakSpot = weakSpot->GetVehicleKit()) vehicleWeakSpot->SetCanBeCastedByPassengers(true);*/ } } }
void Reset() { uiSinsterStrikeTimer = 7 * IN_MILLISECONDS; uiCallFlamesTimer = 10 * IN_MILLISECONDS; uiRitualOfSwordTimer = 20 * IN_MILLISECONDS; uiSacrificeTimer = 8 * IN_MILLISECONDS; bSacrificed = false; Phase = NORMAL; DoTeleportTo(296.632f, -346.075f, 90.6307f); me->SetUnitMovementFlags(MOVEMENTFLAG_WALKING); summons.DespawnAll(); if (pInstance) { pInstance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, NOT_STARTED); pInstance->SetData64(DATA_SACRIFICED_PLAYER, 0); } }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*Sender*/, uint32 Action) { player->PlayerTalkClass->ClearMenus(); switch (Action) { case GOSSIP_ACTION_INFO_DEF+1: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_DOOMREL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); player->SEND_GOSSIP_MENU(2605, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+2: player->CLOSE_GOSSIP_MENU(); //start event here creature->setFaction(FACTION_HOSTILE); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); creature->AI()->AttackStart(player); InstanceScript* instance = creature->GetInstanceScript(); if (instance) instance->SetData64(DATA_EVENSTARTER, player->GetGUID()); break; } return true; }
void Reset() { sacrificed = false; SetCombatMovement(true); summons.DespawnAll(); me->RemoveAllAuras(); if (Phase > NORMAL) Phase = NORMAL; me->SetDisableGravity(Phase == NORMAL); introTimer = 1 * IN_MILLISECONDS; introPhase = 0; arthasGUID = 0; if (instance) { instance->SetData(DATA_SVALA_SORROWGRAVE_EVENT, NOT_STARTED); instance->SetData64(DATA_SACRIFICED_PLAYER, 0); } }
void Reset() override { uiOpFerTimer = urand(15*IN_MILLISECONDS, 20*IN_MILLISECONDS); uiCycloneTimer = 3*IN_MILLISECONDS; uiBoltTimer = 7*IN_MILLISECONDS; uiThunderTimer = 12*IN_MILLISECONDS; bOpFerok = false; bOpFerokFail = false; bOnGround = false; bCanDown = false; volunteerWork = true; if (!bFirstTime) instance->SetBossState(DATA_JEDOGA_SHADOWSEEKER, FAIL); instance->SetData64(DATA_PL_JEDOGA_TARGET, 0); instance->SetData64(DATA_ADD_JEDOGA_OPFER, 0); instance->SetData(DATA_JEDOGA_RESET_INITIANDS, 0); MoveUp(); bFirstTime = false; }
void UpdateAI(const uint32 diff) { if (Phase == IDLE) return; if (Phase == INTRO) { if (introTimer <= diff) { Creature* arthas = Unit::GetCreature(*me, arthasGUID); if (!arthas) return; switch (introPhase) { case 0: Talk(SAY_SVALA_INTRO_0); ++introPhase; introTimer = 8100; break; case 1: arthas->AI()->Talk(SAY_DIALOG_OF_ARTHAS_1); ++introPhase; introTimer = 10000; break; case 2: arthas->CastSpell(me, SPELL_TRANSFORMING_CHANNEL, false); pos.Relocate(me); pos.m_positionZ += 8.0f; me->GetMotionMaster()->MoveTakeoff(0, pos); // spectators flee event if (instance) { std::list<Creature*> lspectatorList; GetCreatureListWithEntryInGrid(lspectatorList, me, CREATURE_SPECTATOR, 100.0f); for (std::list<Creature*>::iterator itr = lspectatorList.begin(); itr != lspectatorList.end(); ++itr) { if ((*itr)->isAlive()) { (*itr)->SetStandState(UNIT_STAND_STATE_STAND); (*itr)->SetWalk(false); (*itr)->GetMotionMaster()->MovePoint(1, spectatorWP[0][0], spectatorWP[0][1], spectatorWP[0][2]); } } } ++introPhase; introTimer = 4200; break; case 3: me->CastSpell(me, SPELL_SVALA_TRANSFORMING1, false); ++introPhase; introTimer = 6200; break; case 4: me->CastSpell(me, SPELL_SVALA_TRANSFORMING2, false); arthas->InterruptNonMeleeSpells(true); me->RemoveAllAuras(); me->UpdateEntry(CREATURE_SVALA_SORROWGRAVE); me->SetFacingToObject(arthas); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); ++introPhase; introTimer = 3200; break; case 5: Talk(SAY_SVALA_INTRO_1); ++introPhase; introTimer = 10000; break; case 6: arthas->AI()->Talk(SAY_DIALOG_OF_ARTHAS_2); ++introPhase; introTimer = 7200; break; case 7: Talk(SAY_SVALA_INTRO_2); me->SetOrientation(1.58f); me->SendMovementFlagUpdate(); arthas->SetVisible(false); ++introPhase; introTimer = 13800; break; case 8: pos.Relocate(me); pos.m_positionX = me->GetHomePosition().GetPositionX(); pos.m_positionY = me->GetHomePosition().GetPositionY(); pos.m_positionZ = 90.6065f; me->GetMotionMaster()->MoveLand(0, pos); me->SetDisableGravity(false, true); me->SetHover(true); ++introPhase; introTimer = 3000; break; case 9: if (GameObject* mirror = GetClosestGameObjectWithEntry(me, OBJECT_UTGARDE_MIRROR, 100.0f)) mirror->SetGoState(GO_STATE_ACTIVE); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); arthas->DespawnOrUnsummon(); arthasGUID = 0; Phase = NORMAL; break; } } else introTimer -= diff; return; } if (Phase == NORMAL) { //Return since we have no target if (!UpdateVictim()) return; if (sinsterStrikeTimer <= diff) { DoCast(me->getVictim(), SPELL_SINSTER_STRIKE); sinsterStrikeTimer = urand(5 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); } else sinsterStrikeTimer -= diff; if (callFlamesTimer <= diff) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) { DoCast(target, SPELL_CALL_FLAMES); callFlamesTimer = urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); } } else callFlamesTimer -= diff; if (!sacrificed) { if (HealthBelowPct(50)) { if (Unit* sacrificeTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true)) { if (instance) instance->SetData64(DATA_SACRIFICED_PLAYER, sacrificeTarget->GetGUID()); Talk(SAY_SACRIFICE_PLAYER); DoCast(sacrificeTarget, SPELL_RITUAL_PREPARATION); SetCombatMovement(false); Phase = SACRIFICING; sacrePhase = 0; sacrificeTimer = 1 * IN_MILLISECONDS; DoCast(me, SPELL_RITUAL_OF_THE_SWORD); sacrificed = true; } } } DoMeleeAttackIfReady(); } else //SACRIFICING { if (sacrificeTimer <= diff) { switch (sacrePhase) { case 0: // spawn ritual channelers if (instance) { DoCast(me, SPELL_RITUAL_CHANNELER_1, true); DoCast(me, SPELL_RITUAL_CHANNELER_2, true); DoCast(me, SPELL_RITUAL_CHANNELER_3, true); } ++sacrePhase; sacrificeTimer = 2 * IN_MILLISECONDS; break; case 1: me->StopMoving(); me->GetMotionMaster()->MoveIdle(); me->InterruptNonMeleeSpells(true); DoCast(me, SPELL_RITUAL_STRIKE_TRIGGER, true); ++sacrePhase; sacrificeTimer = 200; break; case 2: DoCast(me, SPELL_RITUAL_DISARM); ++sacrePhase; break; case 3: break; } } else sacrificeTimer -= diff; } }
void DoSummonGrandChampion(uint32 bossId) { ++summonTimes; uint32 NPC_TO_SUMMON_1 = 0; // Grand Champion uint32 NPC_TO_SUMMON_2 = 0; // Faction Champions switch (bossId) { case 0: NPC_TO_SUMMON_1 = NPC_MOKRA; NPC_TO_SUMMON_2 = NPC_ORGRIMMAR_CHAMPION; break; case 1: NPC_TO_SUMMON_1 = NPC_ERESSEA; NPC_TO_SUMMON_2 = NPC_SILVERMOON_CHAMPION; break; case 2: NPC_TO_SUMMON_1 = NPC_RUNOK; NPC_TO_SUMMON_2 = NPC_THUNDER_CHAMPION; break; case 3: NPC_TO_SUMMON_1 = NPC_ZULTORE; NPC_TO_SUMMON_2 = NPC_TROLL_CHAMPION; break; case 4: NPC_TO_SUMMON_1 = NPC_VISCERI; NPC_TO_SUMMON_2 = NPC_UNDERCITY_CHAMPION; break; default: return; } if (Creature* boss = me->SummonCreature(NPC_TO_SUMMON_1, SpawnPosition)) { if (instance) instance->SetData64(DATA_GRAND_CHAMPION_1 - 1 + summonTimes, boss->GetGUID()); boss->AI()->SetData(summonTimes, 0); for (uint8 i = 0; i < 3; ++i) { if (Creature* add = me->SummonCreature(NPC_TO_SUMMON_2, SpawnPosition, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000)) { switch (summonTimes) { case 1: Champion1List.push_back(add->GetGUID()); break; case 2: Champion2List.push_back(add->GetGUID()); break; case 3: Champion3List.push_back(add->GetGUID()); break; } switch (i) { case 0: add->GetMotionMaster()->MoveFollow(boss, 2.0f, M_PI); break; case 1: add->GetMotionMaster()->MoveFollow(boss, 2.0f, M_PI / 2); break; case 2: add->GetMotionMaster()->MoveFollow(boss, 2.0f, M_PI / 2 + M_PI); break; } } } } }
void DoSummonGrandChampion(uint32 uiBoss) { ++uiSummonTimes; uint32 VEHICLE_TO_SUMMON1 = 0; uint32 VEHICLE_TO_SUMMON2 = 0; switch (uiBoss) { case 0: if (instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE) Talk(H_SAY_WARRIOR_ENTERS); else Talk(A_SAY_WARRIOR_ENTERS); Talk(SAY_WARRIOR_CHEER); VEHICLE_TO_SUMMON1 = VEHICLE_MOKRA_SKILLCRUSHER_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_ORGRIMMAR_WOLF; break; case 1: if (instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE) Talk(H_SAY_MAGE_ENTERS); else Talk(A_SAY_MAGE_ENTERS); Talk(SAY_MAGE_CHEER); VEHICLE_TO_SUMMON1 = VEHICLE_ERESSEA_DAWNSINGER_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_SILVERMOON_HAWKSTRIDER; break; case 2: if (instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE) Talk(H_SAY_SHAMAN_ENTERS); else Talk(A_SAY_SHAMAN_ENTERS); Talk(SAY_SHAMAN_CHEER); VEHICLE_TO_SUMMON1 = VEHICLE_RUNOK_WILDMANE_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_THUNDER_BLUFF_KODO; break; case 3: Talk(SAY_HUNTER_ENTERS); Talk(SAY_HUNTER_CHEER); VEHICLE_TO_SUMMON1 = VEHICLE_ZUL_TORE_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_DARKSPEAR_RAPTOR; break; case 4: if (instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE) Talk(H_SAY_ROGUE_ENTERS); else Talk(A_SAY_ROGUE_ENTERS); Talk(SAY_ROGUE_CHEER); VEHICLE_TO_SUMMON1 = VEHICLE_DEATHSTALKER_VESCERI_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_FORSAKE_WARHORSE; break; default: return; } if (Creature* pBoss = me->SummonCreature(VEHICLE_TO_SUMMON1,SpawnPosition)) { switch(uiSummonTimes) { case 1: { uiVehicle1GUID = pBoss->GetGUID(); if (Creature* pBoss = ObjectAccessor::GetCreature(*me, uiVehicle1GUID)) if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* pUnit = pVehicle->GetPassenger(0)) uiGrandChampionBoss1 = pUnit->GetGUID(); instance->SetData64(DATA_GRAND_CHAMPION_1, uiGrandChampionBoss1); pBoss->AI()->SetData(1,0); break; } case 2: { uiVehicle2GUID = pBoss->GetGUID(); if (Creature* pBoss = ObjectAccessor::GetCreature(*me, uiVehicle2GUID)) if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* pUnit = pVehicle->GetPassenger(0)) uiGrandChampionBoss2 = pUnit->GetGUID(); instance->SetData64(DATA_GRAND_CHAMPION_2, uiGrandChampionBoss2); pBoss->AI()->SetData(2, 0); break; } case 3: { uiVehicle3GUID = pBoss->GetGUID(); if (Creature* pBoss = ObjectAccessor::GetCreature(*me, uiVehicle3GUID)) if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* pUnit = pVehicle->GetPassenger(0)) uiGrandChampionBoss3 = pUnit->GetGUID(); if (instance) instance->SetData64(DATA_GRAND_CHAMPION_3, uiGrandChampionBoss3); pBoss->AI()->SetData(3, 0); break; } default: return; } for (uint8 i = 0; i < 3; ++i) { if (Creature* pAdd = me->SummonCreature(VEHICLE_TO_SUMMON2,SpawnPosition,TEMPSUMMON_CORPSE_DESPAWN)) { switch (uiSummonTimes) { case 1: Champion1List.push_back(pAdd->GetGUID()); break; case 2: Champion2List.push_back(pAdd->GetGUID()); break; case 3: Champion3List.push_back(pAdd->GetGUID()); break; } switch (i) { case 0: pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.5f, M_PI); break; case 1: pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.5f, M_PI / 2); break; case 2: pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.5f, M_PI / 2 + M_PI); break; } } } } }
void UpdateAI(const uint32 diff) { if (Phase == NORMAL) { //Return since we have no target if (!UpdateVictim()) return; if (uiSinsterStrikeTimer <= diff) { DoCast(me->getVictim(), SPELL_SINSTER_STRIKE); uiSinsterStrikeTimer = urand(5 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); } else uiSinsterStrikeTimer -= diff; if (uiCallFlamesTimer <= diff) { if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) { DoCast(pTarget, SPELL_CALL_FLAMES); uiCallFlamesTimer = urand(8 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); } } else uiCallFlamesTimer -= diff; if (!bSacrificed) { if (uiRitualOfSwordTimer <= diff) { if (Unit* pSacrificeTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) { DoScriptText( RAND(SAY_SACRIFICE_PLAYER_1, SAY_SACRIFICE_PLAYER_2, SAY_SACRIFICE_PLAYER_3, SAY_SACRIFICE_PLAYER_4, SAY_SACRIFICE_PLAYER_5), me); DoCast(pSacrificeTarget, SPELL_RITUAL_OF_THE_SWORD); //Spell doesn't teleport DoTeleportPlayer(pSacrificeTarget, 296.632f, -346.075f, 90.63f, 4.6f); me->SetUnitMovementFlags(MOVEMENTFLAG_CAN_FLY); DoTeleportTo(296.632f, -346.075f, 120.85f); Phase = SACRIFICING; if (pInstance) { pInstance->SetData64(DATA_SACRIFICED_PLAYER, pSacrificeTarget->GetGUID()); for (uint8 i = 0; i < 3; ++i) if (Creature* pSummon = me->SummonCreature(CREATURE_RITUAL_CHANNELER, RitualChannelerPos[i], TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000)) pSummon->AI()->DoAction(0); } bSacrificed = true; } } else uiRitualOfSwordTimer -= diff; } DoMeleeAttackIfReady(); } else //SACRIFICING { if (uiSacrificeTimer <= diff) { Unit* pSacrificeTarget = pInstance ? Unit::GetUnit( *me, pInstance->GetData64( DATA_SACRIFICED_PLAYER)) : NULL; if (pInstance && !summons.empty() && pSacrificeTarget && pSacrificeTarget->isAlive()) me->Kill(pSacrificeTarget, false); // durability damage? //go down Phase = NORMAL; pSacrificeTarget = NULL; me->SetUnitMovementFlags(MOVEMENTFLAG_WALKING); if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) me->GetMotionMaster()->MoveChase(pTarget); uiSacrificeTimer = 8 * IN_MILLISECONDS; } else uiSacrificeTimer -= diff; } }
void EnterCombat(Unit* who) { me->InterruptNonMeleeSpells(false); if (pInstance) pInstance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, who->GetGUID()); }
void UpdateAI(const uint32 uiDiff) { if (!UpdateVictim()) return; //Common to PHASE_START && PHASE_END if (m_uiPhase == PHASE_START || m_uiPhase == PHASE_END) { //Specific to PHASE_START || PHASE_END if (m_uiPhase == PHASE_START) { if (HealthBelowPct(60)) { SetCombatMovement(false); m_uiPhase = PHASE_BREATH; me->GetMotionMaster()->MovePoint(10, Phase2Location); return; } } else { if (m_uiBellowingRoarTimer <= uiDiff) { DoCastVictim(SPELL_BELLOWING_ROAR); // Eruption GameObject* pFloor = NULL; Trillium::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15); Trillium::GameObjectLastSearcher<Trillium::GameObjectInRangeCheck> searcher(me, pFloor, check); me->VisitNearbyGridObject(30, searcher); if (m_pInstance && pFloor) m_pInstance->SetData64(DATA_FLOOR_ERUPTION_GUID, pFloor->GetGUID()); m_uiBellowingRoarTimer = 30000; } else m_uiBellowingRoarTimer -= uiDiff; } if (m_uiFlameBreathTimer <= uiDiff) { DoCastVictim(SPELL_FLAME_BREATH); m_uiFlameBreathTimer = urand(10000, 20000); } else m_uiFlameBreathTimer -= uiDiff; if (m_uiTailSweepTimer <= uiDiff) { DoCastAOE(SPELL_TAIL_SWEEP); m_uiTailSweepTimer = urand(15000, 20000); } else m_uiTailSweepTimer -= uiDiff; if (m_uiCleaveTimer <= uiDiff) { DoCastVictim(SPELL_CLEAVE); m_uiCleaveTimer = urand(2000, 5000); } else m_uiCleaveTimer -= uiDiff; if (m_uiWingBuffetTimer <= uiDiff) { DoCastVictim(SPELL_WING_BUFFET); m_uiWingBuffetTimer = urand(15000, 30000); } else m_uiWingBuffetTimer -= uiDiff; DoMeleeAttackIfReady(); } else { if (HealthBelowPct(40)) { m_uiPhase = PHASE_END; if (m_pInstance) m_pInstance->SetData(DATA_ONYXIA_PHASE, m_uiPhase); DoScriptText(SAY_PHASE_3_TRANS, me); SetCombatMovement(true); me->SetFlying(false); m_bIsMoving = false; me->GetMotionMaster()->MovePoint(9, me->GetHomePosition()); return; } if (m_uiDeepBreathTimer <= uiDiff) { if (!m_bIsMoving) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); DoScriptText(EMOTE_BREATH, me); DoCast(me, m_pPointData->uiSpellId); m_uiDeepBreathTimer = 70000; } } else m_uiDeepBreathTimer -= uiDiff; if (m_uiMovementTimer <= uiDiff) { if (!m_bIsMoving) { SetNextRandomPoint(); m_pPointData = GetMoveData(); if (!m_pPointData) return; me->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ); m_bIsMoving = true; m_uiMovementTimer = 25000; } } else m_uiMovementTimer -= uiDiff; if (m_uiFireballTimer <= uiDiff) { if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) DoCast(target, SPELL_FIREBALL); m_uiFireballTimer = 8000; } } else m_uiFireballTimer -= uiDiff; if (m_uiLairGuardTimer <= uiDiff) { me->SummonCreature(NPC_LAIRGUARD, aSpawnLocations[2].GetPositionX(), aSpawnLocations[2].GetPositionY(), aSpawnLocations[2].GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN); m_uiLairGuardTimer = 30000; } else m_uiLairGuardTimer -= uiDiff; if (m_uiWhelpTimer <= uiDiff) { me->SummonCreature(NPC_WHELP, aSpawnLocations[0].GetPositionX(), aSpawnLocations[0].GetPositionY(), aSpawnLocations[0].GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN); me->SummonCreature(NPC_WHELP, aSpawnLocations[1].GetPositionX(), aSpawnLocations[1].GetPositionY(), aSpawnLocations[1].GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN); if (m_uiSummonWhelpCount >= RAID_MODE(20, 40)) { m_uiSummonWhelpCount = 0; m_uiWhelpTimer = 90000; } else m_uiWhelpTimer = 500; } else m_uiWhelpTimer -= uiDiff; } }
void JustSummoned(Creature* summoned) { listOfMobs.Summon(summoned); if (summoned) instance->SetData64(DATA_ADD_TRASH_MOB, summoned->GetGUID()); }
void UpdateAI(uint32 diff) { if (!UpdateVictim() || (me->HasUnitState(UNIT_STATE_CASTING) && phase != PHASE_TWO)) return; events.Update(diff); while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_WRACK: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0.0f, 100.0f, true, 0)) DoCast(target, SPELL_WRACK, true); events.ScheduleEvent(EVENT_WRACK, urand(75000, 80000), phase); break; case EVENT_FLAME_BREATH: DoCastAOE(SPELL_FLAME_BREATH); events.ScheduleEvent(EVENT_FLAME_BREATH, 20000, phase); break; case EVENT_TWILIGHT_SLICER: for (uint8 i = 0; i < 2; i++) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0.0f, 100.0f, true, -SPELL_PURPLE_BEAM)) { Position pos; target->GetPosition(&pos); if (Creature* orb = me->SummonCreature(49863, pos, TEMPSUMMON_TIMED_DESPAWN, 15500, 0)) { if (!orbs[0]) { orbs[0] = orb; if (instance) instance->SetData64(DATA_ORB_0, orb->GetGUID()); } else { orbs[1] = orb; if (instance) instance->SetData64(DATA_ORB_1, orb->GetGUID()); } orb->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); orb->AddThreat(target, 1000000.0f); orb->Attack(target, true); // Twilight pulse! orb->CastSpell(orb, SPELL_TWILIGHT_PULSE, true); if (Aura* aur = orb->AddAura(SPELL_PURPLE_BEAM, target)) aur->SetDuration(60000); } } } events.ScheduleEvent(EVENT_RESET_ORBS, 18000, phase); events.ScheduleEvent(EVENT_TWILIGHT_SLICER, 28000, phase); events.ScheduleEvent(EVENT_ORB_START_CHANNEL, 3500, phase); break; case EVENT_ORB_START_CHANNEL: if (orbs[0] && orbs[1]) { orbs[1]->CastSpell(orbs[0], SPELL_TWILIGHT_SLICER, true); orbs[1]->ClearUnitState(UNIT_STATE_CASTING); if (orbs[1]->getVictim()) orbs[1]->GetMotionMaster()->MoveChase(orbs[1]->getVictim()); } break; case EVENT_RESET_ORBS: orbs[0] = NULL; orbs[1] = NULL; if (instance) instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PURPLE_BEAM); break; case EVENT_CHECK_MELEE: if (me->GetDistance2d(me->getVictim()) >= 5.0f) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0.0f, 100.0f, true, 0)) me->CastSpell(target, SPELL_SIN_TWILIGHT_BLAST, false); } events.ScheduleEvent(EVENT_CHECK_MELEE, 2000, phase); break; case EVENT_WHELP: for (uint8 i = 0; i < 5; i++) { uint8 posId = urand(0, 8); me->SummonCreature(48050, spawnPos[posId]); } me->MonsterYell(YELL_SUMMON, LANG_UNIVERSAL, 0); events.ScheduleEvent(EVENT_WHELP, 50000, phase); break; case EVENT_TWILIGHT_DRAKE: me->SummonCreature(55636, spawnPos[urand(0, 8)]); events.ScheduleEvent(EVENT_TWILIGHT_DRAKE, urand(18000, 30000), PHASE_TWO); break; case EVENT_SPITECALLER: me->SummonCreature(48415, spawnPos[urand(0, 8)]); events.ScheduleEvent(EVENT_SPITECALLER, urand(18000, 35000), PHASE_TWO); break; case EVENT_START_MAGIC_FIGHT: if (Creature* calen = me->SummonCreature(46277, -1009.35f, -801.97f, 438.59f, 0.81f)) { calen->CastSpell(calen, SPELL_PYRRHIC_FOCUS, true); calen->MonsterYell("Sintharia! Your master owes me a great debt... one that I intend to extract from his consort's hide!", LANG_UNIVERSAL, 0); if (Creature* target = me->SummonCreature(46288, -988.828f, -787.879f, 449.618f, 0.49f)) { target->SetHover(true); target->SetDisableGravity(true); target->SetCanFly(true); target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); target->GetMotionMaster()->MoveTakeoff(0, target->GetHomePosition()); calen->CastSpell(target, SPELL_FIERY_RESOLVE, false); me->CastSpell(target, SPELL_TWILIGHT_POWER, false); calen->setRegeneratingHealth(false); } } me->MonsterYell("This will be your tomb as well as theirs!", LANG_UNIVERSAL, 0); // Expose eggs! if (eggs[0]) eggs[0]->RemoveAura(SPELL_TWILIGHT_CARAPACE); if (eggs[1]) eggs[1]->RemoveAura(SPELL_TWILIGHT_CARAPACE); break; default: break; } } DoMeleeAttackIfReady(); }
void DoSummonGrandChampion(uint32 uiBoss) { ++uiSummonTimes; uint32 VEHICLE_TO_SUMMON1 = 0; uint32 VEHICLE_TO_SUMMON2 = 0; switch (uiBoss) { case 0: VEHICLE_TO_SUMMON1 = VEHICLE_MOKRA_SKILLCRUSHER_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_ORGRIMMAR_WOLF; break; case 1: VEHICLE_TO_SUMMON1 = VEHICLE_ERESSEA_DAWNSINGER_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_SILVERMOON_HAWKSTRIDER; break; case 2: VEHICLE_TO_SUMMON1 = VEHICLE_RUNOK_WILDMANE_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_THUNDER_BLUFF_KODO; break; case 3: VEHICLE_TO_SUMMON1 = VEHICLE_ZUL_TORE_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_DARKSPEAR_RAPTOR; break; case 4: VEHICLE_TO_SUMMON1 = VEHICLE_DEATHSTALKER_VESCERI_MOUNT; VEHICLE_TO_SUMMON2 = VEHICLE_FORSAKE_WARHORSE; break; default: return; } if (Creature* pBoss = me->SummonCreature(VEHICLE_TO_SUMMON1, SpawnPosition)) { switch (uiSummonTimes) { case 1: { uiVehicle1GUID = pBoss->GetGUID(); uint64 uiGrandChampionBoss1 = 0; if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* unit = pVehicle->GetPassenger(0)) uiGrandChampionBoss1 = unit->GetGUID(); if (instance) { instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID); instance->SetData64(DATA_GRAND_CHAMPION_1, uiGrandChampionBoss1); } pBoss->AI()->SetData(1, 0); break; } case 2: { uiVehicle2GUID = pBoss->GetGUID(); uint64 uiGrandChampionBoss2 = 0; if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* unit = pVehicle->GetPassenger(0)) uiGrandChampionBoss2 = unit->GetGUID(); if (instance) { instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID); instance->SetData64(DATA_GRAND_CHAMPION_2, uiGrandChampionBoss2); } pBoss->AI()->SetData(2, 0); break; } case 3: { uiVehicle3GUID = pBoss->GetGUID(); uint64 uiGrandChampionBoss3 = 0; if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* unit = pVehicle->GetPassenger(0)) uiGrandChampionBoss3 = unit->GetGUID(); if (instance) { instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID); instance->SetData64(DATA_GRAND_CHAMPION_3, uiGrandChampionBoss3); } pBoss->AI()->SetData(3, 0); break; } default: return; } for (uint8 i = 0; i < 3; ++i) { if (Creature* pAdd = me->SummonCreature(VEHICLE_TO_SUMMON2, SpawnPosition, TEMPSUMMON_CORPSE_DESPAWN)) { switch (uiSummonTimes) { case 1: Champion1List.push_back(pAdd->GetGUID()); break; case 2: Champion2List.push_back(pAdd->GetGUID()); break; case 3: Champion3List.push_back(pAdd->GetGUID()); break; } switch (i) { case 0: pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI); break; case 1: pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI / 2); break; case 2: pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI / 2 + M_PI); break; } } } } }
void UpdateAI(uint32 Diff) { if (!UpdateVictim()) return; //Common to PHASE_START && PHASE_END if (Phase == PHASE_START || Phase == PHASE_END) { //Specific to PHASE_START || PHASE_END if (Phase == PHASE_START) { if (HealthBelowPct(60)) { SetCombatMovement(false); Phase = PHASE_BREATH; me->GetMotionMaster()->MovePoint(10, Phase2Location); return; } } else { if (BellowingRoarTimer <= Diff) { DoCastVictim(SPELL_BELLOWING_ROAR); // Eruption GameObject* Floor = NULL; Trinity::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15); Trinity::GameObjectLastSearcher<Trinity::GameObjectInRangeCheck> searcher(me, Floor, check); me->VisitNearbyGridObject(30, searcher); if (instance && Floor) instance->SetData64(DATA_FLOOR_ERUPTION_GUID, Floor->GetGUID()); BellowingRoarTimer = 30000; } else BellowingRoarTimer -= Diff; } if (FlameBreathTimer <= Diff) { DoCastVictim(SPELL_FLAME_BREATH); FlameBreathTimer = urand(10000, 20000); } else FlameBreathTimer -= Diff; if (TailSweepTimer <= Diff) { DoCastAOE(SPELL_TAIL_SWEEP); TailSweepTimer = urand(15000, 20000); } else TailSweepTimer -= Diff; if (CleaveTimer <= Diff) { DoCastVictim(SPELL_CLEAVE); CleaveTimer = urand(2000, 5000); } else CleaveTimer -= Diff; if (WingBuffetTimer <= Diff) { DoCastVictim(SPELL_WING_BUFFET); WingBuffetTimer = urand(15000, 30000); } else WingBuffetTimer -= Diff; DoMeleeAttackIfReady(); } else { if (HealthBelowPct(40)) { Phase = PHASE_END; if (instance) instance->SetData(DATA_ONYXIA_PHASE, Phase); Talk(SAY_PHASE_3_TRANS); SetCombatMovement(true); me->SetCanFly(false); IsMoving = false; me->GetMotionMaster()->MovePoint(9, me->GetHomePosition()); return; } if (DeepBreathTimer <= Diff) { if (!IsMoving) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); Talk(EMOTE_BREATH); DoCast(me, PointData->SpellId); DeepBreathTimer = 70000; } } else DeepBreathTimer -= Diff; if (MovementTimer <= Diff) { if (!IsMoving) { SetNextRandomPoint(); PointData = GetMoveData(); if (!PointData) return; me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); IsMoving = true; MovementTimer = 25000; } } else MovementTimer -= Diff; if (FireballTimer <= Diff) { if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) DoCast(target, SPELL_FIREBALL); FireballTimer = 8000; } } else FireballTimer -= Diff; if (LairGuardTimer <= Diff) { me->SummonCreature(NPC_LAIRGUARD, SpawnLocations[2], TEMPSUMMON_CORPSE_DESPAWN); LairGuardTimer = 30000; } else LairGuardTimer -= Diff; if (WhelpTimer <= Diff) { me->SummonCreature(NPC_WHELP, SpawnLocations[0], TEMPSUMMON_CORPSE_DESPAWN); me->SummonCreature(NPC_WHELP, SpawnLocations[1], TEMPSUMMON_CORPSE_DESPAWN); if (SummonWhelpCount >= RAID_MODE(20, 40)) { SummonWhelpCount = 0; WhelpTimer = 90000; } else WhelpTimer = 500; } else WhelpTimer -= Diff; } }
void SummonedMobDied(Creature *pSummoned) { listOfMobs.Despawn(pSummoned); if (pSummoned) pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID()); }
void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker) { switch (action.type) { case ACTION_T_TEXT: { if (!action.text.TextId1) return; int32 temp = action.text.TextId1; if (action.text.TextId2 && action.text.TextId3) temp = RAND(action.text.TextId1, action.text.TextId2, action.text.TextId3); else if (action.text.TextId2 && urand(0, 1)) temp = action.text.TextId2; if (temp) { Unit* target = NULL; if (actionInvoker) { if (actionInvoker->GetTypeId() == TYPEID_PLAYER) target = actionInvoker; else if (Unit* owner = actionInvoker->GetOwner()) { if (owner->GetTypeId() == TYPEID_PLAYER) target = owner; } } else { target = me->getVictim(); if (target && target->GetTypeId() != TYPEID_PLAYER) if (Unit* owner = target->GetOwner()) if (owner->GetTypeId() == TYPEID_PLAYER) target = owner; } DoScriptText(temp, me, target); } break; } case ACTION_T_SET_FACTION: { if (action.set_faction.factionId) me->setFaction(action.set_faction.factionId); else { if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(me->GetEntry())) { //if no id provided, assume reset and then use default if (me->getFaction() != ci->faction_A) me->setFaction(ci->faction_A); } } break; } case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: { if (action.morph.creatureId || action.morph.modelId) { //set model based on entry from creature_template if (action.morph.creatureId) { if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(action.morph.creatureId)) { uint32 display_id = sObjectMgr->ChooseDisplayId(0, ci); me->SetDisplayId(display_id); } } //if no param1, then use value from param2 (modelId) else me->SetDisplayId(action.morph.modelId); } else me->DeMorph(); break; } case ACTION_T_SOUND: me->PlayDirectSound(action.sound.soundId); break; case ACTION_T_EMOTE: me->HandleEmoteCommand(action.emote.emoteId); break; case ACTION_T_RANDOM_SOUND: { int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3); if (temp >= 0) me->PlayDirectSound(temp); break; } case ACTION_T_RANDOM_EMOTE: { int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3); if (temp >= 0) me->HandleEmoteCommand(temp); break; } case ACTION_T_CAST: { Unit* target = GetTargetByType(action.cast.target, actionInvoker); Unit* caster = me; if (!target) return; if (action.cast.castFlags & CAST_FORCE_TARGET_SELF) caster = target; //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered bool canCast = !caster->IsNonMeleeSpellCasted(false) || (action.cast.castFlags & (CAST_TRIGGERED | CAST_INTERRUPT_PREVIOUS)); // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them if (action.cast.castFlags & CAST_AURA_NOT_PRESENT) { if (target->HasAura(action.cast.spellId)) return; } if (canCast) { const SpellInfo* tSpell = sSpellMgr->GetSpellInfo(action.cast.spellId); //Verify that spell exists if (tSpell) { //Check if cannot cast spell if (!(action.cast.castFlags & (CAST_FORCE_TARGET_SELF | CAST_FORCE_CAST)) && !CanCast(target, tSpell, (action.cast.castFlags & CAST_TRIGGERED))) { //Melee current victim if flag not set if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM)) { if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) { m_AttackDistance = 0.0f; m_AttackAngle = 0.0f; me->GetMotionMaster()->MoveChase(me->getVictim(), m_AttackDistance, m_AttackAngle); } } } else { //Interrupt any previous spell if (caster->IsNonMeleeSpellCasted(false) && action.cast.castFlags & CAST_INTERRUPT_PREVIOUS) caster->InterruptNonMeleeSpells(false); caster->CastSpell(target, action.cast.spellId, (action.cast.castFlags & CAST_TRIGGERED)); } } else sLog->outErrorDb("CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", eventId, me->GetEntry(), action.cast.spellId); } break; } case ACTION_T_SUMMON: { Unit* target = GetTargetByType(action.summon.target, actionInvoker); Creature* creature = NULL; if (action.summon.duration) creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); else creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); if (!creature) sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, eventId, me->GetEntry()); else if (action.summon.target != TARGET_T_SELF && target) creature->AI()->AttackStart(target); break; } case ACTION_T_THREAT_SINGLE_PCT: if (Unit* target = GetTargetByType(action.threat_single_pct.target, actionInvoker)) me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); break; case ACTION_T_THREAT_ALL_PCT: { std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) me->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); break; } case ACTION_T_QUEST_EVENT: if (Unit* target = GetTargetByType(action.quest_event.target, actionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->AreaExploredOrEventHappens(action.quest_event.questId); break; case ACTION_T_CAST_EVENT: if (Unit* target = GetTargetByType(action.cast_event.target, actionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->CastedCreatureOrGO(action.cast_event.creatureId, me->GetGUID(), action.cast_event.spellId); break; case ACTION_T_SET_UNIT_FIELD: { Unit* target = GetTargetByType(action.set_unit_field.target, actionInvoker); // not allow modify important for integrity object fields if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) return; if (target) target->SetUInt32Value(action.set_unit_field.field, action.set_unit_field.value); break; } case ACTION_T_SET_UNIT_FLAG: if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); break; case ACTION_T_REMOVE_UNIT_FLAG: if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); break; case ACTION_T_AUTO_ATTACK: m_MeleeEnabled = action.auto_attack.state != 0; break; case ACTION_T_COMBAT_MOVEMENT: // ignore no affect case if (m_CombatMovementEnabled == (action.combat_movement.state != 0)) return; m_CombatMovementEnabled = action.combat_movement.state != 0; //Allow movement (create new targeted movement gen only if idle) if (m_CombatMovementEnabled) { Unit* victim = me->getVictim(); if (me->isInCombat() && victim) { if (action.combat_movement.melee) { me->AddUnitState(UNIT_STATE_MELEE_ATTACKING); me->SendMeleeAttackStart(victim); } if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) me->GetMotionMaster()->MoveChase(victim, m_AttackDistance, m_AttackAngle); // Targeted movement generator will start melee automatically, no need to send it explicitly } } else { if (me->isInCombat()) { Unit* victim = me->getVictim(); if (action.combat_movement.melee && victim) { me->ClearUnitState(UNIT_STATE_MELEE_ATTACKING); me->SendMeleeAttackStop(victim); } if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) me->GetMotionMaster()->MoveIdle(); } } break; case ACTION_T_SET_PHASE: m_Phase = action.set_phase.phase; break; case ACTION_T_INC_PHASE: { int32 new_phase = int32(m_Phase)+action.set_inc_phase.step; if (new_phase < 0) { sLog->outErrorDb("CreatureEventAI: Event %d decrease m_Phase under 0. CreatureEntry = %d", eventId, me->GetEntry()); m_Phase = 0; } else if (new_phase >= MAX_PHASE) { sLog->outErrorDb("CreatureEventAI: Event %d incremented m_Phase above %u. m_Phase mask cannot be used with phases past %u. CreatureEntry = %d", eventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); m_Phase = MAX_PHASE-1; } else m_Phase = new_phase; break; } case ACTION_T_EVADE: EnterEvadeMode(); break; case ACTION_T_FLEE_FOR_ASSIST: me->DoFleeToGetAssistance(); break; case ACTION_T_QUEST_EVENT_ALL: if (actionInvoker && actionInvoker->GetTypeId() == TYPEID_PLAYER) { if (Unit* Temp = Unit::GetUnit(*me, actionInvoker->GetGUID())) if (Temp->GetTypeId() == TYPEID_PLAYER) Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId, me); } break; case ACTION_T_CAST_EVENT_ALL: { std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (Temp->GetTypeId() == TYPEID_PLAYER) Temp->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, me->GetGUID(), action.cast_event_all.spellId); break; } case ACTION_T_REMOVEAURASFROMSPELL: if (Unit* target = GetTargetByType(action.remove_aura.target, actionInvoker)) target->RemoveAurasDueToSpell(action.remove_aura.spellId); break; case ACTION_T_RANGED_MOVEMENT: m_AttackDistance = (float)action.ranged_movement.distance; m_AttackAngle = action.ranged_movement.angle/180.0f*M_PI; if (m_CombatMovementEnabled) { me->GetMotionMaster()->MoveChase(me->getVictim(), m_AttackDistance, m_AttackAngle); } break; case ACTION_T_RANDOM_PHASE: m_Phase = GetRandActionParam(rnd, action.random_phase.phase1, action.random_phase.phase2, action.random_phase.phase3); break; case ACTION_T_RANDOM_PHASE_RANGE: if (action.random_phase_range.phaseMin <= action.random_phase_range.phaseMax) m_Phase = urand(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax); else sLog->outErrorDb("CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", eventId, me->GetEntry()); break; case ACTION_T_SUMMON_ID: { Unit* target = GetTargetByType(action.summon_id.target, actionInvoker); CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr->GetCreatureEventAISummonMap().find(action.summon_id.spawnId); if (i == sEventAIMgr->GetCreatureEventAISummonMap().end()) { sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, eventId, me->GetEntry()); return; } Creature* creature = NULL; if ((*i).second.SpawnTimeSecs) creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); else creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); if (!creature) sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, eventId, me->GetEntry()); else if (action.summon_id.target != TARGET_T_SELF && target) creature->AI()->AttackStart(target); break; } case ACTION_T_KILLED_MONSTER: //first attempt player who tapped creature if (Player* player = me->GetLootRecipient()) player->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player); // player as param is a hacky solution not to use GUID else { //if not available, use actionInvoker if (Unit* target = GetTargetByType(action.killed_monster.target, actionInvoker)) if (Player* player2 = target->GetCharmerOrOwnerPlayerOrPlayerItself()) player2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player2); } break; case ACTION_T_SET_INST_DATA: { InstanceScript* instance = (InstanceScript*)me->GetInstanceScript(); if (!instance) { sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", eventId, me->GetEntry()); return; } instance->SetData(action.set_inst_data.field, action.set_inst_data.value); break; } case ACTION_T_SET_INST_DATA64: { Unit* target = GetTargetByType(action.set_inst_data64.target, actionInvoker); if (!target) { sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", eventId, me->GetEntry()); return; } InstanceScript* instance = (InstanceScript*)me->GetInstanceScript(); if (!instance) { sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", eventId, me->GetEntry()); return; } instance->SetData64(action.set_inst_data64.field, target->GetGUID()); break; } case ACTION_T_UPDATE_TEMPLATE: if (me->GetEntry() == action.update_template.creatureId) { sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", eventId, me->GetEntry()); return; } me->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE); break; case ACTION_T_DIE: if (me->isDead()) { sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", eventId, me->GetEntry()); return; } me->Kill(me); break; case ACTION_T_ZONE_COMBAT_PULSE: { me->SetInCombatWithZone(); break; } case ACTION_T_CALL_FOR_HELP: { me->CallForHelp((float)action.call_for_help.radius); break; } break; // TRINITY ONLY case ACTION_T_MOVE_RANDOM_POINT: //dosen't work in combat { float x, y, z; me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)action.raw.param1); me->GetMotionMaster()->MovePoint(0, x, y, z); break; } case ACTION_T_SET_STAND_STATE: me->SetStandState(UnitStandStateType(action.raw.param1)); break; case ACTION_T_SET_PHASE_MASK: me->SetPhaseMask(action.raw.param1, true); break; case ACTION_T_SET_VISIBILITY: me->SetVisible(bool(action.raw.param1)); break; case ACTION_T_SET_ACTIVE: me->setActive(action.raw.param1 ? true : false); break; case ACTION_T_SET_AGGRESSIVE: me->SetReactState(ReactStates(action.raw.param1)); break; case ACTION_T_ATTACK_START_PULSE: AttackStart(me->SelectNearestTarget((float)action.raw.param1)); break; case ACTION_T_SUMMON_GO: { GameObject* object = NULL; float x, y, z; me->GetPosition(x, y, z); object = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); if (!object) { sLog->outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, eventId, me->GetEntry()); } break; } case ACTION_T_SET_SHEATH: { me->SetSheath(SheathState(action.set_sheath.sheath)); break; } case ACTION_T_FORCE_DESPAWN: { me->DespawnOrUnsummon(action.forced_despawn.msDelay); break; } case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: { if (action.invincibility_hp_level.is_percent) m_InvincibilityHpLevel = me->CountPctFromMaxHealth(action.invincibility_hp_level.hp_level); else m_InvincibilityHpLevel = action.invincibility_hp_level.hp_level; break; } case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: { if (action.mount.creatureId || action.mount.modelId) { // set model based on entry from creature_template if (action.mount.creatureId) { if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(action.mount.creatureId)) { uint32 display_id = sObjectMgr->ChooseDisplayId(0, cInfo); me->Mount(display_id); } } //if no param1, then use value from param2 (modelId) else me->Mount(action.mount.modelId); } else me->Dismount(); break; } } }
void JustDied(Unit* /*killer*/) override { instance->SetData64(DATA_RUIN_DWELLER_DIED, me->GetGUID()); if (instance->GetData(DATA_ALIVE_RUIN_DWELLERS) == 0) me->SummonCreature(CREATURE_ECK, EckSpawnPoint, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300*IN_MILLISECONDS); }
void SummonedMobDied(Creature* summoned) { listOfMobs.Despawn(summoned); if (summoned) instance->SetData64(DATA_DEL_TRASH_MOB, summoned->GetGUID()); }