PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp

https://github.com/Archives/TrinityCore
C++ | 279 lines | 229 code | 38 blank | 12 comment | 35 complexity | 9297c163e267998f905220686fb8831f 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 "halls_of_reflection.h"
  13. enum
  14. {
  15. SAY_MARWYN_INTRO = -1594506,
  16. SAY_MARWYN_AGGRO = -1668060,
  17. SAY_MARWYN_DEATH = -1668063,
  18. SAY_MARWYN_SLAY01 = -1668061,
  19. SAY_MARWYN_SLAY02 = -1668062,
  20. SAY_MARWYN_SP01 = -1668064,
  21. SAY_MARWYN_SP02 = -1668065,
  22. SPELL_OBLITERATE_N = 72360,
  23. SPELL_OBLITERATE_H = 72434,
  24. SPELL_SHARED_SUFFERING_N = 72368,
  25. SPELL_SHARED_SUFFERING_H = 72369,
  26. SPELL_WELL_OF_CORRUPTION = 72362,
  27. SPELL_CORRUPTED_FLESH_N = 72363,
  28. SPELL_CORRUPTED_FLESH_H = 72436,
  29. SPELL_BERSERK = 47008,
  30. };
  31. class boss_marwyn : public CreatureScript
  32. {
  33. public:
  34. boss_marwyn() : CreatureScript("boss_marwyn") {}
  35. struct boss_marwynAI : public ScriptedAI
  36. {
  37. boss_marwynAI(Creature *pCreature) : ScriptedAI(pCreature)
  38. {
  39. m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  40. Regular = pCreature->GetMap()->IsRegularDifficulty();
  41. Reset();
  42. }
  43. InstanceScript* m_pInstance;
  44. bool Regular;
  45. bool m_bIsCall;
  46. //FUNCTIONS
  47. uint32 m_uiBerserkTimer;
  48. uint32 m_uiSharedSufferingTimer;
  49. uint32 m_uiWellTimer;
  50. uint32 m_uiTouchTimer;
  51. uint32 m_uiFleshTimer;
  52. uint32 m_uiObliterateTimer;
  53. uint32 m_uiSummonTimer;
  54. uint32 m_uiLocNo;
  55. uint64 m_uiSummonGUID[16];
  56. uint32 m_uiCheckSummon;
  57. uint8 SummonCount;
  58. uint32 pSummon;
  59. void Reset()
  60. {
  61. m_uiBerserkTimer = 180000;
  62. m_uiSharedSufferingTimer = 4000;
  63. m_uiWellTimer = 12000;
  64. m_uiTouchTimer = 8000;
  65. m_uiFleshTimer = 21000;
  66. m_uiObliterateTimer = 5000;
  67. SummonCount = 0;
  68. m_bIsCall = false;
  69. m_uiSummonTimer = 15000;
  70. me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  71. me->SetVisible(false);
  72. }
  73. void Summon()
  74. {
  75. m_uiLocNo = 14;
  76. for(uint8 i = 0; i < 14; i++)
  77. {
  78. switch(urand(0,3))
  79. {
  80. case 0:
  81. switch(urand(1, 3))
  82. {
  83. case 1: pSummon = NPC_DARK_1; break;
  84. case 2: pSummon = NPC_DARK_3; break;
  85. case 3: pSummon = NPC_DARK_6; break;
  86. }
  87. break;
  88. case 1:
  89. switch(urand(1, 3))
  90. {
  91. case 1: pSummon = NPC_DARK_2; break;
  92. case 2: pSummon = NPC_DARK_3; break;
  93. case 3: pSummon = NPC_DARK_4; break;
  94. }
  95. break;
  96. case 2:
  97. switch(urand(1, 3))
  98. {
  99. case 1: pSummon = NPC_DARK_2; break;
  100. case 2: pSummon = NPC_DARK_5; break;
  101. case 3: pSummon = NPC_DARK_6; break;
  102. }
  103. break;
  104. case 3:
  105. switch(urand(1, 3))
  106. {
  107. case 1: pSummon = NPC_DARK_1; break;
  108. case 2: pSummon = NPC_DARK_5; break;
  109. case 3: pSummon = NPC_DARK_4; break;
  110. }
  111. break;
  112. }
  113. m_uiCheckSummon = 0;
  114. if(Creature* Summon = me->SummonCreature(pSummon, SpawnLoc[m_uiLocNo].x, SpawnLoc[m_uiLocNo].y, SpawnLoc[m_uiLocNo].z, SpawnLoc[m_uiLocNo].o, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000))
  115. {
  116. m_uiSummonGUID[i] = Summon->GetGUID();
  117. Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  118. Summon->SetReactState(REACT_PASSIVE);
  119. Summon->setFaction(974);
  120. }
  121. m_uiLocNo++;
  122. }
  123. }
  124. void CallFallSoldier()
  125. {
  126. for(uint8 i = 0; i < 4; i++)
  127. {
  128. if(Creature* Summon = m_pInstance->instance->GetCreature(m_uiSummonGUID[m_uiCheckSummon]))
  129. {
  130. Summon->setFaction(14);
  131. Summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  132. Summon->SetReactState(REACT_AGGRESSIVE);
  133. Summon->SetInCombatWithZone();
  134. }
  135. m_uiCheckSummon++;
  136. }
  137. }
  138. void JustDied(Unit* pKiller)
  139. {
  140. if(m_pInstance)
  141. {
  142. m_pInstance->SetData(TYPE_MARWYN, DONE);
  143. m_pInstance->SetData(TYPE_PHASE, 3);
  144. }
  145. DoScriptText(SAY_MARWYN_DEATH, me);
  146. }
  147. void KilledUnit(Unit* pVictim)
  148. {
  149. switch(urand(0,1))
  150. {
  151. case 0: DoScriptText(SAY_MARWYN_SLAY01, me); break;
  152. case 1: DoScriptText(SAY_MARWYN_SLAY02, me); break;
  153. }
  154. }
  155. void EnterCombat(Unit* pVictim)
  156. {
  157. if (!m_pInstance) return;
  158. //me->RemoveFlag(MOVEFLAG_WALK, MOVEMENTFLAG_WALK_MODE);
  159. DoScriptText(SAY_MARWYN_AGGRO, me);
  160. }
  161. void AttackStart(Unit* who)
  162. {
  163. if (!m_pInstance) return;
  164. if (m_pInstance->GetData(TYPE_MARWYN) != IN_PROGRESS)
  165. return;
  166. ScriptedAI::AttackStart(who);
  167. }
  168. void UpdateAI(const uint32 uiDiff)
  169. {
  170. if(!m_pInstance) return;
  171. if (m_pInstance->GetData(TYPE_FALRIC) == SPECIAL)
  172. {
  173. if(!m_bIsCall)
  174. {
  175. m_bIsCall = true;
  176. Summon();
  177. }
  178. }
  179. if(m_pInstance->GetData(TYPE_MARWYN) == SPECIAL)
  180. {
  181. if(m_uiSummonTimer < uiDiff)
  182. {
  183. ++SummonCount;
  184. if(SummonCount == 1)
  185. DoScriptText(SAY_MARWYN_INTRO, me);
  186. if(SummonCount > 4)
  187. {
  188. m_pInstance->SetData(TYPE_MARWYN, IN_PROGRESS);
  189. me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  190. me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  191. me->SetInCombatWithZone();
  192. }
  193. else CallFallSoldier();
  194. m_uiSummonTimer = 60000;
  195. } else m_uiSummonTimer -= uiDiff;
  196. }
  197. if (!UpdateVictim())
  198. return;
  199. if(m_uiObliterateTimer < uiDiff)
  200. {
  201. DoCast(me->getVictim(), Regular ? SPELL_OBLITERATE_N : SPELL_OBLITERATE_H);
  202. m_uiObliterateTimer = urand(8000, 12000);
  203. } else m_uiObliterateTimer -= uiDiff;
  204. if (m_uiWellTimer < uiDiff)
  205. {
  206. DoScriptText(SAY_MARWYN_SP02, me);
  207. if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  208. DoCast(pTarget, SPELL_WELL_OF_CORRUPTION);
  209. m_uiWellTimer= urand(25000, 30000);
  210. } else m_uiWellTimer -= uiDiff;
  211. if (m_uiSharedSufferingTimer < uiDiff)
  212. {
  213. if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  214. DoCast(pTarget, Regular ? SPELL_SHARED_SUFFERING_N : SPELL_SHARED_SUFFERING_H);
  215. m_uiSharedSufferingTimer = urand(15000, 20000);
  216. } else m_uiSharedSufferingTimer -= uiDiff;
  217. if (m_uiFleshTimer < uiDiff)
  218. {
  219. DoScriptText(SAY_MARWYN_SP01, me);
  220. if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  221. DoCast(pTarget, Regular ? SPELL_CORRUPTED_FLESH_N : SPELL_CORRUPTED_FLESH_H);
  222. m_uiFleshTimer = urand(10000, 16000);
  223. } else m_uiFleshTimer -= uiDiff;
  224. if(m_uiBerserkTimer < uiDiff)
  225. {
  226. DoCast(me, SPELL_BERSERK);
  227. m_uiBerserkTimer = 180000;
  228. } else m_uiBerserkTimer -= uiDiff;
  229. DoMeleeAttackIfReady();
  230. return;
  231. }
  232. };
  233. CreatureAI* GetAI(Creature* pCreature) const
  234. {
  235. return new boss_marwynAI(pCreature);
  236. }
  237. };
  238. void AddSC_boss_marwyn()
  239. {
  240. new boss_marwyn();
  241. }