Guest User

Untitled

a guest
Dec 10th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.33 KB | None | 0 0
  1. diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp
  2. index 89064a5..4231a1e 100644
  3. --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp
  4. +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp
  5. @@ -34,6 +34,18 @@ enum Spells
  6.      SPELL_POISONOUS_MUSHROOM_VISUAL_AREA          = 61566, // Self
  7.      SPELL_POISONOUS_MUSHROOM_VISUAL_AURA          = 56741, // Self
  8.      SPELL_PUTRID_MUSHROOM                         = 31690, // To make the mushrooms visible
  9. +    SPELL_POWER_MUSHROOM_VISUAL_AURA              = 56740,
  10. +};
  11. +
  12. +enum event
  13. +{
  14. +    EVENT_SPAWN = 1,
  15. +    EVENT_MINI,
  16. +    EVENT_ROOT,  
  17. +    EVENT_BASH,
  18. +    EVENT_BOLT,
  19. +    EVENT_AURA,
  20. +    EVENT_DEATH
  21.  };
  22.  
  23.  enum Creatures
  24. @@ -47,33 +59,21 @@ class boss_amanitar : public CreatureScript
  25.  public:
  26.      boss_amanitar() : CreatureScript("boss_amanitar") { }
  27.  
  28. -    struct boss_amanitarAI : public ScriptedAI
  29. +    struct boss_amanitarAI : public BossAI
  30.      {
  31. -        boss_amanitarAI(Creature* creature) : ScriptedAI(creature)
  32. +        boss_amanitarAI(Creature* creature) : BossAI(creature, DATA_AMANITAR)
  33.          {
  34.              instance = creature->GetInstanceScript();
  35.              bFirstTime = true;
  36.          }
  37.  
  38.          InstanceScript* instance;
  39. -
  40. -        uint32 uiRootTimer;
  41. -        uint32 uiBashTimer;
  42. -        uint32 uiBoltTimer;
  43. -        uint32 uiSpawnTimer;
  44. +        EventMap events;
  45.  
  46.          bool bFirstTime;
  47.  
  48.          void Reset()
  49.          {
  50. -            uiRootTimer = urand(5*IN_MILLISECONDS, 9*IN_MILLISECONDS);
  51. -            uiBashTimer = urand(10*IN_MILLISECONDS, 14*IN_MILLISECONDS);
  52. -            uiBoltTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
  53. -            uiSpawnTimer = 0;
  54. -
  55. -            me->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE);
  56. -            me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
  57. -
  58.              if (instance)
  59.              {
  60.                  instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MINI);
  61. @@ -82,6 +82,18 @@ public:
  62.                  else
  63.                      bFirstTime = false;
  64.              }
  65. +
  66. +            events.Reset();
  67. +            events.ScheduleEvent(EVENT_ROOT, urand(5,9)*IN_MILLISECONDS);
  68. +            events.ScheduleEvent(EVENT_BASH, urand(10,14)*IN_MILLISECONDS);
  69. +            events.ScheduleEvent(EVENT_BOLT, urand(15,20)*IN_MILLISECONDS);
  70. +            events.ScheduleEvent(EVENT_MINI, urand(12,18)*IN_MILLISECONDS);
  71. +            events.ScheduleEvent(EVENT_SPAWN, 5 *IN_MILLISECONDS);
  72. +
  73. +            me->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE);
  74. +            me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
  75. +            
  76. +            summons.DespawnAll();
  77.          }
  78.  
  79.          void JustDied(Unit* /*killer*/)
  80. @@ -90,11 +102,13 @@ public:
  81.              {
  82.                  instance->SetData(DATA_AMANITAR_EVENT, DONE);
  83.                  instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MINI);
  84. +                summons.DespawnAll();
  85.              }
  86.          }
  87.  
  88.          void EnterCombat(Unit* /*who*/)
  89.          {
  90. +            me->SetInCombatWithZone();
  91.              if (instance)
  92.                  instance->SetData(DATA_AMANITAR_EVENT, IN_PROGRESS);
  93.  
  94. @@ -111,6 +125,7 @@ public:
  95.                  {
  96.                      Position pos;
  97.                      victim->GetPosition(&pos);
  98. +                    //pos.m_positionZ = me->GetMap()->GetHeight(pos.GetPositionX(), pos.GetPositionY(), MAX_HEIGHT) + 2.0f;
  99.                      me->GetRandomNearPosition(pos, float(urand(5, 80)));
  100.                      me->SummonCreature(NPC_POISONOUS_MUSHROOM, pos, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30*IN_MILLISECONDS);
  101.                      me->GetRandomNearPosition(pos, float(urand(5, 80)));
  102. @@ -121,36 +136,40 @@ public:
  103.  
  104.          void UpdateAI(const uint32 diff)
  105.          {
  106. -            //Return since we have no target
  107.              if (!UpdateVictim())
  108.                  return;
  109.  
  110. -            if (uiSpawnTimer <= diff)
  111. -            {
  112. -                SpawnAdds();
  113. -                uiSpawnTimer = urand(35*IN_MILLISECONDS, 40*IN_MILLISECONDS);
  114. -            } else uiSpawnTimer -= diff;
  115. -
  116. -            if (uiRootTimer <= diff)
  117. -            {
  118. -                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
  119. -                    DoCast(target, SPELL_ENTANGLING_ROOTS);
  120. -                uiRootTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
  121. -            } else uiRootTimer -= diff;
  122. +            events.Update(diff);
  123.  
  124. -            if (uiBashTimer <= diff)
  125. -            {
  126. -                DoCastVictim(SPELL_BASH);
  127. -                uiBashTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
  128. -            } else uiBashTimer -= diff;
  129. +            if (me->HasUnitState(UNIT_STATE_CASTING))
  130. +                return;
  131.  
  132. -            if (uiBoltTimer <= diff)
  133. +            while (uint32 eventId = events.ExecuteEvent())
  134.              {
  135. -                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
  136. -                    DoCast(target, SPELL_VENOM_BOLT_VOLLEY);
  137. -                uiBoltTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
  138. -            } else uiBoltTimer -= diff;
  139. -
  140. +                switch (eventId)
  141. +                {
  142. +                    case EVENT_SPAWN:  
  143. +                        SpawnAdds();
  144. +                        events.ScheduleEvent(EVENT_SPAWN, urand(35,40)*IN_MILLISECONDS);
  145. +                        break;
  146. +                    case EVENT_MINI:
  147. +                        DoCast(SPELL_MINI);
  148. +                        events.ScheduleEvent(EVENT_BASH, urand(25,30)*IN_MILLISECONDS);
  149. +                        break;
  150. +                    case EVENT_ROOT:
  151. +                        DoCast(SelectTarget(SELECT_TARGET_RANDOM,0, 100, true),SPELL_ENTANGLING_ROOTS);
  152. +                        events.ScheduleEvent(EVENT_ROOT, urand(10,5)*IN_MILLISECONDS);
  153. +                        break;
  154. +                    case EVENT_BASH:
  155. +                        DoCastVictim(SPELL_BASH);
  156. +                        events.ScheduleEvent(EVENT_BASH, urand(7,12)*IN_MILLISECONDS);
  157. +                        break;
  158. +                    case EVENT_BOLT:
  159. +                        DoCast(SelectTarget(SELECT_TARGET_RANDOM,0, 100, true),SPELL_VENOM_BOLT_VOLLEY);
  160. +                        events.ScheduleEvent(EVENT_BASH, urand(18,22)*IN_MILLISECONDS);
  161. +                        break;
  162. +                }
  163. +            }
  164.              DoMeleeAttackIfReady();
  165.          }
  166.      };
  167. @@ -170,18 +189,20 @@ public:
  168.      {
  169.          mob_amanitar_mushroomsAI(Creature* creature) : Scripted_NoMovementAI(creature) {}
  170.  
  171. -        uint32 uiAuraTimer;
  172. -        uint32 uiDeathTimer;
  173. +        EventMap events;
  174.  
  175.          void Reset()
  176.          {
  177. -            DoCast(me, SPELL_PUTRID_MUSHROOM, true); // Hack, to make the mushrooms visible, can't find orig. spell...
  178. +            DoCast(me, SPELL_PUTRID_MUSHROOM, true);
  179.  
  180.              if (me->GetEntry() == NPC_POISONOUS_MUSHROOM)
  181.                  DoCast(me, SPELL_POISONOUS_MUSHROOM_VISUAL_AURA, true);
  182. +            else
  183. +                DoCast(SPELL_POWER_MUSHROOM_VISUAL_AURA);
  184.  
  185. -            uiAuraTimer = 0;
  186. -            uiDeathTimer = 30*IN_MILLISECONDS;
  187. +            events.Reset();
  188. +            events.ScheduleEvent(EVENT_AURA, 1*IN_MILLISECONDS);
  189. +            events.ScheduleEvent(EVENT_DEATH, 30*IN_MILLISECONDS);
  190.          }
  191.  
  192.          void JustDied(Unit* killer)
  193. @@ -196,23 +217,43 @@ public:
  194.              }
  195.          }
  196.  
  197. +        
  198. +        //void DamageTaken(Unit* /*attacker*/, uint32 &damage)
  199. +        //{
  200. +            //if (damage >= me->GetHealth() && me->GetEntry() == NPC_HEALTHY_MUSHROOM)
  201. +                //DoCast(me, SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS, true);
  202. +        //}
  203. +
  204.          void EnterCombat(Unit* /*who*/) {}
  205.          void AttackStart(Unit* /*victim*/) {}
  206.  
  207.          void UpdateAI(const uint32 diff)
  208.          {
  209. -            if (me->GetEntry() == NPC_POISONOUS_MUSHROOM)
  210. +            if (!UpdateVictim())
  211. +                return;
  212. +
  213. +            events.Update(diff);
  214. +
  215. +            if (me->HasUnitState(UNIT_STATE_CASTING))
  216. +                return;
  217. +
  218. +            while (uint32 eventId = events.ExecuteEvent())
  219.              {
  220. -                if (uiAuraTimer <= diff)
  221. +                switch (eventId)
  222.                  {
  223. -                    DoCast(me, SPELL_POISONOUS_MUSHROOM_VISUAL_AREA, true);
  224. -                    DoCast(me, SPELL_POISONOUS_MUSHROOM_POISON_CLOUD, false);
  225. -                    uiAuraTimer = 7*IN_MILLISECONDS;
  226. -                } else uiAuraTimer -= diff;
  227. +                    case EVENT_AURA:
  228. +                        if (me->GetEntry() == NPC_POISONOUS_MUSHROOM)
  229. +                        {
  230. +                            DoCast(me, SPELL_POISONOUS_MUSHROOM_VISUAL_AREA, true);
  231. +                            DoCast(me, SPELL_POISONOUS_MUSHROOM_POISON_CLOUD, false);
  232. +                        }
  233. +                        events.ScheduleEvent(EVENT_AURA, 7*IN_MILLISECONDS);
  234. +                        break;
  235. +                    case EVENT_DEATH:
  236. +                        me->DisappearAndDie();
  237. +                        break;
  238. +                }
  239.              }
  240. -            if (uiDeathTimer <= diff)
  241. -                me->DisappearAndDie();
  242. -            else uiDeathTimer -= diff;
  243.          }
  244.      };
Add Comment
Please, Sign In to add comment