From 2265aef916e3b2d63d87faa68a2b51e7d747c54c Mon Sep 17 00:00:00 2001 From: Seline Date: Tue, 14 Oct 2008 11:57:03 -0500 Subject: [svn] * Merge Temp dev SVN with Assembla. * Changes include: - Implementation of w12x's Outdoor PvP and Game Event Systems. - Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed). - All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql). - Improved Config cleanup. - And many more changes. --HG-- branch : trunk --- src/game/GameEvent.h | 94 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 14 deletions(-) (limited to 'src/game/GameEvent.h') diff --git a/src/game/GameEvent.h b/src/game/GameEvent.h index 535422eb407..c49c50ba6cb 100644 --- a/src/game/GameEvent.h +++ b/src/game/GameEvent.h @@ -1,5 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 Trinity + * + * Thanks to the original authors: MaNGOS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOS_GAMEEVENT_H -#define MANGOS_GAMEEVENT_H +#ifndef TRINITY_GAMEEVENT_H +#define TRINITY_GAMEEVENT_H #include "Platform/Define.h" #include "Creature.h" @@ -25,16 +27,44 @@ #define max_ge_check_delay 86400 // 1 day in seconds +enum GameEventState +{ + GAMEEVENT_NORMAL = 0, // standard game events + GAMEEVENT_WORLD_INACTIVE, // not yet started + GAMEEVENT_WORLD_CONDITIONS, // condition matching phase + GAMEEVENT_WORLD_NEXTPHASE, // conditions are met, now 'lenght' timer to start next event + GAMEEVENT_WORLD_FINISHED // next events are started, unapply this one +}; + +struct GameEventFinishCondition +{ + float reqNum; // required number // use float, since some events use percent + float done; // done number + uint32 max_world_state; // max resource count world state update id + uint32 done_world_state; // done resource count world state update id +}; + +struct GameEventQuestToEventConditionNum +{ + uint16 event_id; + uint32 condition; + float num; +}; + struct GameEventData { - GameEventData() : start(1),end(0),occurence(0),length(0) {} - time_t start; - time_t end; - uint32 occurence; - uint32 length; + GameEventData() : start(1),end(0),nextstart(0),occurence(0),length(0),state(GAMEEVENT_NORMAL) {} + time_t start; // occurs after this time + time_t end; // occurs before this time + time_t nextstart; // after this time the follow-up events count this phase completed + uint32 occurence; // time between end and start + uint32 length; // length of the event (minutes) after finishing all conditions + GameEventState state; // state of the game event, these are saved into the game_event table on change! + std::map conditions; // conditions to finish + std::set prerequisite_events; // events that must be completed before starting this event std::string description; - bool isValid() const { return length > 0; } + bool isValid() const { return ((length > 0) || (state > GAMEEVENT_NORMAL)); } }; struct ModelEquip @@ -45,6 +75,16 @@ struct ModelEquip uint32 equipement_id_prev; }; +struct NPCVendorEntry +{ + uint32 entry; // creature entry + uint32 item; // item id + uint32 maxcount; // 0 for infinite + uint32 incrtime; // time for restore items amount if maxcount != 0 + uint32 ExtendedCost; +}; + +class Player; class GameEvent { public: @@ -60,9 +100,14 @@ class GameEvent uint32 Update(); bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); } uint32 Initialize(); - void StartEvent(uint16 event_id, bool overwrite = false); + bool StartEvent(uint16 event_id, bool overwrite = false); void StopEvent(uint16 event_id, bool overwrite = false); + void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions + void HandleWorldEventGossip(Player * plr, Creature * c); + uint32 GetNPCFlag(Creature * cr); + uint32 GetNpcTextId(uint32 guid); private: + void SendWorldStateUpdate(Player * plr, uint16 event_id); void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } void ApplyNewEvent(uint16 event_id); @@ -71,6 +116,14 @@ class GameEvent void GameEventUnspawn(int16 event_id); void ChangeEquipOrModel(int16 event_id, bool activate); void UpdateEventQuests(uint16 event_id, bool Activate); + void UpdateEventNPCFlags(uint16 event_id); + void UpdateEventNPCVendor(uint16 event_id, bool activate); + bool CheckOneGameEventConditions(uint16 event_id); + void SaveWorldEventStateToDB(uint16 event_id); + bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); + bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); + bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id); + bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id); protected: typedef std::list GuidList; typedef std::vector GameEventGuidMap; @@ -80,14 +133,27 @@ class GameEvent typedef std::pair QuestRelation; typedef std::list QuestRelList; typedef std::vector GameEventQuestMap; - GameEventQuestMap mGameEventQuests; + typedef std::list NPCVendorList; + typedef std::vector GameEventNPCVendorMap; + typedef std::map QuestIdToEventConditionMap; + typedef std::pair GuidNPCFlagPair; + typedef std::list NPCFlagList; + typedef std::vector GameEventNPCFlagMap; + typedef std::pair EventNPCGossipIdPair; + typedef std::map GuidEventNpcGossipIdMap; + GameEventQuestMap mGameEventCreatureQuests; + GameEventQuestMap mGameEventGameObjectQuests; + GameEventNPCVendorMap mGameEventVendors; GameEventModelEquipMap mGameEventModelEquip; GameEventGuidMap mGameEventCreatureGuids; GameEventGuidMap mGameEventGameobjectGuids; GameEventDataMap mGameEvent; + QuestIdToEventConditionMap mQuestToEventConditions; + GameEventNPCFlagMap mGameEventNPCFlags; + GuidEventNpcGossipIdMap mNPCGossipIds; ActiveEvents m_ActiveEvents; bool isSystemInit; }; -#define gameeventmgr MaNGOS::Singleton::Instance() +#define gameeventmgr Trinity::Singleton::Instance() #endif -- cgit v1.2.3