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 UpdateAI (uint32)
 
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
48 : GameObjectAI(go)
49 {
50 _curIdx = 0;
51 _showRunning = false;
52 _show = nullptr;
53
54 InitShow();
55 }
Definition: GameObjectAI.h:33
void InitShow()
Definition: firework_show.cpp:57
FireworkShow const * _show
Definition: firework_show.cpp:207
uint32_t _curIdx
Definition: firework_show.cpp:205
bool _showRunning
Definition: firework_show.cpp:206

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

Member Function Documentation

◆ InitShow()

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

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
154 {
155 if (!_showRunning)
156 return -1;
157
159 return -2;
160
161 if (_curIdx >= _show->schedule.size)
162 return -3;
163
165 if (posIdx < _show->spawns.size)
166 {
168 _show->spawns.entries[posIdx].x,
169 _show->spawns.entries[posIdx].y,
170 _show->spawns.entries[posIdx].z,
171 _show->spawns.entries[posIdx].o,
172 _show->spawns.entries[posIdx].rot0,
173 _show->spawns.entries[posIdx].rot1,
174 _show->spawns.entries[posIdx].rot2,
175 _show->spawns.entries[posIdx].rot3,
176 0);
177
178 // trigger despawn animation for firework explosion
179 if (go)
180 {
181 go->setActive(true);
182 go->DespawnOrUnsummon();
184 }
185 }
186
188
189 if (++_curIdx >= _show->schedule.size)
190 return -4;
191
193 return -5;
194
195 return (_show->schedule.entries[_curIdx].timestamp - ts);
196 }
std::uint32_t uint32
Definition: Define.h:107
Definition: GameObject.h:120
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition: GameObject.cpp:935
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:2380
uint32 timestamp
Definition: firework_show.h:80
uint32 gameobjectId
Definition: firework_show.h:81
uint32 spawnIndex
Definition: firework_show.h:82
struct FireworkShow::@306 schedule
FireworkShowScheduleEntry const * entries
Definition: firework_show.h:88
struct FireworkShow::@307 spawns
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
90 {
92 return;
93
94 _curIdx = 0;
95 _showRunning = true;
96 me->setActive(true);
97
98 // fast-forward show if we've got a late start
99 if (minutesOffset > 0)
100 {
101 int ts = 0;
102 do {
104 } while ((ts <= (minutesOffset * MINUTE * IN_MILLISECONDS)) && (++_curIdx < _show->schedule.size));
105 }
106
107 _scheduler.Schedule(0s, [this](TaskContext context)
108 {
109 int32 dt = 0;
110 do {
111 dt = SpawnNextFirework();
112 } while (dt == 0);
113
114 if (0 < dt)
115 context.Repeat(Milliseconds(dt));
116 else
117 StopShow();
118 });
119 }
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:153

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

199 {
200 _scheduler.Update(diff);
201 }
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