Guest User

Untitled

a guest
Jul 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.24 KB | None | 0 0
  1. /*######
  2. ## npc_ranger_lilatha
  3. ######*/
  4.  
  5. #define SAY_START -1000140
  6. #define SAY_PROGRESS1 -1000141
  7. #define SAY_PROGRESS2 -1000142
  8. #define SAY_PROGRESS3 -1000143
  9. #define SAY_END1 -1000144
  10. #define SAY_END2 -1000145
  11. #define CAPTAIN_ANSWER -1000146
  12.  
  13. #define QUEST_CATACOMBS 9212
  14. #define GO_CAGE 181152
  15. #define NPC_CAPTAIN_HELIOS 16220
  16.  
  17. struct MANGOS_DLL_DECL npc_ranger_lilathaAI : public npc_escortAI
  18. {
  19. npc_ranger_lilathaAI(Creature *c) : npc_escortAI(c) {Reset();}
  20.  
  21. void SetCage(bool open)
  22. {
  23. GameObject* pGo = NULL;
  24.  
  25. CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
  26. Cell cell(pair);
  27. cell.data.Part.reserved = ALL_DISTRICT;
  28. cell.SetNoCreate();
  29.  
  30. MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*m_creature, GO_CAGE, 10);
  31. MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> searcher(pGo, go_check);
  32.  
  33. TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer> go_searcher(searcher);
  34.  
  35. CellLock<GridReadGuard> cell_lock(cell, pair);
  36. cell_lock->Visit(cell_lock, go_searcher,*(m_creature->GetMap()));
  37.  
  38. if (pGo)
  39. {
  40. if (open)
  41. pGo->SetGoState(0);
  42. else
  43. pGo->SetGoState(1);
  44. } else error_log("SD2: npc_ranger_lilatha: Cannot find Cage!");
  45. }
  46.  
  47. void CaptainAnswer()
  48. {
  49. Creature* pCreature = NULL;
  50.  
  51. CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
  52. Cell cell(pair);
  53. cell.data.Part.reserved = ALL_DISTRICT;
  54. cell.SetNoCreate();
  55.  
  56. MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, NPC_CAPTAIN_HELIOS, true, 30);
  57. MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pCreature, creature_check);
  58.  
  59. TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher);
  60.  
  61. CellLock<GridReadGuard> cell_lock(cell, pair);
  62. cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap()));
  63.  
  64. if (pCreature)
  65. DoScriptText(CAPTAIN_ANSWER, pCreature);
  66. else error_log("SD2: npc_ranger_lilatha: Captain Helios not found!");
  67. }
  68.  
  69. void WaypointReached(uint32 i)
  70. {
  71. Unit* player = Unit::GetUnit((*m_creature), PlayerGUID);
  72.  
  73. if (!player || player->GetTypeId() != TYPEID_PLAYER)
  74. return;
  75.  
  76. switch(i)
  77. {
  78. case 0:
  79. m_creature->SetStandState(PLAYER_STATE_NONE);
  80. SetCage(true);
  81. DoScriptText(SAY_START, m_creature, player);
  82. break;
  83. case 5:
  84. DoScriptText(SAY_PROGRESS1, m_creature, player);
  85. break;
  86. case 11:
  87. DoScriptText(SAY_PROGRESS2, m_creature, player);
  88. break;
  89. case 18:
  90. DoScriptText(SAY_PROGRESS3, m_creature, player);
  91. if (Creature* Summ1 = m_creature->SummonCreature(16342, 7627.083984, -7532.538086, 152.128616, 1.082733, TEMPSUMMON_DEAD_DESPAWN, 0))
  92. Summ1->AI()->AttackStart(m_creature);
  93. if (Creature* Summ2 = m_creature->SummonCreature(16343, 7620.432129, -7532.550293, 152.454865, 0.827478, TEMPSUMMON_DEAD_DESPAWN, 0))
  94. Summ2->AI()->AttackStart(player);
  95. break;
  96. case 19:
  97. m_creature->SetSpeed(MOVE_RUN, 1.5f);
  98. break;
  99. case 25:
  100. m_creature->SetSpeed(MOVE_WALK, 1.0f);
  101. break;
  102. case 30:
  103. ((Player*)player)->GroupEventHappens(QUEST_CATACOMBS,m_creature);
  104. break;
  105. case 32:
  106. DoScriptText(SAY_END1, m_creature, player);
  107. break;
  108. case 33:
  109. DoScriptText(SAY_END2, m_creature, player);
  110. CaptainAnswer();
  111. break;
  112. }
  113. }
  114.  
  115. void Reset()
  116. {
  117. if (!IsBeingEscorted)
  118. m_creature->setFaction(1602);
  119.  
  120. SetCage(false);
  121. }
  122.  
  123. void Aggro(Unit* who)
  124. {
  125. }
  126.  
  127. void JustDied(Unit* killer)
  128. {
  129. if (PlayerGUID)
  130. {
  131. if (Unit* player = Unit::GetUnit((*m_creature), PlayerGUID))
  132. ((Player*)player)->FailQuest(QUEST_CATACOMBS);
  133. }
  134. }
  135.  
  136. void UpdateAI(const uint32 diff)
  137. {
  138. npc_escortAI::UpdateAI(diff);
  139. }
  140. };
  141.  
  142. CreatureAI* GetAI_npc_ranger_lilathaAI(Creature *_Creature)
  143. {
  144. npc_ranger_lilathaAI* ranger_lilathaAI = new npc_ranger_lilathaAI(_Creature);
  145.  
  146. ranger_lilathaAI->AddWaypoint(0, 7545.07, -7359.87, 162.354, 4000);// Say0
  147. ranger_lilathaAI->AddWaypoint(1, 7550.048340, -7362.237793, 162.235657);
  148. ranger_lilathaAI->AddWaypoint(2, 7566.976074, -7364.315430, 161.738770);
  149. ranger_lilathaAI->AddWaypoint(3, 7578.830566, -7361.677734, 161.738770);
  150. ranger_lilathaAI->AddWaypoint(4, 7590.969238, -7359.053711, 162.257660);
  151. ranger_lilathaAI->AddWaypoint(5, 7598.354004, -7362.815430, 162.256683, 4000);// Say1
  152. ranger_lilathaAI->AddWaypoint(6, 7605.861328, -7380.424316, 161.937073);
  153. ranger_lilathaAI->AddWaypoint(7, 7605.295410, -7387.382813, 157.253998);
  154. ranger_lilathaAI->AddWaypoint(8, 7606.131836, -7393.893555, 156.941925);
  155. ranger_lilathaAI->AddWaypoint(9, 7615.207520, -7400.187012, 157.142639);
  156. ranger_lilathaAI->AddWaypoint(10, 7618.956543, -7402.652832, 158.202042);
  157. ranger_lilathaAI->AddWaypoint(11, 7636.850586, -7401.756836, 162.144791);
  158. ranger_lilathaAI->AddWaypoint(12, 7637.058105, -7404.944824, 162.206970, 4000);// Say2
  159. ranger_lilathaAI->AddWaypoint(13, 7636.910645, -7412.585449, 162.366425);
  160. ranger_lilathaAI->AddWaypoint(14, 7637.607910, -7425.591797, 162.630661);
  161. ranger_lilathaAI->AddWaypoint(15, 7637.816895, -7459.057129, 163.302704);
  162. ranger_lilathaAI->AddWaypoint(16, 7638.859863, -7470.902344, 162.517059);
  163. ranger_lilathaAI->AddWaypoint(17, 7641.395996, -7488.217285, 157.381287);
  164. ranger_lilathaAI->AddWaypoint(18, 7634.455566, -7505.451660, 154.682159);
  165. ranger_lilathaAI->AddWaypoint(19, 7631.906738, -7516.948730, 153.597382);// Say3
  166. ranger_lilathaAI->AddWaypoint(20, 7622.231445, -7537.037598, 151.587112);
  167. ranger_lilathaAI->AddWaypoint(21, 7610.921875, -7550.670410, 149.639374);
  168. ranger_lilathaAI->AddWaypoint(22, 7598.229004, -7562.551758, 145.953888);
  169. ranger_lilathaAI->AddWaypoint(23, 7588.509277, -7577.755371, 148.294479);
  170. ranger_lilathaAI->AddWaypoint(24, 7567.339355, -7608.456055, 146.006485);
  171. ranger_lilathaAI->AddWaypoint(25, 7562.547852, -7617.417969, 148.097504);
  172. ranger_lilathaAI->AddWaypoint(26, 7561.508789, -7645.064453, 151.245163);
  173. ranger_lilathaAI->AddWaypoint(27, 7563.337402, -7654.652344, 151.227158);
  174. ranger_lilathaAI->AddWaypoint(28, 7565.533691, -7658.296387, 151.248886);
  175. ranger_lilathaAI->AddWaypoint(29, 7571.155762, -7659.118652, 151.244568);
  176. ranger_lilathaAI->AddWaypoint(30, 7579.119629, -7662.213867, 151.651505);
  177. ranger_lilathaAI->AddWaypoint(31, 7603.768066, -7667.000488, 153.997726);
  178. ranger_lilathaAI->AddWaypoint(32, 7603.768066, -7667.000488, 153.997726, 4000);// Say4
  179. ranger_lilathaAI->AddWaypoint(33, 7603.768066, -7667.000488, 153.997726, 8000);// Say5
  180. ranger_lilathaAI->AddWaypoint(34, 7603.768066, -7667.000488, 153.997726);
  181.  
  182. return (CreatureAI*)ranger_lilathaAI;
  183. }
  184.  
  185. bool QuestAccept_npc_ranger_lilatha(Player* player, Creature* creature, Quest const* quest)
  186. {
  187. if (quest->GetQuestId() == QUEST_CATACOMBS)
  188. {
  189. creature->setFaction(1603);
  190. ((npc_escortAI*)(creature->AI()))->Start(true, true, false, player->GetGUID());
  191. }
  192. return true;
  193. }
  194.  
  195.  
  196. newscript = new Script;
  197. newscript->Name = "npc_ranger_lilatha";
  198. newscript->GetAI = &GetAI_npc_ranger_lilathaAI;
  199. newscript->pQuestAccept = &QuestAccept_npc_ranger_lilatha;
  200. newscript->RegisterSelf();
Add Comment
Please, Sign In to add comment