TrinityCore
boss_apothecary_hummel.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"
20#include "GridNotifiersImpl.h"
21#include "Group.h"
22#include "InstanceScript.h"
23#include "LFGMgr.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "Player.h"
27#include "ScriptedCreature.h"
28#include "ScriptedGossip.h"
29#include "shadowfang_keep.h"
30#include "SpellScript.h"
31
33{
49};
50
52{
62};
63
65{
75};
76
78{
89 PHASE_INTRO = 1
90};
91
92Position const BaxterMovePos = { -221.4115f, 2206.825f, 79.93151f, 0.0f };
93Position const FryeMovePos = { -196.2483f, 2197.224f, 79.9315f, 0.0f };
94
96{
98
99 bool OnGossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
100 {
101 if (menuId == GOSSIP_MENU_HUMMEL && gossipListId == GOSSIP_OPTION_START)
102 {
104 CloseGossipMenuFor(player);
106 }
107 return false;
108 }
109
110 void Reset() override
111 {
112 _Reset();
113 _deadCount = 0;
114 _isDead = false;
118 }
119
120 void EnterEvadeMode(EvadeReason /*why*/) override
121 {
125 }
126
127 void DoAction(int32 action) override
128 {
130 {
133
134 me->SetImmuneToPC(true);
138 }
139 }
140
141 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
142 {
143 if (damage >= me->GetHealth())
144 if (_deadCount < 2)
145 {
146 damage = me->GetHealth() - 1;
147 if (!_isDead)
148 {
149 _isDead = true;
152 me->SetUninteractible(true);
154 }
155 }
156 }
157
158 void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
159 {
160 if (summon->GetEntry() == NPC_APOTHECARY_FRYE || summon->GetEntry() == NPC_APOTHECARY_BAXTER)
161 _deadCount++;
162
165 }
166
167 void JustDied(Unit* /*killer*/) override
168 {
169 if (!_isDead)
171
172 events.Reset();
173 me->SetUninteractible(false);
175
176 Map::PlayerList const& players = me->GetMap()->GetPlayers();
177 if (!players.isEmpty())
178 {
179 if (Group* group = players.begin()->GetSource()->GetGroup())
180 if (group->isLFGGroup())
181 sLFGMgr->FinishDungeon(group->GetGUID(), 288, me->GetMap());
182 }
183 }
184
185 void UpdateAI(uint32 diff) override
186 {
188 return;
189
190 events.Update(diff);
191
193 return;
194
195 while (uint32 eventId = events.ExecuteEvent())
196 {
197 switch (eventId)
198 {
202 break;
206 break;
210 break;
212 {
213 me->SetImmuneToAll(false);
219
221 std::vector<Creature*> trashs;
223 for (Creature* crea : trashs)
224 crea->DespawnOrUnsummon();
225
226 break;
227 }
229 {
234 break;
235 }
236 case EVENT_CALL_FRYE:
237 {
241 break;
242 }
246 break;
250 events.Repeat(Seconds(25));
251 break;
252 default:
253 break;
254 }
255
257 return;
258 }
259 }
260
261 void OnQuestReward(Player* /*player*/, Quest const* quest, LootItemType /*type*/, uint32 /*opt*/) override
262 {
263 if (quest->GetQuestId() == QUEST_YOUVE_BEEN_SERVED)
265 }
266
267 private:
270};
271
273{
274 npc_apothecary_genericAI(Creature* creature, Position pos) : ScriptedAI(creature), _movePos(pos) { }
275
276 void DoAction(int32 action) override
277 {
278 if (action == ACTION_START_EVENT)
279 {
280 me->SetImmuneToPC(true);
283 }
284 else if (action == ACTION_START_FIGHT)
285 {
286 me->SetImmuneToAll(false);
288 }
289 }
290
291 void MovementInform(uint32 type, uint32 pointId) override
292 {
293 if (type == POINT_MOTION_TYPE && pointId == 1)
295 }
296
297protected:
299};
300
302{
304
305 void JustDied(Unit* /*killer*/) override
306 {
308 }
309};
310
312{
314
315 void Reset() override
316 {
317 _events.Reset();
320 }
321
322 void JustDied(Unit* /*killer*/) override
323 {
324 _events.Reset();
326 }
327
328 void UpdateAI(uint32 diff) override
329 {
330 if (!UpdateVictim())
331 return;
332
333 _events.Update(diff);
334
336 return;
337
338 while (uint32 eventId = _events.ExecuteEvent())
339 {
340 switch (eventId)
341 {
345 break;
350 break;
351 default:
352 break;
353 }
354 }
355 }
356
357private:
359};
360
361// 68965 - [DND] Lingering Fumes Targetting (starter)
363{
365 {
366 Unit* caster = GetCaster();
367 if (!caster->IsInCombat() || roll_chance_i(50))
368 return;
369
370 std::list<Creature*> triggers;
371 caster->GetCreatureListWithEntryInGrid(triggers, NPC_VIAL_BUNNY, 100.0f);
372 if (triggers.empty())
373 return;
374
376 caster->GetMotionMaster()->MovePoint(0, trigger->GetPosition());
377
378 }
379
380 void HandleScript(SpellEffIndex /*effindex*/)
381 {
382 Unit* caster = GetCaster();
383 caster->CastSpell(GetHitUnit(), SPELL_VALIDATE_AREA, true);
384 }
385
386 void Register() override
387 {
390 }
391};
392
393// 68644 - [DND] Valentine Boss Validate Area
395{
396 void FilterTargets(std::list<WorldObject*>& targets)
397 {
398 targets.remove_if(Trinity::UnitAuraCheck(true, SPELL_BUNNY_LOCKDOWN));
399 if (targets.empty())
400 return;
401
403 targets.clear();
404 targets.push_back(target);
405 }
406
407 void HandleScript(SpellEffIndex /*effindex*/)
408 {
411 }
412
413 void Register() override
414 {
417 }
418};
419
420// 69038 - Throw Cologne
422{
423 void HandleScript(SpellEffIndex /*effindex*/)
424 {
426 }
427
428 void Register() override
429 {
431 }
432};
433
434// 68966 - Throw Perfume
436{
437 void HandleScript(SpellEffIndex /*effindex*/)
438 {
440 }
441
442 void Register() override
443 {
445 }
446};
447
448// 68798 - Concentrated Alluring Perfume Spill
450{
451 void OnPeriodic(AuraEffect const* /*aurEff*/)
452 {
454 }
455
456 void Register() override
457 {
459 }
460};
461
462// 68614 - Concentrated Irresistible Cologne Spill
464{
465 void OnPeriodic(AuraEffect const* /*aurEff*/)
466 {
468 }
469
470 void Register() override
471 {
473 }
474};
475
477{
487}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ DONE
#define sLFGMgr
Definition: LFGMgr.h:507
LootItemType
Definition: LootItemType.h:24
@ POINT_MOTION_TYPE
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
void CloseGossipMenuFor(Player *player)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_DEST_AREA_ENTRY
@ EMOTE_STATE_USE_STANDING
@ SPELL_EFFECT_DUMMY
@ FACTION_FRIENDLY
@ FACTION_MONSTER
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define SpellCastFn(F)
Definition: SpellScript.h:825
EvadeReason
Definition: UnitAICommon.h:30
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:297
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ QUEST_YOUVE_BEEN_SERVED
@ GOSSIP_OPTION_START
@ ACTION_START_EVENT
@ NPC_CROWN_APOTHECARY
@ NPC_APOTHECARY_BAXTER
@ GOSSIP_MENU_HUMMEL
@ ACTION_START_FIGHT
@ NPC_APOTHECARY_FRYE
@ SPELL_COLOGNE_SPILL_DAMAGE
@ SPELL_COLOGNE_SPRAY
@ SPELL_SUMMON_TABLE
@ SPELL_PERFUME_SPRAY
@ SPELL_THROW_PERFUME
@ SPELL_VALIDATE_AREA
@ SPELL_ALLURING_PERFUME
@ SPELL_COLOGNE_SPILL
@ SPELL_PERFUME_SPILL_DAMAGE
@ SPELL_CHAIN_REACTION
@ SPELL_BUNNY_LOCKDOWN
@ SPELL_QUIET_SUICIDE
@ SPELL_THROW_COLOGNE
@ SPELL_PERMANENT_FEIGN_DEATH
@ SPELL_PERFUME_SPILL
@ EVENT_HUMMEL_SAY_1
@ EVENT_COLOGNE_SPRAY
@ EVENT_START_FIGHT
@ EVENT_CHAIN_REACTION
@ EVENT_PERFUME_SPRAY
@ EVENT_HUMMEL_SAY_0
@ EVENT_CALL_BAXTER
@ EVENT_HUMMEL_SAY_2
Position const FryeMovePos
@ SAY_BAXTER_DEATH
@ SAY_HUMMEL_DEATH
Position const BaxterMovePos
void AddSC_boss_apothecary_hummel()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetTarget() const
InstanceScript *const instance
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetImmuneToPC(bool apply) override
Definition: Creature.h:170
void SetImmuneToAll(bool apply) override
Definition: Creature.h:167
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void Reset()
Definition: EventMap.cpp:21
Definition: Group.h:197
virtual bool SetBossState(uint32 id, EncounterState state)
bool isEmpty() const
Definition: LinkedList.h:110
iterator begin()
Definition: MapRefManager.h:34
PlayerList const & GetPlayers() const
Definition: Map.h:367
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
uint32 GetEntry() const
Definition: Object.h:161
Group * GetGroup(Optional< uint8 > partyIndex)
Definition: Player.h:2606
uint32 GetQuestId() const
Definition: QuestDef.h:587
FROM * GetSource() const
Definition: Reference.h:96
HookList< CastHandler > AfterCast
Definition: SpellScript.h:824
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
void DoZoneInCombat(uint32 entry=0)
void DoAction(int32 info, Predicate &&predicate, uint16 max=0)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
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
void SetFaction(uint32 faction) override
Definition: Unit.h:859
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void RemoveNpcFlag(NPCFlags flags)
Definition: Unit.h:983
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
void SetEmoteState(Emote emote)
Definition: Unit.h:852
uint64 GetHealth() const
Definition: Unit.h:776
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
bool IsInCombat() const
Definition: Unit.h:1043
Map * GetMap() const
Definition: Object.h:624
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition: Object.cpp:3312
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition: Object.cpp:2131
void FilterTargets(std::list< WorldObject * > &targets)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109
@ BOSS_APOTHECARY_HUMMEL
#define RegisterShadowfangKeepCreatureAI(ai_name)
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
void OnQuestReward(Player *, Quest const *quest, LootItemType, uint32) override
void SummonedCreatureDies(Creature *summon, Unit *) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_apothecary_hummel(Creature *creature)
void EnterEvadeMode(EvadeReason) override
bool OnGossipSelect(Player *player, uint32 menuId, uint32 gossipListId) override
void DoAction(int32 action) override
npc_apothecary_baxter(Creature *creature)
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
npc_apothecary_frye(Creature *creature)
void JustDied(Unit *) override
void DoAction(int32 action) override
void MovementInform(uint32 type, uint32 pointId) override
npc_apothecary_genericAI(Creature *creature, Position pos)