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 }
107
108private:
110 std::array<uint32, 5>::const_iterator _path;
111};
112
125
127{
128 npc_partygoer(Creature* creature) : ScriptedAI(creature), _facing(0.0f) { }
129
130 void JustAppeared() override
131 {
134 }
135
136 void UpdateAI(uint32 diff) override
137 {
138 _events.Update(diff);
139
140 while (uint32 eventId = _events.ExecuteEvent())
141 {
142 switch (eventId)
143 {
145 {
146 int8 action = urand(1, 6);
147
148 switch (action)
149 {
150 case 1:
153 break;
154 case 2:
157 break;
158 case 3:
161 break;
162 case 4:
163 me->LoadEquipment(urand(1, 2));
166 break;
167 case 5:
170 break;
171 case 6:
173 me->SetFacingToObject(launcher);
175 break;
176 }
177 break;
178 }
180 me->LoadEquipment(0, true);
182 break;
186 break;
190 break;
194 break;
195 }
196 }
197
198 if (!UpdateVictim())
199 return;
200 }
201
202private:
204 float _facing;
205};
206
int8_t int8
Definition Define.h:152
uint32_t uint32
Definition Define.h:154
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:43
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
@ 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:63
void LoadEquipment(int8 id=1, bool force=false)
void Update(uint32 time)
Definition EventMap.h:77
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13394
void SetEmoteState(Emote emote)
Definition Unit.h:880
void SetFacingTo(float ori, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13385
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition Unit.cpp:1662
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:1544
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
constexpr float GetOrientation() const
Definition Position.h:90
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()