/************************************************************** ************************************************************** **** **** **** Casino Slots by Nikola Sarcevic from Manga nation **** **** (manga.thedigitalrealities.com port 6969). If you **** **** find any bugs or loopholes in the code, contact me **** **** at fuck@servicememartha.com, you will receive full **** **** credit for finding the error and correcting it. I **** **** require the same respect, being the writer of this **** **** snippet, it is required that you leave a visible **** **** creditation somewhere on the MUD using this code, **** **** one stating that it was written by 'Nikola', no- **** **** thing more is required. Thank you for your time, **** **** enjoy. **** **** **** ************************************************************** **************************************************************/ //Note: If you like this, I have also written a craps game that // I may make available on Kyndig soon. /* HELP FILE! This the helpfile I wrote for casino slots, post this on your MUD with whatever altercations needed. The Casino Slots on Manga Nation have ten possible results in each roll: cherry, plum, grape, watermelon, orange, lemon, bar, double bar, triple bar, or seven. Getting three of the same results in a row(this counts diagonally, horizontally, or vertically) wins. The amount you win from that particular result depends on what it is, the result calcu- lations are as follows: CHERRY (any) (any) - Win 1/4 of what you bet(horizontally only). CHERRY CHERRY (any) - Win 1/2 of what you bet(horizontally only). CHERRY x3 - Win the amount you bet. PLUM x3 - Win double the amount you bet. GRAPE x3 - Win triple the amount you bet. WATERMELON x3 - Win the amount you bet x 4. ORANGE x3 - Win the amount you bet x 5. LEMON x3 - Win the amount you bet x 6. BAR x3 - Win the amount you bet x 7. 2BAR x3 - Win the amount you bet x 8. 3BAR x3 - Win the amount you bet x 9. SEVEN x3 - Win the amount you bet x 10. SEVEN x6 - Jackpot, varies(must be aligned diagonally, both ways making an 'X'). One of two arguments may be given when the slots command is entered into the prompt, the first one being play. Entering 'play' as an arg- with the amount you wish to bet as a second argument rolls the slots. You may bet 25, 50, 100, 200, 400, 800, or 1000(amounts in cents). Syntax: slot PLAY <amount> The second of the arguments is 'ascii'. This selection was added for players with odd fonts/clients. Toggling it 'off' will remove the ascii imaging surrounding the slots, leaving only the results to be seen. Syntax: slot ASCII <on/off> The Casino Slots can be located at the Vixion Casino in Neon-Genesis. (Casino Slots written by Nikola Sarcevic of Manga Nation) */ /* * You will need to define this following bits in either merc.h * or at the beginning of the file this code is being inserted in. * * #define OBJ_VNUM_SLOT (the vnum of the item you selected for the slot machine) * * This could also be done another way, you could make a 'slot' * item type that is settable in olc, I didn't write it this way * due to lack of obj_types remaining on Manga. If you do write * it this way, the code will need altered some, I'll leave that * altering up to you. * * You will also need to define one variable in merc.h, the * slascii variable. Under char_data, insert this line: * * sh_int slascii; * * Then in save.c you will need to insert code in two different * places. * * In void fwrite_char: * fprintf( fp, "SLAS %d\n",ch->slascii); * * And in void fread_char under case 'S': * KEY( "SLAS", ch->slascii, fread_number( fp )); * * That should take care of that variable. */ /* * This short function is for showing the result after it is * selected. */ void show_slot(CHAR_DATA *ch, int num) { switch(num) { case 1: send_to_char(" {Rcherry{X ",ch); break; case 2: send_to_char(" {mplum{X ",ch); break; case 3: send_to_char(" {Mgrape{X ",ch); break; case 4: send_to_char(" {Gwatermelon{X ",ch); break; case 5: send_to_char(" {yorange{X ",ch); break; case 6: send_to_char(" {Ylemon{X ",ch); break; case 7: send_to_char(" {Dbar{X ",ch); break; case 8: send_to_char(" {Y2{Dbar{X ",ch); break; case 9: send_to_char(" {R3{Dbar{X ",ch); break; case 10: send_to_char(" {Bseven{X ",ch); break; } return; } /* * Rolls the slots. */ int roll(void) { int num; num = number_range(1,10); return num; } /* * The two functions just written will need defined in * in either manga.h or at the top of the file the code * is being inserted into. Define them as shown: * * int roll args( ( void ) ); * int show_slot args( ( CHAR_DATA *ch, int num ) ); */ /* * The main function... prepare for confusion. */ void do_slot(CHAR_DATA *ch, char *argument) // - Nikola(manga.thedigitalrealities.com port: 6969) { OBJ_DATA *slot=NULL, *obj; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[MSL]; bool CanPlay = TRUE; bool winner = FALSE; int winnings=0, basebet=0, diff=0; int sa=0, sb=0, sc=0, sd=0, se=0, sf=0, sg=0, sh=0, si=0; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if(IS_NPC(ch)) { send_to_char("Mobs cannot gamble.\n\r",ch); return; } //Check the room for the object. for ( obj = object_list; obj != NULL; obj = obj->next ) { if(!obj->in_room) continue; if(obj->in_room != ch->in_room) continue; if(obj->pIndexData->vnum == OBJ_VNUM_SLOT) //Note: This is the only line of code that would { //need changed if you decided to make a 'slot' obj slot = obj; //type. break; } } if(slot == NULL) { send_to_char("There's no slot machine here.\n\r",ch); return; } if(arg1[0] == '\0') { send_to_char("Slot commands{W: <{XPLAY{W/{XASCII{W>{X\n\rFor more information see {W'{XHELP SLOTS{W'{X.\n\r",ch); return; } /* * I added this small bit right here for players with odd fonts or * strange MUD clients. Allows them to toggle the ascii imagine * on or off. */ if(!strcmp(arg1, "ascii")) { if(arg2[0] == '\0') { send_to_char("Syntax{W:{X SLOTS ASCII {W<{XON{W/{XOFF{W>{X\n\r",ch); return; } if(!strcmp(arg2, "on")) { if(ch->slascii <= 0) { send_to_char("{RSlot ascii is already turned {rON{R.{X\n\r",ch); return; } ch->slascii = 0; send_to_char("{WYou will now see slot ascii.{X\n\r",ch); } else if(!strcmp(arg2, "off")) { if(ch->slascii >= 1) { send_to_char("{RSlot ascii is already turned {rOFF{R.{X\n\r",ch); return; } ch->slascii = 1; send_to_char("{WYou will no longer see slot ascii.{X\n\r",ch); } else { send_to_char("Syntax{W:{X SLOT ASCII {W<{XON{W/{XOFF{W>{X\n\r",ch); return; } return; } //Now for the fun part. else if(!strcmp(arg1, "play")) { if(arg2[0] == '\0') { send_to_char("Syntax{W:{X SLOT PLAY {W<{XAMOUNT{W>{X\n\r",ch); return; } basebet = atoi(arg2); //I made it so that only certain amounts can be wagered, it would be //entirely possible to remove this and go with however much they want //to wager, however I added this to give the slots a touch of reality. switch(basebet) { case 25: case 50: case 100: case 200: case 400: case 800: case 1000: break; default: CanPlay = FALSE; break; } if(CanPlay == FALSE) { send_to_char("You may wager 25, 50, 100, 200, 400, 800, 1000.\n\r",ch); return; } //Check to see if the player has enough money and subtract it from //them. The way I wrote this, if they were to have, say... 1000 //dollars in silver, but have no gold and make a 10 gold bet, it will //subtract the amount from their silver rather than not let them play. //This also works oppositely, if they have 10 gold, but don't have //and silver and make a 25 silver bet, it will change 1 gold into //100 silver and subtract 25 from the silver. if(basebet < 100) { if(ch->silver < basebet) { if(ch->gold > 0) { ch->gold -= 1; ch->silver += 100; } else { send_to_char("You don't have that much money.\n\r",ch); return; } ch->silver -= basebet; } else { ch->silver -= basebet; } } else { if(ch->gold < basebet/100) { if((ch->gold + (ch->silver/100)) >= basebet/100) { diff = basebet - ch->gold; ch->silver -= diff * 100; ch->gold += diff / 100; } else { send_to_char("You don't have that much money.\n\r",ch); return; } ch->gold -= basebet/100; } else { ch->gold -= basebet/100; } } //On Manga, we changed 'gold' and 'silver' to 'dollars' and 'cents', //so you may need to change some of the messages. if(basebet < 100) { sprintf(buf,"You put %d cents into the slot machine and pull the handle.\n\r",basebet); send_to_char(buf,ch); } else if(basebet == 100) { send_to_char("You put 1 dollar into the slot machine and pull the handle.\n\r",ch); } else if(basebet > 100) { sprintf(buf,"You put %d dollars into the slot machine and pull the handle.\n\r",basebet/100); send_to_char(buf,ch); } act("$n puts some money in the slot machine and pulls the handle.",ch,NULL,NULL,TO_ROOM); //Roll the slots! sa = roll(); sb = roll(); sc = roll(); sd = roll(); se = roll(); sf = roll(); sg = roll(); sh = roll(); si = roll(); //The following section reveals the slots to the player. if(ch->slascii >= 1) { send_to_char("\n\r {R*{yC{YA{WS{wI{YN{yO {DSL{wO{WTS{R*{X\n\r\n\r",ch); send_to_char(" ",ch); show_slot(ch,sa); send_to_char(" ",ch); show_slot(ch,sb); send_to_char(" ",ch); show_slot(ch,sc); send_to_char("\n\r\n\r",ch); send_to_char(" ",ch); show_slot(ch,sd); send_to_char(" ",ch); show_slot(ch,se); send_to_char(" ",ch); show_slot(ch,sf); send_to_char("\n\r\n\r",ch); send_to_char(" ",ch); show_slot(ch,sg); send_to_char(" ",ch); show_slot(ch,sh); send_to_char(" ",ch); show_slot(ch,si); send_to_char("\n\r\n\r",ch); send_to_char(" {R*{yC{YA{WS{wI{YN{yO {DSL{wO{WTS{R*{X\n\r\n\r",ch); } else { send_to_char("\n\r{D||||||||||||||||||||||||||||||||||||||||||||{X\n\r{D|||||||||||||||{R*{yC{YA{WS{wI{YN{yO {DSL{wO{WTS{R*{D|||||||||||||||{X\n\r{D||||||||||||||||||||||||||||||||||||||||||||{X\n\r{D|| || || ||{X\n\r",ch); send_to_char("{D||{X",ch); show_slot(ch,sa); send_to_char("{D||{X",ch); show_slot(ch,sb); send_to_char("{D||{X",ch); show_slot(ch,sc); send_to_char("{D||{X",ch); send_to_char("\n\r{D|| || || ||{X\n\r{D||||||||||||||||||||||||||||||||||||||||||||{X\n\r{D|| || || ||{X\n\r",ch); send_to_char("{D||{X",ch); show_slot(ch,sd); send_to_char("{D||{X",ch); show_slot(ch,se); send_to_char("{D||{X",ch); show_slot(ch,sf); send_to_char("{D||{X",ch); send_to_char("\n\r{D|| || || ||{X\n\r{D||||||||||||||||||||||||||||||||||||||||||||{X\n\r{D|| || || ||{X\n\r",ch); send_to_char("{D||{X",ch); show_slot(ch,sg); send_to_char("{D||{X",ch); show_slot(ch,sh); send_to_char("{D||{X",ch); show_slot(ch,si); send_to_char("{D||{X",ch) send_to_char("\n\r{D|| || || ||{X\n\r{D||||||||||||||||||||||||||||||||||||||||||||{X\n\r{D|||||||||||||||{R*{yC{YA{WS{wI{YN{yO {DSL{wO{WTS{R*{D|||||||||||||||{X\n\r{D||||||||||||||||||||||||||||||||||||||||||||{X\n\r",ch); } //Decide whether or not they won. if(sa == 1 && sb != 1) { if(winner == FALSE) winner = TRUE; winnings += basebet/4; } else if(sa == 1 && sb == 1 && sc != 1) { if(winner == FALSE) winner = TRUE; winnings += basebet/2; } if(sd == 1 && se != 1) { if(winner == FALSE) winner = TRUE; winnings += basebet/4; } else if(sd == 1 && se == 1 && sf != 1) { if(winner == FALSE) winner = TRUE; winnings += basebet/2; } if(sg == 1 && sh != 1) { if(winner == FALSE) winner = TRUE; winnings += basebet/4; } else if(sg == 1 && sh == 1 && si != 1) { if(winner == FALSE) winner = TRUE; winnings += basebet/2; } if(sa == sb && sb == sc) { if(winner == FALSE) winner = TRUE; winnings += basebet * sb; } if(sd == se && se == sf) { if(winner == FALSE) winner = TRUE; winnings += basebet * se; } if(sg == sh && sh == si) { if(winner == FALSE) winner = TRUE; winnings += basebet * sh; } if(sa == se && se == si) { if(winner == FALSE) winner = TRUE; winnings += basebet * se; } if(sg == se && se == sc) { if(winner == FALSE) winner = TRUE; winnings += basebet * se; } if(sa == sd && sd == sg) { if(winner == FALSE) winner = TRUE; winnings += basebet * sd; } if(sb == se && se == sh) { if(winner == FALSE) winner = TRUE; winnings += basebet * se; } if(sc == sf && sf == si) { if(winner == FALSE) winner = TRUE; winnings += basebet * sf; } //This is the JACKPOT! It gives a special message and is therefore //separated from the regular winning check. I have never hit the //jackpot, so I don't really know if it works right. :-p if(sa == 10 && se == 10 && si == 10 && sg == 10 && sc == 10) { send_to_char("{WHoly shit!!! {RJACKPOT{W!!!{X",ch); //Potty word, if you're a pussy pg13 MUD you'll probably to change it. act("The red light on top of $n's slot machine illuminates and spins. {RJACKPOT{X!!!",ch,NULL,NULL,TO_ROOM); winnings += basebet * 50; winnings += number_range(0,500); if(winnings < 100) { sprintf(buf,"{WYou receive %d cents!{X\n\r",winnings); send_to_char(buf,ch); ch->silver += winnings; } else if(winnings == 100) { send_to_char("{WYou receive 1 dollar!{X\n\r",ch); ch->gold += 1; } else if(winnings > 100) { sprintf(buf,"{WYou receive %d dollars!{X\n\r",winnings/100); send_to_char(buf,ch); ch->gold += winnings/100; } } //Regular winner. else if(winner == TRUE) { send_to_char("{YYeeehaawww! A winner!{X\n\r",ch); act("$n's slot machine flashes and makes loud noises.",ch,NULL,NULL,TO_ROOM); if(winnings < 100) { sprintf(buf,"{WYou receive %d cents!{X\n\r",winnings); send_to_char(buf,ch); ch->silver += winnings; } else if(winnings == 100) { send_to_char("{WYou receive 1 dollar!{X\n\r",ch); ch->gold += 1; } else if(winnings > 100) { sprintf(buf,"{WYou receive %d dollars!{X\n\r",winnings/100); send_to_char(buf,ch); ch->gold += winnings/100; } } //Loser. :( else { send_to_char("{RAwe shit. No luck.{X\n\r",ch); //Another potty word. } return; } else { send_to_char("Slot commands{W: <{XPLAY{W/{XASCII{W>{X\n\rFor more information see {W'{XHELP SLOTS{W'{X.\n\r",ch); return; } return; }