Announcement

Collapse
No announcement yet.

Casino Minigames

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Casino Minigames

    I've put a casino in one of the castle towns in my game. I've read up on how to 'simulate' a random number generator for dice games but I'm not quite confident I can pull it off.

    So, lets take something like blackjack. How would I go about programming it? I can do some cool things with variables and know how they interact. But I still have trouble knowing where to begin programming something like that.

    If someone could post some example code of how you would get started on something like that, I'm confident I could take it from there.

    Thanks in advance if anyone decides to go through the trouble.

    #2
    Re: Casino Minigames

    Having done some complex minigame stuff myself (see "Hell's Dining Room"), the best advice I can give someone who asks this is "find another Maker". RM3 has its strengths but minigames with complex logic can be done so much easier in the other Makers, particularly the PC Makers.

    That being said, if you're gung-ho about doing it in 3, here's roughly how I'd set it up. There are two catches - one, the player can play even if they don't have enough money (you'd need a different currency than default gold if you wanted to do it differently). Two, the cards you get are random and don't take into account what's already been drawn, so it's like you're playing against a casino that uses 8+ decks and shuffles every few hands. In my system, I'm adding one more catch - the game does not immediately end if either player gets a blackjack. This could be done, but it would make things more complicated and I want to give you a relatively basic setup.

    You will need "random" variables for this to be an interesting game. RM3 does not actually have functions to randomly set variables, so the best way to do it is to have it change in unpredictable ways every time it's used, and even sometimes when it's not used. So for example if you want it to change between 1 (Ace) and 13 (King), have most events add an arbitrary amount between 1 and 13 to that variable, then have a conditional branch that says "If the value is 14 or more, subtract 13". Here, I'll use Shared Var 1 - 3 as your random variables.

    A couple other variables I'll use: Shared Var 4 tracks the player's total, Shared Var 5 tracks the house's total, and Shared Var 7 tracks the number of cards the player has taken (used in determining the flow of the game, and also because 21 on 2 cards gives a higher payout). Shared Var 6 doesn't exactly track anything in the game but we need it to judge who wins the game - you'll see in Mode 14.

    Mode 1 should require the player's interaction to get started ("Button", I think it's called). All the other modes can be Auto if you can get that to work (in theory it should work but sometimes RM3 handles it badly), or they can also be button (which requires the player to talk to the event a lot of times just to play one round of Blackjack, but it's more stable).

    Mode 1:
    Message: Welcome to Blackjack. Want to play?
    Choice Branch: Yes, No
    If Yes
    Subtract 50 gold from party
    Set Shared Var 4 to 0
    Set SV 5 to 0
    Set SV 6 to 0
    Set SV 7 to 0
    Go to Mode 2
    End
    If No
    Message: Alright, come back soon.
    End

    Mode 2:
    Val-Cond Branch: Shared Var 1
    If SV1 = 1
    Go to Mode 3
    End
    If SV 1 between 2 and 5
    Go to Mode 4
    End
    If SV 1 b/t 6 and 9
    Go to Mode 5
    End
    If SV 1 b/t 10 and 13
    Go to Mode 6
    End

    Mode 3:
    Message: "You drew an Ace."
    Add 11 to SV 4
    Add 1 to SV 6
    Val-Cond Branch: Shared Var 4
    If SV 4 > 21 (If the player would bust with 11...)
    Subtract 10 from SV 4
    End
    If SV 4 <= 21 (Don't do anything!)
    End
    End
    (Optionally, you could switch to a mode here that tells the player what the totals are. This is a good idea, but it also complicates things even further. So let's skip that for now.)
    Var-Cond Branch: Shared Var 7 (This determines the flow of the event based on the current situation.)
    If SV 4 = 21 (Judge if the player has 21; if so, switch to the dealer; otherwise, use the other logic below)
    Go to Mode 7
    End
    If SV 4 < 21
    If SV7 = 1
    Go to Mode 7 (which will deal the dealer a card)
    End
    If SV7 > 1
    Choice Branch: Hit, Stay
    If Hit
    Go to Mode 12 (which will re-randomize the variable, then deal the player another card)
    End
    If Stay
    Go to Mode 7 (which will allow the dealer to play out the hand)
    End
    End
    End

    Mode 4:

    If SV1 = 2
    Message: You drew a 2.
    Add 2 to SV 4
    End
    If SV1 = 3
    Message: You drew a 3.
    Add 3 to SV 4
    End
    If SV1 = 4
    Message: You drew a 4.
    Add 4 to SV4
    End
    If SV1 = 5
    Message: You drew a 5.
    Add 5 to SV4
    End
    If SV4 >= 22
    Message: "Sorry, you busted! Better luck next time."
    Go to Mode 15
    End
    If SV4 = 21
    Go to Mode 7
    End
    If SV4 < 20
    If SV7 = 1
    Go to Mode 7
    End
    If SV7 > 1
    Choice Branch: Hit, Stay
    If Hit
    Go to Mode 12
    End
    If Stay
    Go to Mode 7
    End
    End
    End

    Mode 5:

    If SV1 = 6
    Message: You drew a 6.
    Add 6 to SV 4
    End
    Do the same thing for 7, 8, and 9
    Var -Cond Branch: Shared Var 4
    Same as the last mode

    Mode 6:

    If SV1 = 10
    Message: You drew a 10.
    Add 10 to SV 4
    End
    If SV1 = 11
    Message: You drew a Jack.
    Add 10 to SV 4
    End
    Do the same thing for 12, and 13
    Var-Cond Branch: Shared Var 4
    Same as the last two modes

    Mode 7:
    Val-Cond Branch: Shared Var 2
    If SV2 = 1
    Go to Mode 8
    End
    If SV 2 between 2 and 5
    Go to Mode 9
    End
    If SV 2 b/t 6 and 9
    Go to Mode 10
    End
    If SV 2 b/t 10 and 13
    Go to Mode 11
    End

    Mode 8:
    Message: The house drew an Ace.
    Add 11 to SV 5
    Add 1 to SV 6
    Val-Cond Branch: Shared Var 5
    If SV 5 > 21 (If the dealer would bust with 11...)
    Subtract 10 from SV 5
    End
    If SV 5 <= 21 (Don't do anything!)
    End
    End
    (Optionally, you could switch to a mode here that tells the player what the totals are.)
    Var-Cond Branch: Shared Var 7 (This determines the flow of the event based on the current situation.)
    If SV7 = 1
    Go to Mode 12 (Explanation: We're still in the dealing phase if the number of cards in the player's hand is 1, so return to the player and give them their second card. But first, hit Mode 12 to re-randomize the value of Shared Var 1)
    End
    If SV7 > 1
    Var-Cond Branch: SV5
    If SV5 < 17 (Dealer hits on less than 17)
    Go to Mode 13 (This re-randomizes the variable and deals the House another card)
    End
    If SV 5 >= 17
    Go to Mode 14 (This judges the winner of the game. It'll also work if the dealer has gone bust, since over 21 is still over 17.)
    End
    End

    Mode 9:

    If SV2 = 2
    Message: The House drew a 2.
    Add 2 to SV 5
    End
    If SV2 = 3
    Message: The House drew a 3.
    Add 3 to SV 5
    End
    Do the same for 4 and 5
    Var-Cond Branch: Shared Var 7 (This determines the flow of the event based on the current situation.)
    If SV7 = 1
    Go to Mode 12
    End
    If SV7 > 1
    Var-Cond Branch: SV5
    If SV5 < 17 (Dealer hits on less than 17)
    Go to Mode 13
    End
    If SV 5 >= 17
    Go to Mode 14
    End
    End

    Mode 10:
    Do the same as Mode 9 for values 6-9.

    Mode 11:
    Do the same as Mode 9 for values 10-J-Q-K.

    Mode 12:
    Add 7 to Shared Var 1.
    Val-Cond Branch: SV1
    If SV 1 > 14
    Subtract 13 from SV1
    End
    If SV1 <= 13
    (Do nothing!)
    End
    Val-Cond Branch: SV2 (Explanation: What we're about to do is change the value of SV1 based on SV2, and then SV3. The reason for this is so we don't have an easy pattern like the card the player draws increasing by 7 every time.)
    If SV 2 <= 4
    Add 4 to Shared Var 1
    End
    If SV 2 between 5 and 8
    Add 9 to SV1
    End
    If SV 2 >= 9
    Add 1 to SV1
    End
    Val-Cond Branch: SV1
    If SV 1 > 14
    Subtract 13 from SV1
    End
    If SV1 <= 13
    (Do nothing!)
    End
    Val-Cond Branch: SV3
    Do something similar to what you just did, so that SV1 changes based on SV3's value. Then, preferably, do something to change SV3's value.
    Go to Mode 2

    Mode 13: (This is just like Mode 12, but works on SV2, for when we're about to deal the House a card.)
    Add 4 to Shared Var 2.
    Val-Cond Branch: SV2
    If SV 2 > 14
    Subtract 13 from SV2
    End
    If SV2 <= 13
    (Do nothing!)
    End
    Val-Cond Branch: SV2
    If SV 1 <= 5
    Add 9 to Shared Var 1
    End
    If SV 2 between 6 and 10
    Add 2 to SV1
    End
    If SV 2 >= 11
    Add 12 to SV1
    End
    Val-Cond Branch: SV2
    If SV 2 > 14
    Subtract 13 from SV2
    End
    If SV2 <= 13
    (Do nothing!)
    End
    Val-Cond Branch: SV2
    Do something similar to what you just did, so that SV2 changes based on SV3's value. Then, preferably, do something to change SV3's value.
    Go to Mode 7
    Mode 14: (This mode judges whether the player has won. Since we can't directly compare 2 variables, the way around this is to set SV6 to 100, add the player's score, and subtract the dealer's score. If it's greater than 100, you've won! But first, we want to make sure the dealer hasn't busted.)
    Val-Cond Branch: SV5 (The dealer's score)
    If SV5 >= 22
    Message: The dealer busted. You have won!
    Raise party's gold by 100
    End
    If SV5 <= 21
    Set SV6 equal to 0
    Add the value of SV4 to SV9
    Subtract the value of SV5 from SV6
    Val-Cond Branch: SV6
    If SV6 > 100
    If SV4 = 21
    If SV7 = 2
    Message: Nice Blackjack! You get paid 3 to 2.
    Raise party's gold by 125
    End
    If SV7 > 2
    Message: Your score beat the dealer's. You have won!
    Raise party's gold by 100
    End
    If SV4 < 21
    Message: Your score beat the dealer's. You have won!
    Raise party's gold by 100
    End
    End
    If SV6 = 100
    Message: It's a push! You get your money back.
    Raise party's gold by 50
    End
    If SV6 < 100
    Message: Sorry, the dealer beat you! Better luck next time.
    End
    Set Mode to 15

    Mode 15:
    Use this mode to re-randomize SV1, SV2, and SV3 one more time.
    Then set the Mode back to 1 so the player can play again.



    As you can see, lots of effort and lots of Data Usage just for this one little minigame. It's a cool feature and I'm sure people will be impressed that you pulled it off using RM3, but you have to weigh whether it will add enough to your game to make it worthwhile.

    If anyone finds any flaws with my logic/game progression above, please say so!


    How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

    "I live and love in God's peculiar light." - Michelangelo

    Comment


      #3
      Re: Casino Minigames

      That post was awesome, wavelength. Thanks for taking the time.

      I'm gonna give it a shot, using those guidelines. In terms of memory, what are we talking, like, 5-7% of the whole game for the complete blackjack setup?

      I was thinking you could create an item like "casino voucher" to get around the money problem. They'd be worth a set amount of gold that you could sell to shops, and you just bet and win those. That would only require some simple variable manipulation on top of everything else, unless I'm mistaken.

      I was looking into buying one of the PC makers but I've heard tell they don't work so well with the new Windows.

      Comment


        #4
        Re: Casino Minigames

        Originally posted by zg4real View Post
        That post was awesome, wavelength. Thanks for taking the time.

        I'm gonna give it a shot, using those guidelines. In terms of memory, what are we talking, like, 5-7% of the whole game for the complete blackjack setup?
        You're welcome! Glad you're going to give it a try. Hope you make it awesome. Yeah, I'd say 7% of the game's total memory would probably be a good estimate. Might be slightly higher. Certainly won't be like 30% or anything.

        I was thinking you could create an item like "casino voucher" to get around the money problem. They'd be worth a set amount of gold that you could sell to shops, and you just bet and win those. That would only require some simple variable manipulation on top of everything else, unless I'm mistaken.
        You can't check to see whether the player has a normal item, and I don't think you can stack more than one of a Key Item nor buy/sell Key Items in shops. Also, you can't adjust a variable based on whether an item is bought/sold in shops.

        So I don't think your idea will work exactly as you're thinking, but you're very close. What you could do is only have casino vouchers granted by events in the game (or even by random battles, via Obright's trick: you have the monster drop a treasure and have an Auto Event that activates if you hold that treasure, and takes away that treasure but increases your Voucher variable), and track them by variables... and then have the player spend one voucher (again tracked by variable) and gain two if they win (or three if they hit Blackjack). You don't have any vouchers, you can't play.

        Then, you could have a custom "cashier" type of event in the casino, where the player can sell vouchers in return for gold or other items (via eventing, not regular shop processing). The one thing you couldn't really do without a full custom currency system would be to make vouchers buyable.

        I was looking into buying one of the PC makers but I've heard tell they don't work so well with the new Windows.
        I've heard a few similar things as well but I think most people have had a good experience with it: see here. You could always try the free 30-day demo of the PC Maker of your choice (I recommend VX Ace or XP) to see whether it works correctly before buying it outright.

        It's a good platform for this type of thing because (depsite the large number of event commands you'd need) you can do it quickly (probably about five times as quickly as with RM3), and it doesn't come with any of the same hang-ups (When I made a card-game I was able to smoothly have it pick from an actual set of 52, for example, instead of just picking randomly between 1 and 13). And if you have any art talent, you can draw pictures of the cards, import them into your game, and display them onscreen as the player plays the minigame.


        How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

        "I live and love in God's peculiar light." - Michelangelo

        Comment

        Working...
        X