TrinityCore
zalazane_fall.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 "CreatureAIImpl.h"
20#include "MotionMaster.h"
21#include "ObjectAccessor.h"
22#include "Player.h"
23#include "ScriptedCreature.h"
24#include "SpellInfo.h"
25#include "SpellScript.h"
26#include "TemporarySummon.h"
27#include "Vehicle.h"
28
30{
31 // Tiger Matriarch Credit
33
34 // Troll Volunteer
37};
38
40{
41 // Tiger Matriarch Credit
46
47 // Tiger Matriarch
48 SPELL_POUNCE = 61184,
53
54 // Troll Volunteer
59 SPELL_TURNIN = 73953,
61
62 // Vol'jin War Drums
65};
66
68{
69 // Tiger Matriarch Credit
71
72 // Troll Volunteer
73 NPC_URUZIN = 40253,
76
77 // Vol'jin War Drums
80};
81
83{
84 // Tiger Matriarch Credit
86
87 // Tiger Matriarch
90};
91
93{
94 POINT_URUZIN = 4026400,
95};
96
98{
100 {
101 SetCombatMovement(false);
103 }
104
105 void UpdateAI(uint32 diff) override
106 {
107 events.Update(diff);
108
110 {
111 std::list<Creature*> tigers;
113 if (!tigers.empty())
114 {
115 for (std::list<Creature*>::iterator itr = tigers.begin(); itr != tigers.end(); ++itr)
116 {
117 if (!(*itr)->IsSummon())
118 continue;
119
120 if (Unit* summoner = (*itr)->ToTempSummon()->GetSummonerUnit())
121 if (!summoner->HasAura(SPELL_NO_SUMMON_AURA) && !summoner->HasAura(SPELL_SUMMON_ZENTABRA_TRIGGER)
122 && !summoner->IsInCombat())
123 {
124 me->AddAura(SPELL_NO_SUMMON_AURA, summoner);
125 me->AddAura(SPELL_DETECT_INVIS, summoner);
126 summoner->CastSpell(summoner, SPELL_SUMMON_MATRIARCH, true);
127 Talk(SAY_MATRIARCH_AGGRO, summoner);
128 }
129 }
130 }
131
133 }
134 }
135
136private:
138};
139
141{
143 {
144 }
145
146 void JustEngagedWith(Unit* /*target*/) override
147 {
148 _events.Reset();
151 }
152
153 void IsSummonedBy(WorldObject* summonerWO) override
154 {
155 Player* summoner = summonerWO->ToPlayer();
156 if (!summoner || !summoner->GetVehicle())
157 return;
158
159 _tigerGuid = summoner->GetVehicle()->GetBase()->GetGUID();
161 {
162 AddThreat(tiger, 500000.0f);
164 }
165 }
166
167 void KilledUnit(Unit* victim) override
168 {
169 if (victim->GetTypeId() != TYPEID_UNIT || !victim->IsSummon())
170 return;
171
172 if (Unit* vehSummoner = victim->ToTempSummon()->GetSummonerUnit())
173 {
174 vehSummoner->RemoveAurasDueToSpell(SPELL_NO_SUMMON_AURA);
175 vehSummoner->RemoveAurasDueToSpell(SPELL_DETECT_INVIS);
176 vehSummoner->RemoveAurasDueToSpell(SPELL_SPIRIT_OF_THE_TIGER_RIDER);
177 vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER);
178 }
180 }
181
182 void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
183 {
184 if (!attacker || !attacker->IsSummon())
185 return;
186
187 if (HealthBelowPct(20))
188 {
189 damage = 0;
191 if (Unit* vehSummoner = attacker->ToTempSummon()->GetSummonerUnit())
192 {
193 vehSummoner->AddAura(SPELL_SUMMON_ZENTABRA_TRIGGER, vehSummoner);
194 vehSummoner->CastSpell(vehSummoner, SPELL_SUMMON_ZENTABRA, true);
195 attacker->CastSpell(attacker, SPELL_EJECT_PASSENGERS, true);
196 vehSummoner->RemoveAurasDueToSpell(SPELL_NO_SUMMON_AURA);
197 vehSummoner->RemoveAurasDueToSpell(SPELL_DETECT_INVIS);
198 vehSummoner->RemoveAurasDueToSpell(SPELL_SPIRIT_OF_THE_TIGER_RIDER);
199 vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER);
200 }
201
203 }
204 }
205
206 void UpdateAI(uint32 diff) override
207 {
208 if (!UpdateVictim())
209 return;
210
211 if (!_tigerGuid)
212 return;
213
214 _events.Update(diff);
215
216 while (uint32 eventId = _events.ExecuteEvent())
217 {
218 switch (eventId)
219 {
220 case EVENT_POUNCE:
223 break;
224 case EVENT_NOSUMMON: // Reapply SPELL_NO_SUMMON_AURA
226 {
227 if (tiger->IsSummon())
228 if (Unit* vehSummoner = tiger->ToTempSummon()->GetSummonerUnit())
229 me->AddAura(SPELL_NO_SUMMON_AURA, vehSummoner);
230 }
232 break;
233 default:
234 break;
235 }
236 }
237 }
238
239private:
242};
243
244// These models was found in sniff.
247{11665, 11734, 11750, 12037, 12038, 12042, 12049, 12849, 13529, 14759, 15570, 15701,
24815702, 1882, 1897, 1976, 2025, 27286, 2734, 2735, 4084, 4085, 4087, 4089, 4231, 4357,
2494358, 4360, 4361, 4362, 4363, 4370, 4532, 4537, 4540, 4610, 6839, 7037, 9767, 9768};
250
252{
254 {
255 Initialize();
256 _mountModel = 0;
257 }
258
260 {
261 _complete = false;
262 }
263
264 void InitializeAI() override
265 {
266 if (me->isDead() || !me->GetOwner())
267 return;
268
269 Reset();
270
271 switch (urand(0, 3))
272 {
273 case 0:
274 _mountModel = 6471;
275 break;
276 case 1:
277 _mountModel = 6473;
278 break;
279 case 2:
280 _mountModel = 6469;
281 break;
282 default:
283 _mountModel = 6472;
284 break;
285 }
287 if (Player* player = me->GetOwner()->ToPlayer())
288 me->GetMotionMaster()->MoveFollow(player, 5.0f, (rand_norm() + 1.0f) * float(M_PI) / 3.0f * 4.0f);
289 }
290
291 void Reset() override
292 {
293 Initialize();
299 }
300
301 // This is needed for mount check aura to know what mountmodel the npc got stored
303 {
304 return _mountModel;
305 }
306
307 void MovementInform(uint32 type, uint32 id) override
308 {
309 if (type != POINT_MOTION_TYPE)
310 return;
311 if (id == POINT_URUZIN)
313 }
314
315 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
316 {
317 if (spellInfo->Id == SPELL_AOE_TURNIN && caster->GetEntry() == NPC_URUZIN && !_complete)
318 {
319 _complete = true; // Preventing from giving credit twice
323 me->Dismount();
325 me->GetMotionMaster()->MovePoint(POINT_URUZIN, caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ());
326 }
327 }
328
329private:
332};
333
335
336// 75420 - Mounting Check
338{
339 bool Validate(SpellInfo const* /*spellInfo*/) override
340 {
342 }
343
344 void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
345 {
346 Unit* target = GetTarget();
347 Unit* owner = target->GetOwner();
348
349 if (!owner)
350 return;
351
352 if (owner->IsMounted() && !target->IsMounted())
353 {
354 if (VolunteerAI* volunteerAI = CAST_AI(VolunteerAI, target->GetAI()))
355 target->Mount(volunteerAI->GetMountId());
356 }
357 else if (!owner->IsMounted() && target->IsMounted())
358 target->Dismount();
359
360 target->SetSpeedRate(MOVE_RUN, owner->GetSpeedRate(MOVE_RUN));
362 }
363
364 void Register() override
365 {
367 }
368};
369
370// 75102 - Vol'jin's War Drums
372{
373 bool Validate(SpellInfo const* /*spellInfo*/) override
374 {
376 }
377
378 void HandleDummy(SpellEffIndex /*effIndex*/)
379 {
380 Unit* caster = GetCaster();
381 if (Unit* target = GetHitUnit())
382 {
383 uint32 motivate = 0;
384 if (target->GetEntry() == NPC_CITIZEN_1)
385 motivate = SPELL_MOTIVATE_1;
386 else if (target->GetEntry() == NPC_CITIZEN_2)
387 motivate = SPELL_MOTIVATE_2;
388 if (motivate)
389 caster->CastSpell(target, motivate, false);
390 }
391 }
392
393 void Register() override
394 {
396 }
397};
398
400{
406}
Texts
#define M_PI
Definition: Common.h:115
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
Spells
Definition: PlayerAI.cpp:32
float rand_norm()
Definition: Random.cpp:75
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define CAST_AI(a, b)
Definition: UnitAI.h:28
@ MOVE_RUN
Definition: UnitDefines.h:118
@ MOVE_WALK
Definition: UnitDefines.h:117
@ REACT_PASSIVE
Definition: UnitDefines.h:506
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetTarget() const
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 SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
void SetDisplayId(uint32 displayId, bool setNative=false) override
Definition: Creature.cpp:3402
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
uint32 const Id
Definition: SpellInfo.h:325
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
Unit * GetSummonerUnit() const
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
Vehicle * GetVehicle() const
Definition: Unit.h:1713
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void Dismount()
Definition: Unit.cpp:7920
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:11618
TempSummon * ToTempSummon()
Definition: Unit.h:1756
UnitAI * GetAI() const
Definition: Unit.h:660
void Mount(uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
Definition: Unit.cpp:7887
bool IsSummon() const
Definition: Unit.h:738
bool IsMounted() const
Definition: Unit.h:898
float GetSpeedRate(UnitMoveType mtype) const
Definition: Unit.h:1644
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition: Unit.cpp:8525
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
bool isDead() const
Definition: Unit.h:1166
Unit * GetBase() const
Definition: Vehicle.h:49
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Unit * GetOwner() const
Definition: Object.cpp:2229
void Register() override
bool Validate(SpellInfo const *) override
void HandleEffectPeriodic(AuraEffect const *)
bool Validate(SpellInfo const *) override
void HandleDummy(SpellEffIndex)
void Register() override
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetPositionZ() const
Definition: Position.h:78
void SetCombatMovement(bool allowMovement)
bool HealthBelowPct(uint32 pct) const
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
npc_tiger_matriarch_credit(Creature *creature)
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *victim) override
void DamageTaken(Unit *attacker, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
void IsSummonedBy(WorldObject *summonerWO) override
npc_tiger_matriarch(Creature *creature)
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override
npc_troll_volunteer(Creature *creature)
void Reset() override
void InitializeAI() override
void MovementInform(uint32 type, uint32 id) override
void AddSC_event_zalazane_fall()
@ NPC_CITIZEN_1
@ NPC_TIGER_VEHICLE
@ NPC_VOLUNTEER_2
@ NPC_VOLUNTEER_1
@ NPC_URUZIN
@ NPC_CITIZEN_2
@ POINT_URUZIN
@ SPELL_POUNCE
@ SPELL_PETACT_AURA
@ SPELL_DETECT_INVIS
@ SPELL_SUMMON_ZENTABRA
@ SPELL_SUMMON_MATRIARCH
@ SPELL_EJECT_PASSENGERS
@ SPELL_AOE_TURNIN
@ SPELL_VOLUNTEER_AURA
@ SPELL_MOTIVATE_1
@ SPELL_MOUNTING_CHECK
@ SPELL_SPIRIT_OF_THE_TIGER_RIDER
@ SPELL_MOTIVATE_2
@ SPELL_QUEST_CREDIT
@ SPELL_NO_SUMMON_AURA
@ SPELL_TURNIN
@ SPELL_FURIOUS_BITE
@ SPELL_SUMMON_ZENTABRA_TRIGGER
@ SAY_VOLUNTEER_START
@ SAY_MATRIARCH_AGGRO
@ SAY_VOLUNTEER_END
uint32 const trollmodel[]
@ EVENT_NOSUMMON
@ EVENT_POUNCE
@ EVENT_CHECK_SUMMON_AURA
npc_troll_volunteer VolunteerAI