AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
go_firework_show Struct Reference
Inheritance diagram for go_firework_show:
GameObjectAI

Public Member Functions

 go_firework_show (GameObject *go)
 
void InitShow ()
 
void StartShow (int minutesOffset)
 
void StopShow ()
 
int32 SpawnNextFirework ()
 
void UpdateAI (uint32 diff) override
 
- Public Member Functions inherited from GameObjectAI
 GameObjectAI (GameObject *go)
 
virtual ~GameObjectAI ()
 
virtual void InitializeAI ()
 
virtual void Reset ()
 
virtual void DoAction (int32)
 
virtual void SetGUID (ObjectGuid, int32)
 
virtual ObjectGuid GetGUID (int32) const
 
virtual bool GossipHello (Player *, bool)
 
virtual bool GossipSelect (Player *, uint32, uint32)
 
virtual bool GossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual bool QuestAccept (Player *, Quest const *)
 
virtual bool QuestReward (Player *, Quest const *, uint32)
 
virtual uint32 GetDialogStatus (Player *)
 
virtual void Destroyed (Player *, uint32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void OnGameEvent (bool, uint16)
 
virtual void OnStateChanged (uint32, Unit *)
 
virtual void EventInform (uint32)
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual bool CanBeSeen (Player const *)
 
virtual void JustSummoned (Creature *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void SummonedCreatureEvade (Creature *)
 

Private Attributes

TaskScheduler _scheduler
 
uint32_t _curIdx
 
bool _showRunning
 
FireworkShow const * _show
 

Additional Inherited Members

- Static Public Member Functions inherited from GameObjectAI
static int32 Permissible (GameObject const *go)
 
- Protected Attributes inherited from GameObjectAI
GameObject *const me
 

Detailed Description

Constructor & Destructor Documentation

◆ go_firework_show()

go_firework_show::go_firework_show ( GameObject go)
inline
49 : GameObjectAI(go)
50 {
51 _curIdx = 0;
52 _showRunning = false;
53 _show = nullptr;
54
55 InitShow();
56 }
Definition GameObjectAI.h:33
void InitShow()
Definition firework_show.cpp:58
FireworkShow const * _show
Definition firework_show.cpp:208
uint32_t _curIdx
Definition firework_show.cpp:206
bool _showRunning
Definition firework_show.cpp:207

References _curIdx, _show, _showRunning, and InitShow().

Member Function Documentation

◆ InitShow()

void go_firework_show::InitShow ( )
inline
59 {
60 _show = nullptr;
61
62 auto itr = FireworkShowStore.find(std::make_pair(me->GetMapId(), me->GetZoneId()));
63 if (itr != FireworkShowStore.end() && itr->second)
64 _show = itr->second;
65
66 StopShow();
67
68 _scheduler.Schedule(Milliseconds(4200), [this](TaskContext context)
69 {
70 // check for show start
71 if (!_showRunning)
72 {
73 tzset(); // set timezone for localtime_r() -> fix issues due to daylight time
74 tm local_tm = Acore::Time::TimeBreakdown();
75
76 // each show runs approx. 12 minutes
77 // and starts at the full hour
78 if ((local_tm.tm_min >= 0) && (local_tm.tm_min < 12))
79 {
80 StartShow(local_tm.tm_min);
81 }
82 }
83
84 context.Repeat();
85 });
86 }
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:27
GameObject *const me
Definition GameObjectAI.h:35
Definition TaskScheduler.h:421
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
Definition TaskScheduler.h:493
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition TaskScheduler.h:232
uint32 GetMapId() const
Definition Position.h:280
uint32 GetZoneId() const
Definition Object.cpp:3148
std::map< std::pair< uint32, uint32 >, FireworkShow const * > const FireworkShowStore
Definition firework_show.cpp:34
AC_COMMON_API std::tm TimeBreakdown(time_t t=0)
Definition Timer.cpp:233
TaskScheduler _scheduler
Definition firework_show.cpp:205
void StopShow()
Definition firework_show.cpp:122
void StartShow(int minutesOffset)
Definition firework_show.cpp:90

References _scheduler, _show, _showRunning, FireworkShowStore, WorldLocation::GetMapId(), WorldObject::GetZoneId(), GameObjectAI::me, TaskContext::Repeat(), TaskScheduler::Schedule(), StartShow(), StopShow(), and Acore::Time::TimeBreakdown().

Referenced by go_firework_show().

◆ SpawnNextFirework()

int32 go_firework_show::SpawnNextFirework ( )
inline
155 {
156 if (!_showRunning)
157 return -1;
158
160 return -2;
161
162 if (_curIdx >= _show->schedule.size)
163 return -3;
164
166 if (posIdx < _show->spawns.size)
167 {
169 _show->spawns.entries[posIdx].x,
170 _show->spawns.entries[posIdx].y,
171 _show->spawns.entries[posIdx].z,
172 _show->spawns.entries[posIdx].o,
173 _show->spawns.entries[posIdx].rot0,
174 _show->spawns.entries[posIdx].rot1,
175 _show->spawns.entries[posIdx].rot2,
176 _show->spawns.entries[posIdx].rot3,
177 0);
178
179 // trigger despawn animation for firework explosion
180 if (go)
181 {
182 go->setActive(true);
183 go->DespawnOrUnsummon();
185 }
186 }
187
189
190 if (++_curIdx >= _show->schedule.size)
191 return -4;
192
194 return -5;
195
196 return (_show->schedule.entries[_curIdx].timestamp - ts);
197 }
std::uint32_t uint32
Definition Define.h:107
Definition GameObject.h:120
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition GameObject.cpp:936
void setActive(bool isActiveObject)
Definition Object.cpp:1094
void AddObjectToRemoveList()
Definition Object.cpp:2160
GameObject * SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition Object.cpp:2382
uint32 timestamp
Definition firework_show.h:80
uint32 gameobjectId
Definition firework_show.h:81
uint32 spawnIndex
Definition firework_show.h:82
FireworkShowScheduleEntry const * entries
Definition firework_show.h:88
struct FireworkShow::@304 spawns
struct FireworkShow::@303 schedule
uint32 const size
Definition firework_show.h:89

References _curIdx, _show, _showRunning, WorldObject::AddObjectToRemoveList(), GameObject::DespawnOrUnsummon(), FireworkShow::entries, FireworkShowScheduleEntry::gameobjectId, GameObjectAI::me, FireworkShow::schedule, WorldObject::setActive(), FireworkShow::size, FireworkShowScheduleEntry::spawnIndex, FireworkShow::spawns, WorldObject::SummonGameObject(), and FireworkShowScheduleEntry::timestamp.

Referenced by StartShow().

◆ StartShow()

void go_firework_show::StartShow ( int  minutesOffset)
inline
91 {
93 return;
94
95 _curIdx = 0;
96 _showRunning = true;
97 me->setActive(true);
98
99 // fast-forward show if we've got a late start
100 if (minutesOffset > 0)
101 {
102 int ts = 0;
103 do {
105 } while ((ts <= (minutesOffset * MINUTE * IN_MILLISECONDS)) && (++_curIdx < _show->schedule.size));
106 }
107
108 _scheduler.Schedule(0s, [this](TaskContext context)
109 {
110 int32 dt = 0;
111 do {
112 dt = SpawnNextFirework();
113 } while (dt == 0);
114
115 if (0 < dt)
116 context.Repeat(Milliseconds(dt));
117 else
118 StopShow();
119 });
120 }
constexpr auto IN_MILLISECONDS
Definition Common.h:53
constexpr auto MINUTE
Definition Common.h:47
std::int32_t int32
Definition Define.h:103
int32 SpawnNextFirework()
Definition firework_show.cpp:154

References _curIdx, _scheduler, _show, _showRunning, FireworkShow::entries, IN_MILLISECONDS, GameObjectAI::me, MINUTE, TaskContext::Repeat(), TaskScheduler::Schedule(), FireworkShow::schedule, WorldObject::setActive(), FireworkShow::size, SpawnNextFirework(), FireworkShow::spawns, StopShow(), and FireworkShowScheduleEntry::timestamp.

Referenced by InitShow().

◆ StopShow()

void go_firework_show::StopShow ( )
inline
123 {
124 if (_showRunning)
125 {
126 // Trigger SAI to spawn 'Toasting Goblets' on show end
127 std::list<GameObject*> _goList;
129
130 for (std::list<GameObject*>::const_iterator itr = _goList.begin(); itr != _goList.end(); ++itr)
131 {
132 if (GameObjectAI* ai = (*itr)->AI())
133 ai->SetData(0, 1);
134 }
135
136 // Trigger SAI to make Revelers cheer on show end
137 for (uint32 i = 0; i < COUNT_REVELER_ID; i++)
138 {
139 std::list<Creature*> _crList;
140 me->GetCreatureListWithEntryInGrid(_crList, _show->revelerId[i], 1420.0f);
141
142 for (std::list<Creature*>::const_iterator itr = _crList.begin(); itr != _crList.end(); ++itr)
143 {
144 if (CreatureAI* ai = (*itr)->AI())
145 ai->SetData(0, 1);
146 }
147 }
148 }
149
150 _showRunning = false;
151 me->setActive(false);
152 }
Definition CreatureAI.h:70
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2506
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2513
@ COUNT_REVELER_ID
Definition firework_show.h:63
@ GO_TOASTING_GOBLET
Definition firework_show.h:49
uint32 const revelerId[COUNT_REVELER_ID]
Definition firework_show.h:95

References _show, _showRunning, COUNT_REVELER_ID, WorldObject::GetCreatureListWithEntryInGrid(), WorldObject::GetGameObjectListWithEntryInGrid(), GO_TOASTING_GOBLET, GameObjectAI::me, FireworkShow::revelerId, and WorldObject::setActive().

Referenced by InitShow(), and StartShow().

◆ UpdateAI()

void go_firework_show::UpdateAI ( uint32  diff)
inlineoverridevirtual

Reimplemented from GameObjectAI.

200 {
201 _scheduler.Update(diff);
202 }
TaskScheduler & Update(success_t const &callback=EmptyCallback)
Definition TaskScheduler.cpp:27

References _scheduler, and TaskScheduler::Update().

Member Data Documentation

◆ _curIdx

uint32_t go_firework_show::_curIdx
private

◆ _scheduler

TaskScheduler go_firework_show::_scheduler
private

Referenced by InitShow(), StartShow(), and UpdateAI().

◆ _show

FireworkShow const* go_firework_show::_show
private

◆ _showRunning

bool go_firework_show::_showRunning
private

The documentation for this struct was generated from the following file: