// Emote Ardonis and Pathaleon void Turn_to_Pathaleons_Image() { Creature* ardonis = Unit::GetCreature(*me, ardonisGUID); Creature* pathaleon = Unit::GetCreature(*me, pathaleonGUID); Player* player = Unit::GetPlayer(*me, PlayerGUID); if (!ardonis || !pathaleon || !player) return; //Calculate the angle to Pathaleon angle_dawnforge = me->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY()); angle_ardonis = ardonis->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY()); //Turn Dawnforge and update me->SetOrientation(angle_dawnforge); me->SendUpdateToPlayer(player); //Turn Ardonis and update ardonis->SetOrientation(angle_ardonis); ardonis->SendUpdateToPlayer(player); //Set them to kneel me->SetStandState(UNIT_STAND_STATE_KNEEL); ardonis->SetStandState(UNIT_STAND_STATE_KNEEL); }
void UpdateAI(const uint32 diff) { if (MoveTimer <= diff) { if (me->GetVehicleKit()->HasEmptySeat(-1)) { Creature* pContainer = me->FindNearestCreature(MOB_CONTAINER, 50, true); if (pContainer && !pContainer->GetVehicle()) me->GetMotionMaster()->MovePoint(1,pContainer->GetPositionX(),pContainer->GetPositionY(),pContainer->GetPositionZ()); } MoveTimer = 30000; //check next 30 seconds } else MoveTimer-=diff; }
void UpdateAI(uint32 diff) { if (pTarget == NULL || !isAtAnEgg || me->HasUnitState(UNIT_STATE_CASTING)) return; events.Update(diff); while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_CAST_SHIELD_OF_NIGHTMARE_DELAY: DoCast(me, SPELL_SHIELD_OF_NIGHTMARE, true); break; default: break; } } if (isCastingUmbraMending) { // If the Egg is Death and Umbra Mending was casted go to the next Egg pTarget = GetNextEgg(); if (pTarget != NULL) // Solves Crashes if the Faceless killed all eggs me->GetMotionMaster()->MovePoint(POINT_FACELESS_IS_AT_AN_EGG, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ()); isAtAnEgg = false; isCastingUmbraMending = false; return; } if (pTarget->isDead()) { if (Unit* pErudax = me->FindNearestCreature(BOSS_ERUDAX, 1000.0f, true)) DoCast(pErudax, SPELL_UMBRAL_MENDING, false); isCastingUmbraMending = true; return; } pTarget->AI()->DoZoneInCombat(); DoCast(pTarget, SPELL_TWILIGHT_CORRUPTION_DOT, true); DoCast(pTarget, SPELL_TWILIGHT_CORRUPTION_VISUAL, true); }
void ConfusedMovementGenerator::Initialize(Creature &creature) { const float wander_distance=11; float x,y,z,z2; x = creature.GetPositionX(); y = creature.GetPositionY(); z = creature.GetPositionZ(); uint32 mapid=creature.GetMapId(); Map* map = MapManager::Instance().GetMap(mapid); z2 = map->GetHeight(x,y); if( abs( z2 - z ) < 5 ) z = z2; i_nextMove = 1; bool is_water_ok = creature.isCanSwimOrFly(); bool is_land_ok = creature.isCanWalkOrFly(); for(unsigned int idx=0; idx < MAX_CONF_WAYPOINTS+1; ++idx) { const float wanderX=((wander_distance*rand())/RAND_MAX)-wander_distance/2; const float wanderY=((wander_distance*rand())/RAND_MAX)-wander_distance/2; i_waypoints[idx][0] = x + wanderX; i_waypoints[idx][1] = y + wanderY; // prevent invalid coordinates generation MaNGOS::NormalizeMapCoord(i_waypoints[idx][0]); MaNGOS::NormalizeMapCoord(i_waypoints[idx][1]); bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1]); // if generated wrong path just ignore if( is_water && !is_water_ok || !is_water && !is_land_ok ) { i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x; i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y; } z2 = map->GetHeight(i_waypoints[idx][0],i_waypoints[idx][1]); if( abs( z2 - z ) < 5 ) z = z2; i_waypoints[idx][2] = z; } creature.StopMoving(); }
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; }
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; }
void IsSummonedBy(Unit* summoner) { pTarget = GetRandomEgg(); DoZoneInCombat(); if(me->GetMap()->IsHeroic()) events.ScheduleEvent(EVENT_CAST_SHIELD_OF_NIGHTMARE_DELAY, 3000); if(pTarget != NULL) { me->GetMotionMaster()->MovePoint(POINT_FACELESS_IS_AT_AN_EGG,pTarget->GetPositionX()-4.0f,pTarget->GetPositionY()-4.0f,pTarget->GetPositionZ()); } me->SetReactState(REACT_PASSIVE); // That the Faceless are not running to Players while running to Eggs }
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); /// @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(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; }
static bool HandleNpcInfoCommand(ChatHandler* handler, const char* /*args*/) { Creature* target = handler->getSelectedCreature(); if (!target) { handler->SendSysMessage(LANG_SELECT_CREATURE); handler->SetSentErrorMessage(true); return false; } uint32 faction = target->getFaction(); uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); uint32 displayid = target->GetDisplayId(); uint32 nativeid = target->GetNativeDisplayId(); uint32 Entry = target->GetEntry(); CreatureInfo const* cInfo = target->GetCreatureInfo(); int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); if (curRespawnDelay < 0) curRespawnDelay = 0; std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay),true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); handler->PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, target->GetPhaseMask()); handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor()); handler->PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); if ((npcflags & UNIT_NPC_FLAG_VENDOR)) { handler->SendSysMessage(LANG_NPCINFO_VENDOR); } if ((npcflags & UNIT_NPC_FLAG_TRAINER)) { handler->SendSysMessage(LANG_NPCINFO_TRAINER); } return true; }
void HandleScriptEffect(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); Creature* target = GetHitCreature(); if (!target || caster == target) return; target->CastSpell(target->GetPositionX()+irand(-10, 10), target->GetPositionY()+irand(-10, 10), target->GetPositionZ() , SPELL_RACER_DEATH_VISUAL, true); target->DespawnOrUnsummon(3000); target->CastSpell(target, SPELL_RACER_FLAMES, true); caster->CastSpell(caster, SPELL_RACER_KILL_COUNTER, true); if (Player* targetSummoner = target->GetCharmerOrOwnerPlayerOrPlayerItself()) { //targetSummoner->RemoveCriteriaProgress(sAchievementCriteriaStore.LookupEntry(RACER_ACHI_CRITERIA)); !ZOMG, ADD ACCESSOR targetSummoner->RemoveAurasDueToSpell(SPELL_RACER_KILL_COUNTER); } }
void RandomCircleMovementGenerator<Creature>::Initialize(Creature &creature) { if (!creature.isAlive()) return; if (creature.canFly() && !(creature.canWalk() && creature.IsAtGroundLevel(creature.GetPositionX(), creature.GetPositionY(), creature.GetPositionZ()))) creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); else creature.AddSplineFlag(SPLINEFLAG_WALKMODE); creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); m_bClockWise = urand(0, 1) ? true : false; i_wpId = 0; fillSplineWayPoints(creature); SplineFlags flags = SplineFlags(SPLINEFLAG_FORWARD | SPLINEFLAG_UNKNOWN7 | SPLINEFLAG_FLYING | creature.GetSplineFlags()); creature.SendSplineMove(&m_splineMap, SPLINETYPE_NORMAL, flags, 500, NULL); }
static bool HandleNpcAddFormationCommand(ChatHandler* handler, const char* args) { if (!*args) return false; uint32 leaderGUID = (uint32) atoi((char*)args); Creature *pCreature = handler->getSelectedCreature(); if (!pCreature || !pCreature->GetDBTableGUIDLow()) { handler->SendSysMessage(LANG_SELECT_CREATURE); handler->SetSentErrorMessage(true); return false; } uint32 lowguid = pCreature->GetDBTableGUIDLow(); if (pCreature->GetFormation()) { handler->PSendSysMessage("Selected creature is already member of group %u", pCreature->GetFormation()->GetId()); return false; } if (!lowguid) return false; Player *chr = handler->GetSession()->GetPlayer(); FormationInfo *group_member; group_member = new FormationInfo; group_member->follow_angle = (pCreature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI; group_member->follow_dist = sqrtf(pow(chr->GetPositionX() - pCreature->GetPositionX(),int(2))+pow(chr->GetPositionY()-pCreature->GetPositionY(),int(2))); group_member->leaderGUID = leaderGUID; group_member->groupAI = 0; CreatureGroupMap[lowguid] = group_member; pCreature->SearchFormation(); WorldDatabase.PExecute("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u','%u','%f', '%f', '%u')", leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI); handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID); return true; }
void OnActivate(Player* pPlayer) { if(!pPlayer) return; QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(9582); if(qle == NULL) return; // What is this ? :O To remove ? Creature* reaver = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 17556); if(reaver) { Creature* reaver2 = pPlayer->GetMapMgr()->GetInterface()->SpawnCreature(17556, reaver->GetPositionX(), reaver->GetPositionY(), reaver->GetPositionZ(), reaver->GetOrientation(), true, false, 0, 0); reaver2->Despawn(5*60*1000, 0); reaver->Despawn(1, 5*60*1000); } }
void DoAction(const int32 actionId) { switch(actionId) { case ACTION_OUTRO: { Position pos; if (Creature* pIck = GetIck()) { // TODO: tele on Ick then run some distance. pIck->GetNearPosition(pos, 5.0f, 3.14f); me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), 0.0f); } me->SetVisibility(VISIBILITY_ON); Creature* pJainaOrSylvanas = me->GetCreature(*me, pInstance->GetData64(DATA_JAINA_SYLVANAS_1)); if (pJainaOrSylvanas) { Position pos; me->GetNearPosition(pos, 5.0f, 0); pJainaOrSylvanas->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetAngle(me->GetPositionX(), me->GetPositionY())); } else { if (pInstance->GetData(DATA_TEAM_IN_INSTANCE) == TEAM_ALLIANCE) pJainaOrSylvanas = me->SummonCreature(NPC_SYLVANAS_PART1, *me, TEMPSUMMON_MANUAL_DESPAWN); else pJainaOrSylvanas = me->SummonCreature(NPC_JAINA_PART1, *me, TEMPSUMMON_MANUAL_DESPAWN); } if (pJainaOrSylvanas) { pJainaOrSylvanas->SetOrientation(pJainaOrSylvanas->GetAngle(me->GetPositionX(), me->GetPositionY())); me->SetOrientation(me->GetAngle(pJainaOrSylvanas->GetPositionX(), pJainaOrSylvanas->GetPositionY())); uiNpcOutroDialog = pJainaOrSylvanas->GetGUID(); } phase = PHASE_OUTRO; events.Reset(); events.ScheduleEvent(EVENT_OUTRO_1, 1000); break; } } }
Creature* 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); o += GetOrientation(); MapManager::NormalizeOrientation(o); creature->Relocate( GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ(), o); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); creature->SetTransportHomePosition(creature->m_movementInfo.t_pos); if (!creature->IsPositionValid()) { sLog->outError("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); creature->setActive(true); 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; }
bool OrbOfMurlocControl(uint32 i, Spell* pSpell) { if(pSpell->m_caster->IsPlayer() == false) return true; Player* plr = TO_PLAYER(pSpell->u_caster); QuestLogEntry *pQuest = plr->GetQuestLogForEntry(11541); if(pQuest == NULL) return true; Unit* mTarget; Creature* cTarget; for(ObjectSet::iterator itr = pSpell->m_caster->GetInRangeSetBegin(); itr != pSpell->m_caster->GetInRangeSetEnd(); itr++) { if((*itr)->IsUnit()) mTarget = TO_UNIT(*itr); else continue; if(pSpell->m_caster->CalcDistance(mTarget) > 5 ) continue; cTarget = TO_CREATURE(mTarget); if(cTarget->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(plr, 25085, cTarget->GetPositionX(), cTarget->GetPositionY(), cTarget->GetPositionZ(), cTarget->GetOrientation(), 0); FreedGreengill->Despawn(6*60*1000, 0); cTarget->Despawn(0, 6*60*1000); pQuest->UpdatePlayerFields(); return true; } } } return true; }
bool OnDummyApply(const Aura* pAura, bool bApply) { if (pAura->GetId() == SPELL_REINFORCED_NET && pAura->GetEffIndex() == EFFECT_INDEX_0 && bApply) { Creature* pCreature = (Creature*)pAura->GetTarget(); Unit* pCaster = pAura->GetCaster(); if (!pCreature || !pCaster || pCaster->GetTypeId() != TYPEID_PLAYER || pCreature->GetEntry() != NPC_FLAMESPITTER) return false; // move the flamespitter to the ground level pCreature->GetMotionMaster()->Clear(); pCreature->SetWalk(false); float fGroundZ = pCreature->GetMap()->GetHeight(pCreature->GetPhaseMask(), pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ()); pCreature->GetMotionMaster()->MovePoint(1, pCreature->GetPositionX(), pCreature->GetPositionY(), fGroundZ); return true; } return false; }
void WorldSession::SendTaxiStatus(uint64 guid) { // cheating checks Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::SendTaxiStatus - Unit (GUID: %u) not found.", uint32(GUID_LOPART(guid))); return; } uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); if (curloc == 0) // Nearest location not found. return; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: current location %u ", curloc); ObjectGuid npcGuid = guid; WorldPacket data(SMSG_TAXI_NODE_STATUS, 9); data.WriteBit(npcGuid[0]); data.WriteBit(npcGuid[7]); data.WriteBits(GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? 1 : 0, 2); data.WriteBit(npcGuid[2]); data.WriteBit(npcGuid[3]); data.WriteBit(npcGuid[6]); data.WriteBit(npcGuid[5]); data.WriteBit(npcGuid[4]); data.WriteBit(npcGuid[1]); data.FlushBits(); uint8 bytesOrder[8] = { 3, 2, 6, 4, 7, 1, 0, 5 }; data.WriteBytesSeq(npcGuid, bytesOrder); SendPacket(&data); sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_TAXI_NODE_STATUS"); }
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; }
void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; //immolateTimer if (immolateTimer <= diff) { if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0)) DoCast(pTarget, SPELL_IMMOLATE); immolateTimer = urand(5000, 10000); } else immolateTimer -= diff; //seperationCheckTimer if (seperationCheckTimer <= diff) { if (instance) return; Creature* Garr = Creature::GetCreature(*me, instance->GetData64(DATA_GARR)); if (Garr && Garr->IsAlive() && !me->IsWithinDist2d(Garr->GetPositionX(), Garr->GetPositionY(), 50.0f)) DoCast(me, SPELL_SEPARATION_ANXIETY, true); seperationCheckTimer = 5000; } else seperationCheckTimer -= diff; //Cast Erruption and let them die if (me->GetHealthPct() <= 10.0f) { DoCastVictim(SPELL_ERUPTION); me->setDeathState(JUST_DIED); me->RemoveCorpse(); } DoMeleeAttackIfReady(); }
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session) { uint64 guid = m_session->GetPlayer()->GetSelection(); if (guid == 0) { SystemMessage(m_session, "No selection."); return true; } Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(guid); if(!unit) { SystemMessage(m_session, "You should select a creature."); return true; } sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f", unit->GetSQL_id(), unit->GetCreatureName()->Name, unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()); if(unit->m_spawn == 0) return false; BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid); if(unit->IsInWorld()) { if(unit->m_spawn) { uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize)); unit->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly)->CreatureSpawns.erase(unit->m_spawn); } unit->RemoveFromWorld(false); } unit->DeleteFromDB(); delete unit; return true; }
Creature* Transport::CreateNPCPassenger(uint32 entry, float x, float y, float z, float o, CreatureData const* data /*= NULL*/) { Map* map = GetMap(); Creature* creature = new Creature(); if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0.0f, 0.0f, 0.0f, 0.0f, data)) { delete creature; return NULL; } creature->SetTransport(this); creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); creature->m_movementInfo.guid = GetGUID(); creature->m_movementInfo.t_pos.Relocate(x, y, z, o); o += GetOrientation(); MapManager::NormalizeOrientation(o); creature->Relocate(GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ(), o); creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); if (!creature->IsPositionValid()) { sLog->outError("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 NULL; } creature->setActive(true); map->Add(creature); AddPassenger(creature); 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; }
// 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; }
void Transform() { if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid)) { Creature* pPreciousDevourer = NULL; Creature* pDemon = m_creature->SummonCreature(NPC_SIMONE_THE_SEDUCTRESS, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetAngle(m_creature), TEMPSUMMON_DEAD_DESPAWN, 0); Creature* pPrecious = GetClosestCreatureWithEntry(m_creature, NPC_PRECIOUS, 100.0f); if (pDemon) { if (npc_simone_seductressAI * pSimone = dynamic_cast<npc_simone_seductressAI*> (pDemon->AI())) pSimone->m_simoneGuid = m_creature->GetObjectGuid(); m_creature->SetVisibility(VISIBILITY_OFF); m_creature->ForcedDespawn(); } if (pDemon && pPrecious) { pPreciousDevourer = m_creature->SummonCreature(NPC_PRECIOUS_THE_DEVOURER, pPrecious->GetPositionX(), pPrecious->GetPositionY(), pPrecious->GetPositionZ(), pPrecious->GetAngle(pPrecious), TEMPSUMMON_DEAD_DESPAWN, 0, true); if (pPreciousDevourer) { if (npc_simone_seductressAI * pSimone = dynamic_cast<npc_simone_seductressAI*> (pDemon->AI())) pSimone->m_preciousGuid = pPreciousDevourer->GetObjectGuid(); if (npc_precious_the_devourerAI * pDevourer = dynamic_cast<npc_precious_the_devourerAI*> (pPreciousDevourer->AI())) pDevourer->m_simoneGuid = pDemon->GetObjectGuid(); } pPrecious->SetVisibility(VISIBILITY_OFF); pPrecious->ForcedDespawn(); } } }
void WorldSession::SendTaxiStatus(uint64 guid) { // cheating checks Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) { sLog.outDebug("WorldSession::SendTaxiStatus - Unit (GUID: %u) not found.", uint32(GUID_LOPART(guid))); return; } uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId()); // not found nearest if (curloc == 0) return; DEBUG_LOG("WORLD: current location %u ",curloc); WorldPacket data(SMSG_TAXINODE_STATUS, 9); data << guid; data << uint8(GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? 1 : 0); SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_TAXINODE_STATUS"); }
void WorldSession::HandleActivateTaxiOpcode(WorldPackets::Taxi::ActivateTaxi& activateTaxi) { Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(activateTaxi.Vendor, UNIT_NPC_FLAG_FLIGHTMASTER); if (!unit) { TC_LOG_DEBUG("network", "WORLD: HandleActivateTaxiOpcode - %s not found or you can't interact with it.", activateTaxi.Vendor.ToString().c_str()); return; } uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); if (!curloc) return; TaxiNodesEntry const* from = sTaxiNodesStore.LookupEntry(curloc); TaxiNodesEntry const* to = sTaxiNodesStore.LookupEntry(activateTaxi.Node); if (!to) return; if (!GetPlayer()->isTaxiCheater()) { if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) || !GetPlayer()->m_taxi.IsTaximaskNodeKnown(activateTaxi.Node)) { SendActivateTaxiReply(ERR_TAXINOTVISITED); return; } } uint32 preferredMountDisplay = 0; if (MountEntry const* mount = sMountStore.LookupEntry(activateTaxi.FlyingMountID)) if (GetPlayer()->HasSpell(mount->SpellId)) preferredMountDisplay = mount->DisplayId; std::vector<uint32> nodes; sTaxiPathGraph.GetCompleteNodeRoute(from, to, GetPlayer(), nodes); GetPlayer()->ActivateTaxiPathTo(nodes, unit, 0, preferredMountDisplay); }
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 WorldSession::SendTaxiStatus(ObjectGuid guid) { // cheating checks Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) { TC_LOG_DEBUG("network", "WorldSession::SendTaxiStatus - %s not found.", guid.ToString().c_str()); return; } uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); WorldPackets::Taxi::TaxiNodeStatus data; data.Unit = guid; if (!curloc) data.Status = TAXISTATUS_NONE; else if (unit->GetReactionTo(GetPlayer()) >= REP_NEUTRAL) data.Status = GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? TAXISTATUS_LEARNED : TAXISTATUS_UNLEARNED; else data.Status = TAXISTATUS_NOT_ELIGIBLE; SendPacket(data.Write()); }