Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- #define MIN_INTERVAL 18000 // 30 minutes
- #define MAX_INTERVAL 72000 // 2 hours
- #define DESPAWN_TIMER_IN_MILISECONDS 60000 // 1 minutes
- #define NPC_WRATHION 190050 // Task Master
- #define SPELL_TELEPORT 33056 // Visual
- class custom_world_event : public WorldScript
- {
- public:
- uint32 Event_Timer;
- custom_world_event() : WorldScript("custom_world_event")
- {
- Event_Timer = 0;
- }
- void OnStartup()
- {
- Event_Timer = urand(MIN_INTERVAL, MAX_INTERVAL);
- }
- void OnUpdate(const uint32 diff)
- {
- if (Event_Timer <= diff)
- {
- SessionMap const& sessions = sWorld->GetAllSessions();
- if (sessions.empty())
- return;
- for (SessionMap::const_iterator itr = sessions.find(urand(0, sessions.size()-1)); itr != sessions.end(); ++itr)
- {
- if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
- continue;
- Player* player = itr->second->GetPlayer();
- Map* playerMap = player->GetMap();
- if (!player->isDead() && !player->isInCombat() && !player->GetMotionMaster()->GetMotionSlotType(FLIGHT_MOTION_TYPE) && !playerMap->IsBattlegroundOrArena() && !playerMap->IsRaidOrHeroicDungeon() && !player->isAFK() && !player->isGameMaster())
- {
- if(Creature* wrathion = player->SummonCreature(NPC_WRATHION, player->GetPositionX(), player->GetPositionY()+5.0f, player->GetPositionZ()+1.0f, player->GetOrientation()+M_PI, TEMPSUMMON_TIMED_DESPAWN, DESPAWN_TIMER_IN_MILISECONDS))
- {
- wrathion->CastSpell(wrathion, SPELL_TELEPORT, true);
- wrathion->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
- std::ostringstream ss;
- ss << "Greetings " << player->GetName() << " could you assist me for a moment please?";
- wrathion->MonsterSay(ss.str().c_str(), LANG_UNIVERSAL, player->GetGUID());
- }
- Event_Timer = urand(MIN_INTERVAL, MAX_INTERVAL);
- }
- else
- Event_Timer = 60000;
- break; // stop looping
- }
- }
- else
- Event_Timer -= diff;
- }
- };
- void AddSC_custom_world_event()
- {
- new custom_world_event;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement