TrinityCore
boss_trollgore.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 "drak_tharon_keep.h"
20#include "InstanceScript.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "ScriptedCreature.h"
24#include "SpellAuraEffects.h"
25#include "SpellScript.h"
26
28{
30 SPELL_CRUSH = 49639,
36
39 SPELL_SUMMON_INVADER_C = 49458, // can't find any sniffs
40
42};
43
44#define SPELL_CONSUME_BUFF_HELPER DUNGEON_MODE<uint32>(SPELL_CONSUME_BUFF, SPELL_CONSUME_BUFF_H)
45
47{
52 SAY_DEATH = 4
53};
54
55enum Misc
56{
59};
60
62{
68};
69
70Position const Landing = { -263.0534f, -660.8658f, 26.50903f, 0.0f };
71
72struct boss_trollgore : public BossAI
73{
75 {
76 Initialize();
77 }
78
80 {
82 }
83
84 void Reset() override
85 {
86 _Reset();
87 Initialize();
88 }
89
90 void JustEngagedWith(Unit* who) override
91 {
94
100 }
101
102 void UpdateAI(uint32 diff) override
103 {
104 if (!UpdateVictim())
105 return;
106
107 events.Update(diff);
108
110 return;
111
112 while (uint32 eventId = events.ExecuteEvent())
113 {
114 switch (eventId)
115 {
116 case EVENT_CONSUME:
120 break;
121 case EVENT_CRUSH:
124 break;
128 break;
133 break;
134 case EVENT_SPAWN:
135 for (uint8 i = 0; i < 3; ++i)
138 .SetOriginalCaster(me->GetGUID()));
139
141 break;
142 default:
143 break;
144 }
145
147 return;
148 }
149
151 {
152 Aura* ConsumeAura = me->GetAura(SPELL_CONSUME_BUFF_HELPER);
153 if (ConsumeAura && ConsumeAura->GetStackAmount() > 9)
154 _consumptionJunction = false;
155 }
156 }
157
158 void JustDied(Unit* /*killer*/) override
159 {
160 _JustDied();
162 }
163
164 uint32 GetData(uint32 type) const override
165 {
166 if (type == DATA_CONSUMPTION_JUNCTION)
167 return _consumptionJunction ? 1 : 0;
168
169 return 0;
170 }
171
172 void KilledUnit(Unit* victim) override
173 {
174 if (victim->GetTypeId() != TYPEID_PLAYER)
175 return;
176
177 Talk(SAY_KILL);
178 }
179
180 void JustSummoned(Creature* summon) override
181 {
183 summons.Summon(summon);
184 }
185
186 private:
188};
189
191{
192 npc_drakkari_invader(Creature* creature) : ScriptedAI(creature) { }
193
194 void MovementInform(uint32 type, uint32 pointId) override
195 {
196 if (type == POINT_MOTION_TYPE && pointId == POINT_LANDING)
197 {
198 me->Dismount();
199 me->SetImmuneToAll(false);
201 }
202 }
203};
204
205// 49380, 59803 - Consume
207{
208 bool Validate(SpellInfo const* /*spellInfo*/) override
209 {
211 }
212
213 void HandleConsume(SpellEffIndex /*effIndex*/)
214 {
215 if (Unit* target = GetHitUnit())
216 target->CastSpell(GetCaster(), SPELL_CONSUME_BUFF, true);
217 }
218
219 void Register() override
220 {
222 }
223};
224
225// 49555, 59807 - Corpse Explode
227{
228 bool Validate(SpellInfo const* /*spellInfo*/) override
229 {
231 }
232
233 void PeriodicTick(AuraEffect const* aurEff)
234 {
235 if (aurEff->GetTickNumber() == 2)
236 if (Unit* caster = GetCaster())
237 caster->CastSpell(GetTarget(), SPELL_CORPSE_EXPLODE_DAMAGE, aurEff);
238 }
239
240 void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
241 {
242 if (Creature* target = GetTarget()->ToCreature())
243 target->DespawnOrUnsummon();
244 }
245
246 void Register() override
247 {
250 }
251};
252
253// 49405 - Invader Taunt Trigger
255{
256 bool Validate(SpellInfo const* spellInfo) override
257 {
258 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
259 }
260
261 void HandleTaunt(SpellEffIndex /*effIndex*/)
262 {
263 if (Unit* target = GetHitUnit())
264 target->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
265 }
266
267 void Register() override
268 {
270 }
271};
272
274{
275 public:
276 achievement_consumption_junction() : AchievementCriteriaScript("achievement_consumption_junction")
277 {
278 }
279
280 bool OnCheck(Player* /*player*/, Unit* target) override
281 {
282 if (!target)
283 return false;
284
285 if (Creature* Trollgore = target->ToCreature())
286 if (Trollgore->AI()->GetData(DATA_CONSUMPTION_JUNCTION))
287 return true;
288
289 return false;
290 }
291};
292
294{
301}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_DUMMY
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ DATA_CONSUMPTION_JUNCTION
@ POINT_LANDING
@ SAY_DEATH
@ SAY_CONSUME
@ SAY_AGGRO
@ SAY_EXPLODE
@ SAY_KILL
@ SPELL_CONSUME
@ SPELL_CORPSE_EXPLODE
@ SPELL_SUMMON_INVADER_C
@ SPELL_CONSUME_BUFF_H
@ SPELL_SUMMON_INVADER_A
@ SPELL_CONSUME_BUFF
@ SPELL_INVADER_TAUNT
@ SPELL_CORPSE_EXPLODE_DAMAGE
@ SPELL_INFECTED_WOUND
@ SPELL_SUMMON_INVADER_B
@ SPELL_CRUSH
void AddSC_boss_trollgore()
#define SPELL_CONSUME_BUFF_HELPER
Position const Landing
@ EVENT_INFECTED_WOUND
@ EVENT_SPAWN
@ EVENT_CONSUME
@ EVENT_CORPSE_EXPLODE
@ EVENT_CRUSH
Yells
uint32 GetTickNumber() const
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetCaster() const
Unit * GetTarget() const
uint8 GetStackAmount() const
Definition: SpellAuras.h:189
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetImmuneToAll(bool apply) override
Definition: Creature.h:167
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
virtual ObjectGuid GetGuidData(uint32 type) const override
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
uint32 const Id
Definition: SpellInfo.h:325
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Definition: SpellScript.h:173
Unit * GetCaster() const
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
void Summon(Creature const *summon)
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void Dismount()
Definition: Unit.cpp:7920
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4560
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool OnCheck(Player *, Unit *target) override
bool Validate(SpellInfo const *) override
void HandleConsume(SpellEffIndex)
void HandleRemove(AuraEffect const *, AuraEffectHandleModes)
void PeriodicTick(AuraEffect const *aurEff)
bool Validate(SpellInfo const *) override
void HandleTaunt(SpellEffIndex)
bool Validate(SpellInfo const *spellInfo) override
#define RegisterDrakTharonKeepCreatureAI(ai_name)
@ DATA_TROLLGORE_INVADER_SUMMONER_1
@ DATA_TROLLGORE
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
uint32 GetData(uint32 type) const override
boss_trollgore(Creature *creature)
void UpdateAI(uint32 diff) override
void JustSummoned(Creature *summon) override
void JustDied(Unit *) override
void KilledUnit(Unit *victim) override
void JustEngagedWith(Unit *who) override
void Reset() override
void MovementInform(uint32 type, uint32 pointId) override
npc_drakkari_invader(Creature *creature)