TrinityCore
Loading...
Searching...
No Matches
gilneas_chapter_1.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 "PhasingHandler.h"
24#include "ScriptedCreature.h"
25#include "SpellInfo.h"
26#include "SpellScript.h"
27#include "TemporarySummon.h"
28
30{
31 namespace Creatures
32 {
33 static constexpr uint32 EvacuationStalkerFirst = 35830;
34 static constexpr uint32 EvacuationStalkerNear = 35010;
35 static constexpr uint32 EvacuationStalkerFar = 35011;
36 }
37
38 namespace Events
39 {
40 namespace EvacuateTheMerchantSquare
41 {
42 static constexpr uint32 TalkFrightened = 1;
43 static constexpr uint32 MoveToNearStalker = 2;
44 static constexpr uint32 MoveToFarStalker = 3;
45 static constexpr uint32 FrightenedDespawn = 4;
46 }
47 }
48
49 namespace Texts
50 {
51 namespace FrightenedCitizen
52 {
53 static constexpr uint32 SayFrightenedCitizenRescue = 0;
54 }
55 }
56
57 namespace Points
58 {
59 static constexpr uint32 PointStalkerFirst = 1;
60 static constexpr uint32 PointStalkerNear = 2;
61 static constexpr uint32 PointStalkerFar = 3;
62 }
63
64// 34981 - Frightened Citizen
65// 35836 - Frightened Citizen
67{
68 npc_frightened_citizen(Creature* creature) : ScriptedAI(creature) {}
69
70 void IsSummonedBy(WorldObject* /*summoner*/) override
71 {
73
75 me->GetMotionMaster()->MovePoint(Points::PointStalkerFirst, stalkerNear->GetPosition(), true);
76 }
77
98
99 void UpdateAI(uint32 diff) override
100 {
101 _events.Update(diff);
102
103 while (uint32 eventId = _events.ExecuteEvent())
104 {
105 switch (eventId)
106 {
108 if (TempSummon* summon = me->ToTempSummon())
109 {
110 if (Unit* summoner = summon->GetSummonerUnit())
111 {
112 if (Player* player = summoner->ToPlayer())
113 {
114 player->KilledMonsterCredit(Creatures::EvacuationStalkerFirst);
116 }
117 }
118 }
120 break;
123 me->GetMotionMaster()->MovePoint(Points::PointStalkerFar, stalker->GetPosition(), true);
125 me->GetMotionMaster()->MovePoint(Points::PointStalkerNear, stalker->GetPosition(), true);
126 break;
129 me->GetMotionMaster()->MovePoint(Points::PointStalkerFar, stalker->GetPosition(), true);
130 break;
133 break;
134 default:
135 break;
136 }
137 }
138 }
139private:
141};
142
143// 67869 - Knocking
145{
146 bool Validate(SpellInfo const* spellInfo) override
147 {
148 return ValidateSpellInfo(
149 {
152 });
153 }
154
156 {
157 GetCaster()->CastSpell(GetCaster(), GetEffectInfo(RAND(EFFECT_1, EFFECT_2)).CalcValueAsInt(), true);
158 }
159
164};
165}
166
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_1
@ EFFECT_2
#define SpellCastFn(F)
@ REACT_PASSIVE
Creatures
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Player * ToPlayer()
Definition Object.h:126
int32 CalcValueAsInt(WorldObject const *caster=nullptr, SpellEffectValue const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:588
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
SpellEffectInfo const & GetEffectInfo() const
HookList< CastHandler > OnCast
Definition Unit.h:635
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
TempSummon * ToTempSummon()
Definition Unit.h:1828
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1517
void AddSC_gilneas_chapter_1()