[TUTORIAL] HIGHER/LOWER GAMBLING MACHINE

Posts

Pages: 1
This is a simple, but effective, type of gambling machine you can put into a Casino or Arcade. It works on the basis that the player recieves a number and then tries to guess if the next number will be higher or lower. It's rather simple, it just takes a large amount of copy/pasting of code due to the large number of conditional branches (fork conditions). This machine is set up so that the cost is 10 Gold and the reward is 20 Gold, if you want to change that then just edit the appropriate bits of text and Gold removal/addition.

---

First off, you're going to have to decide if you want the machine to include pictures or not. If you want it to include pictures, you'll have to make these first. If not, then wherever the code below mentions "Show Picture" just replace it with the equivalent "Show Message".

Second of all, you need two variables, one named "Random Number One" and one named "Random Number Two" (or something to that effect.)

Third of all, make a common event called "Higher/Lower Machine" and have it set to "Call Event". The code for this comes later...

Now make an event for the machine that is the "Same Level As Hero" and "Push Button" activated. Have it have the following code:


If Money > 10
Show Message: "Should I play the Higher/Lower machine? I'll win twice my money back..."
Show Choice: "Yes"/"No"
[Yes Case]
Call Event: Higher/Lower Machine
End Case
[No Case]
Show Message: "Maybe another time..."
End Case
Else Case
Show Message: "I don't have enough money to play the machine."
End Case

Now go to the Common Event "Higher/Lower Machine" and make it's code the following:


Change Money: $10 Remove
Show Message: "The numbers go from 1-12. Simply guess if the next number will be higher or lower!"
Change Variable: var[xxxx: Random Number One]: Set: Random (1 to 12)
Comment: NEW CYCLE STARTS HERE!
Comment: NEW CYCLE STARTS HERE!
Comment: NEW CYCLE STARTS HERE!
If var[xxxx: Random Number One] = 1 Then
Play Sound Effect: A Sound Effect That Sounds Like A Roulette Wheel
Show Picture: ID 1 = A Picture Of The Number One
Show Choice: "Higher"/"Lower"
[Higher Case]
Change Variable: var[xxxx: Random Number Two]: Set: Random (1 to 12)
If var[xxxx: Random Number Two] = 1 Then
Play Sound Effect: A Sound Effect That Sounds Like A Roulette Wheel
Show Picture: ID 1 = A Picture Of The Number One
If var[xxxx: Random Number Two] > var[xxxx: Random Number One]
Show Message: "You were correct! You won 20 Gold!"
Change Gold: $20 Add
Else
Show Message: "You were wrong! You lost 10 Gold!"
End Case
Comment: REPEAT THE ABOVE IF STATEMENT FOR EVERY OTHER POSSIBLE "SECOND" NUMBER.
Comment: I.E EVERY OTHER POSSIBLE OUTCOME FOR THE VARIBALE NAMED "RANDOM NUMBER TWO".
End Case
[Lower Case]
Change Variable: var[xxxx: Random Number Two]: Set: Random (1 to 12)
If var[xxxx: Random Number Two] = 1 Then
Play Sound Effect: A Sound Effect That Sounds Like A Roulette Wheel
Show Picture: ID 1 = A Picture Of The Number One
If var[xxxx: Random Number Two] < var[xxxx: Random Number One]
Show Message: "You were correct! You won 20 Gold!"
Change Gold: $20 Add
Else
Show Message: "You were wrong! You lost 10 Gold!"
End Case
Comment: REPEAT THE ABOVE IF STATEMENT FOR EVERY OTHER POSSIBLE "SECOND" NUMBER.
Comment: I.E EVERY OTHER POSSIBLE OUTCOME FOR THE VARIBALE NAMED "RANDOM NUMBER TWO".
End Case
End Case
Comment: REPEAT THE ABOVE, FROM WHERE THE COMMENT "NEW CYCLE STARTS HERE" IS, FOR EVERY POSSIBLE OUTCOME OF THE "FIRST" NUMBER.
Comment: I.E. EVERY OTHER POSSIBLE OUTCOME FOR THE VARIABLE NAMED "RANDOM NUMBER ONE".

As you can see, there is a lot of repetition needed for this to work and that means you have to be on your toes to make sure you don't screw up when you're copying and pasting things around. Still, this is a solid system that works well and will help give your bars/casinos a bit more diversity. Or so I would hope.

Credit appreciated if used, but I couldn't say I am fussed.
Sounds good. You should add it to the site if you haven't already.
I have. It is waiting to be accepted, I think.
You can avoid the copy/paste by using PicPointerPatch and then using the randomly generated numbers to use as file names. Or better yet, use DestinyPatch to set the rotation of a roulette wheel picture. Feasible for maybe 36 numbers with only one picture.
author=psy_wombats link=topic=2589.msg47947#msg47947 date=1228011679
You can avoid the copy/paste by using PicPointerPatch and then using the randomly generated numbers to use as file names. Or better yet, use DestinyPatch to set the rotation of a roulette wheel picture. Feasible for maybe 36 numbers with only one picture.

I don't use patches, but I'm sure those are both plausible ideas. Using patches runs the risk of breaking some of the other functionalities I like, I find. Or maybe I am just a traditionalist.
author=Fallen-Griever link=topic=2589.msg48894#msg48894 date=1228346391
author=psy_wombats link=topic=2589.msg47947#msg47947 date=1228011679
You can avoid the copy/paste by using PicPointerPatch and then using the randomly generated numbers to use as file names. Or better yet, use DestinyPatch to set the rotation of a roulette wheel picture. Feasible for maybe 36 numbers with only one picture.

I don't use patches, but I'm sure those are both plausible ideas. Using patches runs the risk of breaking some of the other functionalities I like, I find. Or maybe I am just a traditionalist.

No. My patches never have drawbacks.

EDIT: Oh, sorry, this topic is quite old. I haven't looked at the date after finding it by Google.
Pages: 1