Advertisement
slp13at420

Grumboz VIP Engine

Mar 1st, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 38.68 KB | None | 0 0
  1. diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp
  2. index 2749c08..234c43f 100644
  3. --- a/src/server/database/Database/Implementation/LoginDatabase.cpp
  4. +++ b/src/server/database/Database/Implementation/LoginDatabase.cpp
  5. @@ -117,4 +117,9 @@ void LoginDatabaseConnection::DoPrepareStatements()
  6.      PrepareStatement(LOGIN_DEL_RBAC_ACCOUNT_PERMISSION, "DELETE FROM rbac_account_permissions WHERE accountId = ? AND permissionId = ? AND (realmId = ? OR realmId = -1)", CONNECTION_ASYNC);
  7.      PrepareStatement(LOGIN_INS_ACCOUNT_MUTE, "INSERT INTO account_muted VALUES (?, UNIX_TIMESTAMP(), ?, ?, ?)", CONNECTION_ASYNC);
  8.      PrepareStatement(LOGIN_SEL_ACCOUNT_MUTE_INFO, "SELECT mutedate, mutetime, mutereason, mutedby FROM account_muted WHERE guid = ? ORDER BY mutedate ASC", CONNECTION_SYNCH);
  9. +
  10. +   PrepareStatement(LOGIN_LOAD_VIP, "SELECT vip, mg, votes FROM account WHERE id = ?", CONNECTION_SYNCH);
  11. +   PrepareStatement(LOGIN_SET_VIP, "UPDATE account SET `vip`=? WHERE `id`=?", CONNECTION_ASYNC);
  12. +   PrepareStatement(LOGIN_SET_MG, "UPDATE account SET `mg`=? WHERE `id`=?", CONNECTION_ASYNC);
  13. +   PrepareStatement(LOGIN_SET_VOTES, "UPDATE account SET `votes`=? WHERE `id`=?", CONNECTION_ASYNC);
  14.  }
  15. diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h
  16. index a3789fa..5ac442e 100644
  17. --- a/src/server/database/Database/Implementation/LoginDatabase.h
  18. +++ b/src/server/database/Database/Implementation/LoginDatabase.h
  19. @@ -113,6 +113,12 @@ enum LoginDatabaseStatements
  20.  
  21.      LOGIN_INS_ACCOUNT_MUTE,
  22.      LOGIN_SEL_ACCOUNT_MUTE_INFO,
  23. +
  24. +   LOGIN_LOAD_VIP,
  25. +   LOGIN_SET_VIP,
  26. +   LOGIN_SET_MG,
  27. +   LOGIN_SET_VOTES,
  28. +  
  29.      MAX_LOGINDATABASE_STATEMENTS
  30.  };
  31.  
  32. diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp
  33. index 7a183d5..46c5639 100644
  34. --- a/src/server/database/Database/Implementation/WorldDatabase.cpp
  35. +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp
  36. @@ -91,4 +91,6 @@ void WorldDatabaseConnection::DoPrepareStatements()
  37.      PrepareStatement(WORLD_DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_ASYNC);
  38.      PrepareStatement(WORLD_UPD_CREATURE_ZONE_AREA_DATA, "UPDATE creature SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
  39.      PrepareStatement(WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA, "UPDATE gameobject SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
  40. +
  41. +   PrepareStatement(WORLD_SET_ITEM_VIP, "UPDATE item_template SET `vip`=? WHERE `entry`=?", CONNECTION_ASYNC);
  42.  }
  43. diff --git a/src/server/database/Database/Implementation/WorldDatabase.h b/src/server/database/Database/Implementation/WorldDatabase.h
  44. index 6ac4ce5..1360d5d 100644
  45. --- a/src/server/database/Database/Implementation/WorldDatabase.h
  46. +++ b/src/server/database/Database/Implementation/WorldDatabase.h
  47. @@ -100,6 +100,8 @@ enum WorldDatabaseStatements
  48.      WORLD_UPD_CREATURE_ZONE_AREA_DATA,
  49.      WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA,
  50.  
  51. +   WORLD_SET_ITEM_VIP,
  52. +
  53.      MAX_WORLDDATABASE_STATEMENTS
  54.  };
  55.  
  56. diff --git a/src/server/game/Entities/Player/Grumboz_VIP_Core.cpp b/src/server/game/Entities/Player/Grumboz_VIP_Core.cpp
  57. new file mode 100644
  58. index 0000000..28e5f8d
  59. --- /dev/null
  60. +++ b/src/server/game/Entities/Player/Grumboz_VIP_Core.cpp
  61. @@ -0,0 +1,932 @@
  62. +// Vip core engine
  63. +// By slp13at420 of EmuDevs.com
  64. +
  65. +#include "AccountMgr.h"
  66. +#include "chat.h"
  67. +#include "Config.h"
  68. +#include "Grumboz_VIP_Core.h"
  69. +#include "Language.h"
  70. +#include "ObjectMgr.h"
  71. +#include "player.h"
  72. +#include "RBAC.h"
  73. +#include "ScriptedGossip.h"
  74. +#include "ScriptMgr.h"
  75. +#include <unordered_map>
  76. +#include "World.h"
  77. +
  78. +// color definitions since i hate yellow..
  79. +std::string green = "|cff00cc00";
  80. +std::string red = "|cffFF0000";
  81. +std::string white = "|cffFFFFFF";
  82. +std::string blue = "|cff3333FF";
  83. +std::string black = "|cff000000";
  84. +
  85. +float ver = 2.05f;
  86. +
  87. +uint8 VIP_MAX;
  88. +uint8 VIP_LEVEL_BONUS;
  89. +uint8 VIP_TP_BONUS;
  90. +uint32 VIP_STONE_ID;
  91. +uint32 VIP_COIN_ID;
  92. +uint32 VIP_MG_ID;
  93. +uint32 VIP_VOTE_COUNT;
  94. +float VIP_OFFSET;
  95. +bool VIP_VOTE_ENABLE;
  96. +bool VIP_LEVEL_BONUS_ENABLE;
  97. +std::string VIP_COIN_NAME;
  98. +
  99. +std::unordered_map<uint32, VipElements> Vip;
  100. +std::unordered_map<uint32, ItemVIP> ItemVip;
  101. +std::unordered_map<uint8, VipMallGPS> MALL;
  102. +std::unordered_map<uint8, VipHomeGPS> HOME;
  103. +std::unordered_map<uint32, VipHearthStoneGPS> HearthStone;
  104. +
  105. +VIP::VIP() { }
  106. +
  107. +VIP::~VIP()
  108. +{
  109. +}
  110. +
  111. +std::string ConvertNumberToString(uint64 numberX)
  112. +{
  113. +   auto number = numberX;
  114. +   std::stringstream convert;
  115. +   std::string number32_to_string;
  116. +   convert << number;
  117. +   number32_to_string = convert.str();
  118. +
  119. +   return number32_to_string;
  120. +};
  121. +
  122. +void AnnounceLoggingToWorld(Player* player, uint8 type)
  123. +{
  124. +   std::string pName = player->GetName();
  125. +   uint32 acct_id = player->GetSession()->GetAccountId();
  126. +   uint8 PlayerLogInVip = VIP::GetVIP(acct_id);
  127. +
  128. +   SessionMap sessions = sWorld->GetAllSessions(); // GetPlayersInWorld
  129. +
  130. +   for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
  131. +   {
  132. +       if (!itr->second)
  133. +           continue;
  134. +
  135. +       uint8 ItrVip = VIP::GetVIP(itr->second->GetAccountId());
  136. +
  137. +       if (PlayerLogInVip <= ItrVip) // if target is same as or higher. won't announce to lower vip's.
  138. +       {
  139. +           std::string msg = "[" + green + "VIP" + ConvertNumberToString(PlayerLogInVip) + "|r]:";
  140. +           msg = msg + pName + green + " has logged";
  141. +
  142. +           if (type == 0) { msg = msg + " out.|r"; };
  143. +           if (type == 1) { msg = msg + " in.|r"; };
  144. +
  145. +           ChatHandler(itr->second->GetPlayer()->GetSession()).PSendSysMessage(msg.c_str());
  146. +       }
  147. +   }
  148. +};
  149. +
  150. +class VIP_Load_Conf : public WorldScript
  151. +{
  152. +public: VIP_Load_Conf() : WorldScript("VIP_Load_Conf"){ };
  153. +
  154. +   virtual void OnConfigLoad(bool /*reload*/)
  155. +   {
  156. +       TC_LOG_INFO("server.loading", "___________________________________");
  157. +       TC_LOG_INFO("server.loading", "| Grumbo'z  VIP  Engine : Loading |");
  158. +       TC_LOG_INFO("server.loading", "|__________By_Slp13at420__________|");
  159. +       TC_LOG_INFO("server.loading", "|__________of_EmuDev.com__________|");
  160. +       TC_LOG_INFO("server.loading", "|-                               -|");
  161. +       TC_LOG_INFO("server.loading", "|____________Ver:%.2f_____________|", ver);
  162. +
  163. +       QueryResult VIPItemQery = WorldDatabase.Query("SELECT entry, vip FROM item_template;");
  164. +
  165. +       if (VIPItemQery)
  166. +       {
  167. +           do
  168. +           {
  169. +               Field* fields = VIPItemQery->Fetch();
  170. +               uint32 item_id = fields[0].GetUInt32();
  171. +               uint32 vip = fields[1].GetUInt8();
  172. +
  173. +               ItemVIP& data1 = ItemVip[item_id];
  174. +               // Save the DB values to the MyData object
  175. +               data1.item_id = item_id;
  176. +               data1.vip = vip;
  177. +
  178. +           } while(VIPItemQery->NextRow());
  179. +       }
  180. +      
  181. +       QueryResult gpsQery = WorldDatabase.Query("SELECT * FROM hearthstone;");
  182. +
  183. +       if (gpsQery)
  184. +       {
  185. +           do
  186. +           {
  187. +               // unpacks the results of `result` into fields and appoint data to variable.
  188. +               Field* fields = gpsQery->Fetch();
  189. +               uint32 guid = fields[0].GetUInt32();
  190. +               uint32 map_id = fields[1].GetUInt32();
  191. +               float x = fields[2].GetFloat();
  192. +               float y = fields[3].GetFloat();
  193. +               float z = fields[4].GetFloat();
  194. +               float o = fields[5].GetFloat();
  195. +
  196. +               VipHearthStoneGPS& data2 = HearthStone[guid];
  197. +               // Save the DB values to the MyData object
  198. +               data2.guid = guid;
  199. +               data2.map_id = map_id;
  200. +               data2.x = x;
  201. +               data2.y = y;
  202. +               data2.z = z;
  203. +               data2.o = o;
  204. +
  205. +           } while (gpsQery->NextRow());
  206. +       }
  207. +
  208. +       VipMallGPS& data3 = MALL[0];
  209. +       // Save the DB values to the MyData object
  210. +       data3.map_id = 530;
  211. +       data3.x = -1800.3104f;
  212. +       data3.y = 5315.0424f;
  213. +       data3.z = -12.4276f;
  214. +       data3.o = 2.1062f;
  215. +
  216. +       VipMallGPS& data4 = MALL[1]; // like Lua table VIP[acctId].vip
  217. +       // Save the DB values to the MyData object
  218. +       data4.map_id = 530;
  219. +       data4.x = -1921.8005f;
  220. +       data4.y = 5546.6264f;
  221. +       data4.z = -12.4278f;
  222. +       data4.o = 5.2321f;
  223. +
  224. +       VipHomeGPS& data5 = HOME[0]; // like Lua table VIP[acctId].vip
  225. +       // Save the DB values to the MyData object
  226. +       data5.map_id = 0;
  227. +       data5.x = -4906.3911f;
  228. +       data5.y = -970.9063f;
  229. +       data5.z = 501.4540f;
  230. +       data5.o = 2.3338f;
  231. +
  232. +       VipHomeGPS& data6 = HOME[1]; // like Lua table VIP[acctId].vip
  233. +       // Save the DB values to the MyData object
  234. +       data6.map_id = 1;
  235. +       data6.x = 1604.4882f;
  236. +       data6.y = -4394.3603f;
  237. +       data6.z = 9.9671f;
  238. +       data6.o = 3.5517f;
  239. +
  240. +       TC_LOG_INFO("server.loading", "___________________________________");
  241. +       TC_LOG_INFO("server.loading", "|   VIP Teleport GPS's : Loaded   |");
  242. +
  243. +       VIP_MAX                 = sConfigMgr->GetIntDefault("VIP.MAX", 6);
  244. +       VIP_OFFSET              = sConfigMgr->GetFloatDefault("VIP.OFFSET", 0.05f);
  245. +       VIP_VOTE_ENABLE         = sConfigMgr->GetBoolDefault("VIP.VOTE_ENABLE", true);
  246. +       VIP_VOTE_COUNT          = sConfigMgr->GetIntDefault("VIP.VOTE_COUNT", 125);
  247. +       VIP_COIN_ID             = sConfigMgr->GetIntDefault("VIP.COIN", 63020);
  248. +       VIP_STONE_ID            = sConfigMgr->GetIntDefault("VIP.STONE", 63021);
  249. +       VIP_MG_ID               = sConfigMgr->GetIntDefault("VIP.MAGIC_GOLD", 44209);
  250. +       VIP_TP_BONUS            = sConfigMgr->GetIntDefault("VIP.TP_BONUS", 14);
  251. +       VIP_LEVEL_BONUS_ENABLE  = sConfigMgr->GetBoolDefault("VIP.LEVEL_BONUS_ENABLE", true);
  252. +       VIP_LEVEL_BONUS         = sConfigMgr->GetIntDefault("VIP.LEVEL_BONUS", 1);
  253. +
  254. +       TC_LOG_INFO("server.loading", "___________________________________");
  255. +       TC_LOG_INFO("server.loading", "|  VIP MAX_VIP : %u", VIP_MAX);
  256. +
  257. +       if (VIP_VOTE_ENABLE)
  258. +       {
  259. +           TC_LOG_INFO("server.loading", "___________________________________");
  260. +           TC_LOG_INFO("server.loading", "|  VIP VOTES : ENABLED            |");
  261. +       };
  262. +
  263. +       TC_LOG_INFO("server.loading", "___________________________________");
  264. +       TC_LOG_INFO("server.loading", "|  VIP TP BONUS:%u", VIP_TP_BONUS);
  265. +
  266. +       if (VIP_LEVEL_BONUS_ENABLE)
  267. +       {
  268. +           TC_LOG_INFO("server.loading", "___________________________________");
  269. +           TC_LOG_INFO("server.loading", "|  VIP LEVEL BONUS : ENABLED      |");
  270. +           TC_LOG_INFO("server.loading", "|  VIP LEVEL BONUS:%u", VIP_LEVEL_BONUS);
  271. +       };
  272. +
  273. +       if (!sObjectMgr->GetItemTemplate(VIP_COIN_ID)){ TC_LOG_INFO("server.loading", "! VIP COIN %u MISSING FROM DB ! SERVER CRASHING !", VIP_COIN_ID); };
  274. +
  275. +       VIP_COIN_NAME           = sObjectMgr->GetItemTemplate(VIP_COIN_ID)->Name1;
  276. +
  277. +       TC_LOG_INFO("server.loading", "___________________________________");
  278. +       TC_LOG_INFO("server.loading", "|  VIP Config  : Loaded           |");
  279. +       TC_LOG_INFO("server.loading", "| Grumbo'z  VIP Engine  : Loaded  |");
  280. +       TC_LOG_INFO("server.loading", "|_________________________________|");
  281. +   };
  282. +
  283. +};
  284. +
  285. +uint8 VIP::GetVIPMAX()
  286. +{
  287. +   return VIP_MAX;
  288. +};
  289. +
  290. +bool VIP::GetVIPVOTE_ENABLE()
  291. +{
  292. +   return VIP_VOTE_ENABLE;
  293. +}
  294. +
  295. +uint32 VIP::GetVIPVOTECOUNT()
  296. +{
  297. +   return VIP_VOTE_COUNT;
  298. +};
  299. +
  300. +uint32 VIP::GetVIPCOINID()
  301. +{
  302. +   return VIP_COIN_ID;
  303. +};
  304. +
  305. +uint32 VIP::GetVIPSTONEID()
  306. +{
  307. +   return VIP_STONE_ID;
  308. +};
  309. +
  310. +uint32 VIP::GetVIPMGID()
  311. +{
  312. +   return VIP_MG_ID;
  313. +};
  314. +
  315. +float VIP::GetVIPOFFSET()
  316. +{
  317. +   return VIP_OFFSET;
  318. +};
  319. +
  320. +uint8 VIP::GetTALENTBONUS()
  321. +{
  322. +   return VIP_TP_BONUS;
  323. +};
  324. +
  325. +bool VIP::GetLEVELBONUS_ENABLE()
  326. +{
  327. +   return VIP_LEVEL_BONUS_ENABLE;
  328. +};
  329. +
  330. +uint8 VIP::GetLEVELBONUS()
  331. +{
  332. +   return VIP_LEVEL_BONUS;
  333. +};
  334. +
  335. +void VIP::SetVIP(uint32 acct_id, uint8 pvip)
  336. +{ // you must update votes first for the dead mans check
  337. +
  338. +   if (VIP_VOTE_ENABLE)
  339. +   {
  340. +       uint32 pvotes = Vip[acct_id].votes;
  341. +
  342. +       pvip = uint8(pvotes / VIP_VOTE_COUNT); // dead mans check auto-calibrater
  343. +
  344. +       if (pvotes < VIP_VOTE_COUNT)
  345. +       {
  346. +           pvip = 1;
  347. +       }
  348. +
  349. +       if (pvotes >(VIP_VOTE_COUNT * VIP_MAX))
  350. +       {
  351. +           pvip = VIP_MAX;
  352. +       }
  353. +   }
  354. +
  355. +   Vip[acct_id].vip = pvip;
  356. +  
  357. +   PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_VIP);
  358. +   stmt->setUInt8(0, pvip);
  359. +   stmt->setUInt32(1, acct_id);
  360. +   LoginDatabase.Execute(stmt);
  361. +};
  362. +
  363. +void VIP::SetMG(uint32 acct_id, uint32 pmg)
  364. +{
  365. +   PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_MG);
  366. +   stmt->setUInt32(0, pmg);
  367. +   stmt->setUInt32(1, acct_id);
  368. +   LoginDatabase.Execute(stmt);
  369. +
  370. +   Vip[acct_id].mg = pmg;
  371. +};
  372. +
  373. +uint8 VIP::GetVIP(uint32 acct_id)
  374. +{
  375. +   return Vip[acct_id].vip;
  376. +};
  377. +
  378. +uint32 VIP::GetMG(uint32 acct_id)
  379. +{
  380. +   return Vip[acct_id].mg;
  381. +};
  382. +
  383. +uint32 VIP::GetVOTES(uint32 acct_id)
  384. +{
  385. +   return Vip[acct_id].votes;
  386. +};
  387. +
  388. +void VIP::SetHearthStone(uint32 guid, uint32 map_id, float x, float y, float z, float o)
  389. +{
  390. +   WorldDatabase.PExecute("UPDATE `hearthstone` SET `map_id`='%u', `x`='%f', `y`='%f', `z`='%f', `o`='%f' WHERE guid=%u;", map_id, x, y, z, o, guid);
  391. +
  392. +   VipHearthStoneGPS& data = HearthStone[guid];
  393. +   // Save the DB values to the MyData object
  394. +   data.guid = guid;
  395. +   data.map_id = map_id;
  396. +   data.x = x;
  397. +   data.y = y;
  398. +   data.z = z;
  399. +   data.o = o;
  400. +}
  401. +
  402. +void VIP::SetVOTES(uint32 acct_id, uint32 pvotes)
  403. +{
  404. +   PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_VOTES);
  405. +   stmt->setUInt32(0, pvotes);
  406. +   stmt->setUInt32(1, acct_id);
  407. +   LoginDatabase.Execute(stmt);
  408. +
  409. +   Vip[acct_id].votes = pvotes;
  410. +};
  411. +
  412. +uint8 VIP::GetItemVIP(uint32 item_id)
  413. +{
  414. +   TC_LOG_INFO("server.loading", "VIP::ITEM_ID:%u", item_id);
  415. +   return ItemVip[item_id].vip;
  416. +};
  417. +
  418. +void VIP::SetItemVIP(uint32 item_id, uint8 item_vip)
  419. +{
  420. +   if (item_vip < 1) { item_vip = 1; };
  421. +   if (item_vip > VIP_MAX) { item_vip = VIP_MAX; };
  422. +
  423. +   PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SET_ITEM_VIP);
  424. +   stmt->setUInt8(0, item_vip);
  425. +   stmt->setUInt32(1, item_id);
  426. +   WorldDatabase.Execute(stmt);
  427. +
  428. +   ItemVip[item_id].vip = item_vip;
  429. +};
  430. +
  431. +class Grumboz_VIP_Account_Engine : public AccountScript
  432. +{
  433. +public: Grumboz_VIP_Account_Engine() : AccountScript("Grumboz_VIP_Account_Engine"){ };
  434. +
  435. +       virtual void OnAccountLogout(uint32 accountId)
  436. +       {
  437. +           TC_LOG_INFO("server.loading", "ACCOUNT::LOGOUT ID:%u VIP:%u", accountId, Vip[accountId].vip);
  438. +
  439. +           Vip.erase(accountId);
  440. +       };
  441. +
  442. +       virtual void OnAccountLogin(uint32 accountId)
  443. +       {
  444. +           if (accountId > 0)
  445. +           {
  446. +               PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_LOAD_VIP);
  447. +               stmt->setUInt32(0, accountId);
  448. +               PreparedQueryResult result = LoginDatabase.Query(stmt);
  449. +
  450. +               if (!result)
  451. +               {
  452. +                   TC_LOG_INFO("server.loading", "XX ERROR Loading a VIP table ID %u XX", accountId);
  453. +               };
  454. +
  455. +               if (result)
  456. +               {
  457. +                   // unpacks the results of `result` into fields and appoint data to variable.
  458. +                   Field* fields = result->Fetch();
  459. +                   uint8 pvip = fields[0].GetUInt8();
  460. +                   uint32 pmg = fields[1].GetUInt32();
  461. +                   uint32 pvotes = fields[2].GetUInt32();
  462. +
  463. +                   VipElements& data = Vip[accountId]; // like Lua table VIP[acctId].vip
  464. +                   // Save the DB values to the MyData object
  465. +                   data.vip = pvip;
  466. +                   data.mg = pmg;
  467. +                   data.votes = pvotes;
  468. +
  469. +                   VIP::SetVIP(accountId, pvip);
  470. +
  471. +                   TC_LOG_INFO("server.loading", "ACCOUNT::LOGIN ID:%u VIP:%u", accountId, Vip[accountId].vip);
  472. +               }
  473. +           }
  474. +       }
  475. +};
  476. +
  477. +class Grumboz_VIP_Player_Engine : public PlayerScript
  478. +{
  479. +public: Grumboz_VIP_Player_Engine() : PlayerScript("Grumboz_VIP_Player_Engine"){ };
  480. +
  481. +   virtual void OnLogout(Player* player)
  482. +   {
  483. +       AnnounceLoggingToWorld(player, 0);
  484. +   };
  485. +
  486. +   virtual void OnLogin(Player* player, bool firstLogin)
  487. +   {
  488. +       AnnounceLoggingToWorld(player, 1);
  489. +
  490. +       uint32 guid = player->GetGUID();
  491. +       uint32 acct_id = player->GetSession()->GetAccountId();
  492. +       uint8 Pvip = VIP::GetVIP(acct_id);
  493. +       bool lvl_enable = VIP::GetLEVELBONUS_ENABLE();
  494. +       uint8 xtra_levels = VIP::GetLEVELBONUS();
  495. +       uint8 Plvl = player->getLevel();
  496. +       uint8 max_level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
  497. +
  498. +       uint8 VIP_level_cap = (max_level + (xtra_levels * Pvip)) - xtra_levels; // has to compensate for base VIP 1
  499. +
  500. +       ChatHandler(player->GetSession()).PSendSysMessage("Welcome %s, you are VIP %u.", player->GetName().c_str(), Vip[acct_id].vip);
  501. +       ChatHandler(player->GetSession()).PSendSysMessage("%stype `.vip` for a list of VIP commands.", green.c_str());
  502. +
  503. +       if (HearthStone[guid].guid != guid)
  504. +       {
  505. +           WorldDatabase.PExecute("REPLACE INTO hearthstone SET `guid`='%u';", guid);
  506. +
  507. +           VIP::SetHearthStone(guid, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  508. +       }
  509. +
  510. +       if (Plvl != VIP_level_cap)
  511. +       {
  512. +           if (lvl_enable)
  513. +           {
  514. +               player->SetLevel(VIP_level_cap);
  515. +           }
  516. +       }
  517. +   };
  518. +};
  519. +
  520. +class VIP_commands : public CommandScript
  521. +{
  522. +public:
  523. +   VIP_commands() : CommandScript("VIP_commands") { }
  524. +
  525. +   std::vector<ChatCommand> GetCommands() const
  526. +   {
  527. +       static std::vector<ChatCommand> vipCommandChangeTable =
  528. +       {
  529. +           { "race", rbac::RBAC_IN_GRANTED_LIST, true, &HandleChangeRaceCommand, "allows the player to change there race during next login." },
  530. +           { "faction", rbac::RBAC_IN_GRANTED_LIST, true, &HandleChangeFactionCommand, "allows the player to change there faction during next login." },
  531. +           { "custom", rbac::RBAC_IN_GRANTED_LIST, true, &HandleCustomizeCommand, "allows the player to re-costumize there character during next login." },
  532. +       };
  533. +
  534. +       static std::vector<ChatCommand> vipCommandSetTable =
  535. +       {
  536. +           { "hearthstone", rbac::RBAC_IN_GRANTED_LIST, true, &HandleVipSetHearthstoneCommand, "stores players current gps to VIP hearthstone command." },
  537. +       };
  538. +
  539. +       std::string repair_info = "repairs all the players items. Requires the player to possess a " + VIP_COIN_NAME + ".";
  540. +
  541. +       static std::vector<ChatCommand> vipCommandTable =
  542. +
  543. +       {
  544. +           { "mall",       rbac::RBAC_IN_GRANTED_LIST, true, &HandleVipMallCommand, "Teleports the player to a VIP mall." },
  545. +           { "home",       rbac::RBAC_IN_GRANTED_LIST, true, &HandleHomeCommand, "Teleports the player to there faction home mall." },
  546. +           { "repair",     rbac::RBAC_IN_GRANTED_LIST, true, &HandleRepairCommand, repair_info },
  547. +           { "hearthstone",rbac::RBAC_IN_GRANTED_LIST, true, &HandleHearthStoneCommand, "Teleports a player to there custom pre-set location." },
  548. +           { "set",        rbac::RBAC_IN_GRANTED_LIST, true, NULL, "Player customizable commands.", vipCommandSetTable },
  549. +           { "change",     rbac::RBAC_IN_GRANTED_LIST, true, NULL, "Character customizing commands.", vipCommandChangeTable },
  550. +       };
  551. +
  552. +       static std::vector<ChatCommand> commandTable =
  553. +       {
  554. +           { "vip", rbac::RBAC_IN_GRANTED_LIST, true, NULL, "custom VIP commands by Grumbo. Some commands may require player has an item.", vipCommandTable },
  555. +       };
  556. +       return commandTable;
  557. +   }
  558. +
  559. +   static bool HandleVipMallCommand(ChatHandler* handler, const char* args)
  560. +   {
  561. +
  562. +       Player* player = handler->GetSession()->GetPlayer();
  563. +
  564. +       auto team_id = player->GetTeamId();
  565. +
  566. +       if (player->IsInCombat())
  567. +       {
  568. +           handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  569. +           handler->SetSentErrorMessage(true);
  570. +           return false;
  571. +       }
  572. +
  573. +       // stop flight if need
  574. +       if (player->IsInFlight())
  575. +       {
  576. +           player->GetMotionMaster()->MovementExpired();
  577. +           player->CleanupAfterTaxiFlight();
  578. +       }
  579. +       // save only in non-flight case
  580. +       else
  581. +           player->SaveRecallPosition();
  582. +
  583. +       player->TeleportTo(MALL[team_id].map_id, MALL[team_id].x, MALL[team_id].y, MALL[team_id].z, MALL[team_id].o);
  584. +       return true;
  585. +   }
  586. +
  587. +   static bool HandleChangeRaceCommand(ChatHandler* handler, const char* args)
  588. +   {
  589. +       Player* player = handler->GetSession()->GetPlayer();
  590. +       player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
  591. +       handler->PSendSysMessage("Relog to change race of your character.");
  592. +       return true;
  593. +   }
  594. +
  595. +   static bool HandleChangeFactionCommand(ChatHandler* handler, const char* args)
  596. +   {
  597. +       Player* player = handler->GetSession()->GetPlayer();
  598. +       player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
  599. +       handler->PSendSysMessage("Relog to change faction of your character.");
  600. +       return true;
  601. +   }
  602. +
  603. +   static bool HandleCustomizeCommand(ChatHandler* handler, const char* args)
  604. +   {
  605. +       Player* player = handler->GetSession()->GetPlayer();
  606. +       player->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
  607. +       handler->PSendSysMessage("Relog to customize your character.");
  608. +       return true;
  609. +   }
  610. +
  611. +   static bool HandleHomeCommand(ChatHandler* handler, const char* args)
  612. +   {
  613. +
  614. +       Player* player = handler->GetSession()->GetPlayer();
  615. +
  616. +       auto team_id = player->GetTeamId();
  617. +
  618. +       if (player->IsInCombat())
  619. +       {
  620. +           handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  621. +           handler->SetSentErrorMessage(true);
  622. +           return false;
  623. +       }
  624. +
  625. +       // stop flight if need
  626. +       if (player->IsInFlight())
  627. +       {
  628. +           player->GetMotionMaster()->MovementExpired();
  629. +           player->CleanupAfterTaxiFlight();
  630. +       }
  631. +       // save only in non-flight case
  632. +       else
  633. +           player->SaveRecallPosition();
  634. +
  635. +       player->TeleportTo(HOME[team_id].map_id, HOME[team_id].x, HOME[team_id].y, HOME[team_id].z, HOME[team_id].o);
  636. +       return true;
  637. +   }
  638. +
  639. +   static bool HandleRepairCommand(ChatHandler* handler, const char* args)
  640. +   {
  641. +       Player* player = handler->GetSession()->GetPlayer();
  642. +
  643. +       if (!player->HasItemCount(VIP_COIN_ID, 1, false))
  644. +       {
  645. +           handler->PSendSysMessage("You must have a %s to use this command.", VIP_COIN_NAME.c_str());
  646. +           return false;
  647. +       }
  648. +
  649. +       if (player->HasItemCount(VIP_COIN_ID, 1, false))
  650. +       {
  651. +           player->DurabilityRepairAll(0, 0, false);
  652. +           handler->PSendSysMessage("Done.");
  653. +           return true;
  654. +       }
  655. +       return true;
  656. +   }
  657. +
  658. +   static bool HandleVipSetHearthstoneCommand(ChatHandler* handler, const char* args)
  659. +   {
  660. +
  661. +       Player* player = handler->GetSession()->GetPlayer();
  662. +
  663. +       auto team_id = player->GetTeamId();
  664. +
  665. +       if (player->IsInCombat())
  666. +       {
  667. +           handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  668. +           handler->SetSentErrorMessage(true);
  669. +           return false;
  670. +       }
  671. +
  672. +       // stop flight if need
  673. +       if (player->IsInFlight())
  674. +       {
  675. +           player->GetMotionMaster()->MovementExpired();
  676. +           player->CleanupAfterTaxiFlight();
  677. +       }
  678. +       // save only in non-flight case
  679. +       else
  680. +           player->SaveRecallPosition();
  681. +
  682. +       VIP::SetHearthStone(player->GetGUID(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  683. +       handler->PSendSysMessage("%s, your location has been stored.", player->GetName().c_str());
  684. +       return true;
  685. +   }
  686. +
  687. +   static bool HandleHearthStoneCommand(ChatHandler* handler, const char* args)
  688. +   {
  689. +
  690. +       Player* player = handler->GetSession()->GetPlayer();
  691. +
  692. +       uint32 guid = player->GetGUID();
  693. +
  694. +       if (player->IsInCombat())
  695. +       {
  696. +           handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  697. +           handler->SetSentErrorMessage(true);
  698. +           return false;
  699. +       }
  700. +
  701. +       // stop flight if need
  702. +       if (player->IsInFlight())
  703. +       {
  704. +           player->GetMotionMaster()->MovementExpired();
  705. +           player->CleanupAfterTaxiFlight();
  706. +       }
  707. +
  708. +       if (HearthStone[guid].guid != guid)
  709. +       {
  710. +           WorldDatabase.PExecute("REPLACE INTO hearthstone SET `guid`='%u';", guid);
  711. +
  712. +           VIP::SetHearthStone(guid, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  713. +
  714. +           handler->PSendSysMessage("You must store a location first to be able to use this command.");
  715. +           handler->PSendSysMessage("Default location is your current location.");
  716. +           return false;
  717. +       }
  718. +
  719. +       if (HearthStone[guid].guid == guid)
  720. +       {
  721. +           // save only in non-flight case and a location is stored
  722. +           player->SaveRecallPosition();
  723. +
  724. +           player->TeleportTo(HearthStone[guid].map_id, HearthStone[guid].x, HearthStone[guid].y, HearthStone[guid].z, HearthStone[guid].o);
  725. +           return true;
  726. +       }
  727. +       return true;
  728. +   }
  729. +};
  730. +
  731. +class VIP_Coin_Script : public ItemScript
  732. +{
  733. +public: VIP_Coin_Script() : ItemScript("VIP_Coin_Script"){ };
  734. +
  735. +
  736. +       virtual bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
  737. +       {
  738. +           uint32 acct_id = player->GetSession()->GetAccountId();
  739. +           uint8 pVip = VIP::GetVIP(acct_id);
  740. +           uint32 pMg = VIP::GetMG(acct_id);
  741. +           uint32 pVotes = VIP::GetVOTES(acct_id);
  742. +           std::string Votes_Required_Ann;
  743. +           bool voting = VIP::GetVIPVOTE_ENABLE();
  744. +
  745. +           ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str());
  746. +           ChatHandler(player->GetSession()).PSendSysMessage("%sYou are VIP:%s%u%s of %s%u.", green.c_str(), white.c_str(), pVip, green.c_str(), white.c_str(), VIP_MAX);
  747. +           ChatHandler(player->GetSession()).PSendSysMessage("%sYou have %s%u %smg's", green.c_str(), white.c_str(), pMg, green.c_str());
  748. +
  749. +           if (pVotes <= 10){ ChatHandler(player->GetSession()).PSendSysMessage("%sYou have Voted %s%u%s time's.", green.c_str(), white.c_str(), pVotes, green.c_str()); };
  750. +           if (pVotes > 10){ ChatHandler(player->GetSession()).PSendSysMessage("%sThank you for voting %s%u%s time's.", green.c_str(), white.c_str(), pVotes, green.c_str()); };
  751. +
  752. +           ChatHandler(player->GetSession()).PSendSysMessage("%sYou recieve a %s%u%s %sstat increase.", green.c_str(), white.c_str(), uint8(VIP_OFFSET * 100)*pVip, "%", green.c_str());
  753. +
  754. +           if (voting)
  755. +           {
  756. +               if (pVip < VIP_MAX)
  757. +               {
  758. +                   uint32 Votes_Required = ((pVip + 1) * VIP_VOTE_COUNT) - pVotes;
  759. +
  760. +                   ChatHandler(player->GetSession()).PSendSysMessage("%sYou need %s%u%s more votes to reach the next VIP rank:%s%u%s.", green.c_str(), white.c_str(), Votes_Required, green.c_str(), white.c_str(), (pVip + 1), green.c_str());
  761. +
  762. +                   ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str());
  763. +
  764. +                   return true;
  765. +               }
  766. +           }
  767. +           ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str());
  768. +           return true;
  769. +       }
  770. +};
  771. +
  772. +void RemoveItem(uint32 id, Player* player)
  773. +{
  774. +   player->DestroyItemCount(uint32(id), 1, true);
  775. +
  776. +   ChatHandler(player->GetSession()).PSendSysMessage("%s+1 VIP.", green.c_str());
  777. +};
  778. +
  779. +class VIP_Stone_Script : public ItemScript
  780. +{
  781. +public: VIP_Stone_Script() : ItemScript("VIP_Stone_Script"){ };
  782. +
  783. +
  784. +       virtual bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
  785. +       {
  786. +           uint32 acct_id = player->GetSession()->GetAccountId();
  787. +           uint8 pVip = VIP::GetVIP(acct_id);
  788. +           uint32 pMg = VIP::GetMG(acct_id);
  789. +           uint32 pVotes = VIP::GetVOTES(acct_id);
  790. +
  791. +           if (pVip >= VIP_MAX)
  792. +           {
  793. +               ChatHandler(player->GetSession()).PSendSysMessage("%sYou are allready the maximum VIP rank:%s%u.", red.c_str(), white.c_str(), VIP_MAX);
  794. +
  795. +           }
  796. +
  797. +           if (pVip < VIP_MAX)
  798. +           {
  799. +               VIP::SetVOTES(acct_id, pVotes + VIP_VOTE_COUNT); // must be first for the dead mans check
  800. +
  801. +               VIP::SetVIP(acct_id, pVip + 1);
  802. +
  803. +               RemoveItem(VIP_COIN_ID, player);
  804. +
  805. +               return true;
  806. +           }
  807. +           return true;
  808. +       }
  809. +};
  810. +
  811. +class VIP_MG_BANKER : public CreatureScript
  812. +{
  813. +public: VIP_MG_BANKER() : CreatureScript("VIP_MG_BANKER"){ }
  814. +
  815. +       bool OnGossipHello(Player* player, Creature* creature)
  816. +       {
  817. +
  818. +           uint32 accountId = player->GetSession()->GetAccountId();
  819. +           uint8 pVIP = VIP::GetVIP(accountId);
  820. +           uint32 MG = VIP::GetMG(accountId);
  821. +           uint32 itemId = VIP::GetVIPMGID();
  822. +           uint32 pMg = player->GetItemCount(itemId);
  823. +           uint32 pVotes = VIP::GetVOTES(accountId);
  824. +           std::string itemName = sObjectMgr->GetItemTemplate(itemId)->Name1;
  825. +           std::string currency_inBank;
  826. +           std::string deposit_amt;
  827. +
  828. +           if (pMg == 1){ deposit_amt = "Total:" + ConvertNumberToString(pMg) + " " + itemName; };
  829. +           if (pMg == 0 || pMg > 1){ deposit_amt = "Total:" + ConvertNumberToString(pMg) + " " + itemName + "'s"; };
  830. +
  831. +           std::string withdraw10 = "Withdraw 10 " + itemName + "'s. Fee:0 " + itemName + "'s.";
  832. +           std::string withdraw100 = "Withdraw 100 " + itemName + "'s. Fee:1 " + itemName + ".";
  833. +           std::string withdraw1000 = "Withdraw 1,000 " + itemName + "'s. Fee:10 " + itemName + "'s.";
  834. +           std::string withdraw10000 = "Withdraw 10,000 " + itemName + "'s. Fee:100 " + itemName + "'s.";
  835. +           std::string withdraw100000 = "Withdraw 100,000 " + itemName + "'s. Fee:1,000 " + itemName + "'s.";
  836. +
  837. +           if (MG == 1)
  838. +               currency_inBank = "Balance:" + ConvertNumberToString(MG) + " " + itemName;
  839. +           else
  840. +           {
  841. +               currency_inBank = "Balance:" + ConvertNumberToString(MG) + " " + itemName + "'s.";
  842. +           };
  843. +
  844. +           std::string current_VOTES = "Votes:" + ConvertNumberToString(pVotes);
  845. +           std::string current_VIP = "VIP:" + ConvertNumberToString(pVIP);
  846. +
  847. +           if (pMg > 0)
  848. +           {
  849. +               player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  850. +               player->ADD_GOSSIP_ITEM(10, "-Deposit-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  851. +               player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  852. +               player->ADD_GOSSIP_ITEM(10, "Deposit all my custom currency.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2001);
  853. +               player->ADD_GOSSIP_ITEM(10, deposit_amt.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2001);
  854. +               player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  855. +           }
  856. +
  857. +           if (MG >= 10)
  858. +           {
  859. +               player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  860. +               player->ADD_GOSSIP_ITEM(10, "-WithDrawl-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  861. +               player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  862. +               player->ADD_GOSSIP_ITEM(10, withdraw10.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2002);
  863. +
  864. +               if (MG >= 101){ player->ADD_GOSSIP_ITEM(10, withdraw100.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2003); };
  865. +               if (MG >= 1010){ player->ADD_GOSSIP_ITEM(10, withdraw1000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2004); };
  866. +               if (MG >= 10100){ player->ADD_GOSSIP_ITEM(10, withdraw10000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2005); };
  867. +               if (MG >= 101000){ player->ADD_GOSSIP_ITEM(10, withdraw100000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2006); };
  868. +           }
  869. +
  870. +           player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  871. +           player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  872. +           player->ADD_GOSSIP_ITEM(10, "-Bank Balance-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  873. +           player->ADD_GOSSIP_ITEM(10, currency_inBank.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  874. +           player->ADD_GOSSIP_ITEM(10, current_VOTES.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  875. +           player->ADD_GOSSIP_ITEM(10, current_VIP.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  876. +           player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  877. +
  878. +           player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  879. +
  880. +           return true;
  881. +       };
  882. +
  883. +       bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
  884. +       {
  885. +           TC_LOG_INFO("server.loading", "MG_BANKER::OnSelect :%u", actions);
  886. +
  887. +           uint32 accountId = player->GetSession()->GetAccountId();
  888. +           uint8 pVIP = VIP::GetVIP(accountId);
  889. +           uint32 MG = VIP::GetMG(accountId);
  890. +           uint32 itemId = VIP::GetVIPMGID();
  891. +           uint32 pMg = player->GetItemCount(itemId);
  892. +           uint32 pVotes = VIP::GetVOTES(accountId);
  893. +
  894. +           switch (actions)
  895. +           {
  896. +           case GOSSIP_ACTION_INFO_DEF + 2000: // loopbacks
  897. +
  898. +               player->PlayerTalkClass->ClearMenus();
  899. +               player->CLOSE_GOSSIP_MENU();
  900. +
  901. +               OnGossipHello(player, creature);
  902. +               break;
  903. +
  904. +           case GOSSIP_ACTION_INFO_DEF + 2001: // Deposit all
  905. +
  906. +               player->DestroyItemCount(itemId, pMg, true);
  907. +
  908. +               if (player->GetItemCount(itemId) == 0)
  909. +               {
  910. +                   VIP::SetMG(accountId, MG + pMg);
  911. +
  912. +               };
  913. +
  914. +               player->PlayerTalkClass->ClearMenus();
  915. +               player->CLOSE_GOSSIP_MENU();
  916. +
  917. +               OnGossipHello(player, creature);
  918. +               break;
  919. +
  920. +           case GOSSIP_ACTION_INFO_DEF + 2002: // Withdraw 10
  921. +
  922. +               player->PlayerTalkClass->ClearMenus();
  923. +
  924. +               if (player->AddItem(itemId, 10))
  925. +               {
  926. +                   VIP::SetMG(accountId, MG - 10);
  927. +                   player->CLOSE_GOSSIP_MENU();
  928. +               }
  929. +               break;
  930. +
  931. +           case GOSSIP_ACTION_INFO_DEF + 2003: // Withdraw 100
  932. +
  933. +               player->PlayerTalkClass->ClearMenus();
  934. +
  935. +               if (player->AddItem(itemId, 100))
  936. +               {
  937. +                   VIP::SetMG(accountId, MG - 101);
  938. +                   player->CLOSE_GOSSIP_MENU();
  939. +               }
  940. +
  941. +               OnGossipHello(player, creature);
  942. +               break;
  943. +
  944. +           case GOSSIP_ACTION_INFO_DEF + 2004: // Withdraw 1,000
  945. +               player->PlayerTalkClass->ClearMenus();
  946. +
  947. +               if (player->AddItem(itemId, 1000))
  948. +               {
  949. +                   VIP::SetMG(accountId, MG - 1010);
  950. +                   player->CLOSE_GOSSIP_MENU();
  951. +               }
  952. +
  953. +               OnGossipHello(player, creature);
  954. +               break;
  955. +
  956. +           case GOSSIP_ACTION_INFO_DEF + 2005: // Withdraw 10,000
  957. +               player->PlayerTalkClass->ClearMenus();
  958. +
  959. +               if (player->AddItem(itemId, 10000))
  960. +               {
  961. +                   VIP::SetMG(accountId, MG - 10100);
  962. +                   player->CLOSE_GOSSIP_MENU();
  963. +               }
  964. +
  965. +               OnGossipHello(player, creature);
  966. +               break;
  967. +
  968. +           case GOSSIP_ACTION_INFO_DEF + 2006: // Withdraw 100,000
  969. +               player->PlayerTalkClass->ClearMenus();
  970. +
  971. +               if (player->AddItem(itemId, 100000))
  972. +               {
  973. +                   VIP::SetMG(accountId, MG - 101000);
  974. +                   player->CLOSE_GOSSIP_MENU();
  975. +               }
  976. +
  977. +               OnGossipHello(player, creature);
  978. +               break;
  979. +           }
  980. +           return true;
  981. +       };
  982. +};
  983. +
  984. +void AddSC_Grumboz_VIP_Core()
  985. +{
  986. +   new VIP_Load_Conf;
  987. +   new Grumboz_VIP_Account_Engine;
  988. +   new Grumboz_VIP_Player_Engine;
  989. +   new VIP_commands;
  990. +   new VIP_Coin_Script;
  991. +   new VIP_Stone_Script;
  992. +   new VIP_MG_BANKER;
  993. +}
  994. diff --git a/src/server/game/Entities/Player/Grumboz_VIP_Core.h b/src/server/game/Entities/Player/Grumboz_VIP_Core.h
  995. new file mode 100644
  996. index 0000000..41d784a
  997. --- /dev/null
  998. +++ b/src/server/game/Entities/Player/Grumboz_VIP_Core.h
  999. @@ -0,0 +1,82 @@
  1000. +
  1001. +#ifndef GRUMBOZ_VIP_CORE_H
  1002. +#define GRUMBOZ_VIP_CORE_H
  1003. +
  1004. +struct VipElements
  1005. +{
  1006. +   uint8 vip;
  1007. +   uint32 mg;
  1008. +   uint32 votes;
  1009. +};
  1010. +
  1011. +struct ItemVIP
  1012. +{
  1013. +   uint32 item_id;
  1014. +   uint8 vip;
  1015. +};
  1016. +
  1017. +struct VipMallGPS
  1018. +{
  1019. +   uint32 map_id;
  1020. +   float x;
  1021. +   float y;
  1022. +   float z;
  1023. +   float o;
  1024. +};
  1025. +
  1026. +struct VipHomeGPS
  1027. +{
  1028. +   uint32 map_id;
  1029. +   float x;
  1030. +   float y;
  1031. +   float z;
  1032. +   float o;
  1033. +};
  1034. +
  1035. +struct VipHearthStoneGPS
  1036. +{
  1037. +   uint32 guid;
  1038. +   uint32 map_id;
  1039. +   float x;
  1040. +   float y;
  1041. +   float z;
  1042. +   float o;
  1043. +};
  1044. +
  1045. +class VIP
  1046. +{
  1047. +
  1048. +public:
  1049. +   VIP();
  1050. +   ~VIP();
  1051. +
  1052. +   // Getterz
  1053. +   static uint8 GetVIPMAX();
  1054. +   static bool GetVIPVOTE_ENABLE();
  1055. +   static uint32 GetVIPVOTECOUNT();
  1056. +   static uint32 GetVIPCOINID();
  1057. +   static uint32 GetVIPSTONEID();
  1058. +   static uint32 GetVIPMGID();
  1059. +   static float GetVIPOFFSET();
  1060. +   static uint8 GetTALENTBONUS();
  1061. +   static bool GetLEVELBONUS_ENABLE();
  1062. +   static uint8 GetLEVELBONUS();
  1063. +
  1064. +   static uint8 GetItemVIP(uint32 item_id);
  1065. +   static uint8 GetVIP(uint32 acct_id);
  1066. +   static uint32 GetMG(uint32 acct_id);
  1067. +   static uint32 GetVOTES(uint32 acct_id);
  1068. +
  1069. +   // Setterz
  1070. +   static void SetVIP(uint32 acct_id, uint8 pvip);
  1071. +   static void SetMG(uint32 acct_id, uint32 pmg);
  1072. +   static void SetVOTES(uint32 acct_id, uint32 pvotes);
  1073. +   static void SetHearthStone(uint32 guid, uint32 map_id, float x, float y, float z, float o);
  1074. +   static void SetItemVIP(uint32 item_id, uint8 item_vip);
  1075. +
  1076. +private:
  1077. +   // tools
  1078. +   void RemoveItem(uint32 id, Player* player);
  1079. +};
  1080. +
  1081. +#endif // GRUMBOZ_GUILD_WARZ_H_INCLUDED
  1082. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  1083. index e4a2918..cd76f10 100644
  1084. --- a/src/server/game/Entities/Player/Player.cpp
  1085. +++ b/src/server/game/Entities/Player/Player.cpp
  1086. @@ -43,6 +43,7 @@
  1087.  #include "GridNotifiers.h"
  1088.  #include "GridNotifiersImpl.h"
  1089.  #include "Group.h"
  1090. +#include "Grumboz_VIP_Core.h"
  1091.  #include "GroupMgr.h"
  1092.  #include "Guild.h"
  1093.  #include "GuildMgr.h"
  1094. @@ -11129,6 +11130,17 @@ InventoryResult Player::CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, b
  1095.  
  1096.  InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool swap, bool not_loading) const
  1097.  {
  1098. +   // item VIP level 0 or 1 = all players can equip.
  1099. +   uint32 acctId = GetSession()->GetAccountId();
  1100. +   uint8 Pvip = VIP::GetVIP(acctId);
  1101. +   uint8 Ivip = VIP::GetItemVIP(pItem->GetEntry());
  1102. +
  1103. +   if (Pvip < Ivip)
  1104. +   {
  1105. +       ChatHandler(GetSession()).PSendSysMessage("|cffFF0000You Must be VIP%u or higher to equip this item.|r", Ivip);
  1106. +       return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
  1107. +   }
  1108. +
  1109.      dest = 0;
  1110.      if (pItem)
  1111.      {
  1112. diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
  1113. index 07ac1a2..1f26bfd 100644
  1114. --- a/src/server/game/Scripting/ScriptLoader.cpp
  1115. +++ b/src/server/game/Scripting/ScriptLoader.cpp
  1116. @@ -32,6 +32,7 @@ void AddEventsScripts();
  1117.  void AddPetScripts();
  1118.  void AddOutdoorPvPScripts();
  1119.  void AddCustomScripts();
  1120. +void AddSC_Grumboz_VIP_Core();
  1121.  #endif
  1122.  
  1123.  void AddScripts()
  1124. @@ -49,5 +50,6 @@ void AddScripts()
  1125.      AddPetScripts();
  1126.      AddOutdoorPvPScripts();
  1127.      AddCustomScripts();
  1128. +    AddSC_Grumboz_VIP_Core();
  1129.  #endif
  1130.  }
  1131. diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
  1132. index b320a85..3d55891 100644
  1133. --- a/src/server/worldserver/worldserver.conf.dist
  1134. +++ b/src/server/worldserver/worldserver.conf.dist
  1135. @@ -3572,3 +3572,91 @@ PacketSpoof.BanDuration = 86400
  1136.  
  1137.  #
  1138.  ###################################################################################################
  1139. +###################################################################################################
  1140. +# Grumbo'z VIP System
  1141. +#
  1142. +# These settings provide a flexibility to the system.
  1143. +#
  1144. +#  
  1145. +#  VIP.MAX
  1146. +#      Description: Max VIP Level for VIP System. max Uint32 value.
  1147. +#      Default:     6
  1148. +#
  1149. +
  1150. +VIP.MAX = 6
  1151. +
  1152. +#  VIP.OFFSET
  1153. +#      Description: float multiplier for each vip rank.
  1154. +#      this is used for stat mod's. i.e. mod = VIP rank * offset.
  1155. +#      Default:     0.05f 5% muliplier used per VIP rank
  1156. +#
  1157. +
  1158. +VIP.OFFSET = 0.05
  1159. +
  1160. +#  VIP.VOTE.ENABE
  1161. +#      Description: Votes can earn higher vip ranks.
  1162. +#      Default: 1 . 0 off // 1 on.
  1163. +#
  1164. +
  1165. +VIP.VOTE_ENABLE = 1
  1166. +
  1167. +#
  1168. +#  VIP.VOTE.COUNT
  1169. +#      Description: how many Votes to earn each level of VIP.
  1170. +#      Default: 125 votes per.
  1171. +#
  1172. +
  1173. +VIP.VOTE_COUNT = 125
  1174. +
  1175. +#
  1176. +#  VIP.COIN
  1177. +#      Description: an item that is clickable to show a players VIP stats
  1178. +#      Default: 63020
  1179. +#
  1180. +
  1181. +
  1182. +VIP.COIN = 63020
  1183. +
  1184. +#
  1185. +#  VIP.STONE
  1186. +#      Description: an item that is clickable and will increase a players VIP level.
  1187. +#      Default: 63021
  1188. +#
  1189. +
  1190. +VIP.STONE =  63021
  1191. +
  1192. +#
  1193. +#  VIP.MAGIC.GOLD
  1194. +#      Description: just Global custom currency id that can be accessed
  1195. +#      by another character via the VIP banker deposit/withdrawal
  1196. +#      Default: 44209
  1197. +#
  1198. +
  1199. +VIP.MAGIC_GOLD = 44209
  1200. +
  1201. +#
  1202. +#  VIP.TP.BONUS
  1203. +#      Description: how many extra TP's to award per VIP level.
  1204. +#      Default: 14 per VIP level.
  1205. +#
  1206. +
  1207. +VIP.TP_BONUS = 14
  1208. +
  1209. +#  VIP.LEVEL_BONUS_ENABE
  1210. +#      Description: players can reach higher levels per VIP..
  1211. +#      Default: 1 . 0 off // 1 on.
  1212. +#
  1213. +
  1214. +VIP.LEVEL_BONUS_ENABLE = 1
  1215. +
  1216. +#
  1217. +#
  1218. +#  VIP.LEVEL_BONUS
  1219. +#      Description: how many extra level's a player can gain  per VIP level.
  1220. +#      Default: 1
  1221. +#
  1222. +
  1223. +VIP.LEVEL_BONUS = 1
  1224. +
  1225. +#
  1226. +###################################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement