08-05-2005, 01:00 PM
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Hello again.
if you want to add a gambling game like in the Suikoden II, so this script is for you
This script 100% written by me.
Credit to me please ^-^ he..he..he..
In this gambling game you bet some of your money
and then you choose "high"(if the dice show less than 4 you win)
or "low"(the dice must be show more than 3 to win).
If you win, you'll receive 2 X your bet,
if you lose you just lost your money that you bet.
Now the script
first, add this entire script above main and name it Gambling_Script
Code:
#*********************************************************
# Gambling Game by Clock
#*********************************************************
class Scene_Gambling
def initialize(menu_index = 0)
@menu_index = menu_index
end
def main
@spriteset = Spriteset_Map.new
s1 = "Bet 500 "+$data_system.words.gold
s2 = "Bet 1000 "+$data_system.words.gold
s3 = "Bet 2500 "+$data_system.words.gold
s4 = "Bet 5000 "+$data_system.words.gold
s5 = "High"
s6 = "Low"
s7 = "Yes"
s8 = "No"
s9 = "Leave"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s9])
@command_window.index = @menu_index
@command_window.width = 192
@confirm_window = Window_Base.new(220, 128, 200, 64)
@confirm_window.contents = Bitmap.new(168, 32)
@confirm_window.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype
@confirm_window.contents.font.size = $fontsize.is_a?(Integer) ? $fontsize : $defaultfontsize
@confirm_window.visible = false
@confirm_window.z = 1500
@yes_no_window = Window_Command.new(100, [s7, s8])
@yes_no_window.index = @menu_index
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.x = 270
@yes_no_window.y = 192
@command_window1 = Window_Command.new(160, [s5, s6])
@command_window1.index = @menu_index
@command_window1.x = 192
@command_window1.active = false
@command_window1.visible = false
@command_window1.index = -1
@gold_window = Window_Gold.new
@gold_window.y = @command_window.height
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@command_window.dispose
@command_window1.dispose
@confirm_window.dispose
@yes_no_window.dispose
@gold_window.dispose
end
def delay(seconds)
for i in 0...(seconds * 1)
sleep 0.01
Graphics.update
end
end
def update
@command_window.update
@command_window1.update
@yes_no_window.update
@gold_window.update
@confirm_window.update
if @command_window.active
update_command
return
end
if @command_window1.active
update_command1
return
end
if @yes_no_window.active
update_yes_no
confirm_update
return
end
end
def update_command
@confirm_window.visible = false
@yes_no_window.active = false
@yes_no_window.visible = false
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
bet = 500
if $game_party.gold >= bet
@command_window.active = false
@command_window1.active = true
@command_window1.visible = true
@command_window1.index = 0
else
$game_system.se_play($data_system.cancel_se)
end
when 1
$game_system.se_play($data_system.decision_se)
bet = 1000
if $game_party.gold >= bet
@command_window.active = false
@command_window1.active = true
@command_window1.visible = true
@command_window1.index = 0
else
$game_system.se_play($data_system.cancel_se)
end
when 2
$game_system.se_play($data_system.decision_se)
bet = 2500
if $game_party.gold >= bet
@command_window.active = false
@command_window1.active = true
@command_window1.visible = true
@command_window1.index = 0
else
$game_system.se_play($data_system.cancel_se)
end
when 3
$game_system.se_play($data_system.decision_se)
bet = 5000
if $game_party.gold >= bet
@command_window.active = false
@command_window1.active = true
@command_window1.visible = true
@command_window1.index = 0
else
$game_system.se_play($data_system.cancel_se)
end
when 4
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
@bet = bet
return
end
end
def update_command1
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window1.active = false
@command_window1.visible = false
@command_window.active = true
@command_window1.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window1.index
when 1
delay(10)
$game_system.se_play($data_system.decision_se)
dice = 0
i = rand(6)
text = sprintf("%02d", i)
if i < 3
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture(text+"win")
@sprite.x = 320
@sprite.y = 32
$game_party.gain_gold(@bet*2)
@gold_window.refresh
@command_window1.active = false
@command_window1.visible = false
delay(10)
@yes_no_window.active = true
@yes_no_window.visible = true
else
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture(text+"lose")
@sprite.x = 320
@sprite.y = 32
$game_party.lose_gold(@bet)
@gold_window.refresh
@command_window1.active = false
@command_window1.visible = false
delay(10)
@yes_no_window.active = true
@yes_no_window.visible = true
end
when 0
delay(10)
$game_system.se_play($data_system.decision_se)
dice = 1
i = rand(6)
text = sprintf("%02d", i)
if i > 2
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture(text+"win")
@sprite.x = 320
@sprite.y = 32
$game_party.gain_gold(@bet*2)
@gold_window.refresh
@command_window1.active = false
@command_window1.visible = false
delay(10)
@yes_no_window.active = true
@yes_no_window.visible = true
else
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture(text+"lose")
@sprite.x = 320
@sprite.y = 32
$game_party.lose_gold(@bet)
@gold_window.refresh
@command_window1.active = false
@command_window1.visible = false
delay(10)
@yes_no_window.active = true
@yes_no_window.visible = true
end
end
return
end
end
def confirm_update
@confirm_window.visible = true
@confirm_window.active = false
@yes_no_window.visible = true
@yes_no_window.z = 1500
string = "Play again"
cw = @confirm_window.contents.text_size(string).width
center = @confirm_window.contents.width/2 - cw /2
unless @drawn
@confirm_window.contents.draw_text(center, 0, cw, 30, string)
@drawn = true
end
end
def update_yes_no
@yes_no_window.z = 1500
if Input.trigger?(Input::C)
case @yes_no_window.index
when 0
$game_system.se_play($data_system.decision_se)
@command_window.active = true
@sprite.bitmap.dispose
@sprite.dispose
when 1
$game_system.se_play($data_system.cancel_se)
$scene=Scene_Map.new
@sprite.bitmap.dispose
@sprite.dispose
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene=Scene_Map.new
@sprite.bitmap.dispose
@sprite.dispose
end
return
end
end
and then extract it to your picture folder.
now you can play gambling ^-^