Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_amanitar.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "ahnkahet.h"
9
11{
12 SPELL_BASH = 57094, // Victim
13 SPELL_ENTANGLING_ROOTS = 57095, // Random Victim 100Y
14 SPELL_MINI = 57055, // Self
15 SPELL_VENOM_BOLT_VOLLEY = 57088, // Random Victim 100Y
17 SPELL_POISONOUS_MUSHROOM_POISON_CLOUD = 57061, // Self - Duration 8 Sec
20 SPELL_PUTRID_MUSHROOM = 31690, // To make the mushrooms visible
22};
23
25{
27};
28
38
40{
41 public:
42 boss_amanitar() : CreatureScript("boss_amanitar") { }
43
44 struct boss_amanitarAI : public BossAI
45 {
46 boss_amanitarAI(Creature* creature) : BossAI(creature, DATA_AMANITAR) { }
47
49 {
50 _Reset();
51 me->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE);
52 me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
53 }
54
55 void EnterCombat(Unit* /*who*/) OVERRIDE
56 {
58
59 events.ScheduleEvent(EVENT_ROOT, std::rand() % (9 * IN_MILLISECONDS) + (5 * IN_MILLISECONDS));
60 events.ScheduleEvent(EVENT_BASH, std::rand() % (14 * IN_MILLISECONDS) + (10 * IN_MILLISECONDS));
61 events.ScheduleEvent(EVENT_BOLT, std::rand() % (20 * IN_MILLISECONDS) + (15 * IN_MILLISECONDS));
62 events.ScheduleEvent(EVENT_MINI, std::rand() % (18 * IN_MILLISECONDS) + (12 * IN_MILLISECONDS));
63 events.ScheduleEvent(EVENT_SPAWN, 5 * IN_MILLISECONDS);
64 }
65
66 void JustDied(Unit* /*killer*/) OVERRIDE
67 {
68 _JustDied();
69 instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MINI);
70 }
71
72 void SpawnAdds()
73 {
74 uint8 u = 0;
75
76 for (uint8 i = 0; i < 30; ++i)
77 {
78 Position pos;
79 me->GetPosition(&pos);
80 me->GetRandomNearPosition(pos, 30.0f);
81 pos.m_positionZ = me->GetMap()->GetHeight(pos.GetPositionX(), pos.GetPositionY(), MAX_HEIGHT) + 2.0f;
82
83 if (Creature* trigger = me->SummonCreature(NPC_TRIGGER, pos))
84 {
85 Creature* temp1 = trigger->FindNearestCreature(NPC_HEALTHY_MUSHROOM, 4.0f, true);
86 Creature* temp2 = trigger->FindNearestCreature(NPC_POISONOUS_MUSHROOM, 4.0f, true);
87 if (temp1 || temp2)
88 {
89 trigger->DisappearAndDie();
90 }
91 else
92 {
93 u = 1 - u;
94 trigger->DisappearAndDie();
96 }
97 }
98 }
99 }
100
102 {
103 if (!UpdateVictim())
104 return;
105
106 events.Update(diff);
107
108 if (me->HasUnitState(UNIT_STATE_CASTING))
109 return;
110
111 while (uint32 eventId = events.ExecuteEvent())
112 {
113 switch (eventId)
114 {
115 case EVENT_SPAWN:
116 SpawnAdds();
117 events.ScheduleEvent(EVENT_SPAWN, 20 * IN_MILLISECONDS);
118 break;
119 case EVENT_MINI:
121 events.ScheduleEvent(EVENT_MINI, std::rand() % (30 * IN_MILLISECONDS) + (25 * IN_MILLISECONDS));
122 break;
123 case EVENT_ROOT:
125 events.ScheduleEvent(EVENT_ROOT, std::rand() % (15 * IN_MILLISECONDS) + (10 * IN_MILLISECONDS));
126 break;
127 case EVENT_BASH:
129 events.ScheduleEvent(EVENT_BASH, std::rand() % (12 * IN_MILLISECONDS) + (7 * IN_MILLISECONDS));
130 break;
131 case EVENT_BOLT:
133 events.ScheduleEvent(EVENT_BOLT, std::rand() % (22 * IN_MILLISECONDS) + (18 * IN_MILLISECONDS));
134 break;
135 default:
136 break;
137 }
138 }
140 }
141 };
142
144 {
145 return GetAhnKahetAI<boss_amanitarAI>(creature);
146 }
147};
148
150{
151public:
152 npc_amanitar_mushrooms() : CreatureScript("npc_amanitar_mushrooms") { }
153
155 {
157
159
161 {
162 events.Reset();
163 events.ScheduleEvent(EVENT_AURA, 1 * IN_MILLISECONDS);
164
165 me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
167
168 if (me->GetEntry() == NPC_POISONOUS_MUSHROOM)
170 else
172 }
173
174 void DamageTaken(Unit* /*attacker*/, uint32 &damage) OVERRIDE
175 {
176 if (damage >= me->GetHealth() && me->GetEntry() == NPC_HEALTHY_MUSHROOM)
178 }
179
180 void EnterCombat(Unit* /*who*/) OVERRIDE { }
181 void AttackStart(Unit* /*victim*/) OVERRIDE { }
182
184 {
185 if (!UpdateVictim())
186 return;
187
188 events.Update(diff);
189
190 if (me->HasUnitState(UNIT_STATE_CASTING))
191 return;
192
193 while (uint32 eventId = events.ExecuteEvent())
194 {
195 switch (eventId)
196 {
197 case EVENT_AURA:
198 if (me->GetEntry() == NPC_POISONOUS_MUSHROOM)
199 {
202 }
203 events.ScheduleEvent(EVENT_AURA, 7 * IN_MILLISECONDS);
204 break;
205 default:
206 break;
207 }
208 }
209 }
210 };
211
213 {
214 return new npc_amanitar_mushroomsAI(creature);
215 }
216};
217
219{
220 new boss_amanitar();
222}
@ IN_MILLISECONDS
Definition Common.h:125
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
#define MAX_HEIGHT
Definition Map.h:141
@ TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
Definition Object.h:69
@ SPELL_SCHOOL_NATURE
@ IMMUNITY_SCHOOL
@ SPELL_SCHOOL_MASK_NATURE
@ UNIT_STATE_CASTING
Definition Unit.h:527
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ NPC_HEALTHY_MUSHROOM
Definition ahnkahet.h:51
@ NPC_POISONOUS_MUSHROOM
Definition ahnkahet.h:52
AI * GetAhnKahetAI(Creature *creature)
Definition ahnkahet.h:71
@ DATA_AMANITAR
Definition ahnkahet.h:19
Creatures
@ NPC_TRIGGER
@ SPELL_MINI
@ SPELL_VENOM_BOLT_VOLLEY
@ SPELL_ENTANGLING_ROOTS
@ SPELL_BASH
@ SPELL_POWER_MUSHROOM_VISUAL_AURA
@ SPELL_POISONOUS_MUSHROOM_POISON_CLOUD
@ SPELL_POISONOUS_MUSHROOM_VISUAL_AREA
@ SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS
@ SPELL_POISONOUS_MUSHROOM_VISUAL_AURA
@ SPELL_PUTRID_MUSHROOM
void AddSC_boss_amanitar()
@ EVENT_SPAWN
@ EVENT_AURA
@ EVENT_MINI
@ EVENT_BOLT
@ EVENT_BASH
@ EVENT_ROOT
InstanceScript *const instance
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
bool UpdateVictim()
CreatureScript(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
Definition Unit.h:1367
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2801
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
@ NPC_TRIGGER
float m_positionZ
Definition Object.h:289
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
Creature * me
ScriptedAI(Creature *creature)
void JustDied(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
boss_amanitarAI(Creature *creature)
void EnterCombat(Unit *) OVERRIDE
void DamageTaken(Unit *, uint32 &damage) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
@ SPELL_ENTANGLING_ROOTS