Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
GameEventMgr.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SKYFIRE_GAMEEVENT_MGR_H
7#define SKYFIRE_GAMEEVENT_MGR_H
8
9#include "Common.h"
10#include "Define.h"
11#include "Platform/Singleton.h"
12#include "SharedDefines.h"
13
14#define max_ge_check_delay DAY // 1 day in seconds
15
17{
18 GAMEEVENT_NORMAL = 0, // standard game events
19 GAMEEVENT_WORLD_INACTIVE = 1, // not yet started
20 GAMEEVENT_WORLD_CONDITIONS = 2, // condition matching phase
21 GAMEEVENT_WORLD_NEXTPHASE = 3, // conditions are met, now 'length' timer to start next event
22 GAMEEVENT_WORLD_FINISHED = 4, // next events are started, unapply this one
23 GAMEEVENT_INTERNAL = 5 // never handled in update
24};
25
27{
28 float reqNum; // required number // use float, since some events use percent
29 float done; // done number
30 uint32 max_world_state; // max resource count world state update id
31 uint32 done_world_state; // done resource count world state update id
32};
33
40
41typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventConditionMap;
42
44{
46 time_t start; // occurs after this time
47 time_t end; // occurs before this time
48 time_t nextstart; // after this time the follow-up events count this phase completed
49 uint32 occurence; // time between end and start
50 uint32 length; // length of the event (minutes) after finishing all conditions
52 GameEventState state; // state of the game event, these are saved into the game_event table on change!
53 GameEventConditionMap conditions; // conditions to finish
54 std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event
55 std::string description;
56 uint8 announce; // if 0 dont announce, if 1 announce, if 2 take config value
57
58 bool isValid() const { return length > 0 || state > GAMEEVENT_NORMAL; }
59};
60
68
70{
71 uint32 entry; // creature entry
72 uint32 item; // item id
73 int32 maxcount; // 0 for infinite
74 uint32 incrtime; // time for restore items amount if maxcount != 0
76 uint8 Type; // 1 item, 2 currency
77};
78
79class Player;
80class Creature;
81class Quest;
82
84{
85 friend class Skyfire::Singleton<GameEventMgr, Skyfire::NullMutex>;
86
87private:
90
91public:
92 typedef std::set<uint16> ActiveEvents;
93 typedef std::vector<GameEventData> GameEventDataMap;
95 GameEventDataMap const& GetEventMap() const { return mGameEvent; }
96 bool CheckOneGameEvent(uint16 entry) const;
97 uint32 NextCheck(uint16 entry) const;
98 void LoadFromDB();
99 uint32 Update();
100 bool IsActiveEvent(uint16 event_id) { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); }
102 void Initialize();
103 void StartArenaSeason();
104 void StartInternalEvent(uint16 event_id);
105 bool StartEvent(uint16 event_id, bool overwrite = false);
106 void StopEvent(uint16 event_id, bool overwrite = false);
107 void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions
111 uint16 GetEventIdForQuest(Quest const* quest) const;
112private:
113 void SendWorldStateUpdate(Player* player, uint16 event_id);
114 void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
115 void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); }
116 void ApplyNewEvent(uint16 event_id);
117 void UnApplyEvent(uint16 event_id);
118 void GameEventSpawn(int16 event_id);
119 void GameEventUnspawn(int16 event_id);
120 void ChangeEquipOrModel(int16 event_id, bool activate);
121 void UpdateEventQuests(uint16 event_id, bool activate);
122 void UpdateWorldStates(uint16 event_id, bool Activate);
123 void UpdateEventNPCFlags(uint16 event_id);
124 void UpdateEventNPCVendor(uint16 event_id, bool activate);
126 void RunSmartAIScripts(uint16 event_id, bool activate);
127 bool CheckOneGameEventConditions(uint16 event_id);
128 void SaveWorldEventStateToDB(uint16 event_id);
129 bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
130 bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
131 bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id);
132 bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id);
133
134 typedef std::list<uint32> GuidList;
135 typedef std::list<uint32> IdList;
136 typedef std::vector<GuidList> GameEventGuidMap;
137 typedef std::vector<IdList> GameEventIdMap;
138 typedef std::pair<uint32, ModelEquip> ModelEquipPair;
139 typedef std::list<ModelEquipPair> ModelEquipList;
140 typedef std::vector<ModelEquipList> GameEventModelEquipMap;
141 typedef std::pair<uint32, uint32> QuestRelation;
142 typedef std::list<QuestRelation> QuestRelList;
143 typedef std::vector<QuestRelList> GameEventQuestMap;
144 typedef std::list<NPCVendorEntry> NPCVendorList;
145 typedef std::vector<NPCVendorList> GameEventNPCVendorMap;
147 typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair;
148 typedef std::list<GuidNPCFlagPair> NPCFlagList;
149 typedef std::vector<NPCFlagList> GameEventNPCFlagMap;
150 typedef std::vector<uint32> GameEventBitmask;
155 //GameEventGuidMap mGameEventCreatureGuids;
156 //GameEventGuidMap mGameEventGameobjectGuids;
165public:
168};
169
170#define sGameEventMgr Skyfire::Singleton<GameEventMgr, Skyfire::NullMutex>::instance()
171
173bool IsEventActive(uint16 event_id);
174
175#endif
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint16_t uint16
Definition Define.h:78
std::int16_t int16
Definition Define.h:74
bool IsHolidayActive(HolidayIds id)
bool IsEventActive(uint16 event_id)
std::map< uint32, GameEventFinishCondition > GameEventConditionMap
GameEventState
@ GAMEEVENT_NORMAL
@ GAMEEVENT_INTERNAL
@ GAMEEVENT_WORLD_FINISHED
@ GAMEEVENT_WORLD_CONDITIONS
@ GAMEEVENT_WORLD_NEXTPHASE
@ GAMEEVENT_WORLD_INACTIVE
HolidayIds
#define UNORDERED_MAP
uint32 NextCheck(uint16 entry) const
void HandleQuestComplete(uint32 quest_id)
GameEventDataMap const & GetEventMap() const
ActiveEvents m_ActiveEvents
bool StartEvent(uint16 event_id, bool overwrite=false)
GameEventDataMap mGameEvent
uint16 GetEventIdForQuest(Quest const *quest) const
GameEventNPCFlagMap mGameEventNPCFlags
std::list< uint32 > GuidList
bool IsActiveEvent(uint16 event_id)
GameEventIdMap mGameEventPoolIds
std::vector< GameEventData > GameEventDataMap
void GameEventSpawn(int16 event_id)
void GameEventUnspawn(int16 event_id)
GameEventGuidMap mGameEventCreatureGuids
void RemoveActiveEvent(uint16 event_id)
void UnApplyEvent(uint16 event_id)
void UpdateEventQuests(uint16 event_id, bool activate)
void UpdateEventNPCVendor(uint16 event_id, bool activate)
void UpdateWorldStates(uint16 event_id, bool Activate)
void AddActiveEvent(uint16 event_id)
std::vector< GuidList > GameEventGuidMap
void HandleWorldEventGossip(Player *player, Creature *c)
void StartInternalEvent(uint16 event_id)
void ApplyNewEvent(uint16 event_id)
std::vector< NPCVendorList > GameEventNPCVendorMap
GameEventModelEquipMap mGameEventModelEquip
ActiveEvents const & GetActiveEventList() const
std::list< ModelEquipPair > ModelEquipList
void UpdateBattlegroundSettings()
GameEventBitmask mGameEventBattlegroundHolidays
GameEventNPCVendorMap mGameEventVendors
GameEventQuestMap mGameEventCreatureQuests
std::pair< uint32, uint32 > GuidNPCFlagPair
GameEventGuidMap mGameEventGameobjectGuids
void SaveWorldEventStateToDB(uint16 event_id)
UNORDERED_MAP< uint32, uint16 > _questToEventLinks
void UpdateEventNPCFlags(uint16 event_id)
bool CheckOneGameEventConditions(uint16 event_id)
Runs SMART_EVENT_GAME_EVENT_START/_END SAI.
void ChangeEquipOrModel(int16 event_id, bool activate)
uint32 StartSystem()
void RunSmartAIScripts(uint16 event_id, bool activate)
std::set< uint16 > ActiveEvents
QuestIdToEventConditionMap mQuestToEventConditions
std::map< uint32, GameEventQuestToEventConditionNum > QuestIdToEventConditionMap
std::vector< uint32 > GameEventBitmask
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id)
std::list< GuidNPCFlagPair > NPCFlagList
std::list< uint32 > IdList
GameEventQuestMap mGameEventGameObjectQuests
std::vector< QuestRelList > GameEventQuestMap
std::vector< ModelEquipList > GameEventModelEquipMap
std::list< QuestRelation > QuestRelList
void SendWorldStateUpdate(Player *player, uint16 event_id)
uint32 GetNPCFlag(Creature *cr)
std::vector< IdList > GameEventIdMap
uint32 GetNpcTextId(uint32 guid)
bool CheckOneGameEvent(uint16 entry) const
void StopEvent(uint16 event_id, bool overwrite=false)
void StartArenaSeason()
std::list< NPCVendorEntry > NPCVendorList
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id)
std::pair< uint32, uint32 > QuestRelation
bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id)
std::pair< uint32, ModelEquip > ModelEquipPair
std::vector< NPCFlagList > GameEventNPCFlagMap
bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id)
GameEventState state
bool isValid() const
HolidayIds holiday_id
std::set< uint16 > prerequisite_events
GameEventConditionMap conditions
std::string description
uint32 modelid
uint8 equipement_id_prev
uint32 modelid_prev
uint8 equipment_id
uint8 Type
int32 maxcount
uint32 item
uint32 entry
uint32 incrtime
uint32 ExtendedCost