Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* C++ Roulette for Trinity Core
- Made by Crumpets
- Idea and LUA version by Crash45
- Error checking and fixed up by Rochet2
- Modified by Rochet2:
- Added timer and changed rewards
- */
- #define WAITTIME 60 // seconds
- #define REWARD 60000 // item entry
- #define AMOUNT 5000 // amount of items
- class roulette_npc : public CreatureScript
- {
- public:
- roulette_npc() : CreatureScript("roulette_npc") { }
- bool OnGossipHello(Player * player, Creature * creature)
- {
- player->ADD_GOSSIP_ITEM(3, "I wish to play the game of luck!", GOSSIP_SENDER_MAIN, 1);
- player->ADD_GOSSIP_ITEM(1, "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 uiAction)
- {
- player->PlayerTalkClass->ClearMenus();
- if (uiAction == 1)
- {
- if(cooldowns.find(player->GetGUIDLow()) != cooldowns.end())
- {
- double diff = difftime(time(NULL), cooldowns[player->GetGUIDLow()]);
- if (diff < WAITTIME)
- {
- player->GetSession()->SendNotification("You need to wait %ul more seconds", diff);
- OnGossipHello(player, creature);
- return true;
- }
- }
- cooldowns[player->GetGUIDLow()] = time(NULL);
- switch (urand(1, 4))
- {
- case 1:
- player->CastSpell(player, 5);
- creature->MonsterSay("Hahahaha!", LANG_UNIVERSAL, NULL);
- player->PlayDirectSound(11965);
- break;
- case 2:
- creature->MonsterSay("You've won..", LANG_UNIVERSAL, NULL);
- GiveItemAmount(player, REWARD, AMOUNT);
- break;
- case 3:
- player->CastSpell(player, 27604);
- creature->MonsterYell("YOU ARE NOT PREPARED!", LANG_UNIVERSAL, NULL);
- player->PlayDirectSound(11466);
- break;
- case 4:
- creature->MonsterSay("Lets rock!", LANG_UNIVERSAL, NULL);
- player->PlayDirectSound(11803);
- break;
- }
- }
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- private:
- std::map<uint32, time_t> cooldowns;
- bool GiveItemAmount(Player * player, uint32 itemEntry, uint32 amount)
- {
- if (amount < 0)
- {
- player->DestroyItemCount(itemEntry, -amount, true, false);
- return true;
- }
- if (amount == 0)
- amount = 1;
- uint32 noSpaceForCount = 0;
- ItemPosCountVec dest;
- uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemEntry, amount, &noSpaceForCount);
- if (msg != EQUIP_ERR_OK)
- amount -= noSpaceForCount;
- if (amount == 0 || dest.empty())
- return false;
- Item* item = player->StoreNewItem(dest, itemEntry, true, Item::GenerateItemRandomPropertyId(60000));
- // player->SendNewItem(item, amount, true, false);
- return true;
- }
- };
- void AddSC_roulette_npc()
- {
- new roulette_npc();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement