diff options
author | Jesusaves <cpntb1@ymail.com> | 2024-07-29 14:06:39 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2024-07-29 14:06:39 -0300 |
commit | e16584406b84997e73a2747fabcf27d963216109 (patch) | |
tree | 3d4c031a8fe70220d49352a4beb8d027034ca405 | |
parent | aa7af7930d43823b306648495fd9e812f2daac12 (diff) | |
download | serverdata-e16584406b84997e73a2747fabcf27d963216109.tar.gz serverdata-e16584406b84997e73a2747fabcf27d963216109.tar.bz2 serverdata-e16584406b84997e73a2747fabcf27d963216109.tar.xz serverdata-e16584406b84997e73a2747fabcf27d963216109.zip |
Black Jack game, reward is [Beard]
-rw-r--r-- | npc/003-9/gambler.txt | 125 | ||||
-rw-r--r-- | npc/functions/main.txt | 6 |
2 files changed, 131 insertions, 0 deletions
diff --git a/npc/003-9/gambler.txt b/npc/003-9/gambler.txt index eacbc778c..c68d32438 100644 --- a/npc/003-9/gambler.txt +++ b/npc/003-9/gambler.txt @@ -52,3 +52,128 @@ OnInit: 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."); + 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); + 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; +} + diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 043b92d99..6cc49229c 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -65,6 +65,12 @@ function script mesq { return; } +function script img { + //return "~~~graphics/images/" + getarg(0)+ ".png~"; // Does NOT work in M+ + mes "~~~graphics/images/" + getarg(0)+ ".png~"; + return; +} + function script g { return Sex == 0 ? getarg(0) : getarg(1); } |