1. /* Copyright (C) 2006,2007 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #include "../../sc_defines.h"
  17. // **** This script is still under Developement ****
  18. // Teleporting NYI
  19. #define SPELL_ARCANEEXPLOSION 19712
  20. #define SPELL_SHAZZRAHCURSE 19713
  21. #define SPELL_DEADENMAGIC 19714
  22. #define SPELL_COUNTERSPELL 19715
  23. struct MANGOS_DLL_DECL boss_shazzrahAI : public ScriptedAI
  24. {
  25. boss_shazzrahAI(Creature *c) : ScriptedAI(c) {Reset();}
  26. uint32 ArcaneExplosion_Timer;
  27. uint32 ShazzrahCurse_Timer;
  28. uint32 DeadenMagic_Timer;
  29. uint32 Countspell_Timer;
  30. bool InCombat;
  31. void Reset()
  32. {
  33. ArcaneExplosion_Timer = 6000; //These times are probably wrong
  34. ShazzrahCurse_Timer = 30000;
  35. DeadenMagic_Timer = 45000;
  36. Countspell_Timer = 20000;
  37. InCombat = false;
  38. if (m_creature)
  39. EnterEvadeMode();
  40. }
  41. void AttackStart(Unit *who)
  42. {
  43. if (!who)
  44. return;
  45. if (m_creature->getVictim() == NULL && who->isTargetableForAttack() && who!= m_creature)
  46. {
  47. //Begin melee attack if we are within range
  48. DoStartMeleeAttack(who);
  49. InCombat = true;
  50. }
  51. }
  52. void MoveInLineOfSight(Unit *who)
  53. {
  54. if (!who || m_creature->getVictim())
  55. return;
  56. if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))
  57. {
  58. float attackRadius = m_creature->GetAttackDistance(who);
  59. if (m_creature->IsWithinDist(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE)
  60. {
  61. if(who->HasStealthAura())
  62. who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
  63. DoStartMeleeAttack(who);
  64. InCombat = true;
  65. }
  66. }
  67. }
  68. void UpdateAI(const uint32 diff)
  69. {
  70. //If we had a target and it wasn't cleared then it means the target died from some unknown soruce
  71. //But we still need to reset
  72. if (InCombat && !m_creature->SelectHostilTarget())
  73. {
  74. Reset();
  75. return;
  76. }
  77. //Check if we have a current target
  78. if( m_creature->getVictim() && m_creature->isAlive())
  79. {
  80. //ArcaneExplosion_Timer
  81. if (ArcaneExplosion_Timer < diff)
  82. {
  83. //Cast
  84. DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION);
  85. //6 seconds until we should cast this agian
  86. ArcaneExplosion_Timer = 6000;
  87. }else ArcaneExplosion_Timer -= diff;
  88. //ShazzrahCurse_Timer
  89. if (ShazzrahCurse_Timer < diff)
  90. {
  91. //Cast
  92. DoCast(m_creature->getVictim(),SPELL_SHAZZRAHCURSE);
  93. //30 seconds until we should cast this agian
  94. ShazzrahCurse_Timer = 30000;
  95. }else ShazzrahCurse_Timer -= diff;
  96. //DeadenMagic_Timer
  97. if (DeadenMagic_Timer < diff)
  98. {
  99. //Cast
  100. DoCast(m_creature,SPELL_DEADENMAGIC);
  101. //45 seconds until we should cast this agian
  102. DeadenMagic_Timer = 45000;
  103. }else DeadenMagic_Timer -= diff;
  104. //Countspell_Timer
  105. if (Countspell_Timer < diff)
  106. {
  107. //Cast
  108. DoCast(m_creature->getVictim(),SPELL_COUNTERSPELL);
  109. //20 seconds until we should cast this agian
  110. Countspell_Timer = 20000;
  111. }else Countspell_Timer -= diff;
  112. //If we are within range melee the target
  113. if( m_creature->IsWithinDist(m_creature->getVictim(), ATTACK_DIST))
  114. {
  115. //Make sure our attack is ready and we arn't currently casting
  116. if( m_creature->isAttackReady() && !m_creature->m_currentSpell)
  117. {
  118. m_creature->AttackerStateUpdate(m_creature->getVictim());
  119. m_creature->resetAttackTimer();
  120. }
  121. }
  122. }
  123. }
  124. };
  125. CreatureAI* GetAI_boss_shazzrah(Creature *_Creature)
  126. {
  127. return new boss_shazzrahAI (_Creature);
  128. }
  129. void AddSC_boss_shazzrah()
  130. {
  131. Script *newscript;
  132. newscript = new Script;
  133. newscript->Name="boss_shazzrah";
  134. newscript->GetAI = GetAI_boss_shazzrah;
  135. m_scripts[nrscripts++] = newscript;
  136. }