1515 * with this program. If not, see <http://www.gnu.org/licenses/>.
1616 */
1717
18+ /*
19+ * Timers requires to be revisited
20+ */
21+
1822#include " ScriptMgr.h"
23+ #include " Containers.h"
1924#include " ScriptedCreature.h"
2025#include " the_botanica.h"
2126
@@ -44,9 +49,9 @@ enum LajSpells
4449
4550enum LajEvents
4651{
47- EVENT_TELEPORT = 1 ,
48- EVENT_EMOTE ,
49- EVENT_SUMMON ,
52+ EVENT_SEQUENCE_1 = 1 ,
53+ EVENT_SEQUENCE_2 ,
54+ EVENT_SEQUENCE_3 ,
5055 EVENT_ALLERGIC_REACTION ,
5156 EVENT_TRANSFORM ,
5257 EVENT_THRASH
@@ -55,18 +60,22 @@ enum LajEvents
5560// 17980 - Laj
5661struct boss_laj : public BossAI
5762{
58- boss_laj (Creature* creature) : BossAI(creature, DATA_LAJ ), _activeTransformAura( 0 ) { }
63+ boss_laj (Creature* creature) : BossAI(creature, DATA_LAJ ), _lastTransformSpell( 0 ), _isFirstTransform( true ) { }
5964
6065 void Reset () override
6166 {
6267 _Reset ();
63- _activeTransformAura = 0 ;
68+ _lastTransformSpell = 0 ;
69+ _isFirstTransform = true ;
70+
71+ me->SetReactState (REACT_AGGRESSIVE );
6472 }
6573
6674 void JustEngagedWith (Unit* who) override
6775 {
6876 BossAI::JustEngagedWith (who);
69- events.ScheduleEvent (EVENT_TELEPORT , 15s, 25s);
77+
78+ events.ScheduleEvent (EVENT_SEQUENCE_1 , 15s, 25s);
7079 events.ScheduleEvent (EVENT_ALLERGIC_REACTION , 10s, 20s);
7180 events.ScheduleEvent (EVENT_TRANSFORM , 20s, 30s);
7281 events.ScheduleEvent (EVENT_THRASH , 0s, 10s);
@@ -94,24 +103,22 @@ struct boss_laj : public BossAI
94103 switch (eventId)
95104 {
96105 // Teleport sequence
97- case EVENT_TELEPORT :
106+ case EVENT_SEQUENCE_1 :
98107 DoCastSelf (SPELL_TELEPORT_SELF );
99108 me->SetReactState (REACT_PASSIVE );
100109 events.Repeat (25s, 40s);
101- events.ScheduleEvent (EVENT_EMOTE , 2s);
110+ events.ScheduleEvent (EVENT_SEQUENCE_2 , 2s);
102111 break ;
103- case EVENT_EMOTE :
112+ case EVENT_SEQUENCE_2 :
104113 Talk (EMOTE_SUMMON );
105- events.ScheduleEvent (EVENT_SUMMON , 1s);
114+ events.ScheduleEvent (EVENT_SEQUENCE_3 , 1s);
106115 break ;
107- case EVENT_SUMMON :
108- // He can summon 2 creatures of one type or 2 different. He always spawns them at 2 platforms(despite there are 4 in the room)
109- // Even if he uses other 4 spells, that does not make sense because the only difference between them is spells entries
110- // Best guess other spells were added on early development stage for second pair of platforms and were never used on live
111- DoCastSelf (RAND (SPELL_SUMMON_LASHER_1 , SPELL_SUMMON_FLAYER_1 ), true );
112- DoCastSelf (RAND (SPELL_SUMMON_LASHER_2 , SPELL_SUMMON_FLAYER_2 ), true );
116+ case EVENT_SEQUENCE_3 :
117+ DoCastSelf (RAND (SPELL_SUMMON_LASHER_1 , SPELL_SUMMON_FLAYER_1 ));
118+ DoCastSelf (RAND (SPELL_SUMMON_LASHER_2 , SPELL_SUMMON_FLAYER_2 ));
113119 me->SetReactState (REACT_AGGRESSIVE );
114120 break ;
121+
115122 // Abilities
116123 case EVENT_ALLERGIC_REACTION :
117124 if (Unit* target = SelectTarget (SelectTargetMethod::Random, 0 , 8 .f ))
@@ -120,13 +127,25 @@ struct boss_laj : public BossAI
120127 break ;
121128 case EVENT_TRANSFORM :
122129 {
123- // / @todo: Don't apply same aura twice in a row and don't transform to shadow if the event is executed first time
124- if (_activeTransformAura)
125- me->RemoveAurasDueToSpell (_activeTransformAura);
130+ std::vector<uint32> transformSpells = { SPELL_TRANSFORM_ARCANE , SPELL_TRANSFORM_FIRE , SPELL_TRANSFORM_FROST , SPELL_TRANSFORM_NATURE , SPELL_TRANSFORM_SHADOW };
131+
132+ if (_isFirstTransform)
133+ {
134+ std::erase (transformSpells, SPELL_TRANSFORM_SHADOW );
135+ _isFirstTransform = false ;
136+ }
137+
138+ if (_lastTransformSpell)
139+ {
140+ std::erase (transformSpells, _lastTransformSpell);
141+ me->RemoveAurasDueToSpell (_lastTransformSpell);
142+ }
143+
144+ uint32 selectedSpell = Trinity::Containers::SelectRandomContainerElement (transformSpells);
145+
146+ _lastTransformSpell = selectedSpell;
126147
127- uint32 spell = RAND (SPELL_TRANSFORM_ARCANE , SPELL_TRANSFORM_FIRE , SPELL_TRANSFORM_FROST , SPELL_TRANSFORM_NATURE , SPELL_TRANSFORM_SHADOW );
128- DoCastSelf (spell);
129- _activeTransformAura = spell;
148+ DoCastSelf (selectedSpell);
130149 events.Repeat (25s, 45s);
131150 break ;
132151 }
@@ -146,7 +165,8 @@ struct boss_laj : public BossAI
146165 }
147166
148167private:
149- uint32 _activeTransformAura;
168+ uint32 _lastTransformSpell;
169+ bool _isFirstTransform;
150170};
151171
152172void AddSC_boss_laj ()
0 commit comments