LatiusAuro
The Lati Hybrid
- 8
- Posts
- 6
- Years
- Seen Dec 4, 2018
The Lucky Wheel mini-game is a variant of the Slot Machine game, which can have area varients included where each area has different icons for each value. Unlike most other Coin/BP games, it is possible to play this without any Coins/BP, using cash instead. You still only win Coins/BP regardless of what you spend to spin the wheel.
Version History:
To install:
1) Download the View attachment Lucky Wheel.zip and put the folder in your Pictures folder.
2) Add in the following script, preferably in or below the PMinigame area:
3) To play the mini-game, have an event have the script event pbLuckyWheel(x), where x is the area variable between 0 and 2. In the provided pack, 0 is Grass, 1 is Fire and 2 is Water.
Version History:
Spoiler:
V1.0
Original version. Only has a single reel odds selection and three different area variants.
Original version. Only has a single reel odds selection and three different area variants.
To install:
1) Download the View attachment Lucky Wheel.zip and put the folder in your Pictures folder.
2) Add in the following script, preferably in or below the PMinigame area:
Code:
################################################################################
# Lucky Wheel mini-game #
# Based on the Slot Machine mini-game made by Maruno #
# By LatiusAuro #
#------------------------------------------------------------------------------#
# Run with: pbLuckyWheel(0) #
# - The number determines which icons and score sheet to use #
################################################################################
class LuckyWheelReel < BitmapSprite
attr_accessor :reel
attr_accessor :toppos
attr_accessor :spinning
attr_accessor :stopping
attr_accessor :slipping
SCROLLSPEED = 16 # Must be a divisor of 48
ICONSPOOL = [0,1,1,1,1,1,1,1,1,2,2,2,2,2,3,3,3,4,4,5]
SLIPPING = [1,1,1,1,1,2,2,2,2,3,3,3,4,4,5]
def initialize(x,y,reeltype=0)
@viewport=Viewport.new(x,y,64,144)
@viewport.z=99999
super(64,144,@viewport)
@reel=[]
for i in 0...ICONSPOOL.length
@reel.push(ICONSPOOL[i])
end
@reel.shuffle! # Need to replace this with a shuffle which depends on the day,
# the day of the month and the reeltype value
@toppos=0
@spinning=false
@stopping=false
@slipping=0
@index=rand(@reel.length)
# Determine images and BG from reeltype.
# 0 is Grass, 1 is Fire, 2 is Water
@images=AnimatedBitmap.new(_INTL("Graphics/Pictures/Lucky Wheel/image{1}",reeltype))
@shading=AnimatedBitmap.new(_INTL("Graphics/Pictures/Lucky Wheel/ReelOverlay"))
update
end
def startSpinning
@spinning=true
end
def stopSpinning(noslipping=false)
@stopping=true
@slipping=SLIPPING[rand(SLIPPING.length)]
@slipping=0 if noslipping
end
def showing
array=[]
for i in 0...3
num=@index-i
[email protected] if num<0
array.push(@reel[num])
end
return array # [0] = top, [1] = middle, [2] = bottom
end
def update
self.bitmap.clear
if @toppos==0 && @stopping && @slipping==0
@spinning=@stopping=false
end
if @spinning
@toppos+=SCROLLSPEED
if @toppos>0
@toppos-=48
@index=(@index+1)%@reel.length
@slipping-=1 if @slipping>0
end
end
for i in 0...4
num=@index-i
[email protected] if num<0
self.bitmap.blt(0,@toppos+i*48,@images.bitmap,Rect.new(@reel[num]*64,0,64,48))
end
self.bitmap.blt(0,0,@shading.bitmap,Rect.new(0,0,64,144))
end
end
class LuckyWheelScore < BitmapSprite
attr_reader :score
def initialize(x,y,score=0)
@viewport=Viewport.new(x,y,84,22)
@viewport.z=99999
super(84,22,@viewport)
@numbers=AnimatedBitmap.new(_INTL("Graphics/Pictures/Lucky Wheel/numbers"))
self.score=score
end
def score=(value)
@score=value
@score=MAXCOINS if @score>MAXCOINS
refresh
end
def refresh
self.bitmap.clear
for i in 0...6
digit=(@score/(10**i))%10 # Least significant digit first
self.bitmap.blt(14*(5-i),0,@numbers.bitmap,Rect.new(digit*14,0,14,22))
end
end
end
class LuckyWheelWin < BitmapSprite
attr_reader :score
def initialize(x,y,score=0)
@viewport=Viewport.new(x,y,28,22)
@viewport.z=99999
super(28,22,@viewport)
@numbers=AnimatedBitmap.new(_INTL("Graphics/Pictures/Lucky Wheel/numbers"))
self.score=score
end
def score=(value)
@score=value
refresh
end
def refresh
self.bitmap.clear
for i in 0...2
digit=(@score/(10**i))%10 # Least significant digit first
self.bitmap.blt(14*(1-i),0,@numbers.bitmap,Rect.new(digit*14,0,14,22))
end
end
end
class LuckyWheelCash < BitmapSprite
attr_reader :cash
def initialize(x,y,cash=0)
@viewport=Viewport.new(x,y,98,22)
@viewport.z=99999
super(98,22,@viewport)
@numbers=AnimatedBitmap.new(_INTL("Graphics/Pictures/Lucky Wheel/numbers"))
self.cash=cash
end
def cash=(value)
@cash=value
@cash=MAXMONEY if @cash>MAXMONEY
refresh
end
def refresh
self.bitmap.clear
for i in 0...7
digit=(@cash/(10**i))%10 # Least significant digit first
self.bitmap.blt(14*(6-i),0,@numbers.bitmap,Rect.new(digit*14,0,14,22))
end
end
end
class LuckyWheelScene
attr_accessor :gameRunning
attr_accessor :gameEnd
attr_accessor :wager
def update
pbUpdateSpriteHash(@sprites)
end
def pbPayout
payout=0
bonus=0
# Get reel pictures
wheel=@sprites["wheel"].showing
prize=wheel[1] # Centre point of wheel
winner=true
case prize
when 0 # Lose
winner=false
when 1,2,3,4,5 # Win
payout=prize
bonus=1 if prize==5
end
if payout>=0
@sprites["payout"].score=payout
end
frame=0
if payout>0 #Winner
if bonus>0
pbMEPlay("Slots big win")
else
pbMEPlay("Slots win")
end
# Show winning animation
until frame==120 # 40 frames per seconds
Graphics.update
Input.update
update
@sprites["window2"].bitmap.clear if @sprites["window2"].bitmap
@sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/win"))
@sprites["window1"].src_rect.set(152*((frame/5)%4),0,152,208)
if bonus>0
@sprites["window2"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/bonus"))
@sprites["window2"].src_rect.set(152*(bonus-1),0,152,208)
end
@sprites["light1"].visible=true
@sprites["light1"].src_rect.set(0,26*((frame/5)%4),96,26)
@sprites["light2"].visible=true
@sprites["light2"].src_rect.set(0,26*((frame/5)%4),96,26)
frame+=1
end
@sprites["light1"].visible=false
@sprites["light2"].visible=false
@sprites["window1"].src_rect.set(0,0,152,208)
# Pay out
loop do
break if @sprites["payout"].score<=0
Graphics.update
Input.update
update
@sprites["payout"].score-=1
@sprites["credit"].score+=1
if Input.trigger?(Input::C) || @sprites["credit"].score==MAXCOINS
@sprites["credit"].score+=@sprites["payout"].score
@sprites["payout"].score=0
end
end
20.times do
Graphics.update
Input.update
update
end
else
# Show losing animation
until frame==80 # 40 frames per seconds
Graphics.update
Input.update
update
@sprites["window2"].bitmap.clear if @sprites["window2"].bitmap
@sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/lose"))
@sprites["window1"].src_rect.set(152*((frame/10)%2),0,152,208)
frame+=1
end
20.times do
Graphics.update
Input.update
update
end
end
@wager=0
end
def pbStartScene(reeltype)
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
addBackgroundPlane(@sprites,"bg","Lucky Wheel/bg",@viewport)
@sprites["wheel"]=LuckyWheelReel.new(144,112,reeltype)
@sprites["light1"]=IconSprite.new(16,32,@viewport)
@sprites["light1"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/lights"))
@sprites["light1"].visible=false
@sprites["light2"]=IconSprite.new(240,32,@viewport)
@sprites["light2"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/lights"))
@sprites["light2"].mirror=true
@sprites["light2"].visible=false
@sprites["window1"]=IconSprite.new(358,96,@viewport)
@sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/insert"))
@sprites["window1"].src_rect.set(0,0,152,208)
@sprites["window2"]=IconSprite.new(358,96,@viewport)
@sprites["credit"]=LuckyWheelScore.new(49,284,$PokemonGlobal.coins)
@sprites["payout"]=LuckyWheelWin.new(161,284,0)
@sprites["cash"]=LuckyWheelCash.new(217,284,$Trainer.money)
@sprites["reward"]=IconSprite.new(2,320,@viewport)
case reeltype
when 0
@sprites["reward"].setBitmap(sprintf(_INTL"Graphics/Pictures/Lucky Wheel/prize0"))
when 1
@sprites["reward"].setBitmap(sprintf(_INTL"Graphics/Pictures/Lucky Wheel/prize1"))
when 2
@sprites["reward"].setBitmap(sprintf(_INTL"Graphics/Pictures/Lucky Wheel/prize2"))
end
@wager=0
update
pbFadeInAndShow(@sprites)
end
def pbMain
frame=0
loop do
Graphics.update
Input.update
update
@sprites["window1"].bitmap.clear if @sprites["window1"].bitmap
@sprites["window2"].bitmap.clear if @sprites["window2"].bitmap
if @sprites["credit"].score==MAXCOINS
Kernel.pbMessage(_INTL("You've got 999,999 BP!"))
break
elsif $PokemonGlobal.coins<1 && $Trainer.money<100
Kernel.pbMessage(_INTL("You can't buy another spin.\nGame over!"))
break
elsif @gameRunning # Reels are spinning
@sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/stop"))
@sprites["window1"].src_rect.set(152*((frame/10)%4),0,152,208)
if Input.trigger?(Input::C)
pbSEPlay("Slots stop")
if @sprites["wheel"].spinning
@sprites["wheel"].stopSpinning(@replay)
end
end
if !@sprites["wheel"].spinning
@gameEnd=true
@gameRunning=false
end
elsif @gameEnd # Reels have been stopped
pbPayout
@gameEnd=false
else # Awaiting BP/P$ for the next spin
@sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Lucky Wheel/insert"))
@sprites["window1"].src_rect.set(152*((frame/15)%2),0,152,208)
if Input.trigger?(Input::DOWN) && @wager<1 && @sprites["credit"].score>1
# Pay with BP
pbSEPlay("Slots coin")
@wager+=1
@sprites["credit"].score-=1
elsif Input.trigger?(Input::DOWN) && @wager<1 && @sprites["cash"].cash>99
# Pay with Cash
pbSEPlay("Slots coin")
@wager+=1
@sprites["cash"].cash-=100
elsif @wager>=1
@sprites["wheel"].startSpinning
frame=0
@gameRunning=true
elsif Input.trigger?(Input::B) && @wager==0
break
end
end
frame=(frame+1)%120
end
$PokemonGlobal.coins=@sprites["credit"].score
$Trainer.money=@sprites["cash"].cash
end
def pbEndScene
pbFadeOutAndHide(@sprites)
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end
class LuckyWheel
def initialize(scene)
@scene=scene
end
def pbStartScreen(reeltype)
@scene.pbStartScene(reeltype)
@scene.pbMain
@scene.pbEndScene
end
end
def pbLuckyWheel(reeltype=0)
if hasConst?(PBItems,:COINCASE) && !$PokemonBag.pbHasItem?(:COINCASE)
Kernel.pbMessage(_INTL("It's a Lucky Wheel game."))
elsif $PokemonGlobal.coins==0 && $Trainer.money<100
Kernel.pbMessage(_INTL("You can't play without any BP or enough money!"))
elsif $PokemonGlobal.coins==MAXCOINS
Kernel.pbMessage(_INTL("You have a full Battle Card!"))
else
pbFadeOutIn(99999){
scene = LuckyWheelScene.new
screen = LuckyWheel.new(scene)
screen.pbStartScreen(reeltype)
}
end
end
3) To play the mini-game, have an event have the script event pbLuckyWheel(x), where x is the area variable between 0 and 2. In the provided pack, 0 is Grass, 1 is Fire and 2 is Water.