Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.29 KB | None | 0 0
  1. /*######
  2. ## npc_injured_rainspeaker_oracle
  3. ######*/
  4.  
  5. #define GOSSIP_ITEM1 "I am ready to travel to your village now."
  6.  
  7. enum eRainspeaker
  8. {
  9.     SAY_START_IRO                       = -1571000,
  10.     SAY_QUEST_ACCEPT_IRO                = -1571001,
  11.     SAY_END_IRO                         = -1571002,
  12.  
  13.     QUEST_FORTUNATE_MISUNDERSTANDINGS   = 12570,
  14.     FACTION_ESCORTEE_A                  = 774,
  15.     FACTION_ESCORTEE_H                  = 775
  16. };
  17.  
  18. class npc_injured_rainspeaker_oracle : public CreatureScript
  19. {
  20. public:
  21.     npc_injured_rainspeaker_oracle() : CreatureScript("npc_injured_rainspeaker_oracle") { }
  22.  
  23.     struct npc_injured_rainspeaker_oracleAI : public npc_escortAI
  24.     {
  25.         npc_injured_rainspeaker_oracleAI(Creature* c) : npc_escortAI(c) { c_guid = c->GetGUID(); }
  26.  
  27.         uint64 c_guid;
  28.  
  29.         void Reset()
  30.         {
  31.             me->RestoreFaction();
  32.             // if we will have other way to assign this to only one npc remove this part
  33.             if (GUID_LOPART(me->GetGUID()) != 101030)
  34.             {
  35.                 me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
  36.                 me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  37.             }
  38.         }
  39.  
  40.         void WaypointReached(uint32 i)
  41.         {
  42.             Player* pPlayer = GetPlayerForEscort();
  43.  
  44.             if (!pPlayer)
  45.                 return;
  46.  
  47.             switch(i)
  48.             {
  49.             case 1: SetRun(); break;
  50.             case 10:
  51.             case 11:
  52.             case 12:
  53.             case 13:
  54.             case 14:
  55.             case 15:
  56.             case 16:
  57.             case 17:
  58.             case 18:
  59.                 me->RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
  60.                 me->RemoveUnitMovementFlag(MOVEMENTFLAG_JUMPING);
  61.                 me->SetSpeed(MOVE_SWIM, 0.85f, true);
  62.                 me->AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_LEVITATING);
  63.                 break;
  64.             case 19:
  65.                 me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
  66.                 break;
  67.             case 28:
  68.                 if (Player* pPlayer = GetPlayerForEscort())
  69.                     pPlayer->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me);
  70.               //  me->RestoreFaction();
  71.                 DoScriptText(SAY_END_IRO,me);
  72.                 SetRun(false);
  73.                 break;
  74.             }
  75.         }
  76.  
  77.         void JustDied(Unit* /*killer*/)
  78.         {
  79.             if (!HasEscortState(STATE_ESCORT_ESCORTING))
  80.                 return;
  81.  
  82.             if (Player* pPlayer = GetPlayerForEscort())
  83.             {
  84.               if (pPlayer->GetQuestStatus(QUEST_FORTUNATE_MISUNDERSTANDINGS) != QUEST_STATUS_COMPLETE)
  85.                 pPlayer->FailQuest(QUEST_FORTUNATE_MISUNDERSTANDINGS);
  86.             }
  87.         }
  88.     };
  89.  
  90.     bool OnGossipHello(Player* pPlayer, Creature* pCreature)
  91.     {
  92.         if (pCreature->isQuestGiver())
  93.             pPlayer->PrepareQuestMenu(pCreature->GetGUID());
  94.  
  95.         if (pPlayer->GetQuestStatus(QUEST_FORTUNATE_MISUNDERSTANDINGS) == QUEST_STATUS_INCOMPLETE)
  96.             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  97.  
  98.         pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
  99.  
  100.         return true;
  101.     }
  102.  
  103.     bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
  104.     {
  105.         pPlayer->PlayerTalkClass->ClearMenus();
  106.         if (uiAction == GOSSIP_ACTION_INFO_DEF+1)
  107.         {
  108.             CAST_AI(npc_escortAI, (pCreature->AI()))->Start(true, false, pPlayer->GetGUID());
  109.             CAST_AI(npc_escortAI, (pCreature->AI()))->SetMaxPlayerDistance(35.0f);
  110.             pCreature->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
  111.             DoScriptText(SAY_START_IRO, pCreature);
  112.  
  113.             switch (pPlayer->GetTeam()){
  114.             case ALLIANCE:
  115.                 pCreature->setFaction(FACTION_ESCORTEE_A);
  116.                 break;
  117.             case HORDE:
  118.                 pCreature->setFaction(FACTION_ESCORTEE_H);
  119.                 break;
  120.             }
  121.         }
  122.         return true;
  123.     }
  124.  
  125.     bool OnQuestAccept(Player* /*pPlayer*/, Creature* pCreature, Quest const * /*_Quest*/)
  126.     {
  127.         DoScriptText(SAY_QUEST_ACCEPT_IRO, pCreature);
  128.         return false;
  129.     }
  130.  
  131.     CreatureAI *GetAI(Creature *creature) const
  132.     {
  133.         return new npc_injured_rainspeaker_oracleAI(creature);
  134.     }
  135. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement