TrinityCore
Loading...
Searching...
No Matches
boss_the_beast.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#include "ScriptMgr.h"
19#include "blackrock_spire.h"
20#include "InstanceScript.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26
38
48
59
60Position const OrcsRunawayPosition = { 34.163567f, -536.852356f, 110.935196f, 6.056306f };
61
63{
64public:
65 OrcDeathEvent(Creature* me) : _me(me) { }
66
67 bool Execute(uint64 /*time*/, uint32 /*diff*/) override
68 {
70 return true;
71 }
72
73private:
75};
76
77struct boss_the_beast : public BossAI
78{
79 boss_the_beast(Creature* creature) : BossAI(creature, DATA_THE_BEAST), _beastReached(false), _orcYelled(false) { }
80
81 void Reset() override
82 {
83 _Reset();
84 if (_beastReached)
86 }
87
88 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
89 {
90 if (spellInfo->HasEffect(SPELL_EFFECT_SKINNING))
91 if (!me->IsAlive()) // can that even happen?
93 }
94
95 void SetData(uint32 type, uint32 /*data*/) override
96 {
97 switch (type)
98 {
99 case DATA_BEAST_ROOM:
100 {
101 if (!_orcYelled)
102 {
103 if (_nearbyOrcsGUIDs.empty())
105
107 if (_nearbyOrcsGUIDs.empty())
108 return;
109
110 _orcYelled = true;
111
112 // we only need one orc to say the line
114 orc->AI()->Talk(SAY_BLACKHAND_DOOMED);
115 }
116 break;
117 }
119 {
120 if (!_beastReached)
121 {
122 _beastReached = true;
124
125 if (_nearbyOrcsGUIDs.empty())
127
128 for (ObjectGuid guid : _nearbyOrcsGUIDs)
129 {
130 if (Creature* orc = ObjectAccessor::GetCreature(*me, guid))
131 {
132 orc->GetMotionMaster()->MovePoint(1, orc->GetRandomPoint(OrcsRunawayPosition, 5.0f));
133 orc->m_Events.AddEvent(new OrcDeathEvent(orc), me->m_Events.CalculateTime(6s));
134 orc->SetReactState(REACT_PASSIVE);
135 }
136 }
137 // There is a chance player logged in between areatriggers (realm crash or restart)
138 // executing part of script which happens when player enters boss room
139 // otherwise we will see weird behaviour when someone steps on the previous areatrigger (dead mob yelling/moving)
141 }
142 break;
143 }
144 }
145 }
146
157
158 void UpdateAI(uint32 diff) override
159 {
160 if (!UpdateVictim())
161 return;
162
163 events.Update(diff);
164
166 return;
167
168 while (uint32 eventId = events.ExecuteEvent())
169 {
170 switch (eventId)
171 {
174 events.Repeat(Seconds(10));
175 break;
176 case EVENT_IMMOLATE:
177 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.f, true))
178 DoCast(target, SPELL_IMMOLATE);
180 break;
183 events.Repeat(Seconds(20));
184 break;
186 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 38.f, true))
188 events.Repeat(Seconds(15), Seconds(23));
189 break;
190 case EVENT_FIREBALL:
192 events.Repeat(Seconds(8), Seconds(21));
193 break;
194 case EVENT_FIREBLAST:
197 break;
198 }
199
201 return;
202 }
204 }
205
207 {
208 std::vector<Creature*> temp;
210
211 for (Creature* creature : temp)
212 _nearbyOrcsGUIDs.push_back(creature->GetGUID());
213 }
214
215private:
219};
220
223{
224public:
225 at_trigger_the_beast_movement() : AreaTriggerScript("at_trigger_the_beast_movement") { }
226
227 bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) override
228 {
229 if (player->IsGameMaster())
230 return false;
231
232 if (InstanceScript* instance = player->GetInstanceScript())
233 {
234 if (Creature* beast = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_THE_BEAST)))
235 beast->AI()->SetData(DATA_BEAST_REACHED, DATA_BEAST_REACHED);
236 return true;
237 }
238 return false;
239 }
240};
241
243{
244public:
245 at_the_beast_room() : AreaTriggerScript("at_the_beast_room") { }
246
247 bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) override
248 {
249 if (player->IsGameMaster())
250 return false;
251
252 if (InstanceScript* instance = player->GetInstanceScript())
253 {
254 if (Creature* beast = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_THE_BEAST)))
255 beast->AI()->SetData(DATA_BEAST_ROOM, DATA_BEAST_ROOM);
256 return true;
257 }
258 return false;
259 }
260};
261
uint64_t uint64
Definition Define.h:132
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:262
@ SPELL_EFFECT_SKINNING
@ REACT_PASSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:235
#define RegisterBlackrockSpireCreatureAI(ai_name)
@ DATA_THE_BEAST
BeastSpells
@ SPELL_FIREBLAST
@ SPELL_FINKLE_IS_EINHORN
@ SPELL_FLAMEBREAK
@ SPELL_FIREBALL
@ SPELL_SUICIDE
@ SPELL_IMMOLATE
@ SPELL_TERRIFYINGROAR
@ SPELL_BERSERKER_CHARGE
BeastMisc
@ BEAST_MOVEMENT_ID
@ DATA_BEAST_ROOM
@ DATA_BEAST_REACHED
@ NPC_BLACKHAND_ELITE
@ SAY_BLACKHAND_DOOMED
BeastEvents
@ EVENT_IMMOLATE
@ EVENT_FIREBALL
@ EVENT_FIREBLAST
@ EVENT_BERSERKER_CHARGE
@ EVENT_FLAME_BREAK
@ EVENT_TERRIFYING_ROAR
void AddSC_boss_thebeast()
Position const OrcsRunawayPosition
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Milliseconds CalculateTime(Milliseconds t_offset) const
void MovePath(uint32 pathId, bool repeatable)
bool Execute(uint64, uint32) override
OrcDeathEvent(Creature *me)
bool IsGameMaster() const
Definition Player.h:998
bool HasEffect(SpellEffects effect) const
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:3153
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
EventProcessor m_Events
Definition Object.h:591
bool OnTrigger(Player *player, const AreaTriggerEntry *) override
The beast room areatrigger, this one triggers boss pathing. (AT Id 2066)
bool OnTrigger(Player *player, const AreaTriggerEntry *) override
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void JustEngagedWith(Unit *who) override
GuidVector _nearbyOrcsGUIDs
void Reset() override
void SetData(uint32 type, uint32) override
boss_the_beast(Creature *creature)
void UpdateAI(uint32 diff) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override