TrinityCore
Loading...
Searching...
No Matches
boss_broggok.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "blood_furnace.h"
24#include "GameObject.h"
25#include "GameObjectAI.h"
26#include "InstanceScript.h"
27#include "MotionMaster.h"
28#include "ScriptedCreature.h"
29#include "SpellAuraEffects.h"
30#include "SpellScript.h"
31
39
41{
42 // Broggok - Combat
46
47 // Broggok - Misc
50
51 // Nascent Fel Orc
53 SPELL_STOMP = 31900,
54
55 // Fel Orc Neophyte
56 SPELL_CHARGE = 22120,
57 SPELL_FRENZY = 8269
58};
59
72
74{
75 PATH_ROOM = 1381150
76};
77
78// 17380 - Broggok
79struct boss_broggok : public BossAI
80{
81 boss_broggok(Creature* creature) : BossAI(creature, DATA_BROGGOK) { }
82
83 void JustAppeared() override
84 {
85 me->SetUninteractible(true);
87 }
88
99
100 // Do nothing, don't store summons, don't despawn them in case of wipe or death - correct behavior
101 void JustSummoned(Creature* /*summoned*/) override { }
102
103 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
104 {
106 }
107
108 void DoAction(int32 action) override
109 {
110 switch (action)
111 {
114 break;
117 break;
120 break;
121 default:
122 break;
123 }
124 }
125
127 {
128 events.Update(diff);
129
130 while (uint32 eventId = events.ExecuteEvent())
131 {
132 switch (eventId)
133 {
134 case EVENT_INTRO_1:
137 break;
138 case EVENT_INTRO_2:
140 break;
141
142 case EVENT_RELEASE_1:
144 me->SetUninteractible(false);
146 break;
147 case EVENT_RELEASE_2:
150 break;
151 default:
152 break;
153 }
154 }
155 }
156
157 void UpdateAI(uint32 diff) override
158 {
159 if (!UpdateVictim())
160 {
162 return;
163 }
164
165 events.Update(diff);
166
168 return;
169
170 while (uint32 eventId = events.ExecuteEvent())
171 {
172 switch (eventId)
173 {
176 events.Repeat(10s, 15s);
177 break;
180 events.Repeat(10s, 15s);
181 break;
184 events.Repeat(10s, 25s);
185 break;
186 default:
187 break;
188 }
189
191 return;
192 }
193 }
194};
195
197{
198 BroggokPrisionerBaseAI(Creature* creature) : ScriptedAI(creature), Instance(creature->GetInstanceScript()) { }
199
200 void JustAppeared() override
201 {
202 if (IsHighCellPrisoner())
203 {
204 me->SetUninteractible(true);
206 me->SetImmuneToNPC(true);
207 }
208 else if (IsCellPrisoner())
209 {
210 me->SetUninteractible(true);
213 }
214 }
215
216 void Reset() override
217 {
219 }
220
221 void JustEngagedWith(Unit* /*who*/) override
222 {
223 if (IsCellPrisoner())
225
227
228 if (roll_chance(15))
230 }
231
233 {
234 return me->HasStringId("BroggokPrisonerHighCell");
235 }
236
238 {
239 return me->HasStringId("BroggokPrisonerCell1") || me->HasStringId("BroggokPrisonerCell2") || me->HasStringId("BroggokPrisonerCell3") || me->HasStringId("BroggokPrisonerCell4");
240 }
241
242 void DoAction(int32 action) override
243 {
244 if (action == ACTION_PRISONER_ENGAGE)
245 {
246 me->SetUninteractible(false);
249 }
250 }
251
253 {
254 // Timer is random but all prisoners from the same cell plays emote at the same time,
255 // meaning they are in same spawn group and event is linked to all spawn group members.
256 // We can't support that for now in an easy way
257 Scheduler.Schedule(6s, 12s, [this](TaskContext& task)
258 {
259 switch (task.GetRepeatCounter() % 3)
260 {
261 case 0:
262 me->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT);
263 break;
264 case 1:
265 me->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
266 break;
267 case 2:
268 me->HandleEmoteCommand(EMOTE_ONESHOT_BATTLE_ROAR);
269 break;
270 default:
271 break;
272 }
273
274 task.Repeat(6s, 12s);
275 });
276 }
277
278 virtual void ScheduleEvents() = 0;
279
280 void JustReachedHome() override
281 {
283
284 if (!IsCellPrisoner())
285 return;
286
288
289 // This is not correct in case of wipe. Flags aren't set back. We do it for safety reasons
290 me->SetUninteractible(true);
293 }
294
295 void UpdateAI(uint32 diff) override
296 {
297 Scheduler.Update(diff);
298
299 if (!UpdateVictim())
300 return;
301 }
302
303protected:
306};
307
308// 17398 - Nascent Fel Orc
310{
312
313 void ScheduleEvents() override
314 {
316 .Schedule(5s, 15s, [this](TaskContext& task)
317 {
319 task.Repeat(20s, 30s);
320 })
321 .Schedule(0s, 10s, [this](TaskContext& task)
322 {
324 task.Repeat(10s, 20s);
325 });
326 }
327};
328
329// 17429 - Fel Orc Neophyte
331{
333
334 void ScheduleEvents() override
335 {
337 .Schedule(5s, 10s, [this](TaskContext& task)
338 {
340 DoCast(target, SPELL_CHARGE);
341 task.Repeat(20s, 30s);
342 })
343 .Schedule(0s, 10s, [this](TaskContext& task)
344 {
346 task.Repeat(120s);
347 });
348 }
349};
350
351// 181982 - Cell Door Lever
353{
354 go_broggok_lever(GameObject* go) : GameObjectAI(go), _instance(go->GetInstanceScript()) { }
355
356 bool OnGossipHello(Player* /*player*/) override
357 {
360
362
363 return false;
364 }
365
366private:
368};
369
370// 30914, 38462 - Poison
372{
373 bool Validate(SpellInfo const* spellInfo) override
374 {
375 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
376 }
377
378 void OnPeriodic(AuraEffect const* aurEff)
379 {
381 if (!aurEff->GetTotalTicks())
382 return;
383
384 uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
385 float mod = ((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 2 / 3;
386 GetTarget()->CastSpell(nullptr, triggerSpell, CastSpellExtraArgs(aurEff).AddSpellMod(SPELLVALUE_RADIUS_MOD, mod));
387 }
388
393};
394
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ IN_PROGRESS
@ FAIL
@ DONE
bool roll_chance(float chance, PseudoRandomDistributionState &state)
Definition Random.cpp:131
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_0
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ SPELLVALUE_RADIUS_MOD
#define AuraEffectPeriodicFn(F, I, N)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:290
#define RegisterBloodFurnaceCreatureAI(ai_name)
#define RegisterBloodFurnaceGameObjectAI(ai_name)
@ DATA_BROGGOK
@ DATA_PRISONERS_EVENT
@ ACTION_PERFORM_INTRO
@ ACTION_DESPAWN_TRIGGER
@ ACTION_PRISONER_ENGAGE
@ ACTION_RELEASE_BROGGOK
BroggokSpells
@ SPELL_STOMP
@ SPELL_CONCUSSION_BLOW
@ SPELL_CHARGE
@ SPELL_DESPAWN_INCOMBAT_TRIGGER
@ SPELL_POISON_BOLT
@ SPELL_SUMMON_INCOMBAT_TRIGGER
@ SPELL_SLIME_SPRAY
@ SPELL_FRENZY
@ SPELL_POISON_CLOUD
void AddSC_boss_broggok()
BroggokMisc
@ PATH_ROOM
BroggokTexts
@ SAY_AGGRO
@ SAY_PRISONER_AGGRO
@ SAY_INTRO
BroggokEvents
@ EVENT_POISON_CLOUD
@ EVENT_INTRO_1
@ EVENT_RELEASE_2
@ EVENT_INTRO_2
@ EVENT_SLIME_SPRAY
@ EVENT_POISON_BOLT
@ EVENT_RELEASE_1
uint32 GetTickNumber() const
SpellEffectInfo const & GetSpellEffectInfo() const
uint32 GetTotalTicks() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
virtual void JustReachedHome()
Definition CreatureAI.h:167
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
bool HasStringId(std::string_view id) const
void SetImmuneToNPC(bool apply) override
Definition Creature.h:193
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
GameObject *const me
void ActivateObject(GameObjectActions action, int32 param, WorldObject *spellCaster=nullptr, uint32 spellId=0, int32 effectIndex=-1)
EncounterState GetBossState(uint32 id) const
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 TriggerSpell
Definition SpellInfo.h:234
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:590
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
TaskScheduler::repeated_t GetRepeatCounter() const
Returns the repeat counter which increases every time the task is repeated.
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
void SetUninteractible(bool apply)
Definition Unit.cpp:8583
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
bool Validate(SpellInfo const *spellInfo) override
void OnPeriodic(AuraEffect const *aurEff)
virtual void ScheduleEvents()=0
void JustAppeared() override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
BroggokPrisionerBaseAI(Creature *creature)
void JustReachedHome() override
void DoAction(int32 action) override
InstanceScript * Instance
void WaypointPathEnded(uint32, uint32) override
void JustAppeared() override
void UpdateOutOfCombatEvents(uint32 diff)
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void JustSummoned(Creature *) override
boss_broggok(Creature *creature)
void DoAction(int32 action) override
InstanceScript * _instance
go_broggok_lever(GameObject *go)
bool OnGossipHello(Player *) override
void ScheduleEvents() override
void ScheduleEvents() override