TrinityCore
Loading...
Searching...
No Matches
boss_earthrager_ptah.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 "Containers.h"
21#include "InstanceScript.h"
22#include "Map.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26#include "SpellScript.h"
27#include "TemporarySummon.h"
28#include "Weather.h"
29
31{
34};
35
44
46{
50
53
54 SPELL_SUMMON_QUICKSAND = 75550, // Spell not in DBC, no SMSG_SPELL_START/GO for it
55
57
60};
61
70
75
77{
78public:
79 SummonScarab(Unit* owner, InstanceScript* instance) : _owner(owner), _instance(instance) { }
80
81 bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override
82 {
84 return true; // delete event
85
88 return true;
89 }
90protected:
93};
94
96{
98
99 void Cleanup()
100 {
101 std::list<Creature*> units;
102
104 for (std::list<Creature*>::iterator itr = units.begin(); itr != units.end(); ++itr)
105 (*itr)->DespawnOrUnsummon();
106
107 units.clear();
109 for (std::list<Creature*>::iterator itr = units.begin(); itr != units.end(); ++itr)
110 (*itr)->DespawnOrUnsummon();
111 }
112
113 void Reset() override
114 {
115 me->SetCanMelee(true);
116 _summonDeaths = 0;
117 _hasDispersed = false;
118 Cleanup();
119 _Reset();
124 }
125
126 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
127 {
129 {
131 _hasDispersed = true;
132
133 me->AttackStop();
134 me->SetCanMelee(false);
139
140 std::list<Creature*> stalkers;
142 std::list<Creature*> beetlers = stalkers;
143
144 Trinity::Containers::RandomResize(beetlers, 9); // Holds the summoners of Jeweled Scarab
145
146 for (std::list<Creature*>::iterator itr = beetlers.begin(); itr != beetlers.end(); ++itr)
147 {
148 stalkers.remove((*itr)); // Remove it to prevent a single trigger from spawning multiple npcs.
149 (*itr)->CastSpell((*itr), SPELL_BEETLE_BURROW); // Cast visual
150 // Summon after 5 seconds.
151 (*itr)->m_Events.AddEventAtOffset(new SummonScarab((*itr), instance), 5s);
152 }
153
154 Trinity::Containers::RandomResize(stalkers, 2); // Holds the summoners of Dustbone Horror
155
156 for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
157 (*itr)->CastSpell((*itr), SPELL_SUMMON_DUSTBONE_HORROR);
158 }
159 }
160
161 void SetData(uint32 index, uint32 /*value*/) override
162 {
163 if (index == DATA_SUMMON_DEATHS)
164 {
166 if (_summonDeaths == 11) // All summons died
167 {
170 me->SetCanMelee(true);
175 }
176 }
177 }
178
185
186 void JustDied(Unit* /*killer*/) override
187 {
190 _JustDied();
191 Cleanup();
192 }
193
200
201 void UpdateAI(uint32 diff) override
202 {
203 if (!UpdateVictim() || !CheckInRoom())
204 return;
205
206 events.Update(diff);
207
209 return;
210
211 while (uint32 eventId = events.ExecuteEvent())
212 {
213 switch (eventId)
214 {
218 break;
219 case EVENT_FLAME_BOLT:
222 break;
224 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
227 break;
230 break;
231 case EVENT_QUICKSAND:
232 // Spell not in DBC, it is not cast either, according to sniffs
233 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
234 if (Creature* quicksand = me->SummonCreature(NPC_QUICKSAND, *target))
235 quicksand->SetCreatedBySpell(SPELL_SUMMON_QUICKSAND);
237 break;
238 }
239 }
240 }
241
242protected:
245};
246
248{
249 void FilterTargets(std::list<WorldObject*>& targets)
250 {
251 Trinity::Containers::RandomResize(targets, GetCaster()->GetMap()->IsHeroic() ? 3 : 2);
252 }
253
258};
259
261{
262 void SetFlags(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
263 {
264 if (Unit* ptah = GetCaster())
265 {
266 ptah->SetUninteractible(true);
268 ptah->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
269 }
270 }
271
272 void RemoveFlags(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
273 {
274 if (Unit* ptah = GetCaster())
275 {
276 ptah->SetUninteractible(false);
277 ptah->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
278 ptah->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
279 }
280 }
281
287};
288
uint8_t uint8
Definition Define.h:156
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
@ IN_PROGRESS
@ FAIL
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
@ EFFECT_0
@ TARGET_UNIT_SRC_AREA_ENEMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
@ UNIT_FLAG2_FEIGN_DEATH
DamageEffectType
@ UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ DATA_SUMMON_DEATHS
@ SPELL_EARTH_SPIKE_WARN
@ SPELL_SANDSTORM
@ SPELL_SUMMON_QUICKSAND
@ SPELL_SUMMON_JEWELED_SCARAB
@ SPELL_PTAH_EXPLOSION
@ SPELL_RAGING_SMASH
@ SPELL_SUMMON_DUSTBONE_HORROR
@ SPELL_BEETLE_BURROW
@ SPELL_FLAME_BOLT
@ PHASE_MASK_DISPERSE
@ PHASE_MASK_NORMAL
void AddSC_boss_earthrager_ptah()
@ EVENT_EARTH_SPIKE
@ EVENT_FLAME_BOLT
@ EVENT_QUICKSAND
@ EVENT_PTAH_EXPLODE
@ EVENT_RAGING_SMASH
Unit * GetCaster() const
HookList< EffectApplyHandler > OnEffectRemove
HookList< EffectApplyHandler > OnEffectApply
InstanceScript *const instance
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
EventMap events
virtual bool CheckInRoom()
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
uint8 GetPhaseMask() const
Definition EventMap.h:80
void SetPhase(uint8 phase)
Definition EventMap.cpp:32
virtual bool SetBossState(uint32 id, EncounterState state)
EncounterState GetBossState(uint32 id) const
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float intensity)
Definition Map.cpp:4025
Unit * GetCaster() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
bool Execute(uint64, uint32) override
SummonScarab(Unit *owner, InstanceScript *instance)
InstanceScript * _instance
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:79
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool AttackStop()
Definition Unit.cpp:5965
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
Map * GetMap() const
Definition Object.h:411
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1398
void RemoveFlags(AuraEffect const *, AuraEffectHandleModes)
void SetFlags(AuraEffect const *, AuraEffectHandleModes)
void FilterTargets(std::list< WorldObject * > &targets)
@ WEATHER_STATE_LIGHT_SANDSTORM
Definition Weather.h:56
@ WEATHER_STATE_FOG
Definition Weather.h:48
#define RegisterHallsOfOriginationCreatureAI(ai_name)
@ NPC_BEETLE_STALKER
@ NPC_JEWELED_SCARAB
@ NPC_DUSTBONE_HORROR
@ NPC_QUICKSAND
@ BOSS_EARTHRAGER_PTAH
@ AREA_TOMB_OF_THE_EARTHRAGER
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
void JustDied(Unit *) override
boss_earthrager_ptah(Creature *creature)
void UpdateAI(uint32 diff) override
void SetData(uint32 index, uint32) override
void JustEngagedWith(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override