// TMW2 scripts. // Author: // Jesusalva // Description: // Tulimshar Inn Receptionist 003-9,42,123,0 script Gambler Master NPC_LOF_NOBLEMAN,{ mesn; mesq l("Hello! Welcome to the Inn! I am an Alliance officer, and I oversee gambling all over the world!"); next; mesn; mesq l("So how can I help you?"); do { next; select l("How does Gambling works?"), l("How can I obtain casino coins?"), l("Nothing, thanks."); mes ""; switch (@menu) { case 1: mesn; mesq l("You find a slot machine or another gambler, and make a bet!"); next; mesn; mesq l("If you're right, you'll gain more Casino Coins! And even other nice things!"); next; mesn; mesq l("But if you're wrong, you'll have to pay up! There's no refunds. This is gambling, if you lose you lose!"); next; mesn; mesq l("If you're afraid of losing everything, then DEFINITELY do not gamble. %%2"); break; case 2: mesn; mesq l("I dunno. I don't think they're sold anywhere."); next; mesn; mesq l("I know a few bandits stole a few, and Lava Slimes love to eat Casino Coins."); next; mesn; mesq l("I've even heard of people whom dug Casino Coins out of the ground, but as I said, I don't know. But you'll certainly come across a few o your adventures!"); break; } } while (@menu != 3); close; OnInit: .sex = G_MALE; .distance = 5; end; } 003-9,40,127,0 script Gambler#003-9 NPC_FLOPPED_NOBLEMAN,{ L_Menu: mesn; mesc l("Hey, do you want to play a game of Black Jack?"); mesc l("You need a @@ to play.", getitemlink(CasinoCoins)); mesc l("If a tie happens, I'll give your coin back."); next; menu rif(countitem(CasinoCoins) >= 1, l("Let's play!")), L_Spin, l("Information"), L_Info, l("Leave"), L_Close; L_Info: mes ""; mesc l("Rules:"); mesc l("A card will be drawn. "); mesc l("Each card is worth its own value. Note that \"A\"ce is always worth %s.", b(l("1 point"))); mesc l("And if a Valet (\"J\") is drawn, it'll be worth 11 points. This is different from regular Black Jack!"), 1; mes ""; mesc l("If you get a 21 you win the round. If you go over you lose. After you \"stand\", I'll make my own draws. If my value is bigger than yours, you lose as well."); next; mesc l("Prizes:"); mesc l("If you beat me, you get Experience and money!"); mesc l("If a tie happens, you'll get your coin back."); mes ""; mesc l("If you get a Black Jack (21), you'll get a %s!", getitemlink(Beard)); next; goto L_Menu; L_Spin: .@myScore = 0; .@aiScore = 0; delitem CasinoCoins, 1; goto L_PCLoop; L_PCLoop: .@card = rand2(1,11); .@myScore += .@card; img(sprintf("cards/card%s%d", any("Clubs", "Diamonds", "Hearts", "Spades"), .@card)); mesc l("Your Score: %d", .@myScore); if (.@myScore == 21) goto L_BlackJack; else if (.@myScore > 21) goto L_Busted; mes ""; select l("Hit"), l("Stand"); mes ""; if (@menu == 1) goto L_PCLoop; mes ""; mesc ".:: " + l("Dealer's Turn") + " ::.", 1; mes ""; next; clear; goto L_AILoop; L_AILoop: .@card = rand2(1,11); .@aiScore += .@card; img(sprintf("cards/card%s%d", any("Clubs", "Diamonds", "Hearts", "Spades"), .@card)); mesc l("Your Score: %d", .@myScore); mesc l("Dealer Score: %d", .@aiScore); if (.@aiScore == 21) goto L_Busted; else if (.@aiScore > 21) goto L_Victory; next; // Determine if AI will hit or stand // A good AI would never hit at 18+ when dealing first, // or would just always hit when .@aiScore < .@myScore // But I want it to be fun, not good. switch (.@aiScore) { case 20: .@rng = 0; break; case 19: .@rng = 1; break; case 18: .@rng = 10; break; case 17: .@rng = 25; break; case 16: .@rng = 35; break; case 15: .@rng = 45; break; case 14: .@rng = 55; break; case 13: .@rng = 70; break; case 12: .@rng = 80; break; case 11: .@rng = 95; break; default: .@rng = 100; break; } mes ""; if (rand2(100) < .@rng) goto L_AILoop; mes ""; mesc ".:: " + l("Tally") + " ::.", 1; mes ""; //next; if (.@aiScore > .@myScore) goto L_Busted; else if (.@myScore > .@aiScore) goto L_Victory; else goto L_Draw; L_BlackJack: getitem Beard, 1; mesc ".:: " + l("Blackjack!") + " ::.", 3; mesc l("You have won the match."); X24Event(X24_GROUP1, X24_G1_BLACKJACK); close; L_Busted: mesc ".:: " + l("Busted!") + " ::.", 1; mesc l("You have lost the match."); close; L_Victory: mesc ".:: " + l("Victory") + " ::.", 3; mesc l("You have won the match."); getexp 6 * BaseLevel * (1+REBIRTH), JobLevel * (1+REBIRTH); Zeny += rand2(45, 75); X24Event(X24_GROUP1, X24_G1_BLACKJACK); close; L_Draw: mesc ".:: " + l("Draw") + " ::.", 2; mesc l("No one won the match."); getitem CasinoCoins, 1; close; L_Close: closeclientdialog; close; OnInit: .sex = G_MALE; .distance = 5; end; } // Random NPC 003-9,42,130,0 script Gambling Fedja NPC_PLAYER,{ showavatar ""; mesn; //mesq l("To be honest, the roulette is clocked. And when the repair staff came, they said something about ...???"); mesq l("Do you want to play Roulette? Note that right now, due to gambling regulations, I'm not able to offer you all the bet options."); mes ""; tutmes l("A wheel with numbered from 0 to 36 will be spun, and you must bet on the result. The \"0\" almost always means you lose the bet. %s", "[@@https://www.deviantart.com/giromcalica/art/Roulette-Table-Transparent-447658369|table@@] [@@https://www.britannica.com/topic/roulette-gambling-game|info@@]"), l("Roulette"); if (!countitem(CasinoCoins)) close; next; L_Start: setskin ""; showavatar ""; .@bet=0; // how much you're betting .@wat=0; // what you're betting on. .@pay=0; // Payout you have earned clear; mesc l("How much you'll bet? You have %s Casino Coins.", fnum(countitem(CasinoCoins))); input .@bet, 0, min(1000, countitem(CasinoCoins)); if (.@bet < 1 || .@bet > countitem(CasinoCoins)) goto L_Quit; L_Select: mesc l("What do you want to bet on? Payout is noted, 1:1 will also give you %d gold per coin on bet.", 10); select rif(.@bet <= 500, l("Number (1->35)")), rif(is_staff(), l("Tuple (1->17)")), rif(is_staff(), l("Row (1->11)")), l("Corner (1->8)"), l("Group of 12 (1->2)"), l("Column (1->2)"), l("Odd/Even, Red/Black, Group of 18 (1->1)"); if (@menu == 1) { .@wat=input(l("Which number do you believe that will be choosen? (0-36)"), 0, 36); .@wat += 1; // Validation token } else if (@menu >= 5) { setskin "roulette_special"; select "first 12", "second 12", "third 12", "1 to 18", "19 to 36", "even", "odd", "red", "black", "column a", "column b", "column c"; .@wat = 99+@menu; } else if (@menu == 4) { setskin "roulette_corner"; select "012:023:1245:2356:4578:5689:781011:891112:10111314:11121415:13141617:14151718:16171920:17182021:19202223:20212324:22232526:23242627:25262829:26272930:28293132:29303233:31323435:32333536"; .@wat = 199 + @menu; } else { setskin "roulette_number"; } if (!.@wat) end; L_Spin: setskin ""; showavatar 1300; mesn; mes l("Press \"Roll\" when you're ready."); select l("Roll!"); freeloop(true); .@val=rand2(0,36); // Display the graph .@rolls=37*any(1,3)+.@val; for (.@i=0;.@i<.@rolls;.@i++) { .@cur=(.@i%37); showavatar 1301+.@cur; sleep2(10); } showavatar 1301+.@val; if (.@bet < 1 || .@bet > countitem(CasinoCoins)) end; delitem CasinoCoins, .@bet; // Note that "0" doesn't count toward pretty much anything mesn; .@c$ = (.@val % 2 ? l("Red") : l("Black")); if (!.@val) .@c$=l("Green"); mes l("You rolled a: %d %s", .roulette[.@val], .@c$); .@no = .roulette[.@val]; // The number rolled // Simple number guessing if (.@wat <= 37) .@pay += (.@no == (.@wat - 1) ? .@bet * 35 : 0); // Groups of numbers guessing switch (.@wat) { // .............. // .:: Special ::. // ................ case 100: // 1st twelve .@pay += (is_between(0, 12, .@no) ? .@bet*2 : 0); break; case 101: // 2nd twelve .@pay += (is_between(12, 24, .@no) ? .@bet*2 : 0); break; case 102: // 3rd twelve .@pay += (is_between(24, 36, .@no) ? .@bet*2 : 0); break; case 103: // 1 to 18 .@pay += (is_between(0, 18, .@no) ? .@bet : 0); break; case 104: // 19 to 36 .@pay += (is_between(18, 36, .@no) ? .@bet : 0); break; case 105: // even .@pay += ((!(.@no % 2) && .@val) ? .@bet : 0); break; case 106: // odd .@pay += ((.@no % 2) ? .@bet : 0); break; case 107: // red .@pay += ((.@val % 2) ? .@bet : 0); break; case 108: // black .@pay += ((!(.@val % 2) && .@val) ? .@bet : 0); break; case 109: // column A if (.@no == 1 || .@no == 4 || .@no == 7 || .@no == 10 || .@no == 13 || .@no == 16 || .@no == 19 || .@no == 22 || .@no == 25 || .@no == 28 || .@no == 31 || .@no == 34) .@pay += .@bet*2; break; case 110: // column B if (.@no == 2 || .@no == 5 || .@no == 8 || .@no == 11 || .@no == 14 || .@no == 17 || .@no == 20 || .@no == 23 || .@no == 26 || .@no == 29 || .@no == 32 || .@no == 35) .@pay += .@bet*2; break; case 111: // column C if (.@no == 3 || .@no == 6 || .@no == 9 || .@no == 12 || .@no == 15 || .@no == 18 || .@no == 21 || .@no == 24 || .@no == 27 || .@no == 30 || .@no == 33 || .@no == 36) .@pay += .@bet*2; break; // .............. // .:: Corners ::. // ................ case 200: // 012 if (.@no == 0 || .@no == 1 || .@no == 2) .@pay += .@bet * 8; break; case 201: // 023 if (.@no == 0 || .@no == 2 || .@no == 3) .@pay += .@bet * 8; break; case 202: // 1245 if (.@no == 1 || .@no == 2 || .@no == 4 || .@no == 5) .@pay += .@bet * 8; break; case 203: // 2356 if (.@no == 2 || .@no == 3 || .@no == 5 || .@no == 6) .@pay += .@bet * 8; break; case 204: // 4578 if (.@no == 4 || .@no == 5 || .@no == 7 || .@no == 8) .@pay += .@bet * 8; break; case 205: // 5689 if (.@no == 5 || .@no == 6 || .@no == 8 || .@no == 9) .@pay += .@bet * 8; break; case 206: // 781011 if (.@no == 7 || .@no == 8 || .@no == 10 || .@no == 11) .@pay += .@bet * 8; break; case 207: // 891112 if (.@no == 8 || .@no == 9 || .@no == 11 || .@no == 12) .@pay += .@bet * 8; break; case 208: // 10111314 if (.@no == 10 || .@no == 11 || .@no == 13 || .@no == 14) .@pay += .@bet * 8; break; case 209: // 11121415 if (.@no == 11 || .@no == 12 || .@no == 14 || .@no == 15) .@pay += .@bet * 8; break; case 210: // 13141617 if (.@no == 13 || .@no == 14 || .@no == 16 || .@no == 17) .@pay += .@bet * 8; break; case 211: // 14151718 if (.@no == 14 || .@no == 15 || .@no == 17 || .@no == 18) .@pay += .@bet * 8; break; case 212: // 16171920 if (.@no == 16 || .@no == 17 || .@no == 19 || .@no == 20) .@pay += .@bet * 8; break; case 213: // 17182021 if (.@no == 17 || .@no == 18 || .@no == 20 || .@no == 21) .@pay += .@bet * 8; break; case 214: // 19202223 if (.@no == 19 || .@no == 20 || .@no == 22 || .@no == 23) .@pay += .@bet * 8; break; case 215: // 20212324 if (.@no == 20 || .@no == 21 || .@no == 23 || .@no == 24) .@pay += .@bet * 8; break; case 216: // 22232526 if (.@no == 22 || .@no == 23 || .@no == 25 || .@no == 26) .@pay += .@bet * 8; break; case 217: // 23242627 if (.@no == 23 || .@no == 24 || .@no == 26 || .@no == 27) .@pay += .@bet * 8; break; case 218: // 25262829 if (.@no == 25 || .@no == 26 || .@no == 28 || .@no == 29) .@pay += .@bet * 8; break; case 219: // 26272930 if (.@no == 26 || .@no == 27 || .@no == 29 || .@no == 30) .@pay += .@bet * 8; break; case 220: // 28293132 if (.@no == 28 || .@no == 29 || .@no == 31 || .@no == 32) .@pay += .@bet * 8; break; case 221: // 29303233 if (.@no == 29 || .@no == 30 || .@no == 32 || .@no == 33) .@pay += .@bet * 8; break; case 222: // 31323435 if (.@no == 31 || .@no == 32 || .@no == 34 || .@no == 35) .@pay += .@bet * 8; break; case 223: // 32333536 if (.@no == 32 || .@no == 33 || .@no == 35 || .@no == 36) .@pay += .@bet * 8; break; } if (.@pay) { getitem CasinoCoins, .@pay; mesc l("Congratulations! You've earned %s coins for the %d you had bet.", fnum(.@pay), .@bet), 2; if (.@pay == .@bet) Zeny+=.@pay * 10; } .@pay = 0; mesc l("Do you want to bet again?"); menu rif(countitem(CasinoCoins) >= .@bet, l("Yes, please repeat my bet")), L_Spin, rif(countitem(CasinoCoins) >= .@bet, l("Yes, same amount something else")), L_Select, l("Yes, but some other amount."), L_Start, l("I'm cool, thanks!"), L_Quit; close; L_Quit: closeclientdialog; close; OnInit: setarray .roulette, 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26; .@npcId = getnpcid(.name$); setunitdata(.@npcId, UDT_HEADTOP, TopHat); setunitdata(.@npcId, UDT_HEADMIDDLE, GoldenLightPlatemail); setunitdata(.@npcId, UDT_HEADBOTTOM, RaidTrousers); .sex = G_MALE; .distance = 4; npcsit; end; }