void TeleportToMyBrother() { if (!m_pInstance) return; Teleport_Timer = TELEPORTTIME; if (IAmVeklor()) return; // mechanics handled by veknilash so they teleport exactly at the same time and to correct coordinates Creature *pOtherBoss = GetOtherBoss(); if (pOtherBoss) { //m_creature->MonsterYell("Teleporting ...", LANG_UNIVERSAL); float other_x = pOtherBoss->GetPositionX(); float other_y = pOtherBoss->GetPositionY(); float other_z = pOtherBoss->GetPositionZ(); float other_o = pOtherBoss->GetOrientation(); pOtherBoss->RelocateCreature(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation()); pOtherBoss->GetMotionMaster()->MoveIdle(); m_creature->RelocateCreature(other_x, other_y, other_z, other_o); m_creature->GetMotionMaster()->MoveIdle(); SetAfterTeleport(); if (boss_twinemperorsAI* pOtherAI = dynamic_cast<boss_twinemperorsAI*>(pOtherBoss->AI())) pOtherAI->SetAfterTeleport(); } }
void TeleportToMyBrother() { if (!pInstance) return; Teleport_Timer = TELEPORTTIME; if (IAmVeklor()) return; // mechanics handled by veknilash so they teleport exactly at the same time and to correct coordinates Creature *pOtherBoss = GetOtherBoss(); if (pOtherBoss) { //me->MonsterYell("Teleporting ...", LANG_UNIVERSAL, 0); float other_x = pOtherBoss->GetPositionX(); float other_y = pOtherBoss->GetPositionY(); float other_z = pOtherBoss->GetPositionZ(); float other_o = pOtherBoss->GetOrientation(); Map *thismap = me->GetMap(); thismap->CreatureRelocation(pOtherBoss, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); thismap->CreatureRelocation(me, other_x, other_y, other_z, other_o); SetAfterTeleport(); CAST_AI(boss_twinemperorsAI, pOtherBoss->AI())->SetAfterTeleport(); } }
bool WaypointMovementGenerator<Creature>::StartMove(Creature &creature) { if (!i_path || i_path->empty()) return false; if (Stopped()) return true; const WaypointData *node = i_path->at(i_currentNode); if (m_isArrivalDone) { if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint { creature.SetHomePosition(node->x, node->y, node->z, creature.GetOrientation()); creature.GetMotionMaster()->Initialize(); return false; } i_currentNode = (i_currentNode+1) % i_path->size(); } m_isArrivalDone = false; creature.AddUnitState(UNIT_STAT_ROAMING_MOVE); Movement::MoveSplineInit init(creature); init.MoveTo(node->x, node->y, node->z); if (node->orientation != 100 && node->delay != 0) init.SetFacing(node->orientation); init.SetWalk(!node->run); init.Launch(); //Call for creature group update if (creature.GetFormation() && creature.GetFormation()->getLeader() == &creature) creature.GetFormation()->LeaderMoveTo(node->x, node->y, node->z); return true; }
bool OrbOfMurlocControl(uint32 i, Spell* pSpell) { if(pSpell->m_caster->IsPlayer() == false) return true; Player* pPlayer = TO_PLAYER( pSpell->u_caster ); QuestLogEntry *pQuest = pPlayer->GetQuestLogForEntry(11541); if(pQuest == NULL) return true; Creature* pTarget; for(ObjectSet::iterator itr = pSpell->m_caster->GetInRangeSetBegin(); itr != pSpell->m_caster->GetInRangeSetEnd(); ++itr) { if( (*itr)->IsUnit() && TO_UNIT(*itr)->IsCreature() ) pTarget = TO_CREATURE(*itr); else continue; if( pSpell->m_caster->CalcDistance(pTarget) > 5 ) continue; if( pTarget->GetEntry() == 25084) { if(pQuest->GetMobCount(0) < pQuest->GetQuest()->required_mobcount[0]) { pQuest->SetMobCount(0, pQuest->GetMobCount(0) + 1); pQuest->SendUpdateAddKill(0); Creature* FreedGreengill = sEAS.SpawnCreature(pPlayer, 25085, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), pTarget->GetOrientation(), 0); FreedGreengill->Despawn(6*60*1000, 0); pTarget->Despawn(0, 6*60*1000); pQuest->UpdatePlayerFields(); return true; } } } return true; }
// War is Hell bool WarIsHell(uint32 i, Spell * pSpell) { if( !pSpell->u_caster->IsPlayer() ) return true; Player * plr = TO_PLAYER(pSpell->u_caster); if( plr == NULL ) return true; Creature * target = TO_CREATURE(plr->GetMapMgr()->GetInterface()->GetCreatureNearestCoords( plr->GetPositionX(), plr->GetPositionY() , plr->GetPositionZ(), 24008 )); if( target == NULL ) return true; QuestLogEntry *qle = plr->GetQuestLogForEntry(11270); if( qle == NULL ) return true; GameObject * obj = NULLGOB; if( qle && qle->GetMobCount(0) < qle->GetQuest()->required_mobcount[0] ) { qle->SetMobCount( 0, qle->GetMobCount( 0 ) + 1 ); qle->SendUpdateAddKill( 0 ); obj = sEAS.SpawnGameobject(plr, 183816, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 1, 0, 0, 0, 0); sEAS.GameobjectDelete(obj, 1*30*1000); } target->Despawn( 2000, 60*1000 ); plr->UpdateNearbyGameObjects(); qle->UpdatePlayerFields(); return true; }
bool WaypointMovementGenerator<Creature>::StartMove(Creature &creature) { if (!i_path || i_path->empty()) return false; if (Stopped()) return true; if (m_isArrivalDone) { if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint { creature.SetHomePosition(i_path->at(i_currentNode)->x, i_path->at(i_currentNode)->y, i_path->at(i_currentNode)->z, creature.GetOrientation()); creature.GetMotionMaster()->Initialize(); return false; } i_currentNode = (i_currentNode+1) % i_path->size(); } WaypointData const* node = i_path->at(i_currentNode); m_isArrivalDone = false; creature.AddUnitState(UNIT_STATE_ROAMING_MOVE); Movement::MoveSplineInit init(creature); init.MoveTo(node->x, node->y, node->z); //! Accepts angles such as 0.00001 and -0.00001, 0 must be ignored, default value in waypoint table if (node->orientation && node->delay) init.SetFacing(node->orientation); init.SetWalk(!node->run); init.Launch(); //Call for creature group update if (creature.GetFormation() && creature.GetFormation()->getLeader() == &creature) creature.GetFormation()->LeaderMoveTo(node->x, node->y, node->z); return true; }
void UpdateAI(uint32 diff) { if (!pInstance || !UpdateVictim()) return; events.Update(diff); if (me->HasUnitState(UNIT_STATE_CASTING)) return; if (me->GetVictim()) if (me->GetVictim()->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 55.0f) { DoCastVictim(SPELL_LIGHTNING_BLAST); return; } while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_CHILLING_BREATH: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) DoCast(target, SPELL_CHILLING_BREATH); events.ScheduleEvent(EVENT_CHILLING_BREATH, urand(10000, 16000)); break; case EVENT_RESET_WIND: if (_aircurrent) _aircurrent->DespawnOrUnsummon(); events.DelayEvents(1000); events.ScheduleEvent(EVENT_CALL_OF_WIND, 800); break; case EVENT_CALL_OF_WIND: _aircurrent = me->SummonCreature(NPC_AIR_CURRENT, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), orientations[urand(0, 3)]); events.ScheduleEvent(EVENT_RESET_WIND, 18000); break; case EVENT_CHECK_FACING: if (me->GetMap()->GetPlayers().isEmpty() || !_aircurrent) break; for (Map::PlayerList::const_iterator itr = me->GetMap()->GetPlayers().begin(); itr != me->GetMap()->GetPlayers().end(); ++itr) { if (CheckOrientation(itr->GetSource()->GetOrientation(), _aircurrent->GetOrientation())) { itr->GetSource()->RemoveAurasDueToSpell(SPELL_DOWNWIND_OF_ALTAIRUS); me->AddAura(SPELL_UPWIND_OF_ALTAIRUS, itr->GetSource()); } else { itr->GetSource()->RemoveAurasDueToSpell(SPELL_UPWIND_OF_ALTAIRUS); me->AddAura(SPELL_DOWNWIND_OF_ALTAIRUS, itr->GetSource()); } } events.ScheduleEvent(EVENT_CHECK_FACING, 3000); break; } } DoMeleeAttackIfReady(); }
uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim) { Map* map = GetMap(); //make it world object so it will not be unloaded with grid Creature* creature = new Creature(true); if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0)) { delete creature; return 0; } creature->SetTransport(this); creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); creature->m_movementInfo.guid = GetGUID(); creature->m_movementInfo.t_pos.Relocate(x, y, z, o); if (anim) creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim); creature->Relocate( GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ(), o + GetOrientation()); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); creature->SetTransportHomePosition(creature->m_movementInfo.t_pos); if (!creature->IsPositionValid()) { sLog->outError(LOG_FILTER_TRANSPORTS, "Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", creature->GetGUIDLow(), creature->GetEntry(), creature->GetPositionX(), creature->GetPositionY()); delete creature; return 0; } map->AddToMap(creature); m_NPCPassengerSet.insert(creature); if (tguid == 0) { ++currenttguid; tguid = currenttguid; } else currenttguid = std::max(tguid, currenttguid); creature->SetGUIDTransport(tguid); sScriptMgr->OnAddCreaturePassenger(this, creature); return tguid; }
bool WaypointMovementGenerator<Creature>::Update(Creature &unit, const uint32 &diff) { if (!&unit) return true; if (!path_id) return false; // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff if (unit.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED)) return true; // Clear the generator if the path doesn't exist if (!waypoints || !waypoints->size()) return false; Traveller<Creature> traveller(unit); i_nextMoveTime.Update(diff); i_destinationHolder.UpdateTraveller(traveller, diff, true); if (i_nextMoveTime.GetExpiry() < TIMEDIFF_NEXT_WP) { if (unit.IsStopped()) { if (StopedByPlayer) { ASSERT(node); InitTraveller(unit, *node); i_destinationHolder.SetDestination(traveller, node->x, node->y, node->z); i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); StopedByPlayer = false; return true; } if (i_currentNode == waypoints->size() - 1) // If that's our last waypoint { if (repeating) // If the movement is repeating i_currentNode = 0; // Start moving all over again else { unit.SetHomePosition(node->x, node->y, node->z, unit.GetOrientation()); unit.GetMotionMaster()->Initialize(); return false; // Clear the waypoint movement } } else ++i_currentNode; node = waypoints->at(i_currentNode); InitTraveller(unit, *node); i_destinationHolder.SetDestination(traveller, node->x, node->y, node->z); i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); //Call for creature group update if (unit.GetFormation() && unit.GetFormation()->getLeader() == &unit) unit.GetFormation()->LeaderMoveTo(node->x, node->y, node->z); } else { //Determine waittime if (node->delay) i_nextMoveTime.Reset(node->delay); //note: disable "start" for mtmap if (node->event_id && urand(0,99) < node->event_chance) unit.GetMap()->ScriptsStart(sWaypointScripts, node->event_id, &unit, NULL/*, false*/); i_destinationHolder.ResetTravelTime(); MovementInform(unit); unit.UpdateWaypointID(i_currentNode); unit.ClearUnitState(UNIT_STAT_ROAMING); unit.Relocate(node->x, node->y, node->z); } } else { if (unit.IsStopped() && !i_destinationHolder.HasArrived()) { if (!StopedByPlayer) { i_destinationHolder.IncreaseTravelTime(STOP_TIME_FOR_PLAYER); i_nextMoveTime.Reset(STOP_TIME_FOR_PLAYER); StopedByPlayer = true; } } } return true; }
void instance_halls_of_stone::SortFaces() { std::list<Creature*> lPossibleEyes; GameObject* pFace = NULL; // FACE_MARNAK pFace = instance->GetGameObject(m_aFaces[FACE_MARNAK].m_goFaceGuid); if (pFace) { // Find Marnak NPCs GetValidNPCsOfList(instance, m_lMarnakGUIDs, lPossibleEyes); if (lPossibleEyes.size() > 1) { lPossibleEyes.sort(SortHelper(pFace)); std::list<Creature*>::const_iterator itr = lPossibleEyes.begin(); m_aFaces[FACE_MARNAK].m_leftEyeGuid = (*itr)->GetObjectGuid(); ++itr; m_aFaces[FACE_MARNAK].m_speakerGuid = (*itr)->GetObjectGuid(); } // Find Worldtrigger NPC GetValidNPCsOfList(instance, m_lWorldtriggerGUIDs, lPossibleEyes); if (!lPossibleEyes.empty()) { lPossibleEyes.sort(SortHelper(pFace)); Creature* pDummy = (*lPossibleEyes.begin()); if (Creature* newFace = pFace->SummonCreature(NPC_MARNAK, pDummy->GetPositionX(), pDummy->GetPositionY(), pDummy->GetPositionZ(), pDummy->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) m_aFaces[FACE_MARNAK].m_rightEyeGuid = newFace->GetObjectGuid(); //m_aFaces[FACE_MARNAK].m_rightEyeGuid = (*lPossibleEyes.begin())->GetObjectGuid(); } } // FACE_ABEDNEUM pFace = instance->GetGameObject(m_aFaces[FACE_ABEDNEUM].m_goFaceGuid); if (pFace) { // Find Abedneum NPCs GetValidNPCsOfList(instance, m_lAbedneumGUIDs, lPossibleEyes); if (lPossibleEyes.size() > 1) { lPossibleEyes.sort(SortHelper(pFace)); std::list<Creature*>::const_iterator itr = lPossibleEyes.begin(); m_aFaces[FACE_ABEDNEUM].m_leftEyeGuid = (*itr)->GetObjectGuid(); ++itr; m_aFaces[FACE_ABEDNEUM].m_speakerGuid = (*itr)->GetObjectGuid(); } // Find Worldtrigger NPC GetValidNPCsOfList(instance, m_lWorldtriggerGUIDs, lPossibleEyes); if (!lPossibleEyes.empty()) { lPossibleEyes.sort(SortHelper(pFace)); Creature* pDummy = (*lPossibleEyes.begin()); if (Creature* newFace = pFace->SummonCreature(NPC_ABEDNEUM, pDummy->GetPositionX(), pDummy->GetPositionY(), pDummy->GetPositionZ(), pDummy->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) m_aFaces[FACE_ABEDNEUM].m_rightEyeGuid = newFace->GetObjectGuid(); //m_aFaces[FACE_ABEDNEUM].m_rightEyeGuid = (*lPossibleEyes.begin())->GetObjectGuid(); } } // FACE_KADDRAK pFace = instance->GetGameObject(m_aFaces[FACE_KADDRAK].m_goFaceGuid); if (pFace) { // Find Kaddrak NPCs GetValidNPCsOfList(instance, m_lKaddrakGUIDs, lPossibleEyes); if (lPossibleEyes.size() > 1) { lPossibleEyes.sort(SortHelper(pFace)); std::list<Creature*>::const_iterator itr = lPossibleEyes.begin(); m_aFaces[FACE_KADDRAK].m_leftEyeGuid = (*itr)->GetObjectGuid(); ++itr; m_aFaces[FACE_KADDRAK].m_speakerGuid = (*itr)->GetObjectGuid(); } // Find Tribunal NPC GetValidNPCsOfList(instance, m_lTribunalGUIDs, lPossibleEyes); if (!lPossibleEyes.empty()) { lPossibleEyes.sort(SortHelper(pFace)); Creature* pDummy = (*lPossibleEyes.begin()); if (Creature* newFace = pFace->SummonCreature(NPC_KADDRAK, pDummy->GetPositionX(), pDummy->GetPositionY(), pDummy->GetPositionZ(), pDummy->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) m_aFaces[FACE_KADDRAK].m_rightEyeGuid = newFace->GetObjectGuid(); //m_aFaces[FACE_KADDRAK].m_rightEyeGuid = (*lPossibleEyes.begin())->GetObjectGuid(); } } // Clear GUIDs m_lKaddrakGUIDs.clear(); m_lAbedneumGUIDs.clear(); m_lMarnakGUIDs.clear(); m_lTribunalGUIDs.clear(); m_lWorldtriggerGUIDs.clear(); }
bool ShatariTorch(uint32 i, Spell* pSpell) { if(pSpell->u_caster->IsPlayer() == false) return true; Player *plr = (Player*)pSpell->u_caster; Unit *unit_target = (Unit*)plr->GetMapMgr()->GetCreature((uint32)plr->GetSelection()); if(unit_target == NULL) return true; if(!unit_target->IsCreature()) return true; Creature *target = (Creature*)unit_target; QuestLogEntry *qle = plr->GetQuestLogForEntry(10913); if(qle == NULL) return true; GameObject *obj = NULL; if(target->GetEntry() == 21859) { if(qle->GetMobCount(0) == qle->GetQuest()->required_mobcount[0]) return true; qle->SetMobCount(0, qle->GetMobCount(0)+1); qle->SendUpdateAddKill(0); obj = sEAS.SpawnGameobject(plr, 183816, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 1); sEAS.GameobjectDelete(obj, 1*60*1000); } else if(target->GetEntry() == 21846) { if(qle->GetMobCount(1) == qle->GetQuest()->required_mobcount[1]) return true; qle->SetMobCount(1, qle->GetMobCount(1)+1); qle->SendUpdateAddKill(1); obj = sEAS.SpawnGameobject(plr, 183816, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 1); sEAS.GameobjectDelete(obj, 1*60*1000); } else return true; target->Despawn(0, 1*60*1000); qle->UpdatePlayerFields(); plr->UpdateNearbyGameObjects(); return true; }
Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data) { Map* map = GetMap(); Creature* creature = Creature::CreateCreatureFromDB(guid, map, false); if (!creature) return nullptr; ASSERT(data); float x = data->posX; float y = data->posY; float z = data->posZ; float o = data->orientation; creature->SetTransport(this); creature->m_movementInfo.transport.guid = GetGUID(); creature->m_movementInfo.transport.pos.Relocate(x, y, z, o); creature->m_movementInfo.transport.seat = -1; CalculatePassengerPosition(x, y, z, &o); creature->Relocate(x, y, z, o); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos); /// @HACK - transport models are not added to map's dynamic LoS calculations /// because the current GameObjectModel cannot be moved without recreating creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING); if (!creature->IsPositionValid()) { TC_LOG_ERROR("entities.transport", "Passenger %s not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY()); delete creature; return nullptr; } PhasingHandler::InitDbPhaseShift(creature->GetPhaseShift(), data->phaseUseFlags, data->phaseId, data->phaseGroup); PhasingHandler::InitDbVisibleMapId(creature->GetPhaseShift(), data->terrainSwapMap); if (!map->AddToMap(creature)) { delete creature; return nullptr; } _staticPassengers.insert(creature); sScriptMgr->OnAddCreaturePassenger(this, creature); return creature; }
Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data) { Map* map = GetMap(); Creature* creature = new Creature(); if (!creature->LoadCreatureFromDB(guid, map, false)) { delete creature; return NULL; } float x = data->posX; float y = data->posY; float z = data->posZ; float o = data->orientation; creature->SetTransport(this); creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); creature->m_movementInfo.transport.guid = GetGUID(); creature->m_movementInfo.transport.pos.Relocate(x, y, z, o); CalculatePassengerPosition(x, y, z, &o); creature->Relocate(x, y, z, o); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos); if (!creature->IsPositionValid()) { TC_LOG_ERROR(LOG_FILTER_TRANSPORTS, "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY()); delete creature; return NULL; } if (!map->AddToMap(creature)) { delete creature; return NULL; } _staticPassengers.insert(creature); sScriptMgr->OnAddCreaturePassenger(this, creature); return creature; }
void AIUpdate() { switch(phase) { case 0: { _unit->GetAIInterface()->StopMovement(0); _unit->GetAIInterface()->SetAIState(STATE_SCRIPTMOVE); _unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_WANTEDWP); _unit->GetAIInterface()->setWaypointToMove(1); } break; case 1: { _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "I can only help you with a clean death.", 300); sEventMgr.AddEvent(TO_OBJECT(_unit), &Object::PlaySoundToSet, (uint32)14294, EVENT_UNK, 100, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); Creature* citizen = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), 28167); if(citizen) { _unit->GetAIInterface()->MoveTo(citizen->GetPositionX(), citizen->GetPositionY(), citizen->GetPositionZ(), citizen->GetOrientation()); _unit->DealDamage(citizen, citizen->GetUInt32Value(UNIT_FIELD_HEALTH), 0, 0, 0); } citizen = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), 28169); if(citizen) { _unit->GetAIInterface()->MoveTo(citizen->GetPositionX(), citizen->GetPositionY(), citizen->GetPositionZ(), citizen->GetOrientation()); _unit->DealDamage(citizen, citizen->GetUInt32Value(UNIT_FIELD_HEALTH), 0, 0, 0); } _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "That was just the beginning.", 1000); sEventMgr.AddEvent(TO_OBJECT(_unit), &Object::PlaySoundToSet, (uint32)14295, EVENT_UNK, 1000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); phase++; sEventMgr.AddEvent(_unit, &Creature::CallScriptUpdate, EVENT_SCRIPT_UPDATE_EVENT, 1500, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } break; case 2: { //we need that tricky animation here //spawn Mal'Ganis CreatureProto* cp = CreatureProtoStorage.LookupEntry(26533); CreatureInfo* ci = CreatureNameStorage.LookupEntry(26533); Creature* c = NULL; if(cp && ci) { c = _unit->GetMapMgr()->CreateCreature(26533); if(c) { //position is guessed c->Load(cp, 2113.52f, 1288.01f, 136.382f, 2.30383f); c->PushToWorld(_unit->GetMapMgr()); } } if(c) { c->bInvincible = true; c->GetAIInterface()->m_canMove = false; c->GetAIInterface()->SetAllowedToEnterCombat(false); for(uint8 i = 0; i < 7; i++) c->SchoolImmunityList[i] = 1; c->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); //1 = 0s c->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Yes, this is the beginning. I've been waiting for you, young prince. I am Mal'Ganis."); c->PlaySoundToSet(14410); //2 = 13s //change all citizens to undeads... sEventMgr.AddEvent(c, &Creature::CallScriptUpdate, EVENT_SCRIPT_UPDATE_EVENT, 13000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); c->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "As you can see, your people are now mine. I will now turn this city, household by household, until the flame of life has been snuffed out forever.", 13000); sEventMgr.AddEvent(TO_OBJECT(c), &Object::PlaySoundToSet, (uint32)14411, EVENT_UNK, 13000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); //2 = 32s _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "I won't allow it Mal'Ganis better than these people die by my hand than serve as your slaves in death.", 32000); sEventMgr.AddEvent(TO_OBJECT(_unit), &Object::PlaySoundToSet, (uint32)14296, EVENT_UNK, 32000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); c->Despawn(38500, 0); //3 = 37s /*sEventMgr.AddEvent(TO_UNIT(_unit), &Unit::SendChatMessage, (uint8)CHAT_MSG_MONSTER_SAY, (uint32)LANG_UNIVERSAL, "Mal'Ganis will send out some of his blablabla - write that txt", EVENT_UNIT_CHAT_MSG, 37000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);*/ sEventMgr.AddEvent(TO_OBJECT(_unit), &Object::PlaySoundToSet, (uint32)14885, EVENT_UNK, 39000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } } break; } }
void OnQuestStart( Player* mTarget, QuestLogEntry * qLogEntry) { if( mTarget == NULL || mTarget->GetMapMgr() == NULL || mTarget->GetMapMgr()->GetInterface() == NULL ) return; float SSX = mTarget->GetPositionX(); float SSY = mTarget->GetPositionY(); float SSZ = mTarget->GetPositionZ(); Creature* creat = mTarget->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(SSX, SSY, SSZ, 6546); if(creat == NULL) return; creat->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Fine, if you ready to go!"); Creature* Demon = creat->GetMapMgr()->GetInterface()->SpawnCreature(6549, creat->GetPositionX(), creat->GetPositionY(), creat->GetPositionZ(), creat->GetOrientation(), true, false, 0, 0); sEventMgr.AddEvent(TO_CREATURE(Demon), &Creature::AddToWorld, creat->GetMapMgr(), EVENT_UNK, 12000, 0, 1); sEventMgr.AddEvent(TO_CREATURE(Demon), &Creature::Despawn, (uint32)120000, (uint32)0, EVENT_CREATURE_UPDATE, 12000, 0, 1); creat->GetAIInterface()->setMoveType(11); creat->GetAIInterface()->StopMovement(3000); sEAS.CreateCustomWaypointMap(creat); sEAS.WaypointCreate(creat,-4036.163818f, -3383.940918f, 38.977619f, 2.181819f, 0, 56, 5375); sEAS.WaypointCreate(creat,-4037.754639f, -3376.272461f, 37.400284f, 0.002337f, 0, 56, 5375); sEAS.WaypointCreate(creat,-4028.081787f, -3376.667969f, 38.152534f, 5.775016f, 0, 56, 5375); sEAS.WaypointCreate(creat,-4018.655029f, -3382.780518f, 38.244286f, 5.688624f, 0, 56, 5375); sEAS.WaypointCreate(creat,-4018.655029f, -3382.780518f, 38.244286f, 5.688624f, 11000, 256, 5375); sEAS.WaypointCreate(creat,-4028.081787f, -3376.667969f, 38.152534f, 5.775016f, 0, 256, 5375); sEAS.WaypointCreate(creat,-4037.754639f, -3376.272461f, 37.400284f, 0.002337f, 0, 256, 5375); sEAS.WaypointCreate(creat,-4036.163818f, -3383.940918f, 38.977619f, 2.181819f, 0, 256, 5375); sEAS.WaypointCreate(creat,-4036.1638f, -3383.9409f, 38.9776f, -1.3662f, 0, 256, 5375); sEAS.WaypointCreate(creat,-4032.5759f, -3393.6271f, 38.9960f, 1.8883f, 0, 256, 5375); sEAS.EnableWaypoints(creat); }
void instance_stratholme::Update(uint32 uiDiff) { // Loop over the two Gate traps, each one has up to three timers (trap reset, gate opening delay, critters spawning delay) for (uint8 i = 0; i < 2; i++) { // Check that the trap is not on cooldown, if so check if player/pet is in range if (m_uiGateTrapTimers[i][0]) { m_uiGateTrapTimers[i][0] -= uiDiff; if (m_uiGateTrapTimers[i][0] <= uiDiff) { debug_log("SD2: Instance Stratholme - Rat Trap reseted %u.", i); m_uiGateTrapTimers[i][0] = 0; } } else { Map::PlayerList const& players = instance->GetPlayers(); for (const auto& player : players) { if (Player* pPlayer = player.getSource()) { if (!pPlayer->isGameMaster() && pPlayer->IsWithinDist2d(aGateTrap[i].m_fX, aGateTrap[i].m_fY, 5.5f)) DoGateTrap(i); Pet* pet = pPlayer->GetPet(); if (!pPlayer->isGameMaster() && pet && pet->IsWithinDist2d(aGateTrap[i].m_fX, aGateTrap[i].m_fY, 5.5f)) DoGateTrap(i); } } } // Timer to reopen the gates if (m_uiGateTrapTimers[i][1]) { if (m_uiGateTrapTimers[i][1] <= uiDiff) { DoUseDoorOrButton(aGates[2 * i]); DoUseDoorOrButton(aGates[2 * i + 1]); m_uiGateTrapTimers[i][1] = 0; } else m_uiGateTrapTimers[i][1] -= uiDiff; } // Delay timer to spawn the plagued critters once the gate are closing if (m_uiGateTrapTimers[i][2]) { if (m_uiGateTrapTimers[i][2] <= uiDiff) { if (Player* pPlayer = GetPlayerInMap()) DoSpawnPlaguedCritters(i, pPlayer); m_uiGateTrapTimers[i][2] = 0; } else m_uiGateTrapTimers[i][2] -= uiDiff; } } // Timer to send the Black Guard Sentries out of the Slaughterhouse before Baron Rivendare if (m_uiBlackGuardsTimer) { if (m_uiBlackGuardsTimer <= uiDiff) { // Open the Slaughterhouse door and set a timer to close it after 10 sec to let some time to the 5 Black Guards to move out DoOpenSlaughterhouseDoor(true); m_uiSlaughterDoorTimer = 10000; for (GuidList::const_iterator itr = m_luiGuardGUIDs.begin(); itr != m_luiGuardGUIDs.end(); ++itr) { Creature* pGuard = instance->GetCreature(*itr); if (pGuard && pGuard->isAlive() && !pGuard->isInCombat()) { float fX, fY, fZ; pGuard->GetRandomPoint(aStratholmeLocation[5].m_fX, aStratholmeLocation[5].m_fY, aStratholmeLocation[5].m_fZ, 10.0f, fX, fY, fZ); pGuard->GetMotionMaster()->MovePoint(0, fX, fY, fZ); } } m_uiBlackGuardsTimer = 0; } else m_uiBlackGuardsTimer -= uiDiff; } // Timer to close the gate of the Slaughterhouse before Baron Rivendare after Ramstein/Black Guards moved out if (m_uiSlaughterDoorTimer) { if (m_uiSlaughterDoorTimer <= uiDiff) { DoOpenSlaughterhouseDoor(false); m_uiSlaughterDoorTimer = 0; } else m_uiSlaughterDoorTimer -= uiDiff; } // Timer to teleport Barthilas if (m_uiBarthilasRunTimer) { if (m_uiBarthilasRunTimer <= uiDiff) { Creature* pBarthilas = GetSingleCreatureFromStorage(NPC_BARTHILAS); if (pBarthilas && pBarthilas->isAlive() && !pBarthilas->isInCombat()) pBarthilas->NearTeleportTo(aStratholmeLocation[1].m_fX, aStratholmeLocation[1].m_fY, aStratholmeLocation[1].m_fZ, aStratholmeLocation[1].m_fO); SetData(TYPE_BARTHILAS_RUN, DONE); m_uiBarthilasRunTimer = 0; } else m_uiBarthilasRunTimer -= uiDiff; } // Timer to summon Aurius into the Slaughter House once Baron is engaged if (m_uiAuriusSummonTimer) { if (m_uiAuriusSummonTimer <= uiDiff) { // Teleport Aurius from the Chapel and spawn it in the Slaughter House to engage Baron Creature* pAurius = GetSingleCreatureFromStorage(NPC_AURIUS); if (pAurius && pAurius->isAlive() && !pAurius->isInCombat()) { if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON)) { float fX, fY, fZ; pBaron->GetRandomPoint(pBaron->GetPositionX(), pBaron->GetPositionY(), pBaron->GetPositionZ(), 4.0f, fX, fY, fZ); pAurius->NearTeleportTo(fX, fY, fZ, pAurius->GetOrientation()); pAurius->SetRespawnCoord(fX, fY, fZ, pAurius->GetOrientation()); DoScriptText(SAY_AURIUS_AGGRO, pAurius); pAurius->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP); pAurius->AI()->AttackStart(pBaron); } } m_uiAuriusSummonTimer = 0; } else m_uiAuriusSummonTimer -= uiDiff; } // Check changes for Baron ultimatum timer only if Baron is not already in combat if (m_uiBaronRunTimer && GetData(TYPE_BARON) != IN_PROGRESS) { if (m_uiYellCounter == 0 && m_uiBaronRunTimer <= 10 * MINUTE * IN_MILLISECONDS) { DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_10_MIN, NPC_BARON); ++m_uiYellCounter; } else if (m_uiYellCounter == 1 && m_uiBaronRunTimer <= 5 * MINUTE * IN_MILLISECONDS) { DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_5_MIN, NPC_BARON); ++m_uiYellCounter; } // Used to create a delay of 10s between Baron speech and Ysida's answer else if (m_uiYellCounter == 2 && m_uiBaronRunTimer <= (5 * MINUTE - 10) * IN_MILLISECONDS) { DoOrSimulateScriptTextForThisInstance(SAY_YSIDA_RUN_5_MIN, NPC_YSIDA); ++m_uiYellCounter; } if (m_uiBaronRunTimer <= uiDiff) { if (GetData(TYPE_BARON_RUN) != FAIL) { SetData(TYPE_BARON_RUN, FAIL); // Open the cage and let Ysida face her doom if (Creature* pYsida = GetSingleCreatureFromStorage(NPC_YSIDA)) { pYsida->GetMotionMaster()->MovePoint(0, aStratholmeLocation[8].m_fX, aStratholmeLocation[8].m_fY, aStratholmeLocation[8].m_fZ); DoUseDoorOrButton(GO_YSIDA_CAGE); } DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_FAIL, NPC_BARON); m_uiBaronRunTimer = 8000; // We reset the timer so the speech of Ysida is not said at the same time than the Baron's one } else { // Baron ultimatum failed: let the Baron kill her if (Creature* pYsida = GetSingleCreatureFromStorage(NPC_YSIDA)) { if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON)) pBaron->CastSpell(pYsida, SPELL_BARON_SOUL_DRAIN, TRIGGERED_NONE); } DoOrSimulateScriptTextForThisInstance(SAY_YSIDA_RUN_FAIL, NPC_YSIDA); m_uiBaronRunTimer = 0; // event done for good, no more speech debug_log("SD2: Instance Stratholme: Baron run event reached end. Event has state %u.", GetData(TYPE_BARON_RUN)); } } else m_uiBaronRunTimer -= uiDiff; } if (m_uiMindlessSummonTimer) { if (m_uiMindlessCount < 30) { if (m_uiMindlessSummonTimer <= uiDiff) { if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON)) { // Summon mindless skeletons and move them to random point in the center of the square if (Creature* pTemp = pBaron->SummonCreature(NPC_MINDLESS_UNDEAD, aStratholmeLocation[4].m_fX, aStratholmeLocation[4].m_fY, aStratholmeLocation[4].m_fZ, aStratholmeLocation[4].m_fO, TEMPSPAWN_DEAD_DESPAWN, 0)) { float fX, fY, fZ; pBaron->GetRandomPoint(aStratholmeLocation[5].m_fX, aStratholmeLocation[5].m_fY, aStratholmeLocation[5].m_fZ, 20.0f, fX, fY, fZ); pTemp->SetWalk(false); pTemp->GetMotionMaster()->MovePoint(0, fX, fY, fZ); m_luiUndeadGUIDs.push_back(pTemp->GetObjectGuid()); ++m_uiMindlessCount; } } m_uiMindlessSummonTimer = 400; } else m_uiMindlessSummonTimer -= uiDiff; } else m_uiMindlessSummonTimer = 0; } if (m_uiSlaugtherSquareTimer) { if (m_uiSlaugtherSquareTimer <= uiDiff) { // Call next Abomnations for (auto itr : m_sAbomnationGUID) { Creature* pAbom = instance->GetCreature(itr); // Skip killed and already walking Abomnations if (!pAbom || !pAbom->isAlive() || pAbom->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) continue; // Let Move to somewhere in the middle if (!pAbom->isInCombat()) { if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_PORT_SLAUGTHER)) { float fX, fY, fZ; pAbom->GetRandomPoint(pDoor->GetPositionX(), pDoor->GetPositionY(), pDoor->GetPositionZ(), 10.0f, fX, fY, fZ); pAbom->GetMotionMaster()->MovePoint(0, fX, fY, fZ); } } break; } // TODO - how fast are they called? m_uiSlaugtherSquareTimer = urand(30000, 45000); } else m_uiSlaugtherSquareTimer -= uiDiff; } }
// gunship data Creature* Transport::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 anim) { Map* map = GetMap(); Creature* creature = new Creature; if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0)) { delete creature; return 0; } creature->SetTransport(this); creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); creature->m_movementInfo.guid = GetGUID(); creature->m_movementInfo.transport.pos.Relocate(x, y, z, o); creature->Relocate( GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ(), o + GetOrientation()); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); if (!creature->IsPositionValid()) { delete creature; return 0; } map->AddToMap(creature); m_NPCPassengerSet.insert(creature); creature->setActive(true); sScriptMgr->OnAddCreaturePassenger(this, creature); return creature; }
bool MagnetoCollector(uint32 i, Spell* pSpell) { Player *pPlayer = (Player*)pSpell->u_caster; if(!pPlayer) return true; if(!pSpell->u_caster->IsPlayer()) return true; QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10584); if(qle == NULL) return true; Creature *magneto = static_cast<Creature*>(pSpell->GetUnitTarget()); if(!magneto) return true; Creature *auramagneto = sEAS.SpawnCreature(pPlayer, 21731, magneto->GetPositionX(), magneto->GetPositionY(), magneto->GetPositionZ(), magneto->GetOrientation(), 0); magneto->Despawn(1, 0); auramagneto->Despawn(4*60*1000, 0); return true; }
Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data) { Map* map = GetMap(); Creature* creature = new Creature(); if (!creature->LoadCreatureFromDB(guid, map, false)) { delete creature; return NULL; } float x = data->posX; float y = data->posY; float z = data->posZ; float o = data->orientation; creature->SetTransport(this); creature->m_movementInfo.transport.guid = GetGUID(); creature->m_movementInfo.transport.pos.Relocate(x, y, z, o); CalculatePassengerPosition(x, y, z, &o); creature->Relocate(x, y, z, o); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos); /// @HACK - transport models are not added to map's dynamic LoS calculations /// because the current GameObjectModel cannot be moved without recreating creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING); if (!creature->IsPositionValid()) { TC_LOG_ERROR("entities.transport", "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY()); delete creature; return NULL; } if (!map->AddToMap(creature)) { delete creature; return NULL; } _staticPassengers.insert(creature); sScriptMgr->OnAddCreaturePassenger(this, creature); return creature; }
bool FuryoftheDreghoodElders(uint32 i, Spell * pSpell) { Player *pPlayer = (Player*)pSpell->u_caster; if(!pPlayer) return true; if(!pSpell->u_caster->IsPlayer()) return true; QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10369); if(qle == NULL) return true; Creature *arzethpower = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 19354); if(arzethpower == NULL) return true; Creature *arzethless = sEAS.SpawnCreature(pPlayer, 20680, arzethpower->GetPositionX(), arzethpower->GetPositionY(), arzethpower->GetPositionZ(), arzethpower->GetOrientation(), 0); arzethpower->Despawn(1, 6*60*1000); arzethless->Despawn(5*60*1000, 0); return true; }
Creature * Transport::AddNPCPassengerCreature(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim) { Map* map = GetMap(); Creature * pCreature = new Creature; if (!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0)) { delete pCreature; return NULL; } pCreature->SetTransport(this); pCreature->m_movementInfo.guid = GetGUID(); pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o); if (anim) pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim); pCreature->Relocate( GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ() , o + GetOrientation()); pCreature->SetHomePosition(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation()); if(!pCreature->IsPositionValid()) { sLog->outError(LOG_FILTER_TRANSPORTS, "Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", pCreature->GetGUIDLow(), pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY()); delete pCreature; return NULL; } map->AddToMap(pCreature); m_NPCPassengerSet.insert(pCreature); if (tguid == 0) { ++currenttguid; tguid = currenttguid; } else currenttguid = std::max(tguid, currenttguid); pCreature->SetGUIDTransport(tguid); sScriptMgr->OnAddCreaturePassenger(this, pCreature); return pCreature; }
void AIUpdate() { if(!scene && spells.size() > 0) { for(uint8 i = 0; i < spells.size(); i++) { if(spells[i]->time < getMSTime()) { if(Rand(spells[i]->chance)) { CastScriptSpell(spells[i]); spells[i]->time = getMSTime() + spells[i]->timer; } } } } else { //this is ugly, better ideas? scene = false; Creature* citizen = NULL; uint32 entry = 0; for(uint32 i = 0; i != _unit->GetMapMgr()->m_CreatureHighGuid; ++i) { if(_unit->GetMapMgr()->CreatureStorage[i] != NULL) { entry = _unit->GetMapMgr()->CreatureStorage[i]->GetEntry(); if(entry == 31126 || entry == 31127 || entry == 28167 || entry == 28169) { citizen = _unit->GetMapMgr()->CreatureStorage[i]; CreatureProto* cp = CreatureProtoStorage.LookupEntry(27737);//risen zombie CreatureInfo* ci = CreatureNameStorage.LookupEntry(27737); Creature* c = NULL; if(cp && ci) { c = _unit->GetMapMgr()->CreateCreature(27737); if(c) { //position is guessed c->Load(cp, citizen->GetPositionX(), citizen->GetPositionY(), citizen->GetPositionZ(), citizen->GetOrientation()); c->PushToWorld(_unit->GetMapMgr()); } } citizen->Despawn(0, 0); } } } } }
bool TemporalPhaseModulator(uint32 i, Spell* pSpell) { Player *pPlayer = (Player*)pSpell->u_caster; if(!pPlayer) return true; if(!pSpell->u_caster->IsPlayer()) return true; QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10609); if(qle == NULL) return true; srand ( (int)time(NULL) ); int random = static_cast<int>(rand()*4.33); srand ( random * 23 ); Creature *whelp = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 20021); if(whelp) { if(rand()%2 == 0) { Creature *adolescent = sEAS.SpawnCreature(pPlayer, 21817, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); adolescent->Despawn(5*60*1000, 0); } else { Creature *proto = sEAS.SpawnCreature(pPlayer, 21821, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); proto->Despawn(5*60*1000, 0); } whelp->Despawn(1, 0); return true; } whelp = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 21817); if(whelp) { if(rand()%10 < 8 ) { Creature *mature = sEAS.SpawnCreature(pPlayer, 21820, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); mature->Despawn(5*60*1000, 0); } else { Creature *funnyd = sEAS.SpawnCreature(pPlayer, 21823, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); funnyd->Despawn(5*60*1000, 0); } whelp->Despawn(1, 0); return true; } whelp = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 21821); if(whelp) { if(rand()%10 < 8 ) { Creature *mature = sEAS.SpawnCreature(pPlayer, 21820, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); mature->Despawn(5*60*1000, 0); } else { Creature *funnyd = sEAS.SpawnCreature(pPlayer, 21823, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); funnyd->Despawn(5*60*1000, 0); } whelp->Despawn(1, 0); return true; } whelp = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 21823); if(whelp) { if(rand()%2 == 0) { Creature *adolescent = sEAS.SpawnCreature(pPlayer, 21817, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); adolescent->Despawn(5*60*1000, 0); } else { Creature *proto = sEAS.SpawnCreature(pPlayer, 21821, whelp->GetPositionX(), whelp->GetPositionY(), whelp->GetPositionZ(), whelp->GetOrientation(), 0); proto->Despawn(5*60*1000, 0); } whelp->Despawn(1, 0); return true; } return true; }
bool TheFleshLies(uint32 i, Spell * pSpell) { if(!pSpell->u_caster->IsPlayer()) return true; Player *plr = (Player*)pSpell->u_caster; Creature *target = (Creature*)plr->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(plr->GetPositionX(), plr->GetPositionY() , plr->GetPositionZ(), 20561); if(target == NULL) return true; QuestLogEntry *qle = plr->GetQuestLogForEntry(10345); if(qle == NULL) return true; GameObject *obj = NULL; if(qle && qle->GetMobCount(0) < qle->GetQuest()->required_mobcount[0]) { qle->SetMobCount(0, qle->GetMobCount(0)+1); qle->SendUpdateAddKill(0); obj = EAS::SpawnGameobject(plr, 183816, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 1); EAS::GameobjectDelete(obj, 1*30*1000); } target->Despawn(2000, 60*1000); plr->UpdateNearbyGameObjects(); qle->UpdatePlayerFields(); return true; }
bool EffectDummy(Unit* /*pCaster*/, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Object* pTarget, ObjectGuid /*originalCasterGuid*/) override { Creature* pCreatureTarget = pTarget->ToCreature(); if (uiEffIndex != EFFECT_INDEX_0 || pCreatureTarget->GetEntry() != NPC_SUB_BOSS_TRIGGER) return true; ScriptedInstance* pInstance = (ScriptedInstance*)pCreatureTarget->GetInstanceData(); if (!pInstance) return true; if (Creature* pGoth = pInstance->GetSingleCreatureFromStorage(NPC_GOTHIK)) { uint32 uiNpcEntry = NPC_SPECT_TRAINEE; if (uiSpellId == SPELL_B_TO_SKULL) uiNpcEntry = NPC_SPECT_DEATH_KNIGHT; else if (uiSpellId == SPELL_C_TO_SKULL) uiNpcEntry = NPC_SPECT_RIDER; pGoth->SummonCreature(uiNpcEntry, pCreatureTarget->GetPositionX(), pCreatureTarget->GetPositionY(), pCreatureTarget->GetPositionZ(), pCreatureTarget->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); if (uiNpcEntry == NPC_SPECT_RIDER) pGoth->SummonCreature(NPC_SPECT_HORSE, pCreatureTarget->GetPositionX(), pCreatureTarget->GetPositionY(), pCreatureTarget->GetPositionZ(), pCreatureTarget->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); } return true; }
bool OrbOfMurlocControl(uint32 i, Spell* pSpell) { if(pSpell->u_caster->IsPlayer() == false) return true; Player *plr = (Player*)pSpell->u_caster; Unit *unit_target = (Unit*)plr->GetMapMgr()->GetCreature(GET_LOWGUID_PART(plr->GetSelection())); if(unit_target == NULL) return true; if(!unit_target->IsCreature()) return true; Creature *target = (Creature*)unit_target; QuestLogEntry *qle = plr->GetQuestLogForEntry(11541); if(qle == NULL) return true; if(target->GetEntry() == 25084) { if(qle->GetMobCount(0) < qle->GetQuest()->required_mobcount[0]) { uint32 newcount = qle->GetMobCount(0) + 1; qle->SetMobCount(0, newcount); qle->SendUpdateAddKill(0); Creature *FreedGreengill = sEAS.SpawnCreature(plr, 25085, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 0); FreedGreengill->Despawn(6*60*1000, 0); target->Despawn(0, 6*60*1000); qle->UpdatePlayerFields(); return true; } } return true; }
void UpdateAI(uint32 diff) { // Call speach if (timer) { timer += diff; if (timer >= 4000) { Talk(SAY_TENEBRON_RESPOND); me->SetCanFly(true); me->SetSpeed(MOVE_FLIGHT, 3.0f); me->GetMotionMaster()->MovePath(me->GetEntry()*10, false); timer = 0; } } if (!UpdateVictim()) return; events.Update(diff); if (me->HasUnitState(UNIT_STATE_CASTING)) return; switch (events.GetEvent()) { case EVENT_MINIBOSS_SHADOW_BREATH: if (!urand(0,10)) Talk(SAY_TENEBRON_BREATH); me->CastSpell(me->GetVictim(), SPELL_SHADOW_BREATH, false); events.RepeatEvent(17500); break; case EVENT_MINIBOSS_SHADOW_FISSURE: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) me->CastSpell(target, SPELL_SHADOW_FISSURE, false); events.RepeatEvent(22500); break; case EVENT_MINIBOSS_OPEN_PORTAL: Talk(WHISPER_OPEN_PORTAL); Talk(SAY_TENEBRON_SPECIAL); if (!isSartharion) { if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[BOSS_TENEBRON_EVENT].GetPositionX(), portalPos[BOSS_TENEBRON_EVENT].GetPositionY(), portalPos[BOSS_TENEBRON_EVENT].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0)) portalGUID = Portal->GetGUID(); } else if (pInstance) pInstance->SetData(DATA_ADD_PORTAL, 0); events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2000); events.RepeatEvent(60000); break; case EVENT_MINIBOSS_SPAWN_HELPERS: { Talk(WHISPER_HATCH_EGGS); Creature* cr = NULL; for (uint8 i = 0; i < 6; ++i) { if (cr = me->SummonCreature(NPC_TWILIGHT_EGG, EggsPos[isSartharion ? i+6 : i].GetPositionX(), EggsPos[isSartharion ? i+6 : i].GetPositionY(), EggsPos[isSartharion ? i+6 : i].GetPositionZ(), EggsPos[isSartharion ? i+6 : i].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000)) { summons.Summon(cr); cr->SetPhaseMask(16, true); } if (cr = me->SummonCreature(NPC_TWILIGHT_WHELP, EggsPos[isSartharion ? i+6 : i].GetPositionX(), EggsPos[isSartharion ? i+6 : i].GetPositionY(), EggsPos[isSartharion ? i+6 : i].GetPositionZ(), EggsPos[isSartharion ? i+6 : i].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000)) { summons.Summon(cr); cr->SetPhaseMask(16, true); } } events.ScheduleEvent(EVENT_MINIBOSS_HATCH_EGGS, 25000); events.PopEvent(); break; } case EVENT_MINIBOSS_HATCH_EGGS: { Creature* cr = NULL; summons.RemoveNotExisting(); summons.DespawnEntry(NPC_TWILIGHT_WHELP); for (SummonList::iterator i = summons.begin(); i != summons.end(); ++i) { if (cr = ObjectAccessor::GetCreature(*me, *i)) { if (!cr->IsAlive()) continue; if (cr->GetEntry() == NPC_TWILIGHT_EGG) if (cr = me->SummonCreature(NPC_TWILIGHT_WHELP, cr->GetPositionX(), cr->GetPositionY(), cr->GetPositionZ(), cr->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000)) summons2.Summon(cr); } } if (!isSartharion) { // Remove phase shift if (InstanceScript* instance = me->GetInstanceScript()) instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_SHIFT); RemoveTwilightPortal(); } else if (pInstance) pInstance->SetData(DATA_CLEAR_PORTAL, 0); EntryCheckPredicate pred(NPC_TWILIGHT_EGG); summons.DoAction(ACTION_SWITCH_PHASE, pred); events.PopEvent(); break; } } DoMeleeAttackIfReady(); }
uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim) { Map* map = GetMap(); CreatureInfo const *ci = sObjectMgr.GetCreatureTemplate(entry); if (!ci) return 0; Creature* pCreature = NULL; if(ci->ScriptID) pCreature = sScriptMgr.GetCreatureScriptedClass(ci->ScriptID); if(pCreature == NULL) pCreature = new Creature(); if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0)) { delete pCreature; return 0; } pCreature->SetTransport(this); pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); pCreature->m_movementInfo.guid = GetGUID(); pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o); if (anim) pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim); pCreature->Relocate( GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ() , o + GetOrientation()); pCreature->SetHomePosition(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation()); if(!pCreature->IsPositionValid()) { sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); delete pCreature; return 0; } map->Add(pCreature); m_NPCPassengerSet.insert(pCreature); if (tguid == 0) { ++currenttguid; tguid = currenttguid; } else currenttguid = std::max(tguid, currenttguid); pCreature->SetGUIDTransport(tguid); sScriptMgr.OnAddCreaturePassenger(this, pCreature); return tguid; }
Creature* Transport::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 anim) { Map* map = GetMap(); Creature* pCreature = new Creature; if(!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0)) { delete pCreature; return NULL; } pCreature->SetTransport(this); pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); pCreature->m_movementInfo.guid = GetGUID(); pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o); o += GetOrientation(); MapManager::NormalizeOrientation(o); pCreature->Relocate( GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ() , o); pCreature->SetHomePosition(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation()); if(!pCreature->IsPositionValid()) { sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", pCreature->GetGUIDLow(), pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY()); delete pCreature; return NULL; } map->Add(pCreature); m_NPCPassengerSet.insert(pCreature); pCreature->setActive(true); sScriptMgr->OnAddCreaturePassenger(this, pCreature); return pCreature; }
bool TestingTheAntidote(uint32 i, Spell* pSpell) { if(!pSpell->GetUnitTarget() || pSpell->GetUnitTarget()->GetTypeId() != TYPEID_UNIT) return true; Creature *target = NULL; target = static_cast<Creature*>(pSpell->GetUnitTarget()); if(!target || target->GetEntry() != 16880) // Hulking Helboar return true; Creature *spawned = NULL; spawned = target->GetMapMgr()->GetInterface()->SpawnCreature(16992, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), false, false, 0, 0); if(!spawned) return true; target->Despawn(0, 300000); spawned->GetAIInterface()->SetNextTarget(pSpell->u_caster); return true; }