大概就是这个图的意思了~~~通过NPC来实现。。应该是非常有趣的一种设置了!增加单机中的趣味
然后我们来看看代码
class gamble_npc : public CreatureScript
{
public:
gamble_npc() : CreatureScript("gamble_npc") { }
std::string colorstring(uint16 type)
{
switch(type)
{
default:
return false;
case 2:
return "black";
case 3:
return "red";
case 4:
return "green";
}
}
int GenerateNumberMessage(uint32 numbervalue)
{
uint32 black[18] = {2, 28, 26, 11, 20, 17, 22, 15, 24, 13, 10, 29, 8, 31, 6, 33, 4, 35};
uint32 red[18] = {9, 30, 7, 32, 5, 34, 3, 36, 1, 27, 25, 12, 19, 18, 21, 16, 23, 14};
uint32 green[2] = {0, 00};
for(uint16 i = 0; i < 18; i++)
{
if (numbervalue == black)
return 2;
else
if (numbervalue == red)
return 3;
else
if (numbervalue == 37 || 0)
return 4;
}
}
bool OnGossipHello(Player * player, Creature * creature)
{
player->ADD_GOSSIP_ITEM(3, "I want to play Roulette!", GOSSIP_SENDER_MAIN, 1337);
player->ADD_GOSSIP_ITEM(3, "How does this Game work?", GOSSIP_SENDER_MAIN, 999);
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 == 1337)
{
player->ADD_GOSSIP_ITEM(3, "I want to bet on a number.", GOSSIP_SENDER_MAIN,997);
player->ADD_GOSSIP_ITEM(3, "I want to bet on a color.", GOSSIP_SENDER_MAIN, 996);
player->ADD_GOSSIP_ITEM(3, "I want to bet on a number set.", GOSSIP_SENDER_MAIN, 995);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
if(uiAction == 997)
{
player->ADD_GOSSIP_ITEM(3, "Stats for this table: Odds 35:1 (1-36, 0, and 00) Payout: x35", GOSSIP_SENDER_MAIN, 997);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 0.", GOSSIP_SENDER_MAIN, 0, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 1.", GOSSIP_SENDER_MAIN, 1, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 2.", GOSSIP_SENDER_MAIN, 2, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 3.", GOSSIP_SENDER_MAIN, 3, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 4.", GOSSIP_SENDER_MAIN, 4, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 5.", GOSSIP_SENDER_MAIN, 5, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 6.", GOSSIP_SENDER_MAIN, 6, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 7.", GOSSIP_SENDER_MAIN, 7, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 8.", GOSSIP_SENDER_MAIN, 8, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to bet on 9.", GOSSIP_SENDER_MAIN, 9, "How much gold do you want to bet?", 0, true);
player->ADD_GOSSIP_ITEM(3, "Next", GOSSIP_SENDER_MAIN, 1338);
player->ADD_GOSSIP_ITEM(3, "Back", GOSSIP_SENDER_MAIN, 1337);
这些是部分代码。。里面的菜单内容都还没有汉化过来。有兴趣的朋友可以试试。。
你首先得学会如何在Trinity里面加NPC脚本!!
完整的脚本代码:American Roulette完整的代码下载
|