KitsuneKouta
狐 康太
- 442
- Posts
- 15
- Years
- Seen Nov 20, 2017
This slot machine script is modeled after the RSE version. You can alter it without too much trouble into whatever other version you want. All features found in the RSE slot machines are included in this script, except for the Reel Time feature. It has been started, but I'll get to that momentarily.
To put this script into your game, simply paste this into a new script section:
To call the script, use $scene=Scene_Slots.new.
The global variable for coins is already implemented in Essentials, so I simply adapted the script to work with it. To add coins to the players coin bag, use $PokemonGlobal.coins+=XXXX.
You must download the images and audio and copy/paste the contents into the Graphics/Pictures and Audio/ME or Audio/SE directories (indicated by the folder names for audio).
If you don't like the speed of any of the animations (such as the flashing lines or the win animation), look for the portion of code that corresponds to the animation and change the frame numbers. It'll be under a "case @FrameCount" line with several checks for the frame number (such as "when 2" "when 4" etc.). It's best to keep them in a pattern though so that the animation is smooth (i.e. count by 2s, 5s, 10s, etc.).
If you want to implement the Reel Time feature, you have to script in a function that performs a replay several times, and sums the payouts at the end. I was working on it, but lost interest after a few failed attempts. All of the variables necessary to implement it should still be present, and in the appropriate areas. The related code has been commented out, so you can pick up where I left off or try something else. The necessary graphics have also been included for the Pikachu animation, just not formatted and arranged.
The script was initially created by Itachihro, and the original can be found on YouTube by searching for "RPGXP Casino Slots Script." I built the script using his as the core, and added/edited tons of things. Also, I translated the comments and variable names into English to make it easier to understand and modify. Although some of the stuff I named may be odd sounding, since it was off the top of my head.
The graphics were ripped by Guille-kun (the large image, which I broke into the smaller pieces).
The sound effects were ripped by me.
If there are any problems, or if there is anything you don't understand about the script, let me know. And if anyone has the patience to implement the Reel Time feature and the accompanying animation, I'll add it to this and give you appropriate credit for your contribution.
To put this script into your game, simply paste this into a new script section:
Code:
###################################################################
# The one-armed bandit for the Casino ©Nintendo (Made by Itachihro)
# Translated and improved by KitsuneKouta
###################################################################
class Scene_Slots
def initialize(usedcoins=0,slot1=nil,slot2=nil,slot3=nil,bolts=-1)
#Initialization of the game
@content1=slot1#Content of @Slot1
@content2=slot2#Content of @Slot2
@content3=slot3#Content of @Slot3
@usedcoins=usedcoins
#Initialization of variables
@FrameCount=0
@GameActive=false
@RedSevenWin=[1,1,1]
@BlueSevenWin=[2,2,2]
@LotadWin=[5,5,5]
@AzurillWin=[4,4,4]
@PikachuWin=[7,7,7]
@ReplayWin=[3,3,3]
@PokeballWin=[6,6]
@BigPokeballWin=[6,6,6]
@SmallRedBonus=[1,1,2]
@SmallBlueBonus=[2,2,1]
@Payout=0
@fastPayout=false
@WinAnimationOver=false
@bolts=bolts
@ReelTime=false
@ReelCount=0
@time=0
@Line1Flash=false
@Line2aFlash=false
@Line2bFlash=false
@Line3aFlash=false
@Line3bFlash=false
#Graphics are defined here
#Insert (thrown coins=0)
@Insert_01=RPG::Cache.picture("Insert 1")
@Insert_02=RPG::Cache.picture("Insert 2")
#Insert (thrown coins=1-3)
@Insert_03=RPG::Cache.picture("Insert 3")
@Insert_04=RPG::Cache.picture("Insert 4")
@Insert_05=RPG::Cache.picture("Insert 5")
@Insert_06=RPG::Cache.picture("Insert 6")
#Reel Time
@ReelTime_0=RPG::Cache.picture("Reel Time 0")
@ReelTime_1=RPG::Cache.picture("Reel Time 1")
@ReelTime_2=RPG::Cache.picture("Reel Time 2")
@ReelTime_3=RPG::Cache.picture("Reel Time 3")
@ReelTime_4=RPG::Cache.picture("Reel Time 4")
@ReelTime_5=RPG::Cache.picture("Reel Time 5")
#Stop
@Stop_01=RPG::Cache.picture("Stop 1")
@Stop_02=RPG::Cache.picture("Stop 2")
@Stop_03=RPG::Cache.picture("Stop 3")
@Stop_04=RPG::Cache.picture("Stop 4")
@Stop_05=RPG::Cache.picture("Stop 5")
@Stop_06=RPG::Cache.picture("Stop 6")
#Win
@Win_01=RPG::Cache.picture("Win 1")
@Win_02=RPG::Cache.picture("Win 2")
@Win_03=RPG::Cache.picture("Win 3")
@Win_04=RPG::Cache.picture("Win 4")
#Big Bonus
@Big_B_01=RPG::Cache.picture("Big Bonus 1")
@Big_B_02=RPG::Cache.picture("Big Bonus 2")
@Big_B_03=RPG::Cache.picture("Big Bonus 3")
@Big_B_04=RPG::Cache.picture("Big Bonus 4")
#Reg Bonus
@Reg_B_01=RPG::Cache.picture("Bonus 1")
@Reg_B_02=RPG::Cache.picture("Bonus 2")
@Reg_B_03=RPG::Cache.picture("Bonus 3")
@Reg_B_04=RPG::Cache.picture("Bonus 4")
#Flashing lights on win
@Win_Light1=RPG::Cache.picture("Win Out")
@Win_Light2=RPG::Cache.picture("Win Middle")
@Win_Light3=RPG::Cache.picture("Win In")
#Lose
@Lose_01=RPG::Cache.picture("Lose 1")
@Lose_02=RPG::Cache.picture("Lose 2")
#Lighting Bolt
@LBolt=RPG::Cache.picture("Bolt")
#Background
@BackgroundIMG=RPG::Cache.picture("Slots Layout")
#Highlighted lines
@Light_1=RPG::Cache.picture("Line 1")
@Light_2_1=RPG::Cache.picture("Line 2")
@Light_2_2=RPG::Cache.picture("Line 2")
@Light_3_1=RPG::Cache.picture("Line 3-1")
@Light_3_2=RPG::Cache.picture("Line 3-2")
#Buttons
@PushButton1=RPG::Cache.picture("Button Pressed")
@PushButton2=RPG::Cache.picture("Button Pressed")
@PushButton3=RPG::Cache.picture("Button Pressed")
#Numbers
@Credit0=RPG::Cache.picture("0")
@Credit1=RPG::Cache.picture("1")
@Credit2=RPG::Cache.picture("2")
@Credit3=RPG::Cache.picture("3")
@Credit4=RPG::Cache.picture("4")
@Credit5=RPG::Cache.picture("5")
@Credit6=RPG::Cache.picture("6")
@Credit7=RPG::Cache.picture("7")
@Credit8=RPG::Cache.picture("8")
@Credit9=RPG::Cache.picture("9")
#Array for the number images
@Credit_Numbers=[@Credit0,@Credit1,@Credit2,@Credit3,@Credit4,@Credit5,@Credit6,
@Credit7,@Credit8,@Credit9]
end
def main
#============================
#Creation of the sprites
#==========================
#Background
@Background=Sprite.new
@Background.bitmap=@BackgroundIMG
#Black window on the right
@SupportWindow=Sprite.new
@SupportWindow.bitmap=@Insert_01
#Used for flashing lights
@SupportWindow2=Sprite.new
#Credit field
@Creditfield1=Sprite.new
@Creditfield1.x=358
@Creditfield1.y=36
@Creditfield2=Sprite.new
@Creditfield2.x=372
@Creditfield2.y=36
@Creditfield3=Sprite.new
@Creditfield3.x=386
@Creditfield3.y=36
@Creditfield4=Sprite.new
@Creditfield4.x=400
@Creditfield4.y=36
#Payout field
@Payoutfield1=Sprite.new
@Payoutfield1.x=422
@Payoutfield1.y=36
@Payoutfield2=Sprite.new
@Payoutfield2.x=436
@Payoutfield2.y=36
@Payoutfield3=Sprite.new
@Payoutfield3.x=450
@Payoutfield3.y=36
@Payoutfield4=Sprite.new
@Payoutfield4.x=464
@Payoutfield4.y=36
#Buttons
@Button1=Sprite.new
@Button1.x=84
@Button1.y=246
@Button2=Sprite.new
@Button2.x=164
@Button2.y=246
@Button3=Sprite.new
@Button3.x=244
@Button3.y=246
#Slots
if @content1!=nil
@Slot1=Slot.new(62,@content1[0],@content1[1],@content1[2])
else
@Slot1=Slot.new(62)
end
if @content2!=nil
@Slot2=Slot.new(142,@content2[0],@content2[1],@content2[2])
else
@Slot2=Slot.new(142)
end
if @content3!=nil
@Slot3=Slot.new(222,@content3[0],@content3[1],@content3[2])
else
@Slot3=Slot.new(222)
end
#Highlighted lines created
@Light=Sprite.new
@Light2=Sprite.new
@Light3=Sprite.new
@Light4=Sprite.new
@Light5=Sprite.new
#Transition
Graphics.transition
#Updates lightning bolt graphics
boltGraphics
#Start Main Loop
loop do
Graphics.update
Input.update
update
#Loopbreak at scene change
if $scene!=self
break
end
end
#Graphics freeze, delete objects
Graphics.freeze
@SupportWindow.dispose
@SupportWindow2.dispose
@Background.dispose
@Creditfield1.dispose
@Creditfield2.dispose
@Creditfield3.dispose
@Creditfield4.dispose
@Payoutfield1.dispose
@Payoutfield2.dispose
@Payoutfield3.dispose
@Payoutfield4.dispose
@Slot1.dispose
@Slot2.dispose
@Slot3.dispose
@Button1.dispose
@Button2.dispose
@Button3.dispose
@Light.dispose
@Light2.dispose
@Light3.dispose
@Light4.dispose
@Light5.dispose
end
#============================================================
#More or less everything worked, processed, and analyzed
#============================================================
def update
@FrameCount=@FrameCount+1
if !(@GameActive)
@evaluated=false
end
def coinCheck
if $PokemonGlobal.coins<9999
$PokemonGlobal.coins=$PokemonGlobal.coins+1
elsif $PokemonGlobal.coins>=9999
$PokemonGlobal.coins=9999
@Payout=0
end
end
if (@Payout==0)&&!(@Replay)&&!(@GameActive)&&($PokemonGlobal.coins==0)#&&!(@ReelTime)
Kernel.pbMessage("You've run out of COINS.\nGame over!")
$scene=Scene_Map.new
end
#=====================================================================
#Handler for finished game (Win or Lose)
#Support Window and Coins
#=====================================================================
if (@GameActive) &&!(@Slot3.active)
if !(@evaluated)
self.evaluate
end
if @Win
case @FrameCount
when 4
lineErase
@SupportWindow2.bitmap=@Win_Light1
if @BigBonus
@SupportWindow.bitmap=@Big_B_01
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_01
else
@SupportWindow.bitmap=@Win_01
end
when 8
lineFlash
@SupportWindow2.bitmap=@Win_Light2
if @BigBonus
@SupportWindow.bitmap=@Big_B_02
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_02
else
@SupportWindow.bitmap=@Win_02
end
when 12
lineErase
@SupportWindow2.bitmap=@Win_Light3
if @BigBonus
@SupportWindow.bitmap=@Big_B_03
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_03
else
@SupportWindow.bitmap=@Win_03
end
when 16
lineFlash
@SupportWindow2.bitmap=@Win_Light2
if @BigBonus
@SupportWindow.bitmap=@Big_B_04
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_04
else
@SupportWindow.bitmap=@Win_04
end
when 20
lineErase
@SupportWindow2.bitmap=@Win_Light1
if @BigBonus
@SupportWindow.bitmap=@Big_B_01
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_01
else
@SupportWindow.bitmap=@Win_01
end
when 24
lineFlash
@SupportWindow2.bitmap=@Win_Light2
if @BigBonus
@SupportWindow.bitmap=@Big_B_02
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_02
else
@SupportWindow.bitmap=@Win_02
end
when 28
lineErase
@SupportWindow2.bitmap=@Win_Light3
if @BigBonus
@SupportWindow.bitmap=@Big_B_03
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_03
else
@SupportWindow.bitmap=@Win_03
end
when 32
lineFlash
@SupportWindow2.bitmap=@Win_Light2
if @BigBonus
@SupportWindow.bitmap=@Big_B_04
elsif @RegBonus
@SupportWindow.bitmap=@Reg_B_04
else
@SupportWindow.bitmap=@Win_04
end
@FrameCount=0
@WinAnimationOver=true
end
def lineFlash
if @Line1Flash
@Light.bitmap=@Light_1
end
if @Line2aFlash
@Light2.bitmap=@Light_2_1
end
if @Line2bFlash
@Light3.bitmap=@Light_2_2
end
if @Line3aFlash
@Light4.bitmap=@Light_3_1
end
if @Line3bFlash
@Light5.bitmap=@Light_3_2
end
end
def lineErase
@Light.bitmap=nil
@Light2.bitmap=nil
@Light3.bitmap=nil
@Light4.bitmap=nil
@Light5.bitmap=nil
end
if ((@FrameCount%1)==0)&&@fastPayout&&@WinAnimationOver&&(@Payout>0)
@Payout=@Payout-1
coinCheck
elsif ((@FrameCount%2)==0)&&@WinAnimationOver&&(@Payout>0)
@Payout=@Payout-1
coinCheck
end
if (Input.trigger?(Input::C))&&@Payout>0
@fastPayout=true
end
if (@Payout==0)&&!(@Replay)#&&!(@ReelTime)
if $PokemonGlobal.coins==9999
Kernel.pbMessage("You've got 9,999 COINS.")
elsif $PokemonGlobal.coins==0
Kernel.pbMessage("You've run out of COINS./nGame over!")
end
@GameActive=false
@FrameCount=0
@Line2_Active=false
@Line3_Active=false
@Light.bitmap=nil
@Light2.bitmap=nil
@Light3.bitmap=nil
@Light4.bitmap=nil
@Light5.bitmap=nil
@SupportWindow2.bitmap=nil
@BigBonus=false
@RegBonus=false
@fastPayout=false
@WinAnimationOver=false
@Line1Flash=false
@Line2aFlash=false
@Line2bFlash=false
@Line3aFlash=false
@Line3bFlash=false
end
if (@Payout==0)&&(@Replay)#&&!(@ReelTime)
@Slot1.active=true
@Slot2.active=true
@Slot3.active=true
@Replay=false
@SupportWindow2.bitmap=nil
@FrameCount=0
@BigBonus=false
@RegBonus=false
@fastPayout=false
@WinAnimationOver=false
@Line1Flash=false
@Line2aFlash=false
@Line2bFlash=false
@Line3aFlash=false
@Line3bFlash=false
end
if (@Payout==0)&&(@WinAnimationOver)#&&(@ReelCount>0)
@Slot1.active=true
@Slot2.active=true
@Slot3.active=true
#@ReelCount-=1
@SupportWindow2.bitmap=nil
@FrameCount=0
@BigBonus=false
@RegBonus=false
@fastPayout=false
@WinAnimationOver=false
@Line1Flash=false
@Line2aFlash=false
@Line2bFlash=false
@Line3aFlash=false
@Line3bFlash=false
#if @ReelCount==0
# @bolts=-1
#end
end
else
case @FrameCount
when 10
@SupportWindow.bitmap=@Lose_02
when 20
@SupportWindow.bitmap=@Lose_01
when 30
@SupportWindow.bitmap=@Lose_02
when 40
@SupportWindow.bitmap=@Lose_01
@FrameCount=0
@GameActive=false
@Line2_Active=false
@Line3_Active=false
@Light.bitmap=nil
@Light2.bitmap=nil
@Light3.bitmap=nil
@Light4.bitmap=nil
@Light5.bitmap=nil
end
end
end
#================================================
#Input Processes
#===============================================
@content1=[@Slot1.TopVal,@Slot1.MidVal,@Slot1.DownVal]
@content2=[@Slot2.TopVal,@Slot2.MidVal,@Slot2.DownVal]
@content3=[@Slot3.TopVal,@Slot3.MidVal,@Slot3.DownVal]
if (Input.trigger?(Input::C))&&(@GameActive)
if @Slot1.active
pbSEPlay("SlotsStop")
@Button1.bitmap=@PushButton1
@Slot1.active=false
elsif @Slot2.active
pbSEPlay("SlotsStop")
@Button2.bitmap=@PushButton2
@Slot2.active=false
elsif @Slot3.active
pbSEPlay("SlotsStop")
@Button3.bitmap=@PushButton3
@Slot3.active=false
end
end
if @GameActive
@time+=1
if [email protected]
if @time>=10
@Button3.bitmap=nil
@Button2.bitmap=nil
@Button1.bitmap=nil
@time=0
end
elsif [email protected]
if @time>=10
@Button3.bitmap=nil
@Button2.bitmap=nil
@Button1.bitmap=nil
@time=0
end
else
if @time>=10
@Button3.bitmap=nil
@Button2.bitmap=nil
@Button1.bitmap=nil
@time=0
end
end
end
if (Input.trigger?(Input::CTRL))&&(@usedcoins<1)&&!(@GameActive)&&(@Payout==0)
$scene=Scene_Slots_Help.new(@usedcoins,@content1,@content2,@content3,@bolts)
end
if (Input.trigger?(Input::DOWN))&&!(@GameActive)&&$PokemonGlobal.coins>0
pbSEPlay("SlotsSelect")
@usedcoins=@usedcoins+1
$PokemonGlobal.coins=$PokemonGlobal.coins-1
if @usedcoins==1
@Light.bitmap=@Light_1
@Light.y=138
@Light.x=2
end
if @usedcoins==2
@Line2_Active=true
@Light.bitmap=@Light_1
@Light.y=138
@Light.x=2
@Light2.bitmap=@Light_2_1
@Light2.y=90
@Light2.x=2
@Light3.bitmap=@Light_2_2
@Light3.y=186
@Light3.x=2
end
if @usedcoins==3
@Light.bitmap=@Light_1
@Light.y=138
@Light.x=2
@Light2.bitmap=@Light_2_1
@Light2.y=90
@Light2.x=2
@Light3.bitmap=@Light_2_2
@Light3.y=186
@Light3.x=2
@Light4.bitmap=@Light_3_1
@Light4.y=50
@Light4.x=2
@Light5.bitmap=@Light_3_2
@Light5.y=50
@Light5.x=2
@Line3_Active=true
@GameActive=true
@Slot1.active=true
@Slot2.active=true
@Slot3.active=true
@FrameCount=0
end
#rnd=rand(20)
#if rnd==1
# @ReelTime=true
# rnd2=rand(5)
#end
#@ReelCount=rnd2#left off
#if @ReelCount==0
# @ReelTime=false
#else
# @ReelTime=true
#end
end
if (Input.trigger?(Input::B))&&!(@GameActive)
if Kernel.pbConfirmMessage("Quit the game?")
$PokemonGlobal.coins=$PokemonGlobal.coins+@usedcoins
@bolts=-1
boltGraphics
$scene=Scene_Map.new
end
end
if (Input.trigger?(Input::C))&&!(@GameActive)&&(@usedcoins>0)
@GameActive=true
@Slot1.active=true
@Slot2.active=true
@Slot3.active=true
@FrameCount=0
end
#=================================================
#@SupportWindow update
#=================================================
# Case: No coins thrown
if @usedcoins==0&&!(@GameActive)
if @FrameCount==16
@SupportWindow.bitmap=@Insert_01
end
if @FrameCount==32
@SupportWindow.bitmap=@Insert_02
@FrameCount=0
end
end
# One or more coins thrown (and the game is not yet active)
if (@usedcoins > 0) && !(@GameActive)
case @FrameCount
when 16
@SupportWindow.bitmap=@Insert_03
when 24
@SupportWindow.bitmap=@Insert_04
when 32
@SupportWindow.bitmap=@Insert_05
when 40
@SupportWindow.bitmap=@Insert_06
@FrameCount=0
end
end
# Game running and Reel Time active
if (@GameActive)&&(@ReelTime)
Graphics.update
case @FrameCount
when 40
@SupportWindow.bitmap=@ReelTime_0
when 80
@SupportWindow.bitmap=@ReelTime_5
when 120
@SupportWindow.bitmap=@ReelTime_4
when 160
@SupportWindow.bitmap=@ReelTime_3
when 200
@SupportWindow.bitmap=@ReelTime_2
when 240
@SupportWindow.bitmap=@ReelTime_1
@ReelTime=false
@bolts= -1
@FrameCount=0
boltGraphics
end
end
# Game running
if (@GameActive)&&(@Slot3.active)#&&!(@ReelTime)
case @FrameCount
when 8
@SupportWindow.bitmap=@Stop_01
when 16
@SupportWindow.bitmap=@Stop_02
when 24
@SupportWindow.bitmap=@Stop_03
when 32
@SupportWindow.bitmap=@Stop_02
when 40
@SupportWindow.bitmap=@Stop_04
when 48
@SupportWindow.bitmap=@Stop_05
when 56
@SupportWindow.bitmap=@Stop_06
when 64
@SupportWindow.bitmap=@Stop_05
@FrameCount=0
end
end
#==================================================
#Credit update
#==================================================
@Creditfield1.bitmap=@Credit_Numbers[$PokemonGlobal.coins/1000]
@Creditfield2.bitmap=@Credit_Numbers[($PokemonGlobal.coins%1000)/100]
@Creditfield3.bitmap=@Credit_Numbers[(($PokemonGlobal.coins%1000)%100)/10]
@Creditfield4.bitmap=@Credit_Numbers[(($PokemonGlobal.coins%1000)%100)%10]
#==========================================================
#Payout update
#==========================================================
@Payoutfield1.bitmap=@Credit_Numbers[@Payout/1000]
@Payoutfield2.bitmap=@Credit_Numbers[(@Payout%1000)/100]
@Payoutfield3.bitmap=@Credit_Numbers[((@Payout%1000)%100)/10]
@Payoutfield4.bitmap=@Credit_Numbers[((@Payout%1000)%100)%10]
#=================================================
#Slots run
#=================================================
if @GameActive&&(@FrameCount%2)==0
if @Slot1.active
@Slot1.run
end#of if
if @Slot2.active
@Slot2.run
end#of if
if @Slot3.active
@Slot3.run
end#of if
end#of if @GameActive
end#of Method
#=================================
#Payout Check and Pikachu Bonus
#=================================
def boost
if @bolts<15
@bolts+=1
end
boltGraphics
end
def boltGraphics
@sprites={}
@sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height)
x=48
overlay=@sprites["overlay"].bitmap
overlay.clear
boltPositions=[]
for i in 0...16
if @bolts>=i
boltPositions[boltPositions.length]=[
"Graphics/Pictures/bolts",x,34,i*16,0,16,16]
end
x+=16
end
pbDrawImagePositions(overlay,boltPositions)
Graphics.update
end
def evaluate
boltGraphics
@evaluated=true
@FrameCount=0
@Payout=0
@Line1=[@Slot1.MidVal,@Slot2.MidVal,@Slot3.MidVal]
@Line2a=[@Slot1.TopVal,@Slot2.TopVal,@Slot3.TopVal]
@Line2b=[@Slot1.DownVal,@Slot2.DownVal,@Slot3.DownVal]
@Line3a=[@Slot1.TopVal,@Slot2.MidVal,@Slot3.DownVal]
@Line3b=[@Slot1.DownVal,@Slot2.MidVal,@Slot3.TopVal]
@usedcoins=0
#Payout Check Line 1
@Replay=false
case @Line1
when @RedSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line1Flash=true
when @BlueSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line1Flash=true
when @SmallRedBonus
@Payout=@Payout+90
@RegBonus=true
@Line1Flash=true
when @SmallBlueBonus
@Payout=@Payout+90
@RegBonus=true
@Line1Flash=true
when @BigPokeballWin
@Payout=@Payout+4
@Line1Flash=true
when @AzurillWin
@Payout=@Payout+12
@Line1Flash=true
when @PikachuWin
@Payout=@Payout+3
boost
@Line1Flash=true
when @LotadWin
@Payout=@Payout+6
@Line1Flash=true
when @ReplayWin
@Replay=true
@Line1Flash=true
else
if @PokeballWin==[@Line1[0],@Line1[1]]
@Payout=@Payout+2
@Line1Flash=true
end
end
#Payout Check Line 2
if @Line2_Active
case @Line2a
when @RedSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line2aFlash=true
when @BlueSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line2aFlash=true
when @SmallRedBonus
@Payout=@Payout+90
@RegBonus=true
@Line2aFlash=true
when @SmallBlueBonus
@Payout=@Payout+90
@RegBonus=true
@Line2aFlash=true
when @BigPokeballWin
@Payout=@Payout+4
@Line2aFlash=true
when @AzurillWin
@Payout=@Payout+12
@Line2aFlash=true
when @PikachuWin
@Payout=@Payout+3
boost
@Line2aFlash=true
when @LotadWin
@Payout=@Payout+6
@Line2aFlash=true
when @ReplayWin
@Replay=true
@Line2aFlash=true
else
if @PokeballWin==[@Line2a[0],@Line2a[1]]
@Payout=@Payout+2
@Line2aFlash=true
end
end
case @Line2b
when @RedSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line2bFlash=true
when @BlueSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line2bFlash=true
when @SmallRedBonus
@Payout=@Payout+90
@RegBonus=true
@Line2bFlash=true
when @SmallBlueBonus
@Payout=@Payout+90
@RegBonus=true
@Line2bFlash=true
when @BigPokeballWin
@Payout=@Payout+4
@Line2bFlash=true
when @AzurillWin
@Payout=@Payout+12
@Line2bFlash=true
when @PikachuWin
@Payout=@Payout+3
boost
@Line2bFlash=true
when @LotadWin
@Payout=@Payout+6
@Line2bFlash=true
when @ReplayWin
@Replay=true
@Line2bFlash=true
else
if @PokeballWin==[@Line2b[0],@Line2b[1]]
@Payout=@Payout+2
@Line2bFlash=true
end
end
end
#Payout Check Line 3
if @Line3_Active
case @Line3a
when @RedSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line3aFlash=true
when @BlueSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line3aFlash=true
when @SmallRedBonus
@Payout=@Payout+90
@RegBonus=true
@Line3aFlash=true
when @SmallBlueBonus
@Payout=@Payout+90
@RegBonus=true
@Line3aFlash=true
when @BigPokeballWin
@Payout=@Payout+4
@Line3aFlash=true
when @AzurillWin
@Payout=@Payout+12
@Line3aFlash=true
when @PikachuWin
@Payout=@Payout+3
boost
@Line3aFlash=true
when @LotadWin
@Payout=@Payout+6
@Line3aFlash=true
when @ReplayWin
@Replay=true
@Line3aFlash=true
else
if @PokeballWin==[@Line3a[0],@Line3a[1]]
@Payout=@Payout+2
@Line3aFlash=true
end
end
case @Line3b
when @RedSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line3bFlash=true
when @BlueSevenWin
@Payout=@Payout+300
@BigBonus=true
@Line3bFlash=true
when @SmallRedBonus
@Payout=@Payout+90
@RegBonus=true
@Line3bFlash=true
when @SmallBlueBonus
@Payout=@Payout+90
@RegBonus=true
@Line3bFlash=true
when @BigPokeballWin
@Payout=@Payout+4
@Line3bFlash=true
when @AzurillWin
@Payout=@Payout+12
@Line3bFlash=true
when @PikachuWin
@Payout=@Payout+3
boost
@Line3bFlash=true
when @LotadWin
@Payout=@Payout+6
@Line3bFlash=true
when @ReplayWin
@Replay=true
@Line3bFlash=true
else
if @PokeballWin==[@Line3b[0],@Line3b[1]]
@Payout=@Payout+2
@Line3bFlash=true
end
end
end
@Win= (@Payout>0)||(@Replay)
if @BigBonus||@RegBonus
pbMEPlay("SlotsBigWin")
elsif @Win
pbMEPlay("SlotsWin")
end
end
end
class Scene_Slots_Help
def initialize(usedcoins,content1,content2,content3,bolts)
#Parameters to pass variables (when returning to Scene_Slots)
@usedcoins=usedcoins
@content1=content1
@content2=content2
@content3=content3
@bolts=bolts
#Numbers
@Credit0=RPG::Cache.picture("0")
@Credit1=RPG::Cache.picture("1")
@Credit2=RPG::Cache.picture("2")
@Credit3=RPG::Cache.picture("3")
@Credit4=RPG::Cache.picture("4")
@Credit5=RPG::Cache.picture("5")
@Credit6=RPG::Cache.picture("6")
@Credit7=RPG::Cache.picture("7")
@Credit8=RPG::Cache.picture("8")
@Credit9=RPG::Cache.picture("9")
@Credit_Numbers=[@Credit0,@Credit1,@Credit2,@Credit3,@Credit4,@Credit5,@Credit6,
@Credit7,@Credit8,@Credit9]
end
def main
#Background
@Background=Sprite.new
@Background.bitmap=RPG::Cache.picture("Slots Info.png")
#Credits field
@Creditfield1=Sprite.new
@Creditfield1.x=358
@Creditfield1.y=36
@Creditfield2=Sprite.new
@Creditfield2.x=372
@Creditfield2.y=36
@Creditfield3=Sprite.new
@Creditfield3.x=386
@Creditfield3.y=36
@Creditfield4=Sprite.new
@Creditfield4.x=400
@Creditfield4.y=36
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene!=self
break
end
end
Graphics.freeze
@Background.dispose
@Creditfield1.dispose
@Creditfield2.dispose
@Creditfield3.dispose
@Creditfield4.dispose
end
def update
if Input.trigger?(Input::CTRL)
$scene=Scene_Slots.new(@usedcoins,@content1,@content2,@content3,@bolts)
end
if Input.trigger?(Input::B)
#Exit the game; returns coins that were input but not used
$PokemonGlobal.coins=$PokemonGlobal.coins+@usedcoins
$scene=Scene_Map.new
end
#Credit field update
@Creditfield1.bitmap=@Credit_Numbers[$PokemonGlobal.coins/1000]
@Creditfield2.bitmap=@Credit_Numbers[($PokemonGlobal.coins%1000)/100]
@Creditfield3.bitmap=@Credit_Numbers[(($PokemonGlobal.coins%1000)%100)/10]
@Creditfield4.bitmap=@Credit_Numbers[(($PokemonGlobal.coins%1000)%100)%10]
end
end
class Slot
attr_accessor :TopVal
attr_accessor :MidVal
attr_accessor :DownVal
attr_accessor :active
def initialize(x, topValue=nil,midValue=nil, downValue=nil)
#Slot images
@Pokeball_Down=RPG::Cache.picture("Pokeballs Bottom")
@Pokeball_Middle=RPG::Cache.picture("Pokeballs Middle")
@Pokeball_Top=RPG::Cache.picture("Pokeballs Top")
@AzurillDown=RPG::Cache.picture("Azurill Bottom")
@AzurillMiddle=RPG::Cache.picture("Azurill Middle")
@AzurillTop=RPG::Cache.picture("Azurill Top")
@PikachuDown=RPG::Cache.picture("Pikachu Bottom")
@PikachuMiddle=RPG::Cache.picture("Pikachu Middle")
@PikachuTop=RPG::Cache.picture("Pikachu Top")
@BlueSeven_Top=RPG::Cache.picture("Blue Seven Top")
@BlueSeven_Middle=RPG::Cache.picture("Blue Seven Middle")
@BlueSeven_Down=RPG::Cache.picture("Blue Seven Bottom")
@Lotad_Down=RPG::Cache.picture("Lotad Bottom")
@Lotad_Middle=RPG::Cache.picture("Lotad Middle")
@Lotad_Top=RPG::Cache.picture("Lotad Top")
@RedSeven_Down=RPG::Cache.picture("Red Seven Bottom")
@RedSeven_Middle=RPG::Cache.picture("Red Seven Middle")
@RedSeven_Top=RPG::Cache.picture("Red Seven Top")
@Replay_Down=RPG::Cache.picture("Replay Bottom")
@Replay_Middle=RPG::Cache.picture("Replay Middle")
@Replay_Top=RPG::Cache.picture("Replay Top")
#Y Coordinates of the images
@y1=78
@y2=127
@y3=176
#Image Position
@Top=Sprite.new
@Top.x=x
@Top.y=@y1
@Middle=Sprite.new
@Middle.x=x
@Middle.y=@y2
@Down=Sprite.new
@Down.x=x
@Down.y=@y3
#Rarity of slot elements is determined here. The more the number appears, the
#more common that element will be. Note that 1 (the Red 7) only occurs once
#and is rare, but 6 (the Pokeballs) occurs 4 times, being very common.
#Newly added elements must be placed here to appear.
#SlotInhalt set (1= Red 7, 2= Blue 7, 3= Replay, 4= Azurill, 5= Lotad,
#6= Pokeballs, 7= Pikachu)
@SlotInhalt=[1,6,6,4,3,7,4,5,2,5,6,4,5,7]
#@SlotInhalt=[1,1,1,1,1,1]# this is for testing the Big Bonus
#@SlotInhalt=[7,7,7,7,7,7]# this is for testing reel time, and the lighting bolts
#If the values are passed to the slots via parameters, use this
#Otherwise, choose randomly
if topValue!=nil
self.TopVal=topValue
self.MidVal=midValue
self.DownVal=downValue
else
self.setValues
end
#Active to false
self.active=false
#Graphs represent
@i=0
@j=1
@k=2
update
end
def setValues
@RndNr=rand(@SlotInhalt.size)
self.TopVal=@SlotInhalt[@RndNr]
if @RndNr==(@SlotInhalt.size-1)
@RndNr=0
else
@RndNr=@RndNr+1
end
self.MidVal=@SlotInhalt[@RndNr]
if @RndNr==(@SlotInhalt.size-1)
@RndNr=0
else
@RndNr=@RndNr+1
end
self.DownVal=@SlotInhalt[@RndNr]
end
def update
case self.TopVal
when 1
@Top.bitmap=@RedSeven_Top
when 2
@Top.bitmap=@BlueSeven_Top
when 3
@Top.bitmap=@Replay_Top
when 4
@Top.bitmap=@AzurillTop
when 5
@Top.bitmap=@Lotad_Top
when 6
@Top.bitmap=@Pokeball_Top
when 7
@Top.bitmap=@PikachuTop
end
case self.MidVal
when 1
@Middle.bitmap=@RedSeven_Middle
when 2
@Middle.bitmap=@BlueSeven_Middle
when 3
@Middle.bitmap=@Replay_Middle
when 4
@Middle.bitmap=@AzurillMiddle
when 5
@Middle.bitmap=@Lotad_Middle
when 6
@Middle.bitmap=@Pokeball_Middle
when 7
@Middle.bitmap=@PikachuMiddle
end
case self.DownVal
when 1
@Down.bitmap=@RedSeven_Down
when 2
@Down.bitmap=@BlueSeven_Down
when 3
@Down.bitmap=@Replay_Down
when 4
@Down.bitmap=@AzurillDown
when 5
@Down.bitmap=@Lotad_Down
when 6
@Down.bitmap=@Pokeball_Down
when 7
@Down.bitmap=@PikachuDown
end
end
def run
self.TopVal=@SlotInhalt[@i]
self.MidVal=@SlotInhalt[@j]
self.DownVal=@SlotInhalt[@k]
@i=@i+1
@j=@j+1
@k=@k+1
if @[email protected]
@i=0
end
if @[email protected]
@j=0
end
if @[email protected]
@k=0
end
update
end
def dispose
@Top.dispose
@Middle.dispose
@Down.dispose
end
end
The global variable for coins is already implemented in Essentials, so I simply adapted the script to work with it. To add coins to the players coin bag, use $PokemonGlobal.coins+=XXXX.
You must download the images and audio and copy/paste the contents into the Graphics/Pictures and Audio/ME or Audio/SE directories (indicated by the folder names for audio).
If you don't like the speed of any of the animations (such as the flashing lines or the win animation), look for the portion of code that corresponds to the animation and change the frame numbers. It'll be under a "case @FrameCount" line with several checks for the frame number (such as "when 2" "when 4" etc.). It's best to keep them in a pattern though so that the animation is smooth (i.e. count by 2s, 5s, 10s, etc.).
If you want to implement the Reel Time feature, you have to script in a function that performs a replay several times, and sums the payouts at the end. I was working on it, but lost interest after a few failed attempts. All of the variables necessary to implement it should still be present, and in the appropriate areas. The related code has been commented out, so you can pick up where I left off or try something else. The necessary graphics have also been included for the Pikachu animation, just not formatted and arranged.
The script was initially created by Itachihro, and the original can be found on YouTube by searching for "RPGXP Casino Slots Script." I built the script using his as the core, and added/edited tons of things. Also, I translated the comments and variable names into English to make it easier to understand and modify. Although some of the stuff I named may be odd sounding, since it was off the top of my head.
The graphics were ripped by Guille-kun (the large image, which I broke into the smaller pieces).
The sound effects were ripped by me.
If there are any problems, or if there is anything you don't understand about the script, let me know. And if anyone has the patience to implement the Reel Time feature and the accompanying animation, I'll add it to this and give you appropriate credit for your contribution.
Last edited: