Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "ScriptedCreature.h"
- #include "ScriptedGossip.h"
- #include "GameEventMgr.h"
- #include "Player.h"
- #include "WorldSession.h"
- #include <stdlib.h>
- // Colors
- #define TEXT_LIGHTBLUE "|cFF00FFFC"
- #define TEXT_RED "|cffA40000"
- #define TEXT_GREEN "|cffABD473"
- static const int32 bets_in_gold[] = {
- 100,
- 250,
- 500,
- 1000,
- };
- class GoldGambling : public CreatureScript
- {
- public:
- GoldGambling() : CreatureScript("GoldGambling")
- {
- }
- bool OnGossipHello(Player* player, Creature* creature) override
- {
- for (auto gold : bets_in_gold)
- 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);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, TEXT_RED "Nevermind..", GOSSIP_SENDER_MAIN, 0);
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature * creature, uint32 sender, uint32 bet) override
- {
- player->PlayerTalkClass->ClearMenus();
- if (sender != GOSSIP_SENDER_MAIN)
- return false;
- if (bet == 0)
- {
- player->PlayerTalkClass->SendCloseGossip();
- return true;
- }
- int32 copper = bet*GOLD;
- if (!player->HasEnoughMoney(copper))
- {
- player->GetSession()->SendNotification("Not enough money");
- OnGossipHello(player, creature);
- return true;
- }
- uint32 number = urand(1, 10); // 1/10 = 10% chance
- if (number == 2)
- {
- player->ModifyMoney(copper);
- creature->Whisper(TEXT_LIGHTBLUE "CONGRATZ YOU WON!! " TEXT_GREEN + std::to_string(bet) + " GOLD", LANG_UNIVERSAL, player);
- }
- else
- {
- player->ModifyMoney(-copper);
- creature->Whisper(TEXT_LIGHTBLUE "I'm sorry but you lost! :(" TEXT_RED + std::to_string(bet) + " GOLD", LANG_UNIVERSAL, player);
- }
- OnGossipHello(player, creature);
- return true;
- }
- };
- void addSC_GoldGambling()
- {
- new GoldGambling();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement