/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp

https://github.com/Archives/TrinityCore · C++ · 187 lines · 144 code · 31 blank · 12 comment · 22 complexity · 91e4fa7b4e9244b935e161c20b2307a6 MD5 · raw file

  1. /*
  2. * Copyright (C) 2008 - 2011 Trinity <http://www.trinitycore.org/>
  3. *
  4. * Copyright (C) 2010 - 2011 Myth Project <http://bitbucket.org/sun/myth-core/>
  5. *
  6. * Myth Project's source is based on the Trinity Project source, you can find the
  7. * link to that easily in Trinity Copyrights. Myth Project is a private community.
  8. * To get access, you either have to donate or pass a developer test.
  9. * You can't share Myth Project's sources! Only for personal use.
  10. */
  11. #include "ScriptPCH.h"
  12. #include "drak_tharon_keep.h"
  13. enum Spells
  14. {
  15. SPELL_INFECTED_WOUND = 49637,
  16. SPELL_CRUSH = 49639,
  17. SPELL_CORPSE_EXPLODE = 49555,
  18. SPELL_CONSUME = 49380,
  19. SPELL_CONSUME_AURA = 49381,
  20. //Heroic spells
  21. H_SPELL_CORPSE_EXPLODE = 59807,
  22. H_SPELL_CONSUME = 59803,
  23. H_SPELL_CONSUME_AURA = 59805,
  24. };
  25. enum Yells
  26. {
  27. SAY_AGGRO = -1600006,
  28. SAY_KILL = -1600007,
  29. SAY_CONSUME = -1600008,
  30. SAY_EXPLODE = -1600009,
  31. SAY_DEATH = -1600010
  32. };
  33. enum Achievements
  34. {
  35. ACHIEV_CONSUMPTION_JUNCTION = 2151
  36. };
  37. enum Creatures
  38. {
  39. NPC_DRAKKARI_INVADER_1 = 27753,
  40. NPC_DRAKKARI_INVADER_2 = 27709
  41. };
  42. Position AddSpawnPoint = { -260.493011f, -622.968018f, 26.605301f, 3.036870f };
  43. class boss_trollgore : public CreatureScript
  44. {
  45. public:
  46. boss_trollgore() : CreatureScript("boss_trollgore") { }
  47. CreatureAI* GetAI(Creature* pCreature) const
  48. {
  49. return new boss_trollgoreAI (pCreature);
  50. }
  51. struct boss_trollgoreAI : public ScriptedAI
  52. {
  53. boss_trollgoreAI(Creature *c) : ScriptedAI(c), lSummons(me)
  54. {
  55. pInstance = c->GetInstanceScript();
  56. }
  57. uint32 uiConsumeTimer;
  58. uint32 uiAuraCountTimer;
  59. uint32 uiCrushTimer;
  60. uint32 uiInfectedWoundTimer;
  61. uint32 uiExplodeCorpseTimer;
  62. uint32 uiSpawnTimer;
  63. bool bAchiev;
  64. SummonList lSummons;
  65. InstanceScript* pInstance;
  66. void Reset()
  67. {
  68. uiConsumeTimer = 15*IN_MILLISECONDS;
  69. uiAuraCountTimer = 15500;
  70. uiCrushTimer = urand(1*IN_MILLISECONDS,5*IN_MILLISECONDS);
  71. uiInfectedWoundTimer = urand(6*IN_MILLISECONDS,10*IN_MILLISECONDS);
  72. uiExplodeCorpseTimer = 3*IN_MILLISECONDS;
  73. uiSpawnTimer = urand(30*IN_MILLISECONDS,40*IN_MILLISECONDS);
  74. bAchiev = IsHeroic();
  75. lSummons.DespawnAll();
  76. me->RemoveAura(DUNGEON_MODE(SPELL_CONSUME_AURA, H_SPELL_CONSUME_AURA));
  77. if (pInstance)
  78. pInstance->SetData(DATA_TROLLGORE_EVENT, NOT_STARTED);
  79. }
  80. void EnterCombat(Unit* /*who*/)
  81. {
  82. DoScriptText(SAY_AGGRO, me);
  83. if (pInstance)
  84. pInstance->SetData(DATA_TROLLGORE_EVENT, IN_PROGRESS);
  85. }
  86. void UpdateAI(uint32 const diff)
  87. {
  88. //Return since we have no target
  89. if (!UpdateVictim())
  90. return;
  91. if (uiSpawnTimer <= diff)
  92. {
  93. uint32 spawnNumber = urand(2, DUNGEON_MODE(3, 5));
  94. for (uint8 i = 0; i < spawnNumber; ++i)
  95. DoSummon(RAND(NPC_DRAKKARI_INVADER_1, NPC_DRAKKARI_INVADER_2), AddSpawnPoint, 0, TEMPSUMMON_DEAD_DESPAWN);
  96. uiSpawnTimer = urand(30*IN_MILLISECONDS, 40*IN_MILLISECONDS);
  97. } else uiSpawnTimer -= diff;
  98. if (uiConsumeTimer <= diff)
  99. {
  100. DoScriptText(SAY_CONSUME, me);
  101. DoCast(SPELL_CONSUME);
  102. uiConsumeTimer = 15*IN_MILLISECONDS;
  103. } else uiConsumeTimer -= diff;
  104. if (bAchiev)
  105. {
  106. Aura *pConsumeAura = me->GetAura(DUNGEON_MODE(SPELL_CONSUME_AURA, H_SPELL_CONSUME_AURA));
  107. if (pConsumeAura && pConsumeAura->GetStackAmount() > 9)
  108. bAchiev = false;
  109. }
  110. if (uiCrushTimer <= diff)
  111. {
  112. DoCastVictim(SPELL_CRUSH);
  113. uiCrushTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS);
  114. } else uiCrushTimer -= diff;
  115. if (uiInfectedWoundTimer <= diff)
  116. {
  117. DoCastVictim(SPELL_INFECTED_WOUND);
  118. uiInfectedWoundTimer = urand(25*IN_MILLISECONDS, 35*IN_MILLISECONDS);
  119. } else uiInfectedWoundTimer -= diff;
  120. if (uiExplodeCorpseTimer <= diff)
  121. {
  122. DoCast(SPELL_CORPSE_EXPLODE);
  123. DoScriptText(SAY_EXPLODE, me);
  124. uiExplodeCorpseTimer = urand(15*IN_MILLISECONDS, 19*IN_MILLISECONDS);
  125. } else uiExplodeCorpseTimer -= diff;
  126. DoMeleeAttackIfReady();
  127. }
  128. void JustDied(Unit* /*killer*/)
  129. {
  130. DoScriptText(SAY_DEATH, me);
  131. lSummons.DespawnAll();
  132. if (pInstance)
  133. {
  134. if (bAchiev)
  135. pInstance->DoCompleteAchievement(ACHIEV_CONSUMPTION_JUNCTION);
  136. pInstance->SetData(DATA_TROLLGORE_EVENT, DONE);
  137. }
  138. }
  139. void KilledUnit(Unit* victim)
  140. {
  141. if (victim == me)
  142. return;
  143. DoScriptText(SAY_KILL, me);
  144. }
  145. void JustSummoned(Creature* summon)
  146. {
  147. lSummons.push_back(summon->GetGUID());
  148. if (summon->AI())
  149. summon->AI()->AttackStart(me);
  150. }
  151. };
  152. };
  153. void AddSC_boss_trollgore()
  154. {
  155. new boss_trollgore();
  156. }