midoking

Untitled

Nov 19th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.56 KB | None | 0 0
  1. // Custom City Battle Flags
  2. class go_city_battle_flags : public GameObjectScript
  3. {
  4. public:
  5.     go_city_battle_flags() : GameObjectScript("go_city_battle_flags") { }
  6.  
  7.     struct go_city_battle_flagsAI : public GameObjectAI
  8.     {
  9.         go_city_battle_flagsAI(GameObject* go) : GameObjectAI(go)
  10.         {
  11.         }
  12.  
  13.         enum ZoneIds
  14.         {
  15.             ZONE_ID_STORMWIND = 1519,
  16.             ZONE_ID_ORGRIMMAR = 1637
  17.         };
  18.  
  19.         void OnGameEvent(bool start, uint16 eventId) override
  20.         {
  21.             if(!start)
  22.                 return;
  23.             if (eventId != 76) // check if eventId is the city battle event id
  24.                 return;
  25.             int flagEntry = me->GetEntry();
  26.             int zoneId = me->GetZoneId();
  27.  
  28.             ObjectGuid guid = me->GetGUID();
  29.             GameObjectData const *data;
  30.             bool removeMe = false;
  31.  
  32.             if (!guid)
  33.                 return;
  34.  
  35.             data = sObjectMgr->GetGameObjectData(guid);
  36.             if (!data)
  37.                 return;
  38.  
  39.             if (zoneId == ZONE_ID_ORGRIMMAR)
  40.             {
  41.                 switch (flagEntry)
  42.                 {
  43.                 case FLAG_ALLY:
  44.                     if (!sCityBattle->isHordeCaptured)
  45.                         removeMe = true;
  46.                     break;
  47.                 case FLAG_HORDE:
  48.                     if (sCityBattle->isHordeCaptured)
  49.                         removeMe = true;
  50.                     break;
  51.                 }
  52.             }
  53.             else if (zoneId == ZONE_ID_STORMWIND)
  54.             {
  55.                 switch (flagEntry)
  56.                 {
  57.                 case FLAG_ALLY:
  58.                     if (sCityBattle->isAllianceCaptured)
  59.                         removeMe = true;
  60.                     break;
  61.                 case FLAG_HORDE:
  62.                     if (!sCityBattle->isAllianceCaptured)
  63.                         removeMe = true;
  64.                     break;
  65.                 }
  66.             }
  67.  
  68.             if (removeMe)
  69.                 me->SetPhaseMask(4,true);
  70.             sWorld->SendGlobalText("|cffffcc00[CityBattle]|r |cFF00FF00CityBattle started!", NULL);
  71.                 //sObjectMgr->RemoveGameobjectFromGrid(guid, data);
  72.  
  73.         }
  74.  
  75.         bool GossipHello(Player* player) override
  76.         {
  77.             if (!sCityBattle->CityBattle_Enable)
  78.                 return true;
  79.             if (player->GetMapId() == 1 && player->GetZoneId() == ZONE_ID_ORGRIMMAR && player->GetTeamId() == TEAM_ALLIANCE)
  80.             {
  81.                 if (sCityBattle->isAllianceCaptured)
  82.                 {
  83.                     ChatHandler(player->GetSession()).PSendSysMessage("You must recapture your base!");
  84.                     return true;
  85.                 }
  86.  
  87.                 if (sCityBattle->isHordeCaptured) // incase there're 2 Horde flags spawned
  88.                 {
  89.                     ChatHandler(player->GetSession()).PSendSysMessage("|cff00FF00The flag is already captured.|r");
  90.                     return true;
  91.                 }
  92.             }
  93.             else if (player->GetMapId() == 0 && player->GetZoneId() == ZONE_ID_STORMWIND && player->GetTeamId() == TEAM_HORDE)
  94.             {
  95.                 if (sCityBattle->isHordeCaptured)
  96.                 {
  97.                     ChatHandler(player->GetSession()).PSendSysMessage("You must recapture your base!");
  98.                     return true;
  99.                 }
  100.  
  101.                 if (sCityBattle->isAllianceCaptured) // incase there're 2 Horde flags spawned
  102.                 {
  103.                     ChatHandler(player->GetSession()).PSendSysMessage("|cff00FF00The flag is already captured.|r");
  104.                     return true;
  105.                 }
  106.             }
  107.             else if (player->GetMapId() == 1 && player->GetZoneId() == ZONE_ID_ORGRIMMAR && player->GetTeamId() == TEAM_HORDE)
  108.             {
  109.                 if (!sCityBattle->isHordeCaptured)
  110.                 {
  111.                     ChatHandler(player->GetSession()).PSendSysMessage("Flag is not captured to recapture.");
  112.                     return true;
  113.                 }
  114.             }
  115.             else if (player->GetMapId() == 0 && player->GetZoneId() == ZONE_ID_STORMWIND && player->GetTeamId() == TEAM_ALLIANCE)
  116.             {
  117.                 if (!sCityBattle->isAllianceCaptured)
  118.                 {
  119.                     ChatHandler(player->GetSession()).PSendSysMessage("Flag is not captured to recapture.");
  120.                     return true;
  121.                 }
  122.             }
  123.  
  124.             player->SetPvP(true);
  125.             player->SetPlrTeleDestMap(-2); // effect flag capture
  126.             player->CastSpell(player, 799, false);  (loading thingy)
  127.             return true;
  128.         }
  129.  
  130.     };
  131.  
  132.     GameObjectAI* GetAI(GameObject* go) const override
  133.     {
  134.         return new go_city_battle_flagsAI(go);
  135.     }
  136. };
Advertisement
Add Comment
Please, Sign In to add comment