slp13at420

Grumboz_VIP_Engine.diff

Mar 13th, 2016
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.22 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 4f056e2..947d9d4 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..080013f 100644
  17. --- a/src/server/database/Database/Implementation/LoginDatabase.h
  18. +++ b/src/server/database/Database/Implementation/LoginDatabase.h
  19. @@ -113,6 +113,11 @@ 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. MAX_LOGINDATABASE_STATEMENTS
  29. };
  30.  
  31. diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp
  32. index 7a183d5..46c5639 100644
  33. --- a/src/server/database/Database/Implementation/WorldDatabase.cpp
  34. +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp
  35. @@ -91,4 +91,6 @@ void WorldDatabaseConnection::DoPrepareStatements()
  36. PrepareStatement(WORLD_DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_ASYNC);
  37. PrepareStatement(WORLD_UPD_CREATURE_ZONE_AREA_DATA, "UPDATE creature SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
  38. PrepareStatement(WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA, "UPDATE gameobject SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
  39. +
  40. + PrepareStatement(WORLD_SET_ITEM_VIP, "UPDATE item_template SET `vip`=? WHERE `entry`=?", CONNECTION_ASYNC);
  41. }
  42. diff --git a/src/server/database/Database/Implementation/WorldDatabase.h b/src/server/database/Database/Implementation/WorldDatabase.h
  43. index 6ac4ce5..5a79c8e 100644
  44. --- a/src/server/database/Database/Implementation/WorldDatabase.h
  45. +++ b/src/server/database/Database/Implementation/WorldDatabase.h
  46. @@ -100,7 +100,8 @@ enum WorldDatabaseStatements
  47. WORLD_UPD_CREATURE_ZONE_AREA_DATA,
  48. WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA,
  49.  
  50. - MAX_WORLDDATABASE_STATEMENTS
  51. + WORLD_SET_ITEM_VIP,
  52. + MAX_WORLDDATABASE_STATEMENTS
  53. };
  54.  
  55. class WorldDatabaseConnection : public MySQLConnection
  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..668de04
  59. --- /dev/null
  60. +++ b/src/server/game/Entities/Player/Grumboz_VIP_Core.cpp
  61. @@ -0,0 +1,931 @@
  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::SetHearthStone(uint32 guid, uint32 map_id, float x, float y, float z, float o)
  336. +{
  337. + 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);
  338. +
  339. + VipHearthStoneGPS& data = HearthStone[guid];
  340. + // Save the DB values to the MyData object
  341. + data.guid = guid;
  342. + data.map_id = map_id;
  343. + data.x = x;
  344. + data.y = y;
  345. + data.z = z;
  346. + data.o = o;
  347. +}
  348. +
  349. +void VIP::SetVIP(uint32 acct_id, uint8 pvip)
  350. +{ // you must update votes first for the dead mans check
  351. +
  352. + if (VIP_VOTE_ENABLE)
  353. + {
  354. + uint32 pvotes = Vip[acct_id].votes;
  355. +
  356. + pvip = uint8(pvotes / VIP_VOTE_COUNT); // dead mans check auto-calibrater
  357. +
  358. + if (pvotes < VIP_VOTE_COUNT)
  359. + {
  360. + pvip = 1;
  361. + }
  362. +
  363. + if (pvotes >(VIP_VOTE_COUNT * VIP_MAX))
  364. + {
  365. + pvip = VIP_MAX;
  366. + }
  367. + }
  368. +
  369. + Vip[acct_id].vip = pvip;
  370. +
  371. + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_VIP);
  372. + stmt->setUInt8(0, pvip);
  373. + stmt->setUInt32(1, acct_id);
  374. + LoginDatabase.Execute(stmt);
  375. +};
  376. +
  377. +void VIP::SetMG(uint32 acct_id, uint32 pmg)
  378. +{
  379. + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_MG);
  380. + stmt->setUInt32(0, pmg);
  381. + stmt->setUInt32(1, acct_id);
  382. + LoginDatabase.Execute(stmt);
  383. +
  384. + Vip[acct_id].mg = pmg;
  385. +};
  386. +
  387. +void VIP::SetVOTES(uint32 acct_id, uint32 pvotes)
  388. +{
  389. + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_VOTES);
  390. + stmt->setUInt32(0, pvotes);
  391. + stmt->setUInt32(1, acct_id);
  392. + LoginDatabase.Execute(stmt);
  393. +
  394. + Vip[acct_id].votes = pvotes;
  395. +};
  396. +
  397. +uint8 VIP::GetVIP(uint32 acct_id)
  398. +{
  399. + return Vip[acct_id].vip;
  400. +};
  401. +
  402. +uint32 VIP::GetMG(uint32 acct_id)
  403. +{
  404. + return Vip[acct_id].mg;
  405. +};
  406. +
  407. +uint32 VIP::GetVOTES(uint32 acct_id)
  408. +{
  409. + return Vip[acct_id].votes;
  410. +};
  411. +
  412. +uint8 VIP::GetItemVIP(uint32 item_id)
  413. +{
  414. + return ItemVip[item_id].vip;
  415. +};
  416. +
  417. +void VIP::SetItemVIP(uint32 item_id, uint8 item_vip)
  418. +{
  419. + if (item_vip < 1) { item_vip = 1; };
  420. + if (item_vip > VIP_MAX) { item_vip = VIP_MAX; };
  421. +
  422. + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SET_ITEM_VIP);
  423. + stmt->setUInt8(0, item_vip);
  424. + stmt->setUInt32(1, item_id);
  425. + WorldDatabase.Execute(stmt);
  426. +
  427. + ItemVip[item_id].vip = item_vip;
  428. +};
  429. +
  430. +class Grumboz_VIP_Account_Engine : public AccountScript
  431. +{
  432. +public: Grumboz_VIP_Account_Engine() : AccountScript("Grumboz_VIP_Account_Engine"){ };
  433. +
  434. + virtual void OnAccountLogout(uint32 accountId)
  435. + {
  436. + TC_LOG_INFO("server.loading", "ACCOUNT::LOGOUT ID:%u VIP:%u", accountId, Vip[accountId].vip);
  437. +
  438. + Vip.erase(accountId);
  439. + };
  440. +
  441. + virtual void OnAccountLogin(uint32 accountId)
  442. + {
  443. + if (accountId > 0)
  444. + {
  445. + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_LOAD_VIP);
  446. + stmt->setUInt32(0, accountId);
  447. + PreparedQueryResult result = LoginDatabase.Query(stmt);
  448. +
  449. + if (!result)
  450. + {
  451. + TC_LOG_INFO("server.loading", "XX ERROR Loading a VIP table ID %u XX", accountId);
  452. + };
  453. +
  454. + if (result)
  455. + {
  456. + // unpacks the results of `result` into fields and appoint data to variable.
  457. + Field* fields = result->Fetch();
  458. + uint8 pvip = fields[0].GetUInt8();
  459. + uint32 pmg = fields[1].GetUInt32();
  460. + uint32 pvotes = fields[2].GetUInt32();
  461. +
  462. + VipElements& data = Vip[accountId]; // like Lua table VIP[acctId].vip
  463. + // Save the DB values to the MyData object
  464. + data.vip = pvip;
  465. + data.mg = pmg;
  466. + data.votes = pvotes;
  467. +
  468. + VIP::SetVIP(accountId, pvip);
  469. +
  470. + TC_LOG_INFO("server.loading", "ACCOUNT::LOGIN ID:%u VIP:%u", accountId, Vip[accountId].vip);
  471. + }
  472. + }
  473. + }
  474. +};
  475. +
  476. +class Grumboz_VIP_Player_Engine : public PlayerScript
  477. +{
  478. +public: Grumboz_VIP_Player_Engine() : PlayerScript("Grumboz_VIP_Player_Engine"){ };
  479. +
  480. + virtual void OnLogout(Player* player)
  481. + {
  482. + AnnounceLoggingToWorld(player, 0);
  483. + };
  484. +
  485. + virtual void OnLogin(Player* player, bool firstLogin)
  486. + {
  487. + AnnounceLoggingToWorld(player, 1);
  488. +
  489. + uint32 guid = player->GetGUID();
  490. + uint32 acct_id = player->GetSession()->GetAccountId();
  491. + uint8 Pvip = VIP::GetVIP(acct_id);
  492. + bool lvl_enable = VIP::GetLEVELBONUS_ENABLE();
  493. + uint8 xtra_levels = VIP::GetLEVELBONUS();
  494. + uint8 Plvl = player->getLevel();
  495. + uint8 max_level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
  496. +
  497. + uint8 VIP_level_cap = (max_level + (xtra_levels * Pvip)) - xtra_levels; // has to compensate for base VIP 1
  498. +
  499. + ChatHandler(player->GetSession()).PSendSysMessage("Welcome %s, you are VIP %u.", player->GetName().c_str(), Vip[acct_id].vip);
  500. + ChatHandler(player->GetSession()).PSendSysMessage("%stype `.vip` for a list of VIP commands.", green.c_str());
  501. +
  502. + if (HearthStone[guid].guid != guid)
  503. + {
  504. + WorldDatabase.PExecute("REPLACE INTO hearthstone SET `guid`='%u';", guid);
  505. +
  506. + VIP::SetHearthStone(guid, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  507. + }
  508. +
  509. + if (Plvl != VIP_level_cap)
  510. + {
  511. + if (lvl_enable)
  512. + {
  513. + player->SetLevel(VIP_level_cap);
  514. + }
  515. + }
  516. + };
  517. +};
  518. +
  519. +class VIP_commands : public CommandScript
  520. +{
  521. +public:
  522. + VIP_commands() : CommandScript("VIP_commands") { }
  523. +
  524. + std::vector<ChatCommand> GetCommands() const
  525. + {
  526. + static std::vector<ChatCommand> vipCommandChangeTable =
  527. + {
  528. + { "race", rbac::RBAC_IN_GRANTED_LIST, true, &HandleChangeRaceCommand, "allows the player to change there race during next login." },
  529. + { "faction", rbac::RBAC_IN_GRANTED_LIST, true, &HandleChangeFactionCommand, "allows the player to change there faction during next login." },
  530. + { "custom", rbac::RBAC_IN_GRANTED_LIST, true, &HandleCustomizeCommand, "allows the player to re-costumize there character during next login." },
  531. + };
  532. +
  533. + static std::vector<ChatCommand> vipCommandSetTable =
  534. + {
  535. + { "hearthstone", rbac::RBAC_IN_GRANTED_LIST, true, &HandleVipSetHearthstoneCommand, "stores players current gps to VIP hearthstone command." },
  536. + };
  537. +
  538. + std::string repair_info = "repairs all the players items. Requires the player to possess a " + VIP_COIN_NAME + ".";
  539. +
  540. + static std::vector<ChatCommand> vipCommandTable =
  541. +
  542. + {
  543. + { "mall", rbac::RBAC_IN_GRANTED_LIST, true, &HandleVipMallCommand, "Teleports the player to a VIP mall." },
  544. + { "home", rbac::RBAC_IN_GRANTED_LIST, true, &HandleHomeCommand, "Teleports the player to there faction home mall." },
  545. + { "repair", rbac::RBAC_IN_GRANTED_LIST, true, &HandleRepairCommand, repair_info },
  546. + { "hearthstone",rbac::RBAC_IN_GRANTED_LIST, true, &HandleHearthStoneCommand, "Teleports a player to there custom pre-set location." },
  547. + { "set", rbac::RBAC_IN_GRANTED_LIST, true, NULL, "Player customizable commands.", vipCommandSetTable },
  548. + { "change", rbac::RBAC_IN_GRANTED_LIST, true, NULL, "Character customizing commands.", vipCommandChangeTable },
  549. + };
  550. +
  551. + static std::vector<ChatCommand> commandTable =
  552. + {
  553. + { "vip", rbac::RBAC_IN_GRANTED_LIST, true, NULL, "custom VIP commands by Grumbo. Some commands may require player has an item.", vipCommandTable },
  554. + };
  555. + return commandTable;
  556. + }
  557. +
  558. + static bool HandleVipMallCommand(ChatHandler* handler, const char* args)
  559. + {
  560. +
  561. + Player* player = handler->GetSession()->GetPlayer();
  562. +
  563. + auto team_id = player->GetTeamId();
  564. +
  565. + if (player->IsInCombat())
  566. + {
  567. + handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  568. + handler->SetSentErrorMessage(true);
  569. + return false;
  570. + }
  571. +
  572. + // stop flight if need
  573. + if (player->IsInFlight())
  574. + {
  575. + player->GetMotionMaster()->MovementExpired();
  576. + player->CleanupAfterTaxiFlight();
  577. + }
  578. + // save only in non-flight case
  579. + else
  580. + player->SaveRecallPosition();
  581. +
  582. + player->TeleportTo(MALL[team_id].map_id, MALL[team_id].x, MALL[team_id].y, MALL[team_id].z, MALL[team_id].o);
  583. + return true;
  584. + }
  585. +
  586. + static bool HandleChangeRaceCommand(ChatHandler* handler, const char* args)
  587. + {
  588. + Player* player = handler->GetSession()->GetPlayer();
  589. + player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
  590. + handler->PSendSysMessage("Relog to change race of your character.");
  591. + return true;
  592. + }
  593. +
  594. + static bool HandleChangeFactionCommand(ChatHandler* handler, const char* args)
  595. + {
  596. + Player* player = handler->GetSession()->GetPlayer();
  597. + player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
  598. + handler->PSendSysMessage("Relog to change faction of your character.");
  599. + return true;
  600. + }
  601. +
  602. + static bool HandleCustomizeCommand(ChatHandler* handler, const char* args)
  603. + {
  604. + Player* player = handler->GetSession()->GetPlayer();
  605. + player->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
  606. + handler->PSendSysMessage("Relog to customize your character.");
  607. + return true;
  608. + }
  609. +
  610. + static bool HandleHomeCommand(ChatHandler* handler, const char* args)
  611. + {
  612. +
  613. + Player* player = handler->GetSession()->GetPlayer();
  614. +
  615. + auto team_id = player->GetTeamId();
  616. +
  617. + if (player->IsInCombat())
  618. + {
  619. + handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  620. + handler->SetSentErrorMessage(true);
  621. + return false;
  622. + }
  623. +
  624. + // stop flight if need
  625. + if (player->IsInFlight())
  626. + {
  627. + player->GetMotionMaster()->MovementExpired();
  628. + player->CleanupAfterTaxiFlight();
  629. + }
  630. + // save only in non-flight case
  631. + else
  632. + player->SaveRecallPosition();
  633. +
  634. + player->TeleportTo(HOME[team_id].map_id, HOME[team_id].x, HOME[team_id].y, HOME[team_id].z, HOME[team_id].o);
  635. + return true;
  636. + }
  637. +
  638. + static bool HandleRepairCommand(ChatHandler* handler, const char* args)
  639. + {
  640. + Player* player = handler->GetSession()->GetPlayer();
  641. +
  642. + if (!player->HasItemCount(VIP_COIN_ID, 1, false))
  643. + {
  644. + handler->PSendSysMessage("You must have a %s to use this command.", VIP_COIN_NAME.c_str());
  645. + return false;
  646. + }
  647. +
  648. + if (player->HasItemCount(VIP_COIN_ID, 1, false))
  649. + {
  650. + player->DurabilityRepairAll(0, 0, false);
  651. + handler->PSendSysMessage("Done.");
  652. + return true;
  653. + }
  654. + return true;
  655. + }
  656. +
  657. + static bool HandleVipSetHearthstoneCommand(ChatHandler* handler, const char* args)
  658. + {
  659. +
  660. + Player* player = handler->GetSession()->GetPlayer();
  661. +
  662. + auto team_id = player->GetTeamId();
  663. +
  664. + if (player->IsInCombat())
  665. + {
  666. + handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  667. + handler->SetSentErrorMessage(true);
  668. + return false;
  669. + }
  670. +
  671. + // stop flight if need
  672. + if (player->IsInFlight())
  673. + {
  674. + player->GetMotionMaster()->MovementExpired();
  675. + player->CleanupAfterTaxiFlight();
  676. + }
  677. + // save only in non-flight case
  678. + else
  679. + player->SaveRecallPosition();
  680. +
  681. + VIP::SetHearthStone(player->GetGUID(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  682. + handler->PSendSysMessage("%s, your location has been stored.", player->GetName().c_str());
  683. + return true;
  684. + }
  685. +
  686. + static bool HandleHearthStoneCommand(ChatHandler* handler, const char* args)
  687. + {
  688. +
  689. + Player* player = handler->GetSession()->GetPlayer();
  690. +
  691. + uint32 guid = player->GetGUID();
  692. +
  693. + if (player->IsInCombat())
  694. + {
  695. + handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  696. + handler->SetSentErrorMessage(true);
  697. + return false;
  698. + }
  699. +
  700. + // stop flight if need
  701. + if (player->IsInFlight())
  702. + {
  703. + player->GetMotionMaster()->MovementExpired();
  704. + player->CleanupAfterTaxiFlight();
  705. + }
  706. +
  707. + if (HearthStone[guid].guid != guid)
  708. + {
  709. + WorldDatabase.PExecute("REPLACE INTO hearthstone SET `guid`='%u';", guid);
  710. +
  711. + VIP::SetHearthStone(guid, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  712. +
  713. + handler->PSendSysMessage("You must store a location first to be able to use this command.");
  714. + handler->PSendSysMessage("Default location is your current location.");
  715. + return false;
  716. + }
  717. +
  718. + if (HearthStone[guid].guid == guid)
  719. + {
  720. + // save only in non-flight case and a location is stored
  721. + player->SaveRecallPosition();
  722. +
  723. + player->TeleportTo(HearthStone[guid].map_id, HearthStone[guid].x, HearthStone[guid].y, HearthStone[guid].z, HearthStone[guid].o);
  724. + return true;
  725. + }
  726. + return true;
  727. + }
  728. +};
  729. +
  730. +class VIP_Coin_Script : public ItemScript
  731. +{
  732. +public: VIP_Coin_Script() : ItemScript("VIP_Coin_Script"){ };
  733. +
  734. +
  735. + virtual bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
  736. + {
  737. + uint32 acct_id = player->GetSession()->GetAccountId();
  738. + uint8 pVip = VIP::GetVIP(acct_id);
  739. + uint32 pMg = VIP::GetMG(acct_id);
  740. + uint32 pVotes = VIP::GetVOTES(acct_id);
  741. + std::string Votes_Required_Ann;
  742. + bool voting = VIP::GetVIPVOTE_ENABLE();
  743. +
  744. + ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str());
  745. + 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);
  746. + ChatHandler(player->GetSession()).PSendSysMessage("%sYou have %s%u %smg's", green.c_str(), white.c_str(), pMg, green.c_str());
  747. +
  748. + 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()); };
  749. + 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()); };
  750. +
  751. + 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());
  752. +
  753. + if (voting)
  754. + {
  755. + if (pVip < VIP_MAX)
  756. + {
  757. + uint32 Votes_Required = ((pVip + 1) * VIP_VOTE_COUNT) - pVotes;
  758. +
  759. + 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());
  760. +
  761. + ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str());
  762. +
  763. + return true;
  764. + }
  765. + }
  766. + ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str());
  767. + return true;
  768. + }
  769. +};
  770. +
  771. +void RemoveItem(uint32 id, Player* player)
  772. +{
  773. + player->DestroyItemCount(uint32(id), 1, true);
  774. +
  775. + ChatHandler(player->GetSession()).PSendSysMessage("%s+1 VIP.", green.c_str());
  776. +};
  777. +
  778. +class VIP_Stone_Script : public ItemScript
  779. +{
  780. +public: VIP_Stone_Script() : ItemScript("VIP_Stone_Script"){ };
  781. +
  782. +
  783. + virtual bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
  784. + {
  785. + uint32 acct_id = player->GetSession()->GetAccountId();
  786. + uint8 pVip = VIP::GetVIP(acct_id);
  787. + uint32 pMg = VIP::GetMG(acct_id);
  788. + uint32 pVotes = VIP::GetVOTES(acct_id);
  789. +
  790. + if (pVip >= VIP_MAX)
  791. + {
  792. + ChatHandler(player->GetSession()).PSendSysMessage("%sYou are allready the maximum VIP rank:%s%u.", red.c_str(), white.c_str(), VIP_MAX);
  793. +
  794. + }
  795. +
  796. + if (pVip < VIP_MAX)
  797. + {
  798. + VIP::SetVOTES(acct_id, pVotes + VIP_VOTE_COUNT); // must be first for the dead mans check
  799. +
  800. + VIP::SetVIP(acct_id, pVip + 1);
  801. +
  802. + RemoveItem(VIP_COIN_ID, player);
  803. +
  804. + return true;
  805. + }
  806. + return true;
  807. + }
  808. +};
  809. +
  810. +class VIP_MG_BANKER : public CreatureScript
  811. +{
  812. +public: VIP_MG_BANKER() : CreatureScript("VIP_MG_BANKER"){ }
  813. +
  814. + bool OnGossipHello(Player* player, Creature* creature)
  815. + {
  816. +
  817. + uint32 accountId = player->GetSession()->GetAccountId();
  818. + uint8 pVIP = VIP::GetVIP(accountId);
  819. + uint32 MG = VIP::GetMG(accountId);
  820. + uint32 itemId = VIP::GetVIPMGID();
  821. + uint32 pMg = player->GetItemCount(itemId);
  822. + uint32 pVotes = VIP::GetVOTES(accountId);
  823. + std::string itemName = sObjectMgr->GetItemTemplate(itemId)->Name1;
  824. + std::string currency_inBank;
  825. + std::string deposit_amt;
  826. +
  827. + if (pMg == 1){ deposit_amt = "Total:" + ConvertNumberToString(pMg) + " " + itemName; };
  828. + if (pMg == 0 || pMg > 1){ deposit_amt = "Total:" + ConvertNumberToString(pMg) + " " + itemName + "'s"; };
  829. +
  830. + std::string withdraw10 = "Withdraw 10 " + itemName + "'s. Fee:0 " + itemName + "'s.";
  831. + std::string withdraw100 = "Withdraw 100 " + itemName + "'s. Fee:1 " + itemName + ".";
  832. + std::string withdraw1000 = "Withdraw 1,000 " + itemName + "'s. Fee:10 " + itemName + "'s.";
  833. + std::string withdraw10000 = "Withdraw 10,000 " + itemName + "'s. Fee:100 " + itemName + "'s.";
  834. + std::string withdraw100000 = "Withdraw 100,000 " + itemName + "'s. Fee:1,000 " + itemName + "'s.";
  835. +
  836. + if (MG == 1)
  837. + currency_inBank = "Balance:" + ConvertNumberToString(MG) + " " + itemName;
  838. + else
  839. + {
  840. + currency_inBank = "Balance:" + ConvertNumberToString(MG) + " " + itemName + "'s.";
  841. + };
  842. +
  843. + std::string current_VOTES = "Votes:" + ConvertNumberToString(pVotes);
  844. + std::string current_VIP = "VIP:" + ConvertNumberToString(pVIP);
  845. +
  846. + if (pMg > 0)
  847. + {
  848. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  849. + player->ADD_GOSSIP_ITEM(10, "-Deposit-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  850. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  851. + player->ADD_GOSSIP_ITEM(10, "Deposit all my custom currency.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2001);
  852. + player->ADD_GOSSIP_ITEM(10, deposit_amt.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2001);
  853. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  854. + }
  855. +
  856. + if (MG >= 10)
  857. + {
  858. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  859. + player->ADD_GOSSIP_ITEM(10, "-WithDrawl-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  860. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  861. + player->ADD_GOSSIP_ITEM(10, withdraw10.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2002);
  862. +
  863. + if (MG >= 101){ player->ADD_GOSSIP_ITEM(10, withdraw100.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2003); };
  864. + if (MG >= 1010){ player->ADD_GOSSIP_ITEM(10, withdraw1000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2004); };
  865. + if (MG >= 10100){ player->ADD_GOSSIP_ITEM(10, withdraw10000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2005); };
  866. + if (MG >= 101000){ player->ADD_GOSSIP_ITEM(10, withdraw100000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2006); };
  867. + }
  868. +
  869. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  870. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  871. + player->ADD_GOSSIP_ITEM(10, "-Bank Balance-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  872. + player->ADD_GOSSIP_ITEM(10, currency_inBank.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  873. + player->ADD_GOSSIP_ITEM(10, current_VOTES.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  874. + player->ADD_GOSSIP_ITEM(10, current_VIP.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  875. + player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000);
  876. +
  877. + player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  878. +
  879. + return true;
  880. + };
  881. +
  882. + bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
  883. + {
  884. + TC_LOG_INFO("server.loading", "MG_BANKER::OnSelect :%u", actions);
  885. +
  886. + uint32 accountId = player->GetSession()->GetAccountId();
  887. + uint8 pVIP = VIP::GetVIP(accountId);
  888. + uint32 MG = VIP::GetMG(accountId);
  889. + uint32 itemId = VIP::GetVIPMGID();
  890. + uint32 pMg = player->GetItemCount(itemId);
  891. + uint32 pVotes = VIP::GetVOTES(accountId);
  892. +
  893. + switch (actions)
  894. + {
  895. + case GOSSIP_ACTION_INFO_DEF + 2000: // loopbacks
  896. +
  897. + player->PlayerTalkClass->ClearMenus();
  898. + player->CLOSE_GOSSIP_MENU();
  899. +
  900. + OnGossipHello(player, creature);
  901. + break;
  902. +
  903. + case GOSSIP_ACTION_INFO_DEF + 2001: // Deposit all
  904. +
  905. + player->DestroyItemCount(itemId, pMg, true);
  906. +
  907. + if (player->GetItemCount(itemId) == 0)
  908. + {
  909. + VIP::SetMG(accountId, MG + pMg);
  910. +
  911. + };
  912. +
  913. + player->PlayerTalkClass->ClearMenus();
  914. + player->CLOSE_GOSSIP_MENU();
  915. +
  916. + OnGossipHello(player, creature);
  917. + break;
  918. +
  919. + case GOSSIP_ACTION_INFO_DEF + 2002: // Withdraw 10
  920. +
  921. + player->PlayerTalkClass->ClearMenus();
  922. +
  923. + if (player->AddItem(itemId, 10))
  924. + {
  925. + VIP::SetMG(accountId, MG - 10);
  926. + player->CLOSE_GOSSIP_MENU();
  927. + }
  928. + break;
  929. +
  930. + case GOSSIP_ACTION_INFO_DEF + 2003: // Withdraw 100
  931. +
  932. + player->PlayerTalkClass->ClearMenus();
  933. +
  934. + if (player->AddItem(itemId, 100))
  935. + {
  936. + VIP::SetMG(accountId, MG - 101);
  937. + player->CLOSE_GOSSIP_MENU();
  938. + }
  939. +
  940. + OnGossipHello(player, creature);
  941. + break;
  942. +
  943. + case GOSSIP_ACTION_INFO_DEF + 2004: // Withdraw 1,000
  944. + player->PlayerTalkClass->ClearMenus();
  945. +
  946. + if (player->AddItem(itemId, 1000))
  947. + {
  948. + VIP::SetMG(accountId, MG - 1010);
  949. + player->CLOSE_GOSSIP_MENU();
  950. + }
  951. +
  952. + OnGossipHello(player, creature);
  953. + break;
  954. +
  955. + case GOSSIP_ACTION_INFO_DEF + 2005: // Withdraw 10,000
  956. + player->PlayerTalkClass->ClearMenus();
  957. +
  958. + if (player->AddItem(itemId, 10000))
  959. + {
  960. + VIP::SetMG(accountId, MG - 10100);
  961. + player->CLOSE_GOSSIP_MENU();
  962. + }
  963. +
  964. + OnGossipHello(player, creature);
  965. + break;
  966. +
  967. + case GOSSIP_ACTION_INFO_DEF + 2006: // Withdraw 100,000
  968. + player->PlayerTalkClass->ClearMenus();
  969. +
  970. + if (player->AddItem(itemId, 100000))
  971. + {
  972. + VIP::SetMG(accountId, MG - 101000);
  973. + player->CLOSE_GOSSIP_MENU();
  974. + }
  975. +
  976. + OnGossipHello(player, creature);
  977. + break;
  978. + }
  979. + return true;
  980. + };
  981. +};
  982. +
  983. +void AddSC_Grumboz_VIP_Core()
  984. +{
  985. + new VIP_Load_Conf;
  986. + new Grumboz_VIP_Account_Engine;
  987. + new Grumboz_VIP_Player_Engine;
  988. + new VIP_commands;
  989. + new VIP_Coin_Script;
  990. + new VIP_Stone_Script;
  991. + new VIP_MG_BANKER;
  992. +}
  993. diff --git a/src/server/game/Entities/Player/Grumboz_VIP_Core.h b/src/server/game/Entities/Player/Grumboz_VIP_Core.h
  994. new file mode 100644
  995. index 0000000..41d784a
  996. --- /dev/null
  997. +++ b/src/server/game/Entities/Player/Grumboz_VIP_Core.h
  998. @@ -0,0 +1,82 @@
  999. +
  1000. +#ifndef GRUMBOZ_VIP_CORE_H
  1001. +#define GRUMBOZ_VIP_CORE_H
  1002. +
  1003. +struct VipElements
  1004. +{
  1005. + uint8 vip;
  1006. + uint32 mg;
  1007. + uint32 votes;
  1008. +};
  1009. +
  1010. +struct ItemVIP
  1011. +{
  1012. + uint32 item_id;
  1013. + uint8 vip;
  1014. +};
  1015. +
  1016. +struct VipMallGPS
  1017. +{
  1018. + uint32 map_id;
  1019. + float x;
  1020. + float y;
  1021. + float z;
  1022. + float o;
  1023. +};
  1024. +
  1025. +struct VipHomeGPS
  1026. +{
  1027. + uint32 map_id;
  1028. + float x;
  1029. + float y;
  1030. + float z;
  1031. + float o;
  1032. +};
  1033. +
  1034. +struct VipHearthStoneGPS
  1035. +{
  1036. + uint32 guid;
  1037. + uint32 map_id;
  1038. + float x;
  1039. + float y;
  1040. + float z;
  1041. + float o;
  1042. +};
  1043. +
  1044. +class VIP
  1045. +{
  1046. +
  1047. +public:
  1048. + VIP();
  1049. + ~VIP();
  1050. +
  1051. + // Getterz
  1052. + static uint8 GetVIPMAX();
  1053. + static bool GetVIPVOTE_ENABLE();
  1054. + static uint32 GetVIPVOTECOUNT();
  1055. + static uint32 GetVIPCOINID();
  1056. + static uint32 GetVIPSTONEID();
  1057. + static uint32 GetVIPMGID();
  1058. + static float GetVIPOFFSET();
  1059. + static uint8 GetTALENTBONUS();
  1060. + static bool GetLEVELBONUS_ENABLE();
  1061. + static uint8 GetLEVELBONUS();
  1062. +
  1063. + static uint8 GetItemVIP(uint32 item_id);
  1064. + static uint8 GetVIP(uint32 acct_id);
  1065. + static uint32 GetMG(uint32 acct_id);
  1066. + static uint32 GetVOTES(uint32 acct_id);
  1067. +
  1068. + // Setterz
  1069. + static void SetVIP(uint32 acct_id, uint8 pvip);
  1070. + static void SetMG(uint32 acct_id, uint32 pmg);
  1071. + static void SetVOTES(uint32 acct_id, uint32 pvotes);
  1072. + static void SetHearthStone(uint32 guid, uint32 map_id, float x, float y, float z, float o);
  1073. + static void SetItemVIP(uint32 item_id, uint8 item_vip);
  1074. +
  1075. +private:
  1076. + // tools
  1077. + void RemoveItem(uint32 id, Player* player);
  1078. +};
  1079. +
  1080. +#endif // GRUMBOZ_GUILD_WARZ_H_INCLUDED
  1081. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  1082. index c9db210..4308faf 100644
  1083. --- a/src/server/game/Entities/Player/Player.cpp
  1084. +++ b/src/server/game/Entities/Player/Player.cpp
  1085. @@ -44,6 +44,7 @@
  1086. #include "GridNotifiersImpl.h"
  1087. #include "Group.h"
  1088. #include "GroupMgr.h"
  1089. +#include "Grumboz_VIP_Core.h"
  1090. #include "Guild.h"
  1091. #include "GuildMgr.h"
  1092. #include "InstanceSaveMgr.h"
  1093. @@ -11146,7 +11147,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit
  1094. //////////////////////////////////////////////////////////////////////////
  1095. InventoryResult Player::CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, bool swap) const
  1096. {
  1097. - dest = 0;
  1098. + dest = 0;
  1099. Item* pItem = Item::CreateItem(item, 1, this);
  1100. if (pItem)
  1101. {
  1102. @@ -11160,7 +11161,18 @@ InventoryResult Player::CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, b
  1103.  
  1104. InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool swap, bool not_loading) const
  1105. {
  1106. - dest = 0;
  1107. + // item VIP level 0 or 1 = all players can equip.
  1108. + uint32 acctId = GetSession()->GetAccountId();
  1109. + uint8 Pvip = VIP::GetVIP(acctId);
  1110. + uint8 Ivip = VIP::GetItemVIP(pItem->GetEntry());
  1111. +
  1112. + if (Pvip < Ivip)
  1113. + {
  1114. + ChatHandler(GetSession()).PSendSysMessage("|cffFF0000You Must be VIP%u or higher to equip this item.|r", Ivip);
  1115. + return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
  1116. + }
  1117. +
  1118. + dest = 0;
  1119. if (pItem)
  1120. {
  1121. TC_LOG_DEBUG("entities.player.items", "Player::CanEquipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u",
  1122. diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
  1123. index 07ac1a2..c97bf19 100644
  1124. --- a/src/server/game/Scripting/ScriptLoader.cpp
  1125. +++ b/src/server/game/Scripting/ScriptLoader.cpp
  1126. @@ -32,6 +32,7 @@ void AddEventsScripts();
  1127. void AddPetScripts();
  1128. void AddOutdoorPvPScripts();
  1129. void AddCustomScripts();
  1130. +void AddSC_Grumboz_VIP_Core();
  1131. #endif
  1132.  
  1133. void AddScripts()
  1134. @@ -49,5 +50,6 @@ void AddScripts()
  1135. AddPetScripts();
  1136. AddOutdoorPvPScripts();
  1137. AddCustomScripts();
  1138. + AddSC_Grumboz_VIP_Core();
  1139. #endif
  1140. }
  1141. diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
  1142. index 12acc74..f3e47a8 100644
  1143. --- a/src/server/worldserver/worldserver.conf.dist
  1144. +++ b/src/server/worldserver/worldserver.conf.dist
  1145. @@ -3566,3 +3566,92 @@ PacketSpoof.BanDuration = 86400
  1146.  
  1147. #
  1148. ###################################################################################################
  1149. +
  1150. +###################################################################################################
  1151. +# Grumbo'z VIP System
  1152. +#
  1153. +# These settings provide a flexibility to the system.
  1154. +#
  1155. +#
  1156. +# VIP.MAX
  1157. +# Description: Max VIP Level for VIP System. max Uint32 value.
  1158. +# Default: 6
  1159. +#
  1160. +
  1161. +VIP.MAX = 6
  1162. +
  1163. +# VIP.OFFSET
  1164. +# Description: float multiplier for each vip rank.
  1165. +# this is used for stat mod's. i.e. mod = VIP rank * offset.
  1166. +# Default: 0.05f 5% muliplier used per VIP rank
  1167. +#
  1168. +
  1169. +VIP.OFFSET = 0.05
  1170. +
  1171. +# VIP.VOTE.ENABE
  1172. +# Description: Votes can earn higher vip ranks.
  1173. +# Default: 1 . 0 off // 1 on.
  1174. +#
  1175. +
  1176. +VIP.VOTE_ENABLE = 1
  1177. +
  1178. +#
  1179. +# VIP.VOTE.COUNT
  1180. +# Description: how many Votes to earn each level of VIP.
  1181. +# Default: 125 votes per.
  1182. +#
  1183. +
  1184. +VIP.VOTE_COUNT = 125
  1185. +
  1186. +#
  1187. +# VIP.COIN
  1188. +# Description: an item that is clickable to show a players VIP stats
  1189. +# Default: 63020
  1190. +#
  1191. +
  1192. +
  1193. +VIP.COIN = 63020
  1194. +
  1195. +#
  1196. +# VIP.STONE
  1197. +# Description: an item that is clickable and will increase a players VIP level.
  1198. +# Default: 63021
  1199. +#
  1200. +
  1201. +VIP.STONE = 63021
  1202. +
  1203. +#
  1204. +# VIP.MAGIC.GOLD
  1205. +# Description: just Global custom currency id that can be accessed
  1206. +# by another character via the VIP banker deposit/withdrawal
  1207. +# Default: 44209
  1208. +#
  1209. +
  1210. +VIP.MAGIC_GOLD = 44209
  1211. +
  1212. +#
  1213. +# VIP.TP.BONUS
  1214. +# Description: how many extra TP's to award per VIP level.
  1215. +# Default: 14 per VIP level.
  1216. +#
  1217. +
  1218. +VIP.TP_BONUS = 14
  1219. +
  1220. +# VIP.LEVEL_BONUS_ENABE
  1221. +# Description: players can reach higher levels per VIP..
  1222. +# Default: 1 . 0 off // 1 on.
  1223. +#
  1224. +
  1225. +VIP.LEVEL_BONUS_ENABLE = 1
  1226. +
  1227. +#
  1228. +#
  1229. +# VIP.LEVEL_BONUS
  1230. +# Description: how many extra level's a player can gain per VIP level.
  1231. +# Default: 1
  1232. +#
  1233. +
  1234. +VIP.LEVEL_BONUS = 1
  1235. +
  1236. +#
  1237. +###################################################################################################
Advertisement
Add Comment
Please, Sign In to add comment