Advertisement
Rochet2

Untitled

May 10th, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptPCH.h"
  2.  
  3. #define MIN_INTERVAL 18000 // 30 minutes
  4. #define MAX_INTERVAL 72000 // 2 hours
  5. #define DESPAWN_TIMER_IN_MILISECONDS 60000 // 1 minutes
  6. #define NPC_WRATHION 190050 // Task Master
  7. #define SPELL_TELEPORT 33056 // Visual
  8.  
  9. class custom_world_event : public WorldScript
  10. {
  11. public:
  12.     uint32 Event_Timer;
  13.  
  14.     custom_world_event() : WorldScript("custom_world_event")
  15.     {
  16.         Event_Timer = 0;
  17.     }
  18.  
  19.     void OnStartup()
  20.     {
  21.         Event_Timer = urand(MIN_INTERVAL, MAX_INTERVAL);
  22.     }
  23.  
  24.     void OnUpdate(const uint32 diff)
  25.     {
  26.         if (Event_Timer <= diff)
  27.         {
  28.             SessionMap const& sessions = sWorld->GetAllSessions();
  29.             if (sessions.empty())
  30.                 return;
  31.  
  32.             for (SessionMap::const_iterator itr = sessions.find(urand(0, sessions.size()-1)); itr != sessions.end(); ++itr)
  33.             {
  34.                 if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
  35.                     continue;
  36.  
  37.                 Player* player = itr->second->GetPlayer();
  38.                 Map* playerMap = player->GetMap();
  39.  
  40.                 if (!player->isDead() && !player->isInCombat() && !player->GetMotionMaster()->GetMotionSlotType(FLIGHT_MOTION_TYPE) && !playerMap->IsBattlegroundOrArena() && !playerMap->IsRaidOrHeroicDungeon() && !player->isAFK() && !player->isGameMaster())
  41.                 {
  42.                     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))
  43.                     {
  44.                         wrathion->CastSpell(wrathion, SPELL_TELEPORT, true);
  45.                         wrathion->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
  46.                         std::ostringstream ss;
  47.                         ss << "Greetings " << player->GetName() << " could you assist me for a moment please?";
  48.                         wrathion->MonsterSay(ss.str().c_str(), LANG_UNIVERSAL, player->GetGUID());
  49.                     }
  50.                     Event_Timer = urand(MIN_INTERVAL, MAX_INTERVAL);
  51.                 }
  52.                 else
  53.                     Event_Timer = 60000;
  54.                 break; // stop looping
  55.             }
  56.         }
  57.         else
  58.             Event_Timer -= diff;
  59.     }
  60. };
  61.  
  62. void AddSC_custom_world_event()
  63. {
  64.     new custom_world_event;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement