TrinityCore
zone_terokkar_forest.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 "Group.h"
21#include "Map.h"
22#include "Player.h"
23#include "ScriptedCreature.h"
24#include "SpellScript.h"
25
26/*######
27## npc_unkor_the_ruthless
28######*/
29
31{
37};
38
40{
41public:
42 npc_unkor_the_ruthless() : CreatureScript("npc_unkor_the_ruthless") { }
43
44 CreatureAI* GetAI(Creature* creature) const override
45 {
46 return new npc_unkor_the_ruthlessAI(creature);
47 }
48
50 {
52 {
53 Initialize();
54 }
55
57 {
58 CanDoQuest = false;
60 Pulverize_Timer = 3000;
61 }
62
66
67 void Reset() override
68 {
69 Initialize();
72 }
73
74 void JustEngagedWith(Unit* /*who*/) override { }
75
76 void DoNice()
77 {
82 me->CombatStop(true);
85 }
86
87 void DamageTaken(Unit* done_by, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
88 {
89 if (!done_by || !me->HealthBelowPctDamaged(30, damage))
90 return;
91
92 if (Player* player = done_by->ToPlayer())
93 {
94 if (Group* group = player->GetGroup())
95 {
96 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
97 {
98 Player* groupie = itr->GetSource();
99 if (groupie && groupie->IsInMap(player) &&
102 {
104 if (!CanDoQuest)
105 CanDoQuest = true;
106 }
107 }
108 }
109 else if (player->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE &&
110 player->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, NPC_BOULDERFIST_INVADER) == REQUIRED_KILL_COUNT)
111 {
112 player->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE);
113 CanDoQuest = true;
114 }
115 }
116 }
117
118 void UpdateAI(uint32 diff) override
119 {
120 if (CanDoQuest)
121 {
123 {
124 //DoCast(me, SPELL_QUID9889); //not using spell for now
125 DoNice();
126 }
127 else
128 {
129 if (UnkorUnfriendly_Timer <= diff)
130 {
132 return;
133 } else UnkorUnfriendly_Timer -= diff;
134 }
135 }
136
137 if (!UpdateVictim())
138 return;
139
140 if (Pulverize_Timer <= diff)
141 {
143 Pulverize_Timer = 9000;
144 } else Pulverize_Timer -= diff;
145 }
146 };
147};
148
149// 40655 - Skyguard Flare
151{
153 {
155 }
156
157 void Register() override
158 {
160 }
161};
162
163/*######
164## Quest 10873: Taken in the Night
165######*/
166
168{
174 SPELL_FREE_WEBBED_6 = 38978
176
177std::array<uint32, 5> const CocoonSummonSpells =
178{
180};
181
182// 38949 - Terrokar Free Webbed Creature
184{
185 bool Validate(SpellInfo const* /*spellInfo*/) override
186 {
188 }
189
190 void HandleDummy(SpellEffIndex /*effIndex*/)
191 {
193 }
194
195 void Register() override
196 {
198 }
199};
200
201// 38950 - Terokkar Free Webbed Creature ON QUEST
203{
204 bool Validate(SpellInfo const* /*spellInfo*/) override
205 {
207 }
208
209 void HandleDummy(SpellEffIndex /*effIndex*/)
210 {
211 Unit* caster = GetCaster();
212 Unit* target = GetHitUnit();
213
214 if (roll_chance_i(66))
216 else
217 target->CastSpell(caster, SPELL_FREE_WEBBED_6, true);
218 }
219
220 void Register() override
221 {
223 }
224};
225
226/*######
227## Quest 10040 & 10041: Who Are They?
228######*/
229
231{
236
237// 48917 - Who Are They: Cast from Questgiver
239{
240 bool Validate(SpellInfo const* /*spellInfo*/) override
241 {
243 }
244
245 void HandleScript(SpellEffIndex /*effIndex*/)
246 {
248 }
249
250 void Register() override
251 {
253 }
254};
255
256// 32756 - Shadowy Disguise
258{
259 bool Validate(SpellInfo const* /*spellInfo*/) override
260 {
262 }
263
264 void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
265 {
266 if (Player* target = GetTarget()->ToPlayer())
267 target->CastSpell(target, target->GetNativeGender() == GENDER_MALE ? SPELL_MALE_SHADOWY_DISGUISE : SPELL_FEMALE_SHADOWY_DISGUISE);
268 }
269
270 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
271 {
272 Unit* target = GetTarget();
275 }
276
277 void Register() override
278 {
281 }
282};
283
284// 32780 - Cancel Shadowy Disguise
286{
287 bool Validate(SpellInfo const* /*spellInfo*/) override
288 {
290 }
291
292 void HandleScript(SpellEffIndex /*effIndex*/)
293 {
295 }
296
297 void Register() override
298 {
300 }
301};
302
304{
312}
uint32_t uint32
Definition: Define.h:142
#define MAX_HEIGHT
Definition: GridDefines.h:60
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ GENDER_MALE
@ TARGET_DEST_TARGET_RANDOM
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ FACTION_FRIENDLY
@ FACTION_OGRE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_FORCE_REACTION
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellDestinationTargetSelectFn(F, I, N)
Definition: SpellScript.h:874
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
@ UNIT_STAND_STATE_STAND
Definition: UnitDefines.h:42
@ UNIT_STAND_STATE_SIT
Definition: UnitDefines.h:43
DamageEffectType
Definition: UnitDefines.h:131
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetTarget() const
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void EngagementOver()
Definition: CreatureAI.cpp:287
GroupReference * next()
Definition: Group.h:197
float GetHeight(PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition: Map.h:290
static Player * ToPlayer(Object *o)
Definition: Object.h:213
uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const
Definition: Player.cpp:16383
void AreaExploredOrEventHappens(uint32 questId)
Definition: Player.cpp:16577
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
Definition: SpellScript.h:873
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition: Unit.cpp:5827
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:10100
void SetFaction(uint32 faction) override
Definition: Unit.h:859
void RemoveAllAuras()
Definition: Unit.cpp:4242
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
Map * GetMap() const
Definition: Object.h:624
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1115
CreatureAI * GetAI(Creature *creature) const override
void ModDestHeight(SpellDestination &dest)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109
constexpr float GetPositionX() const
Definition: Position.h:76
float m_positionZ
Definition: Position.h:55
constexpr float GetPositionY() const
Definition: Position.h:77
WorldLocation _position
Definition: SpellDefines.h:325
void DamageTaken(Unit *done_by, uint32 &damage, DamageEffectType, SpellInfo const *) override
void AddSC_terokkar_forest()
std::array< uint32, 5 > const CocoonSummonSpells
@ SPELL_FEMALE_SHADOWY_DISGUISE
@ SPELL_MALE_SHADOWY_DISGUISE
@ SPELL_SHADOWY_DISGUISE
@ REQUIRED_KILL_COUNT
@ SPELL_PULVERIZE
@ NPC_BOULDERFIST_INVADER
@ QUEST_DONTKILLTHEFATONE
@ SPELL_FREE_WEBBED_4
@ SPELL_FREE_WEBBED_6
@ SPELL_FREE_WEBBED_1
@ SPELL_FREE_WEBBED_3
@ SPELL_FREE_WEBBED_5
@ SPELL_FREE_WEBBED_2