TrinityCore
Loading...
Searching...
No Matches
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
50
63
76
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
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.empty())
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
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(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
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
412
418};
419
420// 69038 - Throw Cologne
433
434// 68966 - Throw Perfume
447
448// 68798 - Concentrated Alluring Perfume Spill
461
462// 68614 - Concentrated Irresistible Cologne Spill
475
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
@ DONE
#define sLFGMgr
Definition LFGMgr.h:515
LootItemType
@ POINT_MOTION_TYPE
bool roll_chance(T chance)
Definition Random.h:55
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void CloseGossipMenuFor(Player *player)
SpellEffIndex
@ EFFECT_0
@ 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)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
EvadeReason
@ UNIT_NPC_FLAG_GOSSIP
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ QUEST_YOUVE_BEEN_SERVED
@ GOSSIP_OPTION_START
@ NPC_CROWN_APOTHECARY
@ NPC_APOTHECARY_BAXTER
@ NPC_APOTHECARY_FRYE
@ SPELL_COLOGNE_SPILL_DAMAGE
@ SPELL_COLOGNE_SPRAY
@ 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_COLOGNE_SPRAY
@ EVENT_CHAIN_REACTION
@ EVENT_PERFUME_SPRAY
Position const FryeMovePos
Position const BaxterMovePos
void AddSC_boss_apothecary_hummel()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
InstanceScript *const instance
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetImmuneToPC(bool apply) override
Definition Creature.h:184
void SetImmuneToAll(bool apply) override
Definition Creature.h:181
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
bool IsInPhase(uint8 phase) const
Definition EventMap.h:222
void SetPhase(uint8 phase)
Definition EventMap.cpp:32
void Reset()
Definition EventMap.cpp:25
Definition Group.h:205
virtual bool SetBossState(uint32 id, EncounterState state)
bool empty() const
Definition LinkedList.h:107
PlayerList const & GetPlayers() const
Definition Map.h:403
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 GetEntry() const
Definition Object.h:89
uint32 GetQuestId() const
Definition QuestDef.h:637
iterator begin()
Definition RefManager.h:35
HookList< CastHandler > AfterCast
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void DoZoneInCombat(uint32 entry=0)
void DoAction(int32 info, Predicate &&predicate, uint16 max=0)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
Definition Unit.h:635
void SetFaction(uint32 faction) override
Definition Unit.h:872
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void RemoveNpcFlag(NPCFlags flags)
Definition Unit.h:998
void SetUninteractible(bool apply)
Definition Unit.cpp:8564
void SetEmoteState(Emote emote)
Definition Unit.h:865
uint64 GetHealth() const
Definition Unit.h:788
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
bool IsInCombat() const
Definition Unit.h:1058
Map * GetMap() const
Definition Object.h:411
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:2658
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:1507
void FilterTargets(std::list< WorldObject * > &targets)
auto SelectRandomContainerElement(C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
@ BOSS_APOTHECARY_HUMMEL
#define RegisterShadowfangKeepCreatureAI(ai_name)
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
void OnQuestReward(Player *, Quest const *quest, LootItemType, uint32) override
void SummonedCreatureDies(Creature *summon, Unit *) override
void UpdateAI(uint32 diff) 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)