Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- # #
- # V's Prize Wheel Mini-Game #
- # Version 0.5 #
- # #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # Written By: V #
- # Last Edited: October 8, 2013 #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # #
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # ** Disclaimer #
- #------------------------------------------------------------------------------#
- # #
- # This script was intended for Non-commercial use only, if you wish to use #
- # this script in a commercial game please PM me at which ever site you found #
- # this script. Either way please give me credit in your game script as the #
- # writer of this script, and send me a PM abuot the release of the game/demo. #
- # #
- # Wooden Prize Wheel Image and Wooden Background Image found inside of the #
- # demo was drawn and contributed by Cap'n K'nuckles, and can only be used #
- # on his terms. #
- # #
- #------------------------------------------------------------------------------#
- # ** How To Use #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # #
- # * Set-Up prizes below in the script's customizable area. #
- # #
- # * To play the game just use one of the commands from below in an event's #
- # script call. #
- # #
- # When using your own prize wheel. #
- # prize_wheel(lable, cost, number_of_sections, prize_wheel, bg_fg, bg_fg_type) #
- # (There is an example in the demo of how to set-up a custom wheel.) #
- # #
- # When using default prize wheel. #
- # prize_wheel(lable, cost) #
- # #
- # * When setting-up the events, the lable and cost will determine which list #
- # to use the rewards from below. #
- # #
- # #
- #------------------------------------------------------------------------------#
- # ** Description #
- #------------------------------------------------------------------------------#
- # #
- # v0.1 #
- # ~=~=~=~ #
- # * This script creates a spin-the-wheel type prize game. #
- # #
- # v0.2 #
- # ~=~=~=~ #
- # * I added a lable feature to allow multitudes of same cost prize set-ups. #
- # I also added options to change the background/foreground. #
- # #
- # v0.3 #
- # ~=~=~=~ #
- # * I added a empty item type for no reward sections. #
- # #
- # v0.4 #
- # ~=~=~=~ #
- # * I set up a customizable audio area below. #
- # #
- # v0.5 #
- # ~=~=~=~ #
- # * I fix a bug wth the audio. #
- # #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- module V_Prize_Wheel
- module Specs
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- # #
- # Start Customizable Area. #
- # #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # #
- # ONLY EDIT AFTER THE EQUALS SYMBOL. #
- # #
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- #============================================================================
- # Audio
- #============================================================================
- BGM = ["Town3", 80, 100]
- Victory_ME = ["Item", 80, 100]
- Failure_ME = ["Gag", 80, 100]
- #============================================================================
- # Prize Set-Up
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # ** When seting-up the wheel start with the section at the bottom and go
- # counter-clockwise. (Look at the prize wheel image inside of the demo's
- # picture folder and use that along with the below set-up as a guide)
- #
- # ** Copy and Paste the below set-up to add different prizes lables
- # and costs.
- #
- # ** You may also include arrays for random items and ammounts.
- #
- #============================================================================
- Prizes = {
- #Lable
- "Example" => {
- #Cost #Items_Type Items/Amount(if gold) Section
- 5 => [[ "weapon", [1,2,3,4], 0 ],
- [ "gold", 1000, 1 ],
- [ "item", 1, 2 ],
- [ "item", [7,8], 3 ],
- [ "armor", 1, 4 ],
- [ "gold", 200, 5 ],
- [ "item", 2, 6 ],
- [ "item", 6, 7 ]
- ], # <--- End Cost
- #Cost #Items_Type Items/Amount(if gold) Section
- 10 => [[ "weapon", [1,2,3,4], 0 ],
- [ "gold", 1000, 1 ],
- [ "item", 1, 2 ],
- [ "item", [7,8], 3 ],
- [ "armor", 1, 4 ],
- [ "gold", 200, 5 ],
- [ "item", 2, 6 ],
- [ "item", 6, 7 ]
- ], # <--- End Cost
- }, # <--- End Lable
- #Lable
- "Example2" => {
- #Cost #Items_Type Items/Amount(if gold) Section
- 5 => [[ "weapon", 6, 0 ],
- [ "gold", [100,400], 1 ],
- [ "item", 10, 2 ],
- [ "item", 1, 3 ],
- [ "empty", 0, 4 ],
- [ "armor", [1,2,5], 5 ]
- ], # <--- End Cost
- }, # <--- End Lable
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- # #
- # DO NOT EDIT PAST THIS POINT UNLESS YOU KNOW WHAT YOUR DOING. #
- # #
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- }
- end
- end
- class Window_PrizeWheel_Choices < Window_Command
- def alignment
- return 1
- end
- def cost?
- $game_system.co <= $game_party.gold
- end
- def make_command_list
- add_command("Spin The Wheel", :start_spin, cost?)
- add_command("Nevermind", :cancel_spin)
- end
- end
- class Window_PrizeWheel_ChoicesText < Window_Base
- def initialize(x, y, width, height)
- super(x, y, width, height)
- text1 = "Give it a shot?"
- text2 = "Only #{$game_system.co} " + Vocab::currency_unit
- draw_v_text(-10, -30, width, height, text1, 1, 16)
- draw_v_text(-10, -10, width, height, text2, 1, 24)
- end
- def draw_v_text(x, y, width, height, text, alignment, size)
- reset_font_settings
- contents.font.size = size
- contents.draw_text(x, y, width, height, text, alignment)
- reset_font_settings
- end
- end
- class Window_PrizeWheel_Rewards < Window_Base
- include V_Prize_Wheel::Specs
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @rt = nil
- @ri = nil
- refresh
- end
- def draw_large_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- icon = Rect.new(x, y, 48, 48)
- contents.stretch_blt(icon, bitmap, rect)
- end
- def draw_v_text(x, y, width, height, text, alignment, size)
- reset_font_settings
- contents.font.size = size
- contents.draw_text(x, y, width, height, text, alignment)
- reset_font_settings
- end
- def draw_contents
- case
- when @rt < 3
- draw_item_reward
- when @rt == 3
- draw_gold_reward
- when @rt == 4
- draw_lose_reward
- end
- end
- def draw_item_reward
- RPG::ME.new(Victory_ME[0],Victory_ME[1],Victory_ME[2]).play
- draw_v_text(-10, -75, 300, 216, "You've Won A...", 1, 36)
- case @rt
- when 0
- item = $data_weapons[@ri]
- $game_party.gain_item(item, 1)
- draw_v_text(75, 0, 300, 216, item.name, 0, 36)
- draw_large_icon(item.icon_index, 20, 75)
- when 1
- item = $data_armors[@ri]
- $game_party.gain_item(item, 1)
- draw_v_text(75, 0, 300, 216, item.name, 0, 36)
- draw_large_icon(item.icon_index, 20, 75)
- when 2
- item = $data_items[@ri]
- $game_party.gain_item(item, 1)
- draw_v_text(75, 0, 300, 216, item.name, 0, 36)
- draw_large_icon(item.icon_index, 20, 75)
- end
- end
- def draw_gold_reward
- RPG::ME.new(Victory_ME[0],Victory_ME[1],Victory_ME[2]).play
- $game_party.gain_gold(@ri)
- text = @ri.to_s + " " + Vocab::currency_unit
- draw_v_text(-10, -75, 300, 216, "You've Won...", 1, 36)
- draw_v_text(-10, 0, 300, 216, text, 1, 36)
- end
- def draw_lose_reward
- RPG::ME.new(Failure_ME[0],Failure_ME[1],Failure_ME[2]).play
- draw_v_text(-10, -35, 300, 216, "You've Lost!", 1, 36)
- end
- def rr(prize)
- case prize[0]
- when "weapon"
- @rt = 0
- when "armor"
- @rt = 1
- when "item"
- @rt = 2
- when "gold"
- @rt = 3
- when "empty"
- @rt = 4
- end
- if prize[1].is_a?(Array)
- @ri = prize[1][rand(prize.size)]
- else
- @ri = prize[1]
- end
- refresh
- end
- def refresh
- contents.clear
- draw_contents unless @ri == nil
- end
- end
- class Scene_PrizeWheel < Scene_Base
- include V_Prize_Wheel::Specs
- def initialize
- super
- RPG::BGM.new(BGM[0], BGM[1], BGM[2]).play
- setup_vars
- draw_command_window
- draw_prize_wheel_window
- draw_reward_window
- end
- def setup_vars
- @pwro = 0
- @tico = 0
- @sttico = 0
- @rati = [40,45,50,55,60,65]
- @rastti = [40,45,50,55,60,65]
- @rasp = [50,60,70]
- @sp = @rasp[rand(3)]
- @ti = @rati[rand(6)]
- @stti = @rastti[rand(6)]
- @start = false
- @ssspwp = false
- @regiou = false
- end
- def draw_command_window
- @pwcw = Window_PrizeWheel_Choices.new(194, 200)
- @pwcw.set_handler(:start_spin, method(:start_prize_wheel))
- @pwcw.set_handler(:cancel_spin, method(:cancel_prize_wheel))
- @pwcwtw = Window_PrizeWheel_ChoicesText.new(164, 135, @pwcw.width + 60, 75)
- @pwcwtw.z = @pwcw.z - 1
- end
- def draw_prize_wheel_window
- @pw = Sprite.new
- @pw.bitmap = Cache.picture($game_system.prwhim)
- @pw.x = 281
- @pw.y = 255
- @pw.ox = @pw.width.to_f / 2
- @pw.oy = @pw.height.to_f / 2
- @pwfg = Sprite.new
- @pwfg.bitmap = Cache.picture($game_system.prwhbgfgim)
- @pwfg.z = 50 if $game_system.prwhbgfgimty == "fg"
- @pwfg.z = -50 if $game_system.prwhbgfgimty == "bg"
- end
- def draw_reward_window
- @rw = Window_PrizeWheel_Rewards.new(122, 125, 300, 166)
- @rw.openness = 0
- end
- def update_wheel_spins
- @tico += 1
- if @tico == @ti
- @ssspwp = true
- start = false
- else
- @pw.angle -= @sp
- @pwro -= @sp
- end
- end
- def stop_wheel_spin
- @sttico += 1
- if @sttico < @stti
- @sp -= 1
- @sttico = 0
- end
- if @sp == 0
- cpwa
- @ssspwp = false
- else
- @pw.angle -= @sp
- @pwro -= @sp
- end
- end
- def cpwa
- section = 0
- sections_width = (360 / $game_system.nuofse)
- angle = ((@pwro * -1) + (sections_width / 2)) + 270
- angle -= 360 until angle <= 360
- $game_system.nuofse.times { |i|
- min = (sections_width * i)
- max = ((sections_width * i) + sections_width)
- section = i if angle >= min && angle < max
- }
- p section
- srp(section)
- end
- def srp(section)
- prize = Prizes[$game_system.rl][$game_system.co][section]
- @rw.rr(prize)
- @rw.open
- @regiou = true
- end
- def start_prize_wheel
- $game_party.lose_gold($game_system.co)
- @pwcw.close
- @pwcw.unselect
- @pwcwtw.close
- @start = true
- end
- def cancel_prize_wheel
- @regiou = false
- return_scene
- RPG::BGM.stop
- end
- def update
- super
- cancel_prize_wheel if (Input.trigger?(:C) || Input.trigger?(:B)) && @regiou == true
- update_wheel_spins if @start == true
- stop_wheel_spin if @ssspwp == true
- end
- end
- class Game_System
- attr_accessor :co
- attr_accessor :rl
- attr_accessor :nuofse
- attr_accessor :prwhim
- attr_accessor :prwhbgfgim
- attr_accessor :prwhbgfgimty
- alias :i0420752452753 :initialize
- def initialize
- @co = 0
- @rl = ""
- @nuofse = 0
- @prwhim = ""
- @prwhbgfgim = ""
- @prwhbgfgimty = ""
- i0420752452753()
- end
- end
- class Game_Interpreter
- def prize_wheel(lable, cost, number_of_sections = 8, prize_wheel = "prize wheel", bg_fg = "prize wheel fg", image_type = "fg")
- $game_system.rl = lable
- $game_system.co = cost
- $game_system.nuofse = number_of_sections
- $game_system.prwhim = prize_wheel
- $game_system.prwhbgfgim = bg_fg
- $game_system.prwhbgfgimty = image_type
- SceneManager.call(Scene_PrizeWheel)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment