Changeset 44 for trunk/src/game/GameEvent.h
- Timestamp:
- 11/19/08 13:27:40 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/GameEvent.h
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 19 #ifndef MANGOS_GAMEEVENT_H20 #define MANGOS_GAMEEVENT_H21 #ifndef TRINITY_GAMEEVENT_H 22 #define TRINITY_GAMEEVENT_H 21 23 22 24 #include "Platform/Define.h" … … 26 28 #define max_ge_check_delay 86400 // 1 day in seconds 27 29 30 enum GameEventState 31 { 32 GAMEEVENT_NORMAL = 0, // standard game events 33 GAMEEVENT_WORLD_INACTIVE, // not yet started 34 GAMEEVENT_WORLD_CONDITIONS, // condition matching phase 35 GAMEEVENT_WORLD_NEXTPHASE, // conditions are met, now 'lenght' timer to start next event 36 GAMEEVENT_WORLD_FINISHED // next events are started, unapply this one 37 }; 38 39 struct GameEventFinishCondition 40 { 41 float reqNum; // required number // use float, since some events use percent 42 float done; // done number 43 uint32 max_world_state; // max resource count world state update id 44 uint32 done_world_state; // done resource count world state update id 45 }; 46 47 struct GameEventQuestToEventConditionNum 48 { 49 uint16 event_id; 50 uint32 condition; 51 float num; 52 }; 53 28 54 struct GameEventData 29 55 { 30 GameEventData() : start(1),end(0),occurence(0),length(0) {} 31 time_t start; 32 time_t end; 33 uint32 occurence; 34 uint32 length; 56 GameEventData() : start(1),end(0),nextstart(0),occurence(0),length(0),state(GAMEEVENT_NORMAL) {} 57 time_t start; // occurs after this time 58 time_t end; // occurs before this time 59 time_t nextstart; // after this time the follow-up events count this phase completed 60 uint32 occurence; // time between end and start 61 uint32 length; // length of the event (minutes) after finishing all conditions 62 GameEventState state; // state of the game event, these are saved into the game_event table on change! 63 std::map<uint32 /*condition id*/, GameEventFinishCondition> conditions; // conditions to finish 64 std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event 35 65 std::string description; 36 66 37 bool isValid() const { return length > 0; }67 bool isValid() const { return ((length > 0) || (state > GAMEEVENT_NORMAL)); } 38 68 }; 39 69 … … 46 76 }; 47 77 78 struct NPCVendorEntry 79 { 80 uint32 entry; // creature entry 81 uint32 item; // item id 82 uint32 maxcount; // 0 for infinite 83 uint32 incrtime; // time for restore items amount if maxcount != 0 84 uint32 ExtendedCost; 85 }; 86 87 class Player; 48 88 class GameEvent 49 89 { … … 61 101 bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); } 62 102 uint32 Initialize(); 63 voidStartEvent(uint16 event_id, bool overwrite = false);103 bool StartEvent(uint16 event_id, bool overwrite = false); 64 104 void StopEvent(uint16 event_id, bool overwrite = false); 105 void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions 106 void HandleWorldEventGossip(Player * plr, Creature * c); 107 uint32 GetNPCFlag(Creature * cr); 108 uint32 GetNpcTextId(uint32 guid); 65 109 private: 110 void SendWorldStateUpdate(Player * plr, uint16 event_id); 66 111 void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } 67 112 void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } … … 72 117 void ChangeEquipOrModel(int16 event_id, bool activate); 73 118 void UpdateEventQuests(uint16 event_id, bool Activate); 119 void UpdateEventNPCFlags(uint16 event_id); 120 void UpdateEventNPCVendor(uint16 event_id, bool activate); 121 bool CheckOneGameEventConditions(uint16 event_id); 122 void SaveWorldEventStateToDB(uint16 event_id); 123 bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); 124 bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); 125 bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id); 126 bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id); 74 127 protected: 75 128 typedef std::list<uint32> GuidList; … … 81 134 typedef std::list<QuestRelation> QuestRelList; 82 135 typedef std::vector<QuestRelList> GameEventQuestMap; 83 GameEventQuestMap mGameEventQuests; 136 typedef std::list<NPCVendorEntry> NPCVendorList; 137 typedef std::vector<NPCVendorList> GameEventNPCVendorMap; 138 typedef std::map<uint32 /*quest id*/, GameEventQuestToEventConditionNum> QuestIdToEventConditionMap; 139 typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; 140 typedef std::list<GuidNPCFlagPair> NPCFlagList; 141 typedef std::vector<NPCFlagList> GameEventNPCFlagMap; 142 typedef std::pair<uint16 /*event id*/, uint32 /*gossip id*/> EventNPCGossipIdPair; 143 typedef std::map<uint32 /*guid*/, EventNPCGossipIdPair> GuidEventNpcGossipIdMap; 144 GameEventQuestMap mGameEventCreatureQuests; 145 GameEventQuestMap mGameEventGameObjectQuests; 146 GameEventNPCVendorMap mGameEventVendors; 84 147 GameEventModelEquipMap mGameEventModelEquip; 85 148 GameEventGuidMap mGameEventCreatureGuids; 86 149 GameEventGuidMap mGameEventGameobjectGuids; 87 150 GameEventDataMap mGameEvent; 151 QuestIdToEventConditionMap mQuestToEventConditions; 152 GameEventNPCFlagMap mGameEventNPCFlags; 153 GuidEventNpcGossipIdMap mNPCGossipIds; 88 154 ActiveEvents m_ActiveEvents; 89 155 bool isSystemInit; 90 156 }; 91 157 92 #define gameeventmgr MaNGOS::Singleton<GameEvent>::Instance()158 #define gameeventmgr Trinity::Singleton<GameEvent>::Instance() 93 159 #endif