SHOW:
|
|
- or go back to the newest paste.
| 1 | #include "ScriptMgr.h" | |
| 2 | #include "ScriptedCreature.h" | |
| 3 | #include "ScriptedGossip.h" | |
| 4 | #include "GameEventMgr.h" | |
| 5 | #include "Player.h" | |
| 6 | #include "WorldSession.h" | |
| 7 | #include <stdlib.h> | |
| 8 | ||
| 9 | // Colors | |
| 10 | #define TEXT_LIGHTBLUE "|cFF00FFFC" | |
| 11 | - | #define TEXT_LIGHTBLUE "|cFF00FFFC" |
| 11 | + | #define TEXT_RED "|cffA40000" |
| 12 | - | #define TEXT_RED "|cffA40000" |
| 12 | + | #define TEXT_GREEN "|cffABD473" |
| 13 | - | #define TEXT_GREEN "|cffABD473" |
| 13 | + | |
| 14 | static const int32 bets_in_gold[] = {
| |
| 15 | 100, | |
| 16 | 250, | |
| 17 | 500, | |
| 18 | - | GoldGambling() : CreatureScript("GoldGambling")
|
| 18 | + | 1000, |
| 19 | - | {
|
| 19 | + | |
| 20 | ||
| 21 | - | } |
| 21 | + | |
| 22 | - | bool OnGossipHello(Player* player, Creature* creature) |
| 22 | + | |
| 23 | - | {
|
| 23 | + | |
| 24 | - | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, TEXT_LIGHTBLUE"I want to gamble!!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); |
| 24 | + | GoldGambling() : CreatureScript("GoldGambling")
|
| 25 | - | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, TEXT_RED"Nevermind..", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); |
| 25 | + | {
|
| 26 | - | player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID()); |
| 26 | + | } |
| 27 | - | return true; |
| 27 | + | |
| 28 | - | } |
| 28 | + | bool OnGossipHello(Player* player, Creature* creature) override |
| 29 | {
| |
| 30 | for (auto gold : bets_in_gold) | |
| 31 | - | bool OnGossipSelect(Player* player, Creature * creature, uint32 Sender, uint32 action) |
| 31 | + | player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, TEXT_LIGHTBLUE "-> Gamble " TEXT_RED + std::to_string(gold) + " GOLD", GOSSIP_SENDER_MAIN, gold, "", gold*GOLD, false); |
| 32 | - | {
|
| 32 | + | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, TEXT_RED "Nevermind..", GOSSIP_SENDER_MAIN, 0); |
| 33 | - | player->PlayerTalkClass->ClearMenus(); |
| 33 | + | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); |
| 34 | - | if (Sender == GOSSIP_SENDER_MAIN) |
| 34 | + | return true; |
| 35 | - | switch (action) |
| 35 | + | } |
| 36 | - | {
|
| 36 | + | |
| 37 | - | case GOSSIP_ACTION_INFO_DEF + 1: |
| 37 | + | |
| 38 | - | if (player->GetMoney() > 1000000) |
| 38 | + | bool OnGossipSelect(Player* player, Creature * creature, uint32 sender, uint32 bet) override |
| 39 | {
| |
| 40 | - | {
|
| 40 | + | player->PlayerTalkClass->ClearMenus(); |
| 41 | - | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, TEXT_LIGHTBLUE "-> Gamble " TEXT_RED "100 GOLD", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); |
| 41 | + | if (sender != GOSSIP_SENDER_MAIN) |
| 42 | - | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); |
| 42 | + | return false; |
| 43 | - | if (player->GetMoney() > 2500000) |
| 43 | + | |
| 44 | - | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, TEXT_LIGHTBLUE "-> Gamble " TEXT_RED "250 GOLD", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); |
| 44 | + | if (bet == 0) |
| 45 | - | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); |
| 45 | + | {
|
| 46 | - | if (player->GetMoney() > 5000000) |
| 46 | + | player->PlayerTalkClass->SendCloseGossip(); |
| 47 | - | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, TEXT_LIGHTBLUE "-> Gamble " TEXT_RED "500 GOLD", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); |
| 47 | + | return true; |
| 48 | - | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); |
| 48 | + | } |
| 49 | ||
| 50 | - | if (player->GetMoney() > 10000000) |
| 50 | + | int32 copper = bet*GOLD; |
| 51 | - | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, TEXT_LIGHTBLUE "-> Gamble " TEXT_RED "1000 GOLD", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); |
| 51 | + | |
| 52 | - | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); |
| 52 | + | if (!player->HasEnoughMoney(copper)) |
| 53 | - | return true; |
| 53 | + | {
|
| 54 | - | } |
| 54 | + | player->GetSession()->SendNotification("Not enough money");
|
| 55 | - | |
| 55 | + | OnGossipHello(player, creature); |
| 56 | - | else |
| 56 | + | return true; |
| 57 | - | {
|
| 57 | + | } |
| 58 | - | creature->Whisper(TEXT_RED"Sorry you do not have the required gold to play!", LANG_UNIVERSAL, player); |
| 58 | + | |
| 59 | - | player->PlayerTalkClass->SendCloseGossip(); |
| 59 | + | uint32 number = urand(1, 10); // 1/10 = 10% chance |
| 60 | - | return true; |
| 60 | + | if (number == 2) |
| 61 | - | } |
| 61 | + | {
|
| 62 | - | case GOSSIP_ACTION_INFO_DEF + 2: |
| 62 | + | player->ModifyMoney(copper); |
| 63 | - | {
|
| 63 | + | creature->Whisper(TEXT_LIGHTBLUE "CONGRATZ YOU WON!! " TEXT_GREEN + std::to_string(bet) + " GOLD", LANG_UNIVERSAL, player); |
| 64 | - | player->PlayerTalkClass->SendCloseGossip(); |
| 64 | + | } |
| 65 | - | return true; |
| 65 | + | else |
| 66 | - | } |
| 66 | + | {
|
| 67 | - | case GOSSIP_ACTION_INFO_DEF + 6: |
| 67 | + | player->ModifyMoney(-copper); |
| 68 | - | {
|
| 68 | + | creature->Whisper(TEXT_LIGHTBLUE "I'm sorry but you lost! :(" TEXT_RED + std::to_string(bet) + " GOLD", LANG_UNIVERSAL, player);
|
| 69 | - | if (player->GetMoney() > 1999999) |
| 69 | + | } |
| 70 | - | {
|
| 70 | + | |
| 71 | - | player->ModifyMoney(-1000000); |
| 71 | + | OnGossipHello(player, creature); |
| 72 | - | uint32 number = urand(0, 10); |
| 72 | + | return true; |
| 73 | - | if (number == 2) |
| 73 | + | } |
| 74 | - | {
|
| 74 | + | |
| 75 | - | player->ModifyMoney(2000000); |
| 75 | + | |
| 76 | - | creature->Whisper(TEXT_LIGHTBLUE"CONGRATZ YOU WON!! " TEXT_GREEN "200 GOLD", LANG_UNIVERSAL, player); |
| 76 | + | |
| 77 | - | player->PlayerTalkClass->SendCloseGossip(); |
| 77 | + | |
| 78 | - | return true; |
| 78 | + | new GoldGambling(); |
| 79 | } |