KolumbPL

Untitled

May 7th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. enum tram {
  2.     EVENT_SPIN = 1,
  3.     EVENT_SPIN_2 = 2
  4. };
  5. class go_call_tram : public GameObjectScript
  6. {
  7. public:
  8.     go_call_tram() : GameObjectScript("go_call_tram") { }
  9.  
  10.     bool flag = false;
  11.     bool flag2 = false;
  12.     bool OnGossipHello(Player* /*player*/, GameObject* go) override
  13.     {
  14.         InstanceScript* instance = go->GetInstanceScript();
  15.  
  16.         if (!instance)
  17.             return false;
  18.  
  19.         switch (go->GetEntry())
  20.         {
  21.             case 194914: // call od mimi
  22.             case 194438: // start od mimi
  23.                 instance->SetData(DATA_CALL_TRAM, 0);
  24.                 flag = true;
  25.          
  26.                 break;
  27.             case 194912: // call do mimi
  28.             case 194437: // start do mimi
  29.                 instance->SetData(DATA_CALL_TRAM, 1);
  30.                 flag2 = true;                
  31.                 break;
  32.         }
  33.  
  34.         go->UseDoorOrButton();
  35.         return true;
  36.     }
  37.     struct go_call_tramAI : ScriptedAI
  38.     {
  39.         go_call_tramAI(Creature* creature) : ScriptedAI(creature){}
  40.         EventMap events;
  41.              
  42.         void UpdateAI(uint32 diff) override
  43.         {
  44.             if (flag == true)
  45.             {
  46.                 events.Reset();
  47.                 events.ScheduleEvent(EVENT_SPIN, 5000);
  48.             }
  49.             if (flag2 == true)
  50.             {
  51.                 events.Reset();
  52.                 events.ScheduleEvent(EVENT_SPIN_2, 5000);
  53.             }
  54.             events.Update(diff);
  55.  
  56.             switch (events.ExecuteEvent())
  57.             {
  58.             case EVENT_SPIN:
  59.                 flag = false;
  60.                 if (GameObject* turnaround = ObjectAccessor::GetGameObject(*go, instance->GetData64(GO_Doodad_UL_Train_Turnaround_01)))
  61.                     turnaround->SetGoState(GO_STATE_ACTIVE);
  62.                 break;
  63.             case EVENT_SPIN_2:
  64.                 flag2 = false;
  65.                 if (GameObject* turnaround = ObjectAccessor::GetGameObject(*go, instance->GetData64(GO_Doodad_UL_Train_Turnaround_02)))
  66.                     turnaround->SetGoState(GO_STATE_ACTIVE);
  67.                 break;
  68.  
  69.             }
  70.         }
  71.     }
  72. };
Add Comment
Please, Sign In to add comment