Advertisement
Guest User

Untitled

a guest
Sep 4th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.81 KB | None | 0 0
  1. /*######
  2. ## npc_ogron
  3. ######*/
  4.  
  5. enum
  6. {
  7. SAY_OGR_START = 0,
  8. SAY_OGR_SPOT = 1,
  9. SAY_OGR_RET_WHAT = 2,
  10. SAY_OGR_RET_SWEAR = 3,
  11. SAY_OGR_REPLY_RET = 4,
  12. SAY_OGR_RET_TAKEN = 5,
  13. SAY_OGR_TELL_FIRE = 6,
  14. SAY_OGR_RET_NOCLOSER = 7,
  15. SAY_OGR_RET_NOFIRE = 8,
  16. SAY_OGR_RET_HEAR = 9,
  17. SAY_OGR_CAL_FOUND = 10,
  18. SAY_OGR_CAL_MERCY = 11,
  19. SAY_OGR_HALL_GLAD = 12,
  20. EMOTE_OGR_RET_ARROW = 13,
  21. SAY_OGR_RET_ARROW = 14,
  22. SAY_OGR_CAL_CLEANUP = 15,
  23. SAY_OGR_NODIE = 16,
  24. SAY_OGR_SURVIVE = 17,
  25. SAY_OGR_RET_LUCKY = 18,
  26. SAY_OGR_THANKS = 19,
  27.  
  28. QUEST_QUESTIONING = 1273,
  29.  
  30. FACTION_GENERIC_FRIENDLY = 35,
  31. FACTION_THER_HOSTILE = 151,
  32.  
  33. NPC_REETHE = 4980,
  34. NPC_CALDWELL = 5046,
  35. NPC_HALLAN = 5045,
  36. NPC_SKIRMISHER = 5044,
  37.  
  38. SPELL_FAKE_SHOT = 7105,
  39.  
  40. PHASE_INTRO = 0,
  41. PHASE_GUESTS = 1,
  42. PHASE_FIGHT = 2,
  43. PHASE_COMPLETE = 3
  44. };
  45.  
  46. static float afSpawn[] = { -3383.501953f, -3203.383301f, 36.149f};
  47. static float afMoveTo[] = { -3371.414795f, -3212.179932f, 34.210f};
  48.  
  49. class npc_ogron : public CreatureScript
  50. {
  51. public:
  52. npc_ogron() : CreatureScript("npc_ogron") { }
  53.  
  54. struct npc_ogronAI : public npc_escortAI
  55. {
  56. npc_ogronAI(Creature* creature) : npc_escortAI(creature)
  57. {
  58. lCreatureList.clear();
  59. Reset();
  60. m_uiPhase = 0;
  61. m_uiPhaseCounter = 0;
  62. }
  63.  
  64. std::list<Creature*> lCreatureList;
  65.  
  66. uint32 m_uiPhase;
  67. uint32 m_uiPhaseCounter;
  68. uint32 m_uiGlobalTimer;
  69.  
  70. void Reset()
  71. {
  72. m_uiGlobalTimer = 5*IN_MILLISECONDS;
  73.  
  74.  
  75. if (!HasEscortState(STATE_ESCORT_ESCORTING))
  76. {
  77. lCreatureList.clear();
  78. m_uiPhase = 0;
  79. m_uiPhaseCounter = 0;
  80. }
  81. }
  82.  
  83. void MoveInLineOfSight(Unit* who)
  84. {
  85. if (HasEscortState(STATE_ESCORT_ESCORTING) && who->GetEntry() == NPC_REETHE && lCreatureList.empty())
  86. lCreatureList.push_back((Creature*)who);
  87.  
  88. npc_escortAI::MoveInLineOfSight(who);
  89. }
  90.  
  91. Creature* GetCreature(uint32 CreatureEntry)
  92. {
  93. if (!lCreatureList.empty())
  94. {
  95. for (std::list<Creature*>::iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr)
  96. {
  97. if ((*itr)->GetEntry() == CreatureEntry && (*itr)->IsAlive())
  98. return (*itr);
  99. }
  100. }
  101.  
  102. return NULL;
  103. }
  104.  
  105. void WaypointReached(uint32 PointId)
  106. {
  107. switch (PointId)
  108. {
  109. case 9:
  110. Talk(SAY_OGR_SPOT);
  111. break;
  112. case 10:
  113. if (Creature* reethe = GetCreature(NPC_REETHE))
  114. reethe->AI()->Talk(SAY_OGR_RET_WHAT);
  115. break;
  116. case 11:
  117. SetEscortPaused(true);
  118. break;
  119. }
  120. }
  121.  
  122. void JustSummoned(Creature* summoned)
  123. {
  124. lCreatureList.push_back(summoned);
  125.  
  126. summoned->setFaction(35);
  127.  
  128. if (summoned->GetEntry() == NPC_CALDWELL)
  129. summoned->GetMotionMaster()->MovePoint(0, afMoveTo[0], afMoveTo[1], afMoveTo[2]);
  130. else
  131. {
  132. if (Creature* caldwell = GetCreature(NPC_CALDWELL))
  133. {
  134. size_t iSize = lCreatureList.size();
  135. summoned->GetMotionMaster()->MoveFollow(caldwell, 0.5f, (M_PI / 2) * (int)iSize);
  136. }
  137. }
  138. }
  139.  
  140. void DoStartAttackMe()
  141. {
  142. if (!lCreatureList.empty())
  143. {
  144. for (std::list<Creature*>::iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr)
  145. {
  146. if ((*itr)->GetEntry() == NPC_REETHE)
  147. continue;
  148.  
  149. if ((*itr)->IsAlive())
  150. {
  151. (*itr)->setFaction(FACTION_THER_HOSTILE);
  152. (*itr)->AI()->AttackStart(me);
  153. }
  154. }
  155. }
  156. }
  157.  
  158. void UpdateAI(uint32 diff)
  159. {
  160. npc_escortAI::UpdateAI(diff);
  161.  
  162. if (!me->GetVictim())
  163. {
  164. if (HasEscortState(STATE_ESCORT_PAUSED))
  165. {
  166. if (m_uiGlobalTimer < diff)
  167. {
  168. m_uiGlobalTimer = 5000;
  169.  
  170. switch (m_uiPhase)
  171. {
  172. case PHASE_INTRO:
  173. {
  174. switch (m_uiPhaseCounter)
  175. {
  176. case 0:
  177. if (Creature* reethe = GetCreature(NPC_REETHE))
  178. reethe->AI()->Talk(SAY_OGR_RET_SWEAR);
  179. break;
  180. case 1:
  181. Talk(SAY_OGR_REPLY_RET);
  182. break;
  183. case 2:
  184. if (Creature* reethe = GetCreature(NPC_REETHE))
  185. reethe->AI()->Talk(SAY_OGR_RET_TAKEN);
  186. break;
  187. case 3:
  188. DoScriptText(SAY_OGR_TELL_FIRE, me);
  189. if (Creature* reethe = GetCreature(NPC_REETHE))
  190. reethe->AI()->Talk(SAY_OGR_RET_NOCLOSER);
  191. break;
  192. case 4:
  193. if (Creature* reethe = GetCreature(NPC_REETHE))
  194. reethe->AI()->Talk(SAY_OGR_RET_NOFIRE);
  195. break;
  196. case 5:
  197. if (Creature* reethe = GetCreature(NPC_REETHE))
  198. reethe->AI()->Talk(SAY_OGR_RET_HEAR);
  199.  
  200. me->SummonCreature(NPC_CALDWELL, afSpawn[0], afSpawn[1], afSpawn[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000);
  201. me->SummonCreature(NPC_HALLAN, afSpawn[0], afSpawn[1], afSpawn[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000);
  202. me->SummonCreature(NPC_SKIRMISHER, afSpawn[0], afSpawn[1], afSpawn[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000);
  203. me->SummonCreature(NPC_SKIRMISHER, afSpawn[0], afSpawn[1], afSpawn[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000);
  204.  
  205. m_uiPhase = PHASE_GUESTS;
  206. break;
  207. }
  208. break;
  209. }
  210. case PHASE_GUESTS:
  211. {
  212. switch (m_uiPhaseCounter)
  213. {
  214. case 6:
  215. if (Creature* caldwell = GetCreature(NPC_CALDWELL))
  216. caldwell->AI()->Talk(SAY_OGR_CAL_FOUND);
  217. break;
  218. case 7:
  219. if (Creature* caldwell = GetCreature(NPC_CALDWELL))
  220. caldwell->AI()->Talk(SAY_OGR_CAL_MERCY);
  221. break;
  222. case 8:
  223. if (Creature* hallan = GetCreature(NPC_HALLAN))
  224. {
  225. hallan->AI()->Talk(SAY_OGR_HALL_GLAD);
  226.  
  227. if (Creature* reethe = GetCreature(NPC_REETHE))
  228. hallan->CastSpell(reethe, SPELL_FAKE_SHOT, false);
  229. }
  230. break;
  231. case 9:
  232. if (Creature* reethe = GetCreature(NPC_REETHE))
  233. {
  234. reethe->AI()->Talk(EMOTE_OGR_RET_ARROW);
  235. reethe->AI()->Talk(SAY_OGR_RET_ARROW);
  236. }
  237. break;
  238. case 10:
  239. if (Creature* caldwell = GetCreature(NPC_CALDWELL))
  240. caldwell->AI()->Talk(SAY_OGR_CAL_CLEANUP);
  241. Talk(SAY_OGR_NODIE);
  242.  
  243. break;
  244. case 11:
  245. DoStartAttackMe();
  246. m_uiPhase = PHASE_FIGHT;
  247. break;
  248. }
  249. break;
  250. }
  251. case PHASE_COMPLETE:
  252. {
  253. switch (m_uiPhaseCounter)
  254. {
  255. case 12:
  256. if (Player* player = GetPlayerForEscort())
  257. player->GroupEventHappens(QUEST_QUESTIONING, me);
  258.  
  259. Talk(SAY_OGR_SURVIVE);
  260. break;
  261. case 13:
  262. if (Creature* reethe = GetCreature(NPC_REETHE))
  263. reethe->AI()->Talk(SAY_OGR_RET_LUCKY);
  264. break;
  265. case 14:
  266. Talk(SAY_OGR_THANKS);
  267. SetRun();
  268. SetEscortPaused(false);
  269. break;
  270. }
  271. break;
  272. }
  273. }
  274.  
  275. if (m_uiPhase != PHASE_FIGHT)
  276. ++m_uiPhaseCounter;
  277. }
  278. else
  279. m_uiGlobalTimer -= diff;
  280. }
  281.  
  282. return;
  283. }
  284.  
  285. DoMeleeAttackIfReady();
  286. }
  287. };
  288.  
  289. bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  290. {
  291. if (quest->GetQuestId() == QUEST_QUESTIONING)
  292. {
  293. if (npc_escortAI* pEscortAI = CAST_AI(npc_ogron::npc_ogronAI, creature->AI()))
  294. pEscortAI->Start(true, false, player->GetGUID());
  295.  
  296. creature->setFaction(290);
  297. creature->AI()->Talk(SAY_OGR_START);
  298. }
  299. return true;
  300. }
  301.  
  302. CreatureAI* GetAI(Creature* creature) const
  303. {
  304. return new npc_ogronAI(creature);
  305. }
  306. };
  307.  
  308. UPDATE `creature_template` SET `AIName`='', `ScriptName`='npc_ogron' WHERE `entry`=4983;
  309. UPDATE `creature_template` SET `AIName`='' WHERE `entry` IN (4980, 5046, 5045, 5044);
  310.  
  311. DELETE FROM `script_waypoint` WHERE `entry`=4983;
  312. INSERT INTO `script_waypoint` (`entry`, `pointid`, `location_x`, `location_y`, `location_z`, `waittime`, `point_comment`) VALUES
  313. (4983, 0, -3322.65, -3124.63, 33.842, 0, ''),
  314. (4983, 1, -3326.34, -3126.83, 34.426, 0, ''),
  315. (4983, 2, -3336.98, -3129.61, 30.692, 0, ''),
  316. (4983, 3, -3342.6, -3132.15, 30.422, 0, ''),
  317. (4983, 4, -3355.83, -3140.95, 29.534, 0, ''),
  318. (4983, 5, -3365.83, -3144.28, 35.176, 0, ''),
  319. (4983, 6, -3368.9, -3147.27, 36.091, 0, ''),
  320. (4983, 7, -3369.36, -3169.83, 36.325, 0, ''),
  321. (4983, 8, -3371.44, -3183.91, 33.454, 0, ''),
  322. (4983, 9, -3373.82, -3190.86, 34.717, 5000, 'SAY_OGR_SPOT'),
  323. (4983, 10, -3368.53, -3198.21, 34.926, 0, 'SAY_OGR_RET_WHAT'),
  324. (4983, 11, -3366.27, -3210.87, 33.733, 5000, 'pause'),
  325. (4983, 12, -3368.53, -3198.21, 34.926, 0, ''),
  326. (4983, 13, -3373.82, -3190.86, 34.717, 0, ''),
  327. (4983, 14, -3371.44, -3183.91, 33.454, 0, ''),
  328. (4983, 15, -3369.36, -3169.83, 36.325, 0, ''),
  329. (4983, 16, -3368.9, -3147.27, 36.091, 0, ''),
  330. (4983, 17, -3365.83, -3144.28, 35.176, 0, ''),
  331. (4983, 18, -3355.83, -3140.95, 29.534, 0, ''),
  332. (4983, 19, -3342.6, -3132.15, 30.422, 0, ''),
  333. (4983, 20, -3336.98, -3129.61, 30.692, 0, ''),
  334. (4983, 21, -3326.34, -3126.83, 34.426, 0, ''),
  335. (4983, 22, -3322.65, -3124.63, 33.842, 0, '');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement