TrinityCore
boss_amanitar.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 "ahnkahet.h"
19#include "InstanceScript.h"
20#include "Player.h"
21#include "ScriptedCreature.h"
22#include "ScriptMgr.h"
23#include "SpellScript.h"
24
26{
27 //Amanitar
28 SPELL_BASH = 57094,
30 SPELL_MINI = 57055,
33 //Mushrooms
39 SPELL_GROW = 57059,
40 SPELL_SHRINK = 31691
41};
42
44{
51};
52
54{
55 { 373.4807f, -856.5301f, -74.30518f, 0.2094395f },
56 { 358.4792f, -879.3193f, -75.9463f, 5.166174f },
57 { 356.5531f, -846.3022f, -72.1796f, 3.193953f },
58 { 332.369f, -846.081f, -74.30516f, 4.834562f },
59 { 360.2234f, -862.055f, -75.22755f, 1.658063f },
60 { 351.7189f, -890.9619f, -76.54617f, 1.064651f },
61 { 345.8126f, -869.1772f, -77.17728f, 1.361357f },
62 { 367.5179f, -884.0129f, -77.32881f, 4.276057f },
63 { 370.6044f, -868.4305f, -74.19881f, 0.8901179f },
64 { 381.3156f, -873.2377f, -74.82656f, 1.099557f },
65 { 371.5869f, -873.8141f, -74.72424f, 1.082104f },
66 { 340.4079f, -891.6375f, -74.99128f, 1.134464f },
67 { 368.21f, -851.5953f, -73.99741f, 4.694936f },
68 { 328.7047f, -853.9812f, -75.51253f, 0.5759587f },
69 { 366.4145f, -876.39f, -75.52739f, 5.253441f },
70 { 380.1362f, -861.4344f, -73.45917f, 3.787364f },
71 { 373.3007f, -888.8057f, -79.03593f, 5.602507f },
72 { 348.3599f, -848.0839f, -73.54117f, 1.745329f },
73 { 352.5586f, -882.6624f, -75.68202f, 3.822271f },
74 { 357.8967f, -871.179f, -75.77553f, 2.443461f },
75 { 360.1034f, -842.3351f, -71.08852f, 4.34587f },
76 { 348.1334f, -861.5244f, -74.61307f, 2.565634f },
77 { 401.4896f, -866.7059f, -73.22395f, 0.8901179f },
78 { 360.1683f, -889.1515f, -76.74798f, 3.612832f },
79 { 350.1828f, -907.7313f, -74.94678f, 5.044002f },
80 { 340.6278f, -856.5973f, -74.23862f, 4.415683f },
81 { 366.4849f, -859.7621f, -74.82679f, 1.500983f },
82 { 359.1482f, -853.3346f, -74.47543f, 5.654867f },
83 { 374.9992f, -879.0921f, -75.56115f, 1.867502f },
84 { 339.5252f, -850.4612f, -74.45442f, 4.764749f },
85 { 337.0534f, -864.002f, -75.72749f, 4.642576f },
86 { 398.2797f, -851.8694f, -68.84419f, 0.5759587f }
87};
88
89struct boss_amanitar : public BossAI
90{
91 boss_amanitar(Creature* creature) : BossAI(creature, DATA_AMANITAR) { }
92
93 void JustEngagedWith(Unit* who) override
94 {
102 }
103
104 void EnterEvadeMode(EvadeReason /*why*/) override
105 {
110 }
111
112 void JustDied(Unit* /*killer*/) override
113 {
114 _JustDied();
117 }
118
119 void JustSummoned(Creature* summon) override
120 {
121 summons.Summon(summon);
122 }
123
124 void SummonedCreatureDies(Creature* summon, Unit* killer) override
125 {
126 _mushroomsDeque.push_back(summon->GetPosition());
127
128 BossAI::SummonedCreatureDies(summon, killer);
129 }
130
131 void SpawnMushroom(Position const pos)
132 {
134 }
135
136 void UpdateAI(uint32 diff) override
137 {
138 if (!UpdateVictim())
139 return;
140
141 events.Update(diff);
142
144 return;
145
146 while (uint32 eventId = events.ExecuteEvent())
147 {
148 switch (eventId)
149 {
150 case EVENT_SPAWN:
151 for (Position const& pos : MushroomPositions)
152 SpawnMushroom(pos);
153 break;
154 case EVENT_MINI:
155 if (SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true, -SPELL_MINI))
156 {
158 events.Repeat(Seconds(30));
159 }
160 else
162 break;
163 case EVENT_ROOT:
164 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true))
165 DoCast(target, SPELL_ENTANGLING_ROOTS, true);
166 events.Repeat(Seconds(10), Seconds(15));
167 break;
168 case EVENT_BASH:
170 events.Repeat(Seconds(7), Seconds(12));
171 break;
172 case EVENT_BOLT:
173 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
174 DoCast(target, SPELL_VENOM_BOLT_VOLLEY, true);
175 events.Repeat(Seconds(18), Seconds(22));
176 break;
177 case EVENT_RESPAWN:
178 while (!_mushroomsDeque.empty())
179 {
181 _mushroomsDeque.pop_front();
182 }
183 events.Repeat(Seconds(40), Seconds(60));
184 break;
185 default:
186 break;
187 }
188
190 return;
191 }
192 }
193
194private:
195 std::deque<Position> _mushroomsDeque;
196};
197
199{
200 npc_amanitar_mushrooms(Creature* creature) : ScriptedAI(creature), _active(false) { }
201
202 void Reset() override
203 {
208 DoCastSelf(SPELL_GROW, true);
209
212 else
213 {
215
216 _scheduler.Schedule(1s, [this](TaskContext checkRangeContext)
217 {
218 std::vector<Player*> playersNearby;
219 GetPlayerListInGrid(playersNearby, me, 2.0f);
220 if (!playersNearby.empty())
221 {
222 _active = true;
223
224 for (Player* foundPlayer : playersNearby)
225 foundPlayer->RemoveAurasDueToSpell(SPELL_POTENT_FUNGUS);
226
228
229 _scheduler.Schedule(Seconds(1), [this](TaskContext /*context*/)
230 {
231 me->SetObjectScale(0.1f);
233 });
234 }
235 else
236 checkRangeContext.Repeat(1s);
237 });
238 }
239
240 _scheduler.Schedule(Milliseconds(800), [this](TaskContext /*context*/)
241 {
242 DoCastSelf(SPELL_GROW, true);
243 });
244 }
245
246 void JustDied(Unit* /*killer*/) override
247 {
250 else if (!_active)
252 }
253
254 void UpdateAI(uint32 diff) override
255 {
256 _scheduler.Update(diff);
257 }
258
259private:
262};
263
264// 56648 - Potent Fungus
266{
267 void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
268 {
269 Unit* target = GetTarget();
270 if (!target->HasAura(SPELL_MINI))
271 return;
272
274 Remove();
275 }
276
277 void Register() override
278 {
280 }
281};
282
284{
288}
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
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
void GetPlayerListInGrid(Container &container, WorldObject *source, float maxSearchRange, bool alive=true)
@ EFFECT_0
Definition: SharedDefines.h:30
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_MOD_SCALE
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ DATA_AMANITAR
Definition: ahnkahet.h:34
#define RegisterAhnKahetCreatureAI(ai_name)
Definition: ahnkahet.h:87
@ NPC_HEALTHY_MUSHROOM
Definition: ahnkahet.h:62
@ NPC_POISONOUS_MUSHROOM
Definition: ahnkahet.h:63
AmanitarEvents
@ EVENT_SPAWN
@ EVENT_MINI
@ EVENT_BOLT
@ EVENT_BASH
@ EVENT_ROOT
@ EVENT_RESPAWN
void AddSC_boss_amanitar()
AmanitarSpells
@ SPELL_SHRINK
@ SPELL_MINI
@ SPELL_VENOM_BOLT_VOLLEY
@ SPELL_ENTANGLING_ROOTS
@ SPELL_BASH
@ SPELL_POWER_MUSHROOM_VISUAL_AURA
@ SPELL_REMOVE_MUSHROOM_POWER
@ SPELL_POISONOUS_MUSHROOM_POISON_CLOUD
@ SPELL_POTENT_FUNGUS
@ SPELL_POISONOUS_MUSHROOM_VISUAL_AURA
@ SPELL_GROW
@ SPELL_PUTRID_MUSHROOM
Position const MushroomPositions[32]
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetTarget() const
void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void _JustDied()
virtual void SummonedCreatureDies(Creature *, Unit *)
Definition: CreatureAI.h:115
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetObjectScale(float scale) override
Definition: Creature.cpp:3391
void SetDisplayFromModel(uint32 modelIdx)
Definition: Creature.cpp:3413
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
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
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
uint32 GetEntry() const
Definition: Object.h:161
void Summon(Creature const *summon)
TaskContext & Repeat(std::chrono::duration< Rep, Period > duration)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
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
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:2025
void OnApply(AuraEffect const *, AuraEffectHandleModes)
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
void JustSummoned(Creature *summon) override
void JustDied(Unit *) override
void SummonedCreatureDies(Creature *summon, Unit *killer) override
void EnterEvadeMode(EvadeReason) override
std::deque< Position > _mushroomsDeque
void SpawnMushroom(Position const pos)
boss_amanitar(Creature *creature)
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
npc_amanitar_mushrooms(Creature *creature)
void UpdateAI(uint32 diff) override