Show
Ignore:
Timestamp:
11/19/08 13:27:40 (17 years ago)
Author:
yumileroy
Message:

[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.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/GameEvent.h

    r2 r44  
    11/* 
    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/> 
    35 * 
    46 * This program is free software; you can redistribute it and/or modify 
     
    911 * This program is distributed in the hope that it will be useful, 
    1012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1214 * GNU General Public License for more details. 
    1315 * 
    1416 * You should have received a copy of the GNU General Public License 
    1517 * along with this program; if not, write to the Free Software 
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1719 */ 
    1820 
    19 #ifndef MANGOS_GAMEEVENT_H 
    20 #define MANGOS_GAMEEVENT_H 
     21#ifndef TRINITY_GAMEEVENT_H 
     22#define TRINITY_GAMEEVENT_H 
    2123 
    2224#include "Platform/Define.h" 
     
    2628#define max_ge_check_delay 86400                            // 1 day in seconds 
    2729 
     30enum 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 
     39struct 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 
     47struct GameEventQuestToEventConditionNum 
     48{ 
     49    uint16 event_id; 
     50    uint32 condition; 
     51    float num; 
     52}; 
     53 
    2854struct GameEventData 
    2955{ 
    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 
    3565    std::string description; 
    3666 
    37     bool isValid() const { return length > 0; } 
     67    bool isValid() const { return ((length > 0) || (state > GAMEEVENT_NORMAL)); } 
    3868}; 
    3969 
     
    4676}; 
    4777 
     78struct 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 
     87class Player; 
    4888class GameEvent 
    4989{ 
     
    61101        bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); } 
    62102        uint32 Initialize(); 
    63         void StartEvent(uint16 event_id, bool overwrite = false); 
     103        bool StartEvent(uint16 event_id, bool overwrite = false); 
    64104        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); 
    65109    private: 
     110        void SendWorldStateUpdate(Player * plr, uint16 event_id); 
    66111        void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } 
    67112        void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } 
     
    72117        void ChangeEquipOrModel(int16 event_id, bool activate); 
    73118        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); 
    74127    protected: 
    75128        typedef std::list<uint32> GuidList; 
     
    81134        typedef std::list<QuestRelation> QuestRelList; 
    82135        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; 
    84147        GameEventModelEquipMap mGameEventModelEquip; 
    85148        GameEventGuidMap  mGameEventCreatureGuids; 
    86149        GameEventGuidMap  mGameEventGameobjectGuids; 
    87150        GameEventDataMap  mGameEvent; 
     151        QuestIdToEventConditionMap mQuestToEventConditions; 
     152        GameEventNPCFlagMap mGameEventNPCFlags; 
     153        GuidEventNpcGossipIdMap mNPCGossipIds; 
    88154        ActiveEvents m_ActiveEvents; 
    89155        bool isSystemInit; 
    90156}; 
    91157 
    92 #define gameeventmgr MaNGOS::Singleton<GameEvent>::Instance() 
     158#define gameeventmgr Trinity::Singleton<GameEvent>::Instance() 
    93159#endif