Advertisement
Guest User

OutdoorPvPWG.h

a guest
Jun 9th, 2010
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.41 KB | None | 0 0
  1. #ifndef OUTDOOR_PVP_WG_
  2. #define OUTDOOR_PVP_WG_
  3.  
  4. #include "OutdoorPvPImpl.h"
  5.  
  6. #define ZONE_WINTERGRASP         4197
  7. #define POS_X_CENTER             5100
  8. #define MAX_VEHICLE_PER_WORKSHOP    4
  9.  
  10. const uint32 WintergraspFaction[3] = {1732, 1735, 35};
  11. const uint32 WG_MARK_OF_HONOR = 43589;
  12. const uint32 VehNumWorldState[2] = {3680,3490};
  13. const uint32 MaxVehNumWorldState[2] = {3681,3491};
  14. const uint32 ClockWorldState[5] = {3785,3784,3782,3976,3975};
  15.  
  16. enum OutdoorPvPWGSpell
  17. {
  18.     SPELL_RECRUIT                                = 37795,
  19.     SPELL_CORPORAL                               = 33280,
  20.     SPELL_LIEUTENANT                             = 55629,
  21.     SPELL_TENACITY                               = 58549,
  22.     SPELL_TENACITY_VEHICLE                       = 59911,
  23.     SPELL_TOWER_CONTROL                          = 62064,
  24.     SPELL_SPIRITUAL_IMMUNITY                     = 58729,
  25.  
  26.     SPELL_VICTORY_REWARD                         = 56902,
  27.     SPELL_DEFEAT_REWARD                          = 58494,
  28.     SPELL_DAMAGED_TOWER                          = 59135,
  29.     SPELL_DESTROYED_TOWER                        = 59136,
  30.     SPELL_DAMAGED_BUILDING                       = 59201,
  31.     SPELL_INTACT_BUILDING                        = 59203,
  32.  
  33.     SPELL_TELEPORT_DALARAN                       = 53360,
  34.     SPELL_VICTORY_AURA                           = 60044,
  35. };
  36.  
  37. /* Not used / Not implemented
  38.  
  39. const uint16 GameEventWintergraspDefender[2] = {50, 51};
  40.  
  41. enum OutdoorPvP_WG_Sounds
  42. {
  43.     OutdoorPvP_WG_SOUND_KEEP_CLAIMED            = 8192,
  44.     OutdoorPvP_WG_SOUND_KEEP_CAPTURED_ALLIANCE  = 8173,
  45.     OutdoorPvP_WG_SOUND_KEEP_CAPTURED_HORDE     = 8213,
  46.     OutdoorPvP_WG_SOUND_KEEP_ASSAULTED_ALLIANCE = 8212,
  47.     OutdoorPvP_WG_SOUND_KEEP_ASSAULTED_HORDE    = 8174,
  48.     OutdoorPvP_WG_SOUND_NEAR_VICTORY            = 8456
  49. };
  50.  
  51. enum DataId
  52. {
  53.     DATA_ENGINEER_DIE,
  54. };
  55.  
  56. enum OutdoorPvP_WG_KeepStatus
  57. {
  58.     OutdoorPvP_WG_KEEP_TYPE_NEUTRAL             = 0,
  59.     OutdoorPvP_WG_KEEP_TYPE_CONTESTED           = 1,
  60.     OutdoorPvP_WG_KEEP_STATUS_ALLY_CONTESTED    = 1,
  61.     OutdoorPvP_WG_KEEP_STATUS_HORDE_CONTESTED   = 2,
  62.     OutdoorPvP_WG_KEEP_TYPE_OCCUPIED            = 3,
  63.     OutdoorPvP_WG_KEEP_STATUS_ALLY_OCCUPIED     = 3,
  64.     OutdoorPvP_WG_KEEP_STATUS_HORDE_OCCUPIED    = 4
  65. };
  66. */
  67.  
  68. enum OutdoorPvPWGCreType
  69. {
  70.     CREATURE_OTHER,
  71.     CREATURE_SIEGE_VEHICLE,
  72.     CREATURE_TURRET,
  73.     CREATURE_ENGINEER,
  74.     CREATURE_GUARD,
  75.     CREATURE_SPECIAL,
  76.     CREATURE_SPIRIT_GUIDE,
  77.     CREATURE_SPIRIT_HEALER,
  78.     CREATURE_QUESTGIVER,
  79. };
  80.  
  81. enum OutdoorPvPWGBuildingType
  82. {
  83.     BUILDING_WALL,
  84.     BUILDING_WORKSHOP,
  85.     BUILDING_TOWER,
  86. };
  87.  
  88. enum OutdoorPvPWGDamageState
  89. {
  90.     DAMAGE_INTACT,
  91.     DAMAGE_DAMAGED,
  92.     DAMAGE_DESTROYED,
  93. };
  94.  
  95. typedef uint32 TeamPair[2];
  96.  
  97. enum OutdoorPvPWGQuest
  98. {
  99.     A_VICTORY_IN_WG                              = 13181,
  100.     H_VICTORY_IN_WG                              = 13183,
  101.     CRE_PVP_KILL                                 = 31086,
  102.     CRE_PVP_KILL_V                               = 31093,
  103. };
  104.  
  105. enum OutdoorPvPWGCreEntry
  106. {
  107.     CRE_ENG_A                                    = 30499,
  108.     CRE_ENG_H                                    = 30400,
  109.     CRE_SPI_A                                    = 31842,
  110.     CRE_SPI_H                                    = 31841,
  111. };
  112.  
  113. const TeamPair OutdoorPvPWGCreEntryPair[] =
  114. {
  115.     {32307, 32308},
  116.     {30739, 30740},
  117.     {32296, 32294},
  118.     {32615, 32626},
  119.     {0,0}
  120. };
  121.  
  122. const TeamPair OutdoorPvPWGGODisplayPair[] =
  123. {
  124.     {5651, 5652},
  125.     {8256, 8257},
  126.     {0,0}
  127. };
  128.  
  129. const uint32 AreaPOIIconId[3][3] = {{7,8,9},{4,5,6},{1,2,3}};
  130. typedef std::list<const AreaPOIEntry *> AreaPOIList;
  131.  
  132. struct BuildingState
  133. {
  134.     explicit BuildingState(uint32 _worldState, TeamId _team, bool asDefault)
  135.         : worldState(_worldState), health(0)
  136.         , defaultTeam(asDefault ? _team : OTHER_TEAM(_team)), team(_team), damageState(DAMAGE_INTACT)
  137.         , building(NULL), type(BUILDING_WALL), graveTeam(NULL)
  138.     {}
  139.     uint32 worldState;
  140.     uint32 health;
  141.     TeamId defaultTeam;
  142.     OutdoorPvPWGDamageState damageState;
  143.     GameObject *building;
  144.     uint32 *graveTeam;
  145.     OutdoorPvPWGBuildingType type;
  146.  
  147.     void SendUpdate(Player *player) const
  148.     {
  149.         player->SendUpdateWorldState(worldState, AreaPOIIconId[team][damageState]);
  150.     }
  151.  
  152.     void FillData(WorldPacket &data) const
  153.     {
  154.         data << worldState << AreaPOIIconId[team][damageState];
  155.     }
  156.  
  157.     TeamId GetTeam() const { return team; }
  158.     void SetTeam(TeamId t)
  159.     {
  160.         team = t;
  161.         if(graveTeam)
  162.             if (uint32 newTeam = TeamId2Team[t])
  163.                 *graveTeam = newTeam;
  164.     }
  165.  
  166. private:
  167.     TeamId team;
  168. };
  169.  
  170. typedef std::map<uint32, uint32> TeamPairMap;
  171.  
  172. class OPvPCapturePointWG;
  173.  
  174. class OutdoorPvPWG : public OutdoorPvP
  175. {
  176.     protected:
  177.         typedef std::map<uint32, BuildingState *> BuildingStateMap;
  178.         typedef std::set<Creature*> CreatureSet;
  179.         typedef std::set<GameObject*> GameObjectSet;
  180.         typedef std::map<std::pair<uint32, bool>, Position> QuestGiverPositionMap;
  181.         typedef std::map<uint32, Creature*> QuestGiverMap;
  182.     public:
  183.         OutdoorPvPWG();
  184.         bool SetupOutdoorPvP();
  185.  
  186.         uint32 GetCreatureEntry(uint32 guidlow, const CreatureData *data);
  187.  
  188.         void OnCreatureCreate(Creature *creature, bool add);
  189.         void OnGameObjectCreate(GameObject *go, bool add);
  190.  
  191.         void ProcessEvent(GameObject *obj, uint32 eventId);
  192.  
  193.         void HandlePlayerEnterZone(Player *plr, uint32 zone);
  194.         void HandlePlayerLeaveZone(Player *plr, uint32 zone);
  195.         void HandlePlayerResurrects(Player * plr, uint32 zone);
  196.         void HandleKill(Player *killer, Unit *victim);
  197.  
  198.         bool Update(uint32 diff);
  199.  
  200.         void BroadcastStateChange(BuildingState *state) const;
  201.  
  202.         uint32 GetData(uint32 id);
  203.         void SetData(uint32 id, uint32 value) {};
  204.  
  205.         void ModifyWorkshopCount(TeamId team, bool add);
  206.         uint32 GetTimer() const { return m_timer / 1000; };
  207.         bool isWarTime() const { return m_wartime; };
  208.         void setTimer(uint32 timer) { if (timer >= 0) m_timer = timer; };
  209.         uint32 GetNumPlayersA() const { return m_players[TEAM_ALLIANCE].size(); };
  210.         uint32 GetNumPlayersH() const { return m_players[TEAM_HORDE].size(); };
  211.         TeamId getDefenderTeam() const { return m_defender; };
  212.         TeamId getAttackerTeam() const { return OTHER_TEAM(m_defender); };
  213.         void forceChangeTeam();
  214.         void forceStopBattle();
  215.         void forceStartBattle();
  216.  
  217.         void SendAreaSpiritHealerQueryOpcode(Player *pl, const uint64& guid);
  218.         void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
  219.         void RemovePlayerFromResurrectQueue(uint64 player_guid);
  220.         void RelocateDeadPlayers(Creature *cr);
  221.     protected:
  222.         std::vector<uint64> m_ResurrectQueue;            
  223.         uint32 m_LastResurrectTime;
  224.         std::map<uint64, std::vector<uint64> >  m_ReviveQueue;
  225.  
  226.         uint32 GetLastResurrectTime() const { return m_LastResurrectTime; }
  227.         uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); }
  228.  
  229.         TeamId m_defender;
  230.         int32 m_tenacityStack;
  231.  
  232.         BuildingStateMap m_buildingStates;
  233.         BuildingState *m_gate;
  234.  
  235.         CreatureSet m_creatures;
  236.         CreatureSet m_vehicles[2];
  237.         GameObjectSet m_gobjects;
  238.         QuestGiverMap m_questgivers;
  239.  
  240.         TeamPairMap m_creEntryPair, m_goDisplayPair;
  241.         QuestGiverPositionMap m_qgPosMap;
  242.  
  243.         bool m_wartime;
  244.         bool m_changeDefender;
  245.         uint32 m_timer;
  246.         uint32 m_clock[5];
  247.         uint32 m_workshopCount[2];
  248.         uint32 m_towerDestroyedCount[2];
  249.         uint32 m_towerDamagedCount[2];
  250.  
  251.         OPvPCapturePointWG *GetWorkshop(uint32 lowguid) const;
  252.         OPvPCapturePointWG *GetWorkshopByEngGuid(uint32 lowguid) const;
  253.         OPvPCapturePointWG *GetWorkshopByGOGuid(uint32 lowguid) const;
  254.  
  255.         void StartBattle();
  256.         void EndBattle();
  257.  
  258.         void UpdateClock();
  259.         void UpdateClockDigit(uint32 &timer, uint32 digit, uint32 mod);
  260.         void PromotePlayer(Player *player) const;
  261.         void UpdateTenacityStack();
  262.         void UpdateAllWorldObject();
  263.         bool UpdateCreatureInfo(Creature *creature);
  264.         bool UpdateGameObjectInfo(GameObject *go) const;
  265.  
  266.         bool CanBuildVehicle(OPvPCapturePointWG *workshop) const;
  267.         OutdoorPvPWGCreType GetCreatureType(uint32 entry) const;
  268.  
  269.         void RebuildAllBuildings();
  270.  
  271.         void SendInitWorldStatesTo(Player *player = NULL) const;
  272.         void RemoveOfflinePlayerWGAuras();
  273.         void RewardMarkOfHonor(Player *player, uint32 count);
  274.         void MoveQuestGiver(uint32 guid);
  275.         void LoadQuestGiverMap(uint32 guid, Position posHorde, Position posAlli);
  276.         bool UpdateQuestGiverPosition(uint32 guid, Creature *creature);
  277. };
  278.  
  279. class OPvPCapturePointWG : public OPvPCapturePoint
  280. {
  281.     public:
  282.         explicit OPvPCapturePointWG(OutdoorPvPWG *opvp, BuildingState *state);
  283.         void SetTeamByBuildingState();
  284.         void ChangeState() {}
  285.         void ChangeTeam(TeamId oldteam);
  286.  
  287.         uint32 *m_spiEntry;
  288.         uint32 m_spiGuid;
  289.         Creature *m_spiritguide;
  290.  
  291.         uint32 *m_engEntry;
  292.         uint32 m_engGuid;
  293.         Creature *m_engineer;
  294.         uint32 m_workshopGuid;
  295.         BuildingState *m_buildingState;
  296.     protected:
  297.         OutdoorPvPWG *m_wintergrasp;
  298. };
  299.  
  300. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement