Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
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
10
enum
Spells
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
16
SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS
= 56648,
// Killer 3Y
17
SPELL_POISONOUS_MUSHROOM_POISON_CLOUD
= 57061,
// Self - Duration 8 Sec
18
SPELL_POISONOUS_MUSHROOM_VISUAL_AREA
= 61566,
// Self
19
SPELL_POISONOUS_MUSHROOM_VISUAL_AURA
= 56741,
// Self
20
SPELL_PUTRID_MUSHROOM
= 31690,
// To make the mushrooms visible
21
SPELL_POWER_MUSHROOM_VISUAL_AURA
= 56740,
22
};
23
24
enum
Creatures
25
{
26
NPC_TRIGGER
= 19656
27
};
28
29
enum
Events
30
{
31
EVENT_SPAWN
= 1,
32
EVENT_MINI
,
33
EVENT_ROOT
,
34
EVENT_BASH
,
35
EVENT_BOLT
,
36
EVENT_AURA
37
};
38
39
class
boss_amanitar
:
public
CreatureScript
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
48
void
Reset
()
OVERRIDE
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
{
57
_EnterCombat
();
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();
95
me
->SummonCreature(u > 0 ?
NPC_POISONOUS_MUSHROOM
:
NPC_HEALTHY_MUSHROOM
, pos,
TempSummonType::TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
, 60 *
IN_MILLISECONDS
);
96
}
97
}
98
}
99
}
100
101
void
UpdateAI
(
uint32
diff)
OVERRIDE
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
:
120
DoCast
(
SPELL_MINI
);
121
events
.ScheduleEvent(
EVENT_MINI
, std::rand() % (30 *
IN_MILLISECONDS
) + (25 *
IN_MILLISECONDS
));
122
break
;
123
case
EVENT_ROOT
:
124
DoCast
(
SelectTarget
(
SELECT_TARGET_RANDOM
, 0, 100,
true
),
SPELL_ENTANGLING_ROOTS
,
true
);
125
events
.ScheduleEvent(
EVENT_ROOT
, std::rand() % (15 *
IN_MILLISECONDS
) + (10 *
IN_MILLISECONDS
));
126
break
;
127
case
EVENT_BASH
:
128
DoCastVictim
(
SPELL_BASH
);
129
events
.ScheduleEvent(
EVENT_BASH
, std::rand() % (12 *
IN_MILLISECONDS
) + (7 *
IN_MILLISECONDS
));
130
break
;
131
case
EVENT_BOLT
:
132
DoCast
(
SelectTarget
(
SELECT_TARGET_RANDOM
, 0, 100,
true
),
SPELL_VENOM_BOLT_VOLLEY
,
true
);
133
events
.ScheduleEvent(
EVENT_BOLT
, std::rand() % (22 *
IN_MILLISECONDS
) + (18 *
IN_MILLISECONDS
));
134
break
;
135
default
:
136
break
;
137
}
138
}
139
DoMeleeAttackIfReady
();
140
}
141
};
142
143
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
144
{
145
return
GetAhnKahetAI<boss_amanitarAI>
(creature);
146
}
147
};
148
149
class
npc_amanitar_mushrooms
:
public
CreatureScript
150
{
151
public
:
152
npc_amanitar_mushrooms
() :
CreatureScript
(
"npc_amanitar_mushrooms"
) { }
153
154
struct
npc_amanitar_mushroomsAI
:
public
ScriptedAI
155
{
156
npc_amanitar_mushroomsAI
(
Creature
* creature) :
ScriptedAI
(creature) { }
157
158
EventMap
events
;
159
160
void
Reset
()
OVERRIDE
161
{
162
events
.Reset();
163
events
.ScheduleEvent(
EVENT_AURA
, 1 *
IN_MILLISECONDS
);
164
165
me
->SetDisplayId(
me
->GetCreatureTemplate()->Modelid2);
166
DoCast
(
SPELL_PUTRID_MUSHROOM
);
167
168
if
(
me
->GetEntry() ==
NPC_POISONOUS_MUSHROOM
)
169
DoCast
(
SPELL_POISONOUS_MUSHROOM_VISUAL_AURA
);
170
else
171
DoCast
(
SPELL_POWER_MUSHROOM_VISUAL_AURA
);
172
}
173
174
void
DamageTaken
(
Unit
*
/*attacker*/
,
uint32
&damage)
OVERRIDE
175
{
176
if
(damage >=
me
->GetHealth() &&
me
->GetEntry() ==
NPC_HEALTHY_MUSHROOM
)
177
DoCast
(
me
,
SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS
,
true
);
178
}
179
180
void
EnterCombat
(
Unit
*
/*who*/
)
OVERRIDE
{ }
181
void
AttackStart
(
Unit
*
/*victim*/
)
OVERRIDE
{ }
182
183
void
UpdateAI
(
uint32
diff)
OVERRIDE
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
{
200
DoCast
(
me
,
SPELL_POISONOUS_MUSHROOM_VISUAL_AREA
,
true
);
201
DoCast
(
me
,
SPELL_POISONOUS_MUSHROOM_POISON_CLOUD
);
202
}
203
events
.ScheduleEvent(
EVENT_AURA
, 7 *
IN_MILLISECONDS
);
204
break
;
205
default
:
206
break
;
207
}
208
}
209
}
210
};
211
212
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
213
{
214
return
new
npc_amanitar_mushroomsAI
(creature);
215
}
216
};
217
218
void
AddSC_boss_amanitar
()
219
{
220
new
boss_amanitar
();
221
new
npc_amanitar_mushrooms
();
222
}
Spells
Spells
Definition
BattlegroundIC.h:645
IN_MILLISECONDS
@ IN_MILLISECONDS
Definition
Common.h:125
uint8
std::uint8_t uint8
Definition
Define.h:79
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
MAX_HEIGHT
#define MAX_HEIGHT
Definition
Map.h:141
TempSummonType::TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
@ TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
Definition
Object.h:69
ScriptMgr.h
ScriptedCreature.h
SPELL_SCHOOL_NATURE
@ SPELL_SCHOOL_NATURE
Definition
SharedDefines.h:259
IMMUNITY_SCHOOL
@ IMMUNITY_SCHOOL
Definition
SharedDefines.h:1598
SPELL_SCHOOL_MASK_NATURE
@ SPELL_SCHOOL_MASK_NATURE
Definition
SharedDefines.h:273
UNIT_STATE_CASTING
@ UNIT_STATE_CASTING
Definition
Unit.h:527
SELECT_TARGET_RANDOM
@ SELECT_TARGET_RANDOM
Definition
UnitAI.h:23
ahnkahet.h
NPC_HEALTHY_MUSHROOM
@ NPC_HEALTHY_MUSHROOM
Definition
ahnkahet.h:51
NPC_POISONOUS_MUSHROOM
@ NPC_POISONOUS_MUSHROOM
Definition
ahnkahet.h:52
GetAhnKahetAI
AI * GetAhnKahetAI(Creature *creature)
Definition
ahnkahet.h:71
DATA_AMANITAR
@ DATA_AMANITAR
Definition
ahnkahet.h:19
Creatures
Creatures
Definition
alterac_valley.cpp:28
Events
Events
Definition
alterac_valley.cpp:40
NPC_TRIGGER
@ NPC_TRIGGER
Definition
boss_amanitar.cpp:26
SPELL_MINI
@ SPELL_MINI
Definition
boss_amanitar.cpp:14
SPELL_VENOM_BOLT_VOLLEY
@ SPELL_VENOM_BOLT_VOLLEY
Definition
boss_amanitar.cpp:15
SPELL_ENTANGLING_ROOTS
@ SPELL_ENTANGLING_ROOTS
Definition
boss_amanitar.cpp:13
SPELL_BASH
@ SPELL_BASH
Definition
boss_amanitar.cpp:12
SPELL_POWER_MUSHROOM_VISUAL_AURA
@ SPELL_POWER_MUSHROOM_VISUAL_AURA
Definition
boss_amanitar.cpp:21
SPELL_POISONOUS_MUSHROOM_POISON_CLOUD
@ SPELL_POISONOUS_MUSHROOM_POISON_CLOUD
Definition
boss_amanitar.cpp:17
SPELL_POISONOUS_MUSHROOM_VISUAL_AREA
@ SPELL_POISONOUS_MUSHROOM_VISUAL_AREA
Definition
boss_amanitar.cpp:18
SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS
@ SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS
Definition
boss_amanitar.cpp:16
SPELL_POISONOUS_MUSHROOM_VISUAL_AURA
@ SPELL_POISONOUS_MUSHROOM_VISUAL_AURA
Definition
boss_amanitar.cpp:19
SPELL_PUTRID_MUSHROOM
@ SPELL_PUTRID_MUSHROOM
Definition
boss_amanitar.cpp:20
AddSC_boss_amanitar
void AddSC_boss_amanitar()
Definition
boss_amanitar.cpp:218
EVENT_SPAWN
@ EVENT_SPAWN
Definition
boss_amanitar.cpp:31
EVENT_AURA
@ EVENT_AURA
Definition
boss_amanitar.cpp:36
EVENT_MINI
@ EVENT_MINI
Definition
boss_amanitar.cpp:32
EVENT_BOLT
@ EVENT_BOLT
Definition
boss_amanitar.cpp:35
EVENT_BASH
@ EVENT_BASH
Definition
boss_amanitar.cpp:34
EVENT_ROOT
@ EVENT_ROOT
Definition
boss_amanitar.cpp:33
BossAI::instance
InstanceScript *const instance
Definition
ScriptedCreature.h:383
BossAI::events
EventMap events
Definition
ScriptedCreature.h:439
BossAI::BossAI
BossAI(Creature *creature, uint32 bossId)
Definition
ScriptedCreature.cpp:456
BossAI::_JustDied
void _JustDied()
Definition
ScriptedCreature.cpp:474
BossAI::_Reset
void _Reset()
Definition
ScriptedCreature.cpp:462
BossAI::_EnterCombat
void _EnterCombat()
Definition
ScriptedCreature.cpp:485
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::UpdateVictim
bool UpdateVictim()
Definition
CreatureAI.cpp:192
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
EventMap
Definition
CreatureAIImpl.h:304
UnitAI::DoMeleeAttackIfReady
void DoMeleeAttackIfReady()
Definition
UnitAI.cpp:28
UnitAI::DoCast
void DoCast(uint32 spellId)
Definition
UnitAI.cpp:110
UnitAI::SelectTarget
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition
UnitAI.cpp:66
UnitAI::DoCastVictim
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition
UnitAI.cpp:168
Unit
Definition
Unit.h:1367
WorldObject::FindNearestCreature
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition
Object.cpp:2801
boss_amanitar
Definition
boss_amanitar.cpp:40
boss_amanitar::boss_amanitar
boss_amanitar()
Definition
boss_amanitar.cpp:42
boss_amanitar::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
boss_amanitar.cpp:143
npc_amanitar_mushrooms
Definition
boss_amanitar.cpp:150
npc_amanitar_mushrooms::npc_amanitar_mushrooms
npc_amanitar_mushrooms()
Definition
boss_amanitar.cpp:152
npc_amanitar_mushrooms::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
boss_amanitar.cpp:212
NPC_TRIGGER
@ NPC_TRIGGER
Definition
hyjal_trash.cpp:17
Position
Definition
Object.h:274
Position::m_positionZ
float m_positionZ
Definition
Object.h:289
Position::GetPositionX
float GetPositionX() const
Definition
Object.h:328
Position::GetPositionY
float GetPositionY() const
Definition
Object.h:329
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
ScriptedAI::ScriptedAI
ScriptedAI(Creature *creature)
Definition
ScriptedCreature.cpp:85
boss_amanitar::boss_amanitarAI::JustDied
void JustDied(Unit *) OVERRIDE
Definition
boss_amanitar.cpp:66
boss_amanitar::boss_amanitarAI::Reset
void Reset() OVERRIDE
Definition
boss_amanitar.cpp:48
boss_amanitar::boss_amanitarAI::SpawnAdds
void SpawnAdds()
Definition
boss_amanitar.cpp:72
boss_amanitar::boss_amanitarAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
boss_amanitar.cpp:101
boss_amanitar::boss_amanitarAI::boss_amanitarAI
boss_amanitarAI(Creature *creature)
Definition
boss_amanitar.cpp:46
boss_amanitar::boss_amanitarAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
boss_amanitar.cpp:55
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI
Definition
boss_amanitar.cpp:155
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::DamageTaken
void DamageTaken(Unit *, uint32 &damage) OVERRIDE
Definition
boss_amanitar.cpp:174
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::events
EventMap events
Definition
boss_amanitar.cpp:158
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::npc_amanitar_mushroomsAI
npc_amanitar_mushroomsAI(Creature *creature)
Definition
boss_amanitar.cpp:156
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::AttackStart
void AttackStart(Unit *) OVERRIDE
Definition
boss_amanitar.cpp:181
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::Reset
void Reset() OVERRIDE
Definition
boss_amanitar.cpp:160
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
boss_amanitar.cpp:180
npc_amanitar_mushrooms::npc_amanitar_mushroomsAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
boss_amanitar.cpp:183
SPELL_ENTANGLING_ROOTS
@ SPELL_ENTANGLING_ROOTS
Definition
zone_teldrassil.cpp:37
src
server
scripts
Northrend
AzjolNerub
Ahnkahet
boss_amanitar.cpp
Generated on
for Project SkyFire Core by
1.17.0