TrinityCore
Loading...
Searching...
No Matches
zone_eversong_woods.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 "GameObject.h"
20#include "MotionMaster.h"
21#include "ScriptedCreature.h"
22
30
31static constexpr std::array<uint32, 5> PARTYGOER_PATHS = { 4755520, 4755528, 4755536, 4755544, 4755552 };
32
34{
35 npc_partygoer_pather(Creature* creature) : ScriptedAI(creature), _path(PARTYGOER_PATHS.begin()) { }
36
37 void JustAppeared() override
38 {
39 _path = PARTYGOER_PATHS.begin();
41 }
42
43 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
44 {
45 ++_path;
46 if (_path == PARTYGOER_PATHS.end())
47 _path = PARTYGOER_PATHS.begin();
48
50 }
51
52 void UpdateAI(uint32 diff) override
53 {
54 _events.Update(diff);
55
56 while (uint32 eventId = _events.ExecuteEvent())
57 {
58 switch (eventId)
59 {
60 case EVENT_PATH:
61 me->GetMotionMaster()->MovePath(*_path, false);
62 break;
64 {
65 int8 action = urand(1, 5);
66
67 switch (action)
68 {
69 case 1:
72 break;
73 case 2:
76 break;
77 case 3:
80 break;
81 case 4:
82 me->LoadEquipment(urand(1, 2));
85 break;
86 case 5:
89 break;
90 }
91 break;
92 }
94 me->LoadEquipment(0, true);
96 break;
100 break;
101 }
102 }
103
104 if (!UpdateVictim())
105 return;
106
108 }
109
110private:
112 std::array<uint32, 5>::const_iterator _path;
113};
114
127
129{
130 npc_partygoer(Creature* creature) : ScriptedAI(creature), _facing(0.0f) { }
131
132 void JustAppeared() override
133 {
136 }
137
138 void UpdateAI(uint32 diff) override
139 {
140 _events.Update(diff);
141
142 while (uint32 eventId = _events.ExecuteEvent())
143 {
144 switch (eventId)
145 {
147 {
148 int8 action = urand(1, 6);
149
150 switch (action)
151 {
152 case 1:
155 break;
156 case 2:
159 break;
160 case 3:
163 break;
164 case 4:
165 me->LoadEquipment(urand(1, 2));
168 break;
169 case 5:
172 break;
173 case 6:
175 me->SetFacingToObject(launcher);
177 break;
178 }
179 break;
180 }
182 me->LoadEquipment(0, true);
184 break;
188 break;
192 break;
196 break;
197 }
198 }
199
200 if (!UpdateVictim())
201 return;
202
204 }
205
206private:
208 float _facing;
209};
210
int8_t int8
Definition Define.h:131
uint32_t uint32
Definition Define.h:133
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1139
@ EMOTE_ONESHOT_EXCLAMATION
@ EMOTE_ONESHOT_LAUGH
@ EMOTE_STATE_DANCE
@ EMOTE_ONESHOT_EAT_NO_SHEATHE
@ EMOTE_ONESHOT_NONE
@ EMOTE_ONESHOT_TALK
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void LoadEquipment(int8 id=1, bool force=false)
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void MovePath(uint32 pathId, bool repeatable)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13259
void SetEmoteState(Emote emote)
Definition Unit.h:967
void HandleEmoteCommand(Emote emoteId)
Definition Unit.cpp:1568
void SetFacingTo(float ori, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13250
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:2121
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
float GetOrientation() const
Definition Position.h:82
npc_partygoer_pather(Creature *creature)
std::array< uint32, 5 >::const_iterator _path
void UpdateAI(uint32 diff) override
void WaypointPathEnded(uint32, uint32) override
void UpdateAI(uint32 diff) override
void JustAppeared() override
npc_partygoer(Creature *creature)
@ EVENT_RESET_FACING
@ EVENT_REMOVE_EQUIPMENT
@ GO_FIREWORKS_LAUNCHER
@ SPELL_SMALL_YELLOW_ROCKET
@ EVENT_THROW_FIREWORKS
@ EVENT_STOP_DANCING
@ EVENT_RANDOM_ACTION
@ EVENT_STOP_DANCING_PATHER
@ EVENT_RANDOM_ACTION_PATHER
@ EVENT_REMOVE_EQUIPMENT_PATHER
static constexpr std::array< uint32, 5 > PARTYGOER_PATHS
void AddSC_eversong_woods()