21
21
#include " GameObject.h"
22
22
#include " GameObjectAI.h"
23
23
#include " InstanceScript.h"
24
- #include " ObjectAccessor .h"
24
+ #include " MotionMaster .h"
25
25
#include " ScriptedCreature.h"
26
26
#include " SpellAuraEffects.h"
27
27
#include " SpellScript.h"
28
28
29
29
enum BroggokTexts
30
30
{
31
- SAY_AGGRO = 0
31
+ SAY_INTRO = 0 ,
32
+ SAY_AGGRO = 1
32
33
};
33
34
34
35
enum BroggokSpells
35
36
{
36
- SPELL_SLIME_SPRAY = 30913 ,
37
- SPELL_POISON_CLOUD = 30916 ,
38
- SPELL_POISON_BOLT = 30917 ,
39
- SPELL_POISON_CLOUD_PASSIVE = 30914 ,
40
- SPELL_SUMMON_INCOMBAT_TRIGGER = 26837 ,
37
+ SPELL_SLIME_SPRAY = 30913 ,
38
+ SPELL_POISON_BOLT = 30917 ,
39
+ SPELL_POISON_CLOUD = 30916 ,
40
+
41
+ SPELL_SUMMON_INCOMBAT_TRIGGER = 26837 ,
42
+ SPELL_DESPAWN_INCOMBAT_TRIGGER = 26838 ,
43
+
44
+ // Cloud
45
+ SPELL_POISON_CLOUD_PASSIVE = 30914 ,
41
46
42
47
// Prisioners
43
- SPELL_STOMP = 31900 ,
44
- SPELL_CONCUSSION_BLOW = 22427 ,
45
- SPELL_FRENZY = 8269 ,
46
- SPELL_CHARGE = 22120
48
+ SPELL_STOMP = 31900 ,
49
+ SPELL_CONCUSSION_BLOW = 22427 ,
50
+ SPELL_FRENZY = 8269 ,
51
+ SPELL_CHARGE = 22120
47
52
};
48
53
49
54
enum BroggokEvents
50
55
{
51
- EVENT_SLIME_SPRAY = 1 ,
56
+ EVENT_SLIME_SPRAY = 1 ,
52
57
EVENT_POISON_BOLT,
53
58
EVENT_POISON_CLOUD,
59
+
60
+ EVENT_INTRO_1,
61
+ EVENT_INTRO_2,
62
+
63
+ EVENT_ACTIVATE_1,
64
+ EVENT_ACTIVATE_2
65
+ };
66
+
67
+ enum BroggokMisc
68
+ {
69
+ PATH_ROOM = 1381150 ,
70
+ NPC_BROGGOK_POISON_CLOUD = 17662 ,
71
+ NPC_INCOMBAT_TRIGGER = 16006
54
72
};
55
73
56
74
// 17380 - Broggok
@@ -67,11 +85,11 @@ struct boss_broggok : public BossAI
67
85
void JustEngagedWith (Unit* who) override
68
86
{
69
87
BossAI::JustEngagedWith (who);
70
- Talk (SAY_AGGRO );
88
+ DoCastSelf (SPELL_DESPAWN_INCOMBAT_TRIGGER );
71
89
72
- events.ScheduleEvent (EVENT_SLIME_SPRAY, 10s );
73
- events.ScheduleEvent (EVENT_POISON_BOLT, 7s );
74
- events.ScheduleEvent (EVENT_POISON_CLOUD, 5s);
90
+ events.ScheduleEvent (EVENT_SLIME_SPRAY, 8s, 12s );
91
+ events.ScheduleEvent (EVENT_POISON_BOLT, 2s, 10s );
92
+ events.ScheduleEvent (EVENT_POISON_CLOUD, 5s, 10s );
75
93
}
76
94
77
95
void JustSummoned (Creature* summoned) override
@@ -90,22 +108,29 @@ struct boss_broggok : public BossAI
90
108
}
91
109
}
92
110
111
+ void EnterEvadeMode (EvadeReason /* why*/ ) override
112
+ {
113
+ summons.DespawnEntry (NPC_BROGGOK_POISON_CLOUD);
114
+ DoCastSelf (SPELL_DESPAWN_INCOMBAT_TRIGGER, true );
115
+ instance->SetBossState (DATA_BROGGOK, NOT_STARTED);
116
+ _DespawnAtEvade ();
117
+ }
118
+
93
119
void DoAction (int32 action) override
94
120
{
95
121
switch (action)
96
122
{
97
123
case ACTION_PREPARE_BROGGOK:
98
- DoCastSelf (SPELL_SUMMON_INCOMBAT_TRIGGER );
124
+ events. ScheduleEvent (EVENT_INTRO_1, 0s );
99
125
break ;
100
126
case ACTION_ACTIVATE_BROGGOK:
101
- me->SetReactState (REACT_AGGRESSIVE);
102
- me->RemoveUnitFlag (UNIT_FLAG_UNINTERACTIBLE);
103
- DoZoneInCombat ();
127
+ events.ScheduleEvent (EVENT_ACTIVATE_1, 0s);
104
128
break ;
105
129
case ACTION_RESET_BROGGOK:
106
130
me->SetReactState (REACT_PASSIVE);
107
131
me->SetUnitFlag (UNIT_FLAG_UNINTERACTIBLE);
108
- summons.DespawnAll ();
132
+ summons.DespawnEntry (NPC_BROGGOK_POISON_CLOUD);
133
+ DoCastSelf (SPELL_DESPAWN_INCOMBAT_TRIGGER);
109
134
instance->SetBossState (DATA_BROGGOK, NOT_STARTED);
110
135
if (GameObject * lever = instance->GetGameObject (DATA_BROGGOK_LEVER))
111
136
{
@@ -118,24 +143,73 @@ struct boss_broggok : public BossAI
118
143
}
119
144
}
120
145
121
- void ExecuteEvent (uint32 eventId ) override
146
+ void UpdateAI (uint32 diff ) override
122
147
{
123
- switch (eventId )
148
+ if (! UpdateVictim () )
124
149
{
125
- case EVENT_SLIME_SPRAY:
126
- DoCastVictim (SPELL_SLIME_SPRAY);
127
- events.Repeat (4s, 12s);
128
- break ;
129
- case EVENT_POISON_BOLT:
130
- DoCastVictim (SPELL_POISON_BOLT);
131
- events.Repeat (4s, 12s);
132
- break ;
133
- case EVENT_POISON_CLOUD:
134
- DoCastSelf (SPELL_POISON_CLOUD);
135
- events.Repeat (20s);
136
- break ;
137
- default :
138
- break ;
150
+ UpdateOutOfCombatEvents (diff);
151
+ return ;
152
+ }
153
+
154
+ events.Update (diff);
155
+
156
+ if (me->HasUnitState (UNIT_STATE_CASTING))
157
+ return ;
158
+
159
+ while (uint32 eventId = events.ExecuteEvent ())
160
+ {
161
+ switch (eventId)
162
+ {
163
+ case EVENT_SLIME_SPRAY:
164
+ DoCastSelf (SPELL_SLIME_SPRAY);
165
+ events.Repeat (4s, 12s);
166
+ break ;
167
+ case EVENT_POISON_BOLT:
168
+ DoCastSelf (SPELL_POISON_BOLT);
169
+ events.Repeat (4s, 12s);
170
+ break ;
171
+ case EVENT_POISON_CLOUD:
172
+ DoCastSelf (SPELL_POISON_CLOUD);
173
+ events.Repeat (20s);
174
+ break ;
175
+ default :
176
+ break ;
177
+ }
178
+
179
+ if (me->HasUnitState (UNIT_STATE_CASTING))
180
+ return ;
181
+ }
182
+
183
+ DoMeleeAttackIfReady ();
184
+ }
185
+
186
+ void UpdateOutOfCombatEvents (uint32 diff)
187
+ {
188
+ events.Update (diff);
189
+
190
+ while (uint32 eventId = events.ExecuteEvent ())
191
+ {
192
+ switch (eventId)
193
+ {
194
+ case EVENT_INTRO_1:
195
+ DoCastSelf (SPELL_SUMMON_INCOMBAT_TRIGGER);
196
+ events.ScheduleEvent (EVENT_INTRO_2, 2s);
197
+ break ;
198
+ case EVENT_INTRO_2:
199
+ Talk (SAY_INTRO);
200
+ break ;
201
+ case EVENT_ACTIVATE_1:
202
+ me->SetReactState (REACT_AGGRESSIVE);
203
+ me->RemoveUnitFlag (UNIT_FLAG_UNINTERACTIBLE);
204
+ events.ScheduleEvent (EVENT_ACTIVATE_2, 4s);
205
+ break ;
206
+ case EVENT_ACTIVATE_2:
207
+ Talk (SAY_AGGRO);
208
+ me->GetMotionMaster ()->MovePath (PATH_ROOM, false );
209
+ break ;
210
+ default :
211
+ break ;
212
+ }
139
213
}
140
214
}
141
215
};
@@ -154,10 +228,10 @@ struct BroggokPrisionersAI : public ScriptedAI
154
228
void Reset () override
155
229
{
156
230
scheduler.CancelAll ();
157
- scheduler.Schedule (1s, 5s, [this ](TaskContext emote )
231
+ scheduler.Schedule (1s, 5s, [this ](TaskContext task )
158
232
{
159
233
me->HandleEmoteCommand (Trinity::Containers::SelectRandomContainerElement (PrisionersEmotes));
160
- emote .Repeat (6s, 9s);
234
+ task .Repeat (6s, 9s);
161
235
});
162
236
}
163
237
@@ -202,17 +276,18 @@ struct npc_nascent_fel_orc : public BroggokPrisionersAI
202
276
203
277
void ScheduleEvents () override
204
278
{
205
- scheduler.Schedule (15s, [this ](TaskContext concussionBlow)
206
- {
207
- DoCastVictim (SPELL_CONCUSSION_BLOW);
208
- concussionBlow.Repeat (8s, 11s);
209
- }).Schedule (7s, [this ](TaskContext stomp)
210
- {
211
- DoCastVictim (SPELL_STOMP);
212
- stomp.Repeat (16s, 21s);
213
- });
279
+ scheduler
280
+ .Schedule (15s, [this ](TaskContext task)
281
+ {
282
+ DoCastVictim (SPELL_CONCUSSION_BLOW);
283
+ task.Repeat (8s, 11s);
284
+ })
285
+ .Schedule (7s, [this ](TaskContext task)
286
+ {
287
+ DoCastSelf (SPELL_STOMP);
288
+ task.Repeat (16s, 21s);
289
+ });
214
290
}
215
-
216
291
};
217
292
218
293
// 17429 - Fel Orc Neophyte
@@ -222,17 +297,19 @@ struct npc_fel_orc_neophyte : public BroggokPrisionersAI
222
297
223
298
void ScheduleEvents () override
224
299
{
225
- scheduler.Schedule (5s, [this ](TaskContext charge)
226
- {
227
- DoCastVictim (SPELL_CHARGE);
228
- charge.Repeat (20s);
229
- }).Schedule (1s, [this ](TaskContext frenzy)
230
- {
231
- DoCastSelf (SPELL_FRENZY);
232
- frenzy.Repeat (12s, 13s);
233
- });
300
+ scheduler
301
+ .Schedule (5s, [this ](TaskContext task)
302
+ {
303
+ if (Unit* target = SelectTarget (SelectTargetMethod::Random, 0 ))
304
+ DoCast (target, SPELL_CHARGE);
305
+ task.Repeat (20s);
306
+ })
307
+ .Schedule (1s, [this ](TaskContext task)
308
+ {
309
+ DoCastSelf (SPELL_FRENZY);
310
+ task.Repeat (12s, 13s);
311
+ });
234
312
}
235
-
236
313
};
237
314
238
315
// 181982 - Cell Door Lever
0 commit comments