Guest User

Untitled

a guest
Nov 23rd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. struct MANGOS_DLL_DECL npc_fireworkAI : public ScriptedAI
  2. {
  3. npc_firework(Creature* pCreature) : ScriptedAI(pCreature)
  4. {
  5. m_bFireworkPossible = false;
  6. m_bTethyrComplete = false;
  7.  
  8. m_uiFirework_1_Timer = urand(1000, 2500);
  9. m_uiFirework_2_Timer = urand(1000, 2500);
  10. m_uiFirework_3_Timer = urand(1000, 2500);
  11. m_uiTethyrCheckTimer = 15000;
  12. Reset();
  13. }
  14.  
  15. bool m_bFireworkPossible;
  16. bool m_bTethyrComplete;
  17.  
  18. uint32 m_uiFirework_1_Timer;
  19. uint32 m_uiFirework_2_Timer;
  20. uint32 m_uiFirework_3_Timer;
  21. uint32 m_uiTethyrCheckTimer;
  22.  
  23. void Reset()
  24. {
  25. m_bFireworkPossible = false;
  26. m_bTethyrComplete = false;
  27.  
  28. m_uiFirework_1_Timer = urand(1000, 2500);
  29. m_uiFirework_2_Timer = urand(1000, 2500);
  30. m_uiFirework_3_Timer = urand(1000, 2500);
  31. m_uiTethyrCheckTimer = 15000;
  32. }
  33.  
  34. void UpdateAI(const uint32 uiDiff)
  35. {
  36. if(m_uiTethyrCheckTimer < uiDiff && m_bFireworkPossible == false)
  37. {
  38. Creature* pTethyr = GetClosestCreatureWithEntry(m_creature, MOB_TETHYR, 150.0f);
  39.  
  40. if (pTethyr)
  41. {
  42. m_bFireworkPossible = true;
  43. }
  44. }
  45.  
  46. if(m_bFireworkPossible == true)
  47. {
  48. if(m_bTethyrComplete == true)
  49. {
  50. switch(urand(0, 2))
  51. {
  52. case 0:
  53. if(m_uiFirework_1_Timer < uiDiff)
  54. {
  55. DoCastSpellIfCan(m_creature, SPELL_FIREWORK_1, CAST_TRIGGERED);
  56. m_uiFirework_1_Timer = urand(1000, 2000);
  57. }
  58. break;
  59. case 1:
  60. if(m_uiFirework_2_Timer < uiDiff)
  61. {
  62. DoCastSpellIfCan(m_creature, SPELL_FIREWORK_2, CAST_TRIGGERED);
  63. m_uiFirework_2_Timer = urand(1000, 2000);
  64. }
  65. break;
  66. case 2:
  67. if(m_uiFirework_3_Timer < uiDiff)
  68. {
  69. DoCastSpellIfCan(m_creature, SPELL_FIREWORK_3, CAST_TRIGGERED);
  70. m_uiFirework_3_Timer = urand(1000, 2000);
  71. }
  72. break;
  73. }
  74. }
  75. }
  76. }
  77. };
  78.  
  79. CreatureAI* GetAI_npc_firework(Creature* pCreature)
  80. {
  81. return new npc_fireworkAI(pCreature);
  82. }
Add Comment
Please, Sign In to add comment