Advertisement
Rochet2

Portal master C++ edited

Apr 11th, 2012
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.20 KB | None | 0 0
  1. /*
  2. Portal Master convert to C++ for Trinitycore
  3. By Rochet2
  4.  
  5. Credits:
  6. Rochet2
  7. Eric
  8.  
  9. ScriptName: TeLe_gossip_codebox
  10. */
  11.  
  12. #include "ScriptPCH.h"
  13.  
  14. // Teleport data
  15.  
  16. struct Eric
  17. {
  18.     uint32 menu_id, next_menu_id;
  19.     uint8 icon;
  20.     std::string name;
  21.     uint32 cost;
  22.     uint8 level, faction; // 0 Both, 1 Horde, 2 Ally
  23.     uint32 map;
  24.     float x, y, z, o;
  25. };
  26. typedef struct Eric Rochet2;
  27.  
  28. //  {menu_id, next_menu_id, icon, name, cost, level, faction, map, x, y, z, o}
  29. Rochet2 TeLe [] = // key = i & Key
  30. {
  31.     {1, 02"Mall", 0020-8322.487305f2091.193115f,   125.813408f,    3.489510f}, // A
  32.     {1, 02"Mall", 0011-8564.412109f-1998.245483f100.350288f,    0.356550f}, // H
  33.     {1, 02"Duel Zone",    000,  MAP,    4298.943848f,   -2761.944336f16.662846f, 3.664825f},
  34.     {1, 02"Gurubashi Arena"000,  MAP,    -13263.814453f, 158.768204f,    36.077797f, 1.079510f},
  35.     {1, 23"Eastern Kingdoms", 00000000},
  36.     {1, 33"Kalimdor", 00000000},
  37.     {1, 43"Outland"058, 000000},
  38.     {1, 59"Raid Teleports",   070, 000000},
  39.    
  40.     {2, 02"Elwynn Forest",    0020-9449.06f64.8392f,   56.3581f,   3.07047f},
  41.     {2, 02"Eversong Woods",   001530,    9024.37f,   -6682.55f16.8973f,   3.14131f},
  42.     {2, 02"Dun Morogh",   0020-5603.76f-482.704f396.98f,    5.23499f},
  43.     {2, 02"Tirisfal Glades"00102274.95f,   323.918f,   34.1137f,   4.24367f},
  44.     {2, 02"Ghostlands",   010, 1530,    7595.73f,   -6819.6f,   84.3718f,   2.56561f},
  45.     {2, 02"Loch modan",   010, 20-5405.85f-2894.15f341.972f,   5.48238f},
  46.     {2, 02"Silverpine Forest",    010, 10505.126f,   1504.63f,   124.808f,   1.77987f},
  47.     {2, 02"Westfall", 010, 20-10684.9f1033.63f,   32.5389f,   6.07384f},
  48.     {2, 02"Redridge mountains",   015, 20-9447.8f,   -2270.85f71.8224f,   0.283853f},
  49.     {2, 02"Duskwood", 018, 20-10531.7f-1281.91f38.8647f,   1.56959f},
  50.     {2, 02"Hillsbrad Foothills"020, 00-385.805f-787.954f54.6655f,   1.03926f},
  51.     {2, 02"Wetlands", 020, 20-3517.75f-913.401f8.86625f,   2.60705f},
  52.     {2, 02"Alterac Mountains",    030, 00275.049f,   -652.044f130.296f,   0.502032f},
  53.     {2, 02"Arathi Highlands", 030, 00-1581.45f-2704.06f35.4168f,   0.490373f},
  54.     {2, 02"Stranglethorn Vale",   030, 00-11921.7f-59.544f,   39.7262f,   3.73574f},
  55.     {2, 02"Badlands", 035, 00-6782.56f-3128.14f240.48f,    5.65912f},
  56.     {2, 02"Swamp of Sorrows", 035, 00-10368.6f-2731.3f,   21.6537f,   5.29238f},
  57.     {2, 02"The Hinterlands"040, 00112.406f,   -3929.74f136.358f,   0.981903f},
  58.     {2, 02"Searing Gorge",    043, 00-6686.33f-1198.55f240.027f,   0.916887f},
  59.     {2, 02"The Blasted Lands",    045, 00-11184.7f-3019.31f7.29238f,   3.20542f},
  60.     {2, 02"Burning Steppes"050, 00-7979.78f-2105.72f127.919f,   5.10148f},
  61.     {2, 02"Western Plaguelands"051, 001743.69f,   -1723.86f59.6648f,   5.23722f},
  62.     {2, 02"Eastern Plaguelands"053, 002280.64f,   -5275.05f82.0166f,   4.7479f},
  63.     {2, 02"Isle of Quel'Danas",   070, 0530,    12806.5f,   -6911.11f41.1156f,   2.22935f},
  64.     {2, 17"Back..",   00000000},
  65.  
  66.     {3, 02"Azuremyst Isle",   002530,    -4192.62f-12576.7f36.7598f,   1.62813f},
  67.     {3, 02"Teldrassil",   00219889.03f,   915.869f,   1307.43f,   1.9336f},
  68.     {3, 02"Durotar"0011228.978f,   -4741.87f10.1027f,   0.416883f},
  69.     {3, 02"Mulgore"0011-2473.87f-501.225f-9.42465f0.6525f},
  70.     {3, 02"Bloodmyst Isle",   015, 2530,    -2095.7f,   -11841.1f51.1557f,   6.19288f},
  71.     {3, 02"Darkshore",    010, 216463.25f,   683.986f,   8.92792f,   4.33534f},
  72.     {3, 02"The Barrens"010, 11-575.772f-2652.45f95.6384f,   0.006469f},
  73.     {3, 02"Stonetalon Mountains", 015, 011574.89f,   1031.57f,   137.442f,   3.8013f},
  74.     {3, 02"Ashenvale Forest", 018, 011919.77f,   -2169.68f94.6729f,   6.14177f},
  75.     {3, 02"Thousand Needles", 025, 11-5375.53f-2509.2f,   -40.432f,   2.41885f},
  76.     {3, 02"Desolace", 030, 01-656.056f1510.12f,   88.3746f,   3.29553f},
  77.     {3, 02"Dustwallow Marsh", 035, 01-3350.12f-3064.85f33.0364f,   5.12666f},
  78.     {3, 02"Feralas"040, 01-4808.31f1040.51f,   103.769f,   2.90655f},
  79.     {3, 02"Tanaris Desert",   040, 01-6940.91f-3725.7f,   48.9381f,   3.11174f},
  80.     {3, 02"Azshara"045, 013117.12f,   -4387.97f91.9059f,   5.49897f},
  81.     {3, 02"Felwood"048, 013898.8f,    -1283.33f220.519f,   6.24307f},
  82.     {3, 02"Un'Goro Crater",   048, 01-6291.55f-1158.62f-258.138f0.457099f},
  83.     {3, 02"Silithus", 055, 01-6815.25f730.015f,   40.9483f,   2.39066f},
  84.     {3, 02"Winterspring", 055, 016658.57f,   -4553.48f718.019f,   5.18088f},
  85.     {3, 17"Back..",   00000000},
  86.    
  87.     {4, 02"Hellfire Peninsula",   058, 0530,    -207.335f2035.92f,   96.464f,    1.59676f},
  88.     {4, 02"Zangarmarsh"060, 0530,    -220.297f5378.58f,   23.3223f,   1.61718f},
  89.     {4, 02"Terokkar Forest"062, 0530,    -2266.23f4244.73f,   1.47728f,   3.68426f},
  90.     {4, 02"Nagrand"064, 0530,    -1610.85f7733.62f,   -17.2773f1.33522f},
  91.     {4, 02"Blade's Edge Mountains",   065, 0530,    2029.75f,   6232.07f,   133.495f,   1.30395f},
  92.     {4, 02"Netherstorm"067, 0530,    3271.2f,    3811.61f,   143.153f,   3.44101f},
  93.     {4, 02"Shadowmoon Valley",    067, 0530,    -3681.01f2350.76f,   76.587f,    4.25995f},
  94.     {4, 17"Back..",   00000000},
  95.    
  96.     {5, 02"Black Temple", 070, 0,  MAP,    -3637.785400f314.684021f,    35.578209f, 2.900472f},
  97.     {5, 02"Hyjal Summit", 070, 0,  MAP,    -8174.817871f-4175.274902f-166.112244f,   0.921193f},
  98.     {5, 02"Karazhan", 070, 0,  MAP,    -11118.900391f, -2010.329956f47.081902f, 0.649895f},
  99.     {5, 02"Serpentshrine Cavern", 070, 0,  MAP,    796.593384f,    6866.157227f,   -65.125031f,    6.275439f},
  100.     {5, 02"Gruul's Lair", 070, 0,  MAP,    3532.722168f,   5101.472168f,   3.636398f5.648614f},
  101.     {5, 02"Sunwel Plateau",   070, 0,  MAP,    12562.410156f-6774.766602f15.090400f, 3.137880f},
  102.     {5, 02"Tempest Keep", 070, 0,  MAP,    3087.918457f,   1379.465820f,   184.908508f,    4.615966f},
  103.     {5, 02"Zul'Aman", 070, 0,  MAP,    6851.916016f,   -7988.957520f189.120056f,    4.690108f},
  104.     {5, 17"Back..",   00000000},
  105.  
  106. //  {6, 0,  2,  "Teleport", 0,  0,  0,  map,    xf, yf, zf, of},
  107. //  {6, 1,  7,  "Back..",   0,  0,  0,  0,  0,  0,  0,  0},
  108. };
  109.  
  110. // TextIDs from npc_text
  111. enum eEnums
  112. {
  113.     TEXT_MAIN_H     =   300000,         //Horde main menu text
  114.     TEXT_MAIN_A     =   300001,         //Alliance main menu text
  115.     TEXT_DUNGEON    =   300002,         //Dungeon teleport menu texts
  116.     TEXT_RAID       =   300003,         //Raid teleport menu text
  117.     TEXT_AREA       =   300004,         //Area teleport location menu texts
  118.    
  119.     TELEPORT_COUNT  =   sizeof TeLe/sizeof(*TeLe),
  120. };
  121.  
  122. #define ARE_YOU_SURE    "Are you sure, that you want to go to "
  123. #define ERROR_COMBAT    "|cffff0000You are in combat|r"
  124.  
  125. bool Custom_FactCheck (uint32 Fact, unsigned char Key)
  126. {
  127.     bool Show = false;
  128.     switch (TeLe[Key].faction)
  129.     {
  130.     case 0:
  131.         Show = true;
  132.         break;
  133.     case 1:
  134.         if (Fact == HORDE)
  135.             Show = true;
  136.         break;
  137.     case 2:
  138.         if (Fact == ALLIANCE)
  139.             Show = true;
  140.         break;
  141.     }
  142.     return (Show);
  143. }
  144.  
  145. uint32 Custom_GetText (unsigned int menu, Player* pPlayer)
  146. {
  147.     uint32 TEXT = TEXT_AREA;
  148.     switch (menu)
  149.     {
  150.     case 0:
  151.         switch (pPlayer->GetTeam())
  152.         {
  153.         case ALLIANCE:
  154.             TEXT = TEXT_MAIN_A;
  155.             break;
  156.         case HORDE:
  157.             TEXT = TEXT_MAIN_H;
  158.             break;
  159.         }
  160.     case 1:
  161.     case 2:
  162.     case 3:
  163.         TEXT = TEXT_DUNGEON;
  164.         break;
  165.     case 4:
  166.         TEXT = TEXT_RAID;
  167.         break;
  168.     }
  169.     return (TEXT);
  170. }
  171.  
  172. void Custom_GetMenu (Player* pPlayer, Creature* pCreature, uint32 Key)
  173. {
  174.     bool ENDMENU = false;
  175.     for(uint32 i = 0; i < TELEPORT_COUNT; i++)
  176.     {
  177.         if (ENDMENU && TeLe[i].menu_id != Key)
  178.             break;
  179.         if (TeLe[i].menu_id == Key && pPlayer->getLevel() >= TeLe[i].level && Custom_FactCheck(pPlayer->GetTeam(), i))
  180.         {
  181.             if (TeLe[i].next_menu_id != 0)
  182.                 pPlayer->ADD_GOSSIP_ITEM_EXTENDED(TeLe[i].icon, TeLe[i].name, GOSSIP_SENDER_MAIN, i, "", TeLe[i].cost, false);
  183.             else
  184.                 pPlayer->ADD_GOSSIP_ITEM_EXTENDED(TeLe[i].icon, TeLe[i].name, GOSSIP_SENDER_MAIN, i, ARE_YOU_SURE+TeLe[i].name, TeLe[i].cost, false);
  185.             ENDMENU = true;
  186.         }
  187.     }
  188.     pPlayer->PlayerTalkClass->SendGossipMenu(Custom_GetText(Key, pPlayer), pCreature->GetGUID());
  189. }
  190.  
  191. class TeLe_gossip_codebox : public CreatureScript
  192. {
  193.     public:
  194.     TeLe_gossip_codebox()
  195.     : CreatureScript("TeLe_gossip_codebox")
  196.     {
  197.     }
  198.  
  199.     bool OnGossipHello(Player* pPlayer, Creature* pCreature)
  200.     {
  201.         Custom_GetMenu(pPlayer, pCreature, 1);
  202.         return true;
  203.     }
  204.  
  205.     bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
  206.     {
  207.         pPlayer->PlayerTalkClass->ClearMenus(); // clear the menu
  208.  
  209.         pPlayer->ModifyMoney(-1 * TeLe[uiAction].cost); // take cash
  210.         uint32 Key = TeLe[uiAction].next_menu_id;
  211.         if (Key == 0) // if no next_menu_id, then teleport to coords
  212.         {
  213.             if (!pPlayer->isInCombat())
  214.             {
  215.                 pPlayer->CLOSE_GOSSIP_MENU();
  216.                 pPlayer->TeleportTo(TeLe[uiAction].map, TeLe[uiAction].x, TeLe[uiAction].y, TeLe[uiAction].z, TeLe[uiAction].o);
  217.                 return true;
  218.             }
  219.             pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_COMBAT);
  220.             Key = TeLe[uiAction].menu_id;
  221.         }
  222.  
  223.         Custom_GetMenu(pPlayer, pCreature, Key);
  224.         return true;
  225.     }
  226. };
  227.  
  228. void AddSC_TeLe_gossip_codebox()
  229. {
  230.     new TeLe_gossip_codebox();
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement