Hi, I was wondering if someone could help me convert a script from RPG maker VX to RPG maker VX Ace.
It's Rei's dance minigame script. I want to use it in a personal project. While I am aware that Shiggy made dance minigame script in 2016 specifically for VX Ace, it's not what I'm looking for as it lacks the a lot of features Rei's does. Problem is that it is not compactible with VX Ace as it is currently written, and only VX.
Here are the images specific to the script that are used for the arrow keys, combo words, numbers, etc
The script also requires two of Rei's other scripts that would also need to be converted.
Any help would be appreciated ^^
It's Rei's dance minigame script. I want to use it in a personal project. While I am aware that Shiggy made dance minigame script in 2016 specifically for VX Ace, it's not what I'm looking for as it lacks the a lot of features Rei's does. Problem is that it is not compactible with VX Ace as it is currently written, and only VX.
Ruby:
#===============================================================================
# TRANSLATOR'S NOTE:
# This script isn't mine. I only translate it too English from the original
# language. From now, I only translate things below. I translate this with
# permission from the creator himself, reijubv. Credit reijubv if you use this
# script. Would be nice if you credit me too. This script was originally posted
# at Rpgmakerid by reijubv and localized by me to rmvx.net.
# - wltr3565, the translator
#===============================================================================
# † [VX] † Rei Dance Minigame † †
# † *Only* a dancing minigame XD !! †
#-------------------------------------------------------------------------------
# † By reijubv [[email hidden]]
# † Rpgmakerid
# † Pubilshed: 08/02/2010
# † Version: 1.1.0b (04 May 2010)
#-------------------------------------------------------------------------------
# To read what has changed from the earlier versions, please read it in the
# Changelog.txt file that was bundled with this script demo.
#-------------------------------------------------------------------------------
# This is a minigame script that let's the player to press an arrow button
# with the correct timing to get some points.
# How to call the minigame :
# In the fourth tab of event commands, click script and type :
# dance_call(Id)
# Change id with the id of the sequences that you can configure below.
#-------------------------------------------------------------------------------
'
_CAUTION_
To use this script optimally, read the green-colored texts carefully in the
Rei module
'
#-------------------------------------------------------------------------------
# Credits:
# reijubv to make this script.
#-------------------------------------------------------------------------------
# Installation:
# Put this above Main, below Materials, edit Rei config.
#-------------------------------------------------------------------------------
# Requirements :
# Rei INI Read
# Rei Audio Player
# Vampyr Keyboard ( If you want to change the input )
#===============================================================================
$imported = {} if $imported == nil
$imported["Rei_"+"Dance"] = true
#===============================================================================
# Rei module
#===============================================================================
module Rei
module Dance
ARR_C = [];SEQ = {};ANI = [];AI_POWER = {}
# Set the buttons used here
# Recommended to use W A S D buttons.
# To use W A S D buttons, copy the Vampyr Keyboard script above this script
# and the Input.dll from this demo's folder.
UP = Input::UP
LEFT = Input::LEFT
DOWN = Input::DOWN
RIGHT = Input::RIGHT
# If you want the W A S D settings, delete the # mark at the 4 rows below
#UP = Keys::W
#LEFT = Keys::A
#DOWN = Keys::S
#RIGHT = Keys::D
# Button to pause the game.
PAUSE = Input::B
# Image to be used for telling the player that the game is currently paused.
PAUSE_PIC = "Pause"
# BGM to be played when the game is paused.
# format = [file,volume,pitch]
# If you don't want to use BGM while pausing, set the PAUSE_BGM = nil
PAUSE_BGM = ["Pause",100,100]
# Image for the arrows, for up down left right arrows, just give _up, _down,
# _left, and _right at the end of the filename.
# The images must be put in Graphics/Pictures folder.
ARROW = "Arrow"
# The order of the arrows : (V.1.10)
# 0 = down, 1 = left, 2 = right, 3 = up
" Please don't use the same number twice, swt"
ARROW_SEQ = [3,1,2,0]
# Animation to use at the arrow when the player presses the button.
# format : ANI[dir] = [anim_id_if_perfect,anim_id_if_good,anim_id_if_miss]
# Set it to 0 if you don't want to use one.
"WARNING!! Using animations (Especially with enormous numbers of frames and
sound effects) will give an enormous LAG as well!"
ANI[0] = 0 # up
ANI[1] = 0 # down
ANI[2] = 0 # left
ANI[3] = 0 # right
# Images for Combo, Perfect, Miss, Good, Score dan numbers
COMBO = "Combo"
PERFECT = "Perfect"
MISS = "Miss"
GOOD = "Good"
SCORE = ""
NUMBER = "Numbers1"
SCORE_NUM = "Numbers2"
# Configure the points here :
# If the player get's "Good", how many points ?
GOOD_POINT = 50
# If the player get's "Perfect", how many points ?
PERFECT_POINT = 100
# If the player get's "MISS", how many points ?
MISS_POINT = -25
# How many points to increase the GOOD's points for each combos?
GOOD_X_POINT = 1
# How many points to increase the PERFECT's points for each combos?
PERFECT_X_POINT = 2
# How many points to increase the MISS's points for each combos?
MISS_X_POINT = 0
# Set all of the game variables below to 0 if you don't want to use it
# Each variable ids used will store the statictics below
VAR_SCORE = 27
VAR_GOOD = 28
VAR_PERFECT = 29
VAR_MISS = 30
# Variable to record existed arrows
VAR_ARROW = 31
"SCORE MAXIMUM IS ONLY 6 DIGITS!!!"
# Configure the color for the arrows here
# if you want the arrow images like you have drew, just set all of it to 0
# red,green,blue
ARR_C[0] = [0,255,0] # UP arrow
ARR_C[1] = [255,255,0] # LEFT arrow
ARR_C[2] = [0,0,255] # DOWN arrow
ARR_C[3] = [255,0,0] # RIGHT arrow
#---------------------------------------------------------------------------
# Configure AI here . . .
#---------------------------------------------------------------------------
# Switch id to activate for challenging the AI
AI = 95
# AI's percentage to get points (Still buggy ??)
# Format : AI_POWER["level"] = percentage
AI_POWER["easy"] = 65
AI_POWER["normal"] = 75
AI_POWER["hard"] = 85
AI_POWER["insane"] = 95
# Store score of the AI ?
AI_SCORE_SAVE = true
# Variable ID for storing the AI's score if AI_SCORE_SAVE = true
VAR_AI_SCORE = 32
VAR_AI_GOOD = 34
VAR_AI_PERFECT = 32
VAR_AI_MISS = 35
#---------------------------------------------------------------------------
# To change the difficulty that will make the arrows harder to see, call
# this script via event"
# $game_temp.dance_lvl = level
# Change the level with one from below :
# "easy" => Arrows will always be visible.
# "normal" => Arrows can be seen from 3/4 of the screen's height
# "hard" => Arrows can be seen from 1/2 of the screen's height
# "insane" => Arrows can be seen from 1/4 of the screen's height
# Other than the 4 above will make an error occur.
#---------------------------------------------------------------------------
# If the corresponding arrow has been pressed the arrow will turn into grey,
# to let the player know that they don't have to brag about that arrow ;)
#---------------------------------------------------------------------------
# What scene to be opened after the dance scene is done?
SCENE = Scene_Map.new
#------------------------------------------
SEQ = {
#------------------------------------------
# Configure the sequences for the dance here
# format : id => [ speed, [seq1,seq2,seq3,seq4,etc], music, background ] ,
# id is the ID number for the sequence, that will be used while calling the
# dance scene.
# *speed is the arrow's speed.
# *seq1,seq2,etc . . are :
# x "up" OR "u" for spawning the up arrow
# x "down" OR "d" for spawning the down arrow
# x "left" OR "l" for spawning the left arrow
# x "right" OR "r" for spawning the right arrow
# x "rand" OR "x" to let the arrow spawn randomly
# x And numbers will indicate the number of frames to delay for the next
# x arrow to spawn.
# x besides those an error will occur.
# x the delay is in frames ( 60 frames = 1 seconds )
# x to evade a chance of bug like whenever the player has pressed the
# x button but the game didn't read it, don't let a same button to spawn
# x more than once in a short time, minimally there should be a delay.
# x Because some keyboard buttons cannot be pressed simultinously, and
# x you want to spawn more than 2 different sequences simultinously,
# x give it some delays . .
# 30 frames. example = "up", 10, "up" << wrong
# "up", "up" << wrong
# "up", 30, "up" << right
# * music is the music to be played while dancing, put it in the Audio/BGM
# * folder
# * background is the background image to use when dancing. The image must
# * be put in Graphics/Parallaxes folder.
# example : (I only made it crappily XD)
#--------------------------------------------------------------------
# to make a new one, copy paste / edit starting from the line below
#--------------------------------------------------------------------
0 => [ 3, # arrow speed
[10 , "up",30, "right",30, "up",60, "down",30, "down",10,
"left",30, "up",10 , "rand",30, "right",30, "up",60, "down",30,
"down",10, "left",30, "up", 10 , "up",30, "right",30, "up",60,
"down",30, "rand",10, "left",30, "rand", 10 , "up",30, "right",30,
"up",60, "down",30, "down",10, "left",30, "up",30,
"up", 20 , "rand",30, "right",30,
"up",20 , "down",20 , "left",10 , "right", 60,
"up",60, "rand",30, "down",10, "left",30, "up",10,
"rand", 10 , "up",30, "rand",30,
"up",60, "rand",30, "rand",10, "left",30, "up",10,
"rand", 20 , "rand",30, "rand",30,
"rand",60, "rand",30, "rand",10, "left",30, "up",10,
"up", 20 , "up",30, "right",30,
"up",60, "down",30, "down",10, "left",30, "up",60,
"rand",10 , "down",10 , "left",10 , "rand",
"up",60, "rand",30, "rand",10, "left",30, "up",10,
"rand", 20 , "rand",30, "rand",30,
"rand",60, "rand",30, "rand",10, "left",30, "up",10,
"up", 20 , "up",30, "right",30,
"up",60, "down",30, "down",10, "left",30, "up",60,
"rand",10 , "down",10 , "left",10 , "rand",
"up",60, "rand",30, "rand",10, "left",30, "up",10,
"rand", 20 , "rand",30, "rand",30,
"rand",60, "rand",30, "rand",10, "rand",30, "up",10,
"rand", 20 , "up",30, "right",30,
"up",60, "down",30, "down",10, "left",30, "up",60,
"rand",10 , "down",10 , "left",10 , "rand",
"up",60, "rand",30, "rand",10, "rand",30, "rand",10,
"rand", 20 , "rand",30, "rand",30,
"rand",60, "rand",30, "rand",10, "left",30, "rand",10,
"up", 20 , "rand",30, "right",30
],
# THE FILE MUST WITH THE EXTENSION!
# volume is about 0 to 1000
# music format : [file,volume]
["Dance3.mp3",1000], # music to use
"Image.png", # background to use
],
#------------------------------------------
# edit / copy paste here for easier setting
#-----------------------------------------
# add as much as you like here
#---------------------------------------------------------------------------
# To make scripters to be able to add features for this script, the features
# available are when the game ends and when updating the game, just scroll
# below and find def pre_start, def finish_game, def update_plugin, and
# def get_score
#---------------------------------------------------------------------------
};end
end
#===============================================================================
# Game_Temp, inserting the dance level here
#===============================================================================
class Game_Temp
attr_accessor :dance_lvl
alias rei_gmt_dnc_init initialize
def initialize
rei_gmt_dnc_init
@dance_lvl = "easy"
end
end
#===============================================================================
# Dance_Arrow sprite, for showing the arrows
#===============================================================================
class Dance_Arrow < Sprite_Base
attr_accessor (:clicked, :state)
def initialize(viewport = nil, dir = 0, speed = 1, ai = false)
super(viewport)
@dir = dir
@state = 0
# Checking the arrows' direction
case @dir
when 0;self.bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_up")
when 1;self.bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_left")
when 2;self.bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_down")
when 3;self.bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_right")
end
# Changing the color like was configured above
self.color.set(Rei::Dance::ARR_C[@dir][0],Rei::Dance::ARR_C[@dir][1],
Rei::Dance::ARR_C[@dir][2])
# Setting the arrows' coordinate
x_p = Rei::Dance::ARROW_SEQ.index(3-@dir)
self.x = self.bitmap.width * x_p
# If the arrow is for AI, x is increase by half of the screen's width
self.x += Graphics.width / 2 if ai
self.y = Graphics.height + self.bitmap.height + 32
self.z = 101
# Setting speed
@speed = speed
# clicked flag
@clicked = false
# Checking the dance level
case $game_temp.dance_lvl
when "easy"
when "normal";@distance=128
when "hard";@distance=64
when "insane";@distance=32
# if the level is not recognized, error occurs and the game crashes.
else;raise "Rei::Dance :\nDance level eror"
end
update
end
def dispose
self.bitmap.dispose
super
end
def update
super
# Decreasing the y coordinate as much as the speed
self.y -= @speed
# Turns the color into black if clicked
self.color.set(96,96,96) if @clicked
distance = self.y ** 2
# Changes the opacity based on the distance from the topmost screen if the
# lvl is not easy
self.opacity = 100*13000/((distance*370/@distance)+6000) if $game_temp.dance_lvl != "easy"
# Update stops if it's clicked
return if @clicked
@state = 0
@state = 2 if self.y.between?(-10,34)
@state = 1 if self.y.between?(0,24)
end
end
#===============================================================================
# Scene_Dance, to run the dance engine
#===============================================================================
class Scene_Dance < Scene_Base
def initialize(id = 0)
# Cppying sequence
@arr = Rei::Dance::SEQ[id][1].clone
@id = id
@len = @arr.size - 1
# Making sprite array for the player
@pbutton = []
@pbutton_mask = []
@combo_sprites = []
@score_sprites = []
@panim_sprite=[]
@arrows = []
# Index of the sequence starting from 0
@index = 0
# Making the background and sprite while pausing
@back = Sprite.new
@back.bitmap = Cache.parallax(Rei::Dance::SEQ[id][3])
@pause = Sprite.new
@pause.bitmap = Cache.parallax(Rei::Dance::PAUSE_PIC)
@pause.visible = false
@pause.x = @pause.ox = @pause.bitmap.width / 2
@pause.y = @pause.oy = @pause.bitmap.height / 2
@pause.z = 999
# Making viewport
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
# Making state sprite that the player can see
@state_sprite = Sprite.new
@state_sprite.bitmap = Cache.picture(Rei::Dance::GOOD)
@state_sprite.opacity = 0
# Making sprite to take screenshots of the screen
@temp_bck = Sprite.new
@temp_bck.z = 998
# Settign some integer variables
@delay = 0
@score = 0
@combo = 0
@score = 0
@old_score = 0
@old_combo = 0
@cmb = 0
# Terminating flag to check if the game is currently terminating
@terminating = false
# Paused flag to check if the game is currently paused
@paused = false
# Setting the arrow speed according to the sequence
@speed = Rei::Dance::SEQ[id][0]
# Making all of the audio to stop
RPG::BGM.stop
RPG::BGS.stop
RPG::ME.stop
RPG::SE.stop
# Resetting variables that's used to store up the game results
reset_variables
# Checking if using an AI, then making variables that will be used by the AI
if $game_switches[Rei::Dance::AI]
@ai_button = []
@ai_button_mask = []
@ai_combo_sprites = []
@ai_score_sprites = []
# Making animation sprites
@ai_anim_sprite=[]
@ai_arrows = []
@ai_state_sprite = Sprite.new
@ai_state_sprite.bitmap = Cache.picture(Rei::Dance::GOOD)
@ai_state_sprite.opacity = 0
@ai_old_combo = 0
@ai_combo = 0
@ai_cmb = 0
@ai_old_score = 0
@ai_score = 0
end
end
# Resetting variables that will be used to record the results
def reset_variables
$game_variables[Rei::Dance::VAR_PERFECT] = 0
$game_variables[Rei::Dance::VAR_SCORE] = 0
$game_variables[Rei::Dance::VAR_GOOD] = 0
$game_variables[Rei::Dance::VAR_MISS] = 0
$game_variables[Rei::Dance::VAR_ARROW] = 0
if $game_switches[Rei::Dance::AI] and Rei::Dance::AI_SCORE_SAVE
$game_variables[Rei::Dance::VAR_AI_PERFECT] = 0
$game_variables[Rei::Dance::VAR_AI_SCORE] = 0
$game_variables[Rei::Dance::VAR_AI_GOOD] = 0
$game_variables[Rei::Dance::VAR_AI_MISS] = 0
end
end
# Edit this if you want, this method will be executed before the dance starts
def pre_start
# Add your script here
#--------------------------
#--------------------------
end
# Starting scene
def start
# Calling pre_start if the user has made extra scripts
pre_start
# from 0..3
for i in 0..3
# Making sprites for buttons that's used by the player
@pbutton[i] = Sprite.new
@pbutton_mask[i] = Sprite.new
# Setting the bitmap that's used by the arrow button
case i
when 0;@pbutton[i].bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_up")
when 1;@pbutton[i].bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_left")
when 2;@pbutton[i].bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_down")
when 3;@pbutton[i].bitmap = Bitmap.new("Graphics/Pictures/#{Rei::Dance::ARROW}_right")
end
# Setting the button's origin
@pbutton[i].ox , @pbutton[i].oy = @pbutton[i].bitmap.width / 2 ,
@pbutton[i].bitmap.height / 2
# Changing the button color as set by the user
@pbutton[i].color.set(Rei::Dance::ARR_C[i][0],Rei::Dance::ARR_C[i][1],
Rei::Dance::ARR_C[i][2])
# Setting button coordinates
x_p = Rei::Dance::ARROW_SEQ.index(3-i)
@pbutton[i].x = @pbutton[i].bitmap.width/2+@pbutton[i].bitmap.width* x_p
@pbutton[i].y = @pbutton[i].bitmap.height / 2
@pbutton[i].z = 100
# Making the opacity a little transparant
@pbutton[i].opacity = 100
# Making the mask used for the buttons
@pbutton_mask[i].bitmap = @pbutton[i].bitmap
@pbutton_mask[i].x = @pbutton[i].x
@pbutton_mask[i].y = @pbutton[i].y
@pbutton_mask[i].z = 102
@pbutton_mask[i].ox = @pbutton[i].ox
@pbutton_mask[i].oy = @pbutton[i].oy
@pbutton_mask[i].opacity = 0
@pbutton_mask[i].color = @pbutton[i].color
# Making sprites for the animation
@panim_sprite[i] = Sprite_Base.new
@panim_sprite[i].x = @pbutton[i].x
@panim_sprite[i].y = @pbutton[i].y
@panim_sprite[i].z = @pbutton_mask[i].z
@panim_sprite[i].ox = @pbutton[i].ox
@panim_sprite[i].oy = @pbutton[i].oy
# If it's for AI, will be configured for AI
if $game_switches[Rei::Dance::AI]
@ai_button[i] = Sprite.new
@ai_button[i].bitmap = @pbutton[i].bitmap
@ai_button[i].color = @pbutton[i].color
@ai_button[i].x = @pbutton[i].x + Graphics.width / 2
@ai_button[i].y = @pbutton[i].y
@ai_button[i].ox = @pbutton[i].ox
@ai_button[i].oy = @pbutton[i].oy
@ai_arrows[i] = []
@ai_button[i].z = @pbutton[i].z
@ai_button[i].opacity = @pbutton[i].opacity
@ai_button_mask[i] = Sprite.new
@ai_button_mask[i].bitmap = @pbutton_mask[i].bitmap
@ai_button_mask[i].x = @pbutton[i].x + Graphics.width / 2
@ai_button_mask[i].y = @pbutton[i].y
@ai_button_mask[i].z = @pbutton_mask[i].z
@ai_button_mask[i].ox = @pbutton[i].ox
@ai_button_mask[i].oy = @pbutton[i].oy
@ai_button_mask[i].opacity = @pbutton_mask[i].opacity
@ai_button_mask[i].color = @pbutton[i].color
@ai_arrows[i] = []
@ai_anim_sprite[i] = Sprite_Base.new
@ai_anim_sprite[i].x = @pbutton[i].x + Graphics.width / 2
@ai_anim_sprite[i].y = @pbutton[i].y
@ai_anim_sprite[i].z = @pbutton_mask[i].z
@ai_anim_sprite[i].ox = @pbutton[i].ox
@ai_anim_sprite[i].oy = @pbutton[i].oy
end
# Making array for the arrows
@arrows[i] = []
end
# Making sprites for combo
for i in 0..2
@combo_sprites[i] = Sprite.new
@combo_sprites[i].x = 64 - 32 * i + 32
@combo_sprites[i].y = 68 + 32
@combo_sprites[i].visible = false
@combo_sprites[i].bitmap = Cache.picture(Rei::Dance::NUMBER)
if $game_switches[Rei::Dance::AI]
@ai_combo_sprites[i] = Sprite.new
@ai_combo_sprites[i].x = @combo_sprites[i].x + Graphics.width / 2
@ai_combo_sprites[i].y = @combo_sprites[i].y
@ai_combo_sprites[i].visible = @combo_sprites[i].visible
@ai_combo_sprites[i].bitmap = @combo_sprites[i].bitmap
end
end
# Making sprites for score
for i in 0..5
@score_sprites[i] = Sprite.new
@score_sprites[i].bitmap = Cache.picture(Rei::Dance::SCORE_NUM)
@score_sprites[i].x = 256 - @score_sprites[i].bitmap.width / 10 * i
@score_sprites[i].y = Graphics.height - @score_sprites[i].bitmap.height - 12
@score_sprites[i].visible = false
if $game_switches[Rei::Dance::AI]
@ai_score_sprites[i] = Sprite.new
@ai_score_sprites[i].bitmap = @score_sprites[i].bitmap
@ai_score_sprites[i].x = @score_sprites[i].x + Graphics.width / 2
@ai_score_sprites[i].y = @score_sprites[i].y
@ai_score_sprites[i].visible = @score_sprites[i].visible
end
end
# Making a sprite for the score label
@score_sprites[6] = Sprite.new
@score_sprites[6].bitmap = Cache.picture(Rei::Dance::SCORE)
@score_sprites[6].x = 0
@score_sprites[6].y = Graphics.height - @score_sprites[0].bitmap.height - 12
# Making sprite for the combo label
@combo_sprites[3] = Sprite.new
@combo_sprites[3].bitmap = Cache.picture(Rei::Dance::COMBO)
@combo_sprites[3].opacity = 0
@combo_sprites[3].x = 0
@combo_sprites[3].y = 68
# Making the coordinates for the state sprite
@state_sprite.x = Graphics.width / 2 - @state_sprite.bitmap.width
@state_sprite.y = 68
if $game_switches[Rei::Dance::AI]
@ai_score_sprites[6] = Sprite.new
@ai_score_sprites[6].bitmap = @score_sprites[6].bitmap
@ai_score_sprites[6].x = Graphics.width / 2
@ai_score_sprites[6].y = @score_sprites[6].y
@ai_combo_sprites[3] = Sprite.new
@ai_combo_sprites[3].bitmap = @combo_sprites[3].bitmap
@ai_combo_sprites[3].opacity = @combo_sprites[3].opacity
@ai_combo_sprites[3].x = Graphics.width / 2
@ai_combo_sprites[3].y = @combo_sprites[3].y
@ai_state_sprite.x = Graphics.width
@ai_state_sprite.y = @state_sprite.y
@ai_state_sprite.ox = @ai_state_sprite.bitmap.width
@ai_state_sprite.oy = 0
end
# Running the Rei Audio Player
Rei::Audio_Player.play(Rei::Dance::SEQ[@id][2][0],Rei::Dance::SEQ[@id][2][1])
end
def update
# Updating the user-made script
update_plugin
# Updating pause
update_pause
# Will finish game if index > array size, the arrows are empty, and delay 0
finish_game if @index >= @len && arrow_empty? && @delay <= 0
# Stops the update if it's currently paused or terminating the game
return if @terminating or @paused
# Decreasing delay
@delay -= 1 if @delay >= 0
# Making arrow when the delay is 0
summon_arrow if @delay <= 0
# Updating state
update_state
# Updating arrows
update_arrows
# Updating user input
update_input
# Updating AI
update_input_ai if $game_switches[Rei::Dance::AI]
# Updating combo
update_combo
# Updating the AI's combo
update_combo_ai if $game_switches[Rei::Dance::AI]
# Updating score
update_score
# Updating the AI's score
update_score_ai if $game_switches[Rei::Dance::AI]
end
# Updating pause
def update_pause
# Decreases the zoom from the pause if it's more than 1.0
@pause.zoom_x = @pause.zoom_y = @pause.zoom_x - 0.1 if @pause.zoom_x > 1.0
# Increasing opacity if it's below 255
@pause.opacity += 5 if @pause.opacity < 255
@temp_bck.opacity += 5 if @temp_bck.opacity < 255
# Checking if the user presses the pause button and toggles the pause
if Input.trigger?(Rei::Dance::PAUSE)
if @paused == true
@paused = false
else
@paused = true
end
pause(@paused)
end
end
def pause(un = false)
# If it's not paused yet
if un
# Pauses the audio player
Rei::Audio_Player.pause
# Running the pause BGM in the RPGMaker's way
Audio.bgm_play("Audio/BGM/"+Rei::Dance::PAUSE_BGM[0],Rei::Dance::PAUSE_BGM[1],
Rei::Dance::PAUSE_BGM[2]) unless Rei::Dance::PAUSE_BGM == nil
# Makes the background and pause opacity into 0
@pause.opacity = 0
@temp_bck.opacity = 0
# Taking screenshot
@temp_bck.bitmap = Graphics.snap_to_bitmap
@temp_bck.bitmap.blur
@temp_bck.color.set(128,128,128,96)
# Makes pause visible
@pause.visible = true
# Making the zoom pause to 2.0
@pause.zoom_x = @pause.zoom_y = 2.0
else
# Let's the RPGMaker's BGM to stop
RPG::BGM.stop
# Let's the audio player to resume
Rei::Audio_Player.resume
# Erases the used bitmap
@temp_bck.bitmap.dispose
# Pause will be not visible
@pause.visible = false
end
end
# Checking if the arrows are empty?
def arrow_empty?
cond = []
for i in 0..3
cond[i] = @arrows[i].empty?
end
return !cond.include?(false)
end
# Updating the player's state
def update_state
# Stops the update if the sprite has been disposed
return if @state_sprite.disposed?
# Decreases the zoom and opacity of the state
@state_sprite.opacity -= 5 if @state_sprite.opacity > 0
@state_sprite.zoom_x -= 0.1 if @state_sprite.zoom_x > 1.0
@state_sprite.zoom_y -= 0.1 if @state_sprite.zoom_y > 1.0
if $game_switches[Rei::Dance::AI]
@ai_state_sprite.opacity -= 5 if @state_sprite.opacity > 0
@ai_state_sprite.zoom_x -= 0.1 if @ai_state_sprite.zoom_x > 1.0
@ai_state_sprite.zoom_y -= 0.1 if @ai_state_sprite.zoom_y > 1.0
end
# Decreases the mask's opacity and zoom
for i in 0..3
@pbutton_mask[i].opacity -= 5 if @pbutton_mask[i].opacity > 0
@pbutton_mask[i].zoom_x -= 0.1 if @pbutton_mask[i].zoom_x > 1.0
@pbutton_mask[i].zoom_y -= 0.1 if @pbutton_mask[i].zoom_y > 1.0
if $game_switches[Rei::Dance::AI]
@ai_button_mask[i].opacity -= 5 if @ai_button_mask[i].opacity > 0
@ai_button_mask[i].zoom_x -= 0.1 if @ai_button_mask[i].zoom_x > 1.0
@ai_button_mask[i].zoom_y -= 0.1 if @ai_button_mask[i].zoom_y > 1.0
end
end
end
# Updating arrows
def update_arrows
for i in 0..3
@panim_sprite[i].update
# Delete 0 values from the array
@arrows[i].delete(0)
for j in 0..@arrows[i].size - 1
# Skip if the arrow is empty or 0
next if @arrows[i][j] == nil or @arrows[i][j] == 0
# Updates the arrow
@arrows[i][j].update
# If the y coordinate of the arrow is lower than the arrow's bitmap
if @arrows[i][j].y <= -@arrows[i][j].bitmap.height
# Get MISS if the arrow has not yet been clicked
get_score(Rei::Dance::MISS_POINT,0) if !@arrows[i][j].clicked
# Disposes the arrow
@arrows[i][j].dispose
# Sets the array with the corresponding arrow's index into 0
@arrows[i][j] = 0
end
end
end
# Updating the AI's arrow
if $game_switches[Rei::Dance::AI]
for i in 0..3
@ai_anim_sprite[i].update
@ai_arrows[i].delete(0)
for j in 0..@ai_arrows[i].size - 1
next if @ai_arrows[i][j] == nil or @ai_arrows[i][j] == 0
@ai_arrows[i][j].update
if @ai_arrows[i][j].y <= -68
ai_get_score(Rei::Dance::MISS_POINT,0) if !@ai_arrows[i][j].clicked
@ai_arrows[i][j].dispose
@ai_arrows[i][j] = 0
end
end
end
end
end
# Calls the arrow
def summon_arrow
# Unofficial patch: Checks if the index is the same as the sequence's size
return if @index == @arr.size
# If the current array with the current index is an array
if @arr[@index].is_a?(Integer)
# Will make the delay minimally 0
@delay = [@arr[@index],0].max
# If it's the string
elsif @arr[@index].is_a?(String)
# Checks the string
case @arr[@index]
when "up","u";dir = 0
when "left","l";dir = 1
when "down","d";dir = 2
when "right","r";dir = 3
when "rand","x";dir = rand(3)
# If the string is not recognized, the game crashes
else raise "Rei::Dance :\nSequence is not recognized"
end
# Makes a new arrow for the player
@arrows[dir] << Dance_Arrow.new(@viewport,dir,@speed)
# Makes a new arrow for the AI
@ai_arrows[dir] << Dance_Arrow.new(@viewport,dir,@speed, true) if $game_switches[Rei::Dance::AI]
# The arrow number increases by 1
$game_variables[Rei::Dance::VAR_ARROW] += 1
else; raise("Rei::Dance :\nSequence is not recognized")
end
# Index increased by one
@index += 1
end
# Updates the player's combo
def update_combo
# If the last combo is not the same as now
if @old_combo != @combo
@old_combo = @combo
# Makes the combo sprite's zoom to 2.0
for i in 0..2
@combo_sprites[i].zoom_x = @combo_sprites[i].zoom_y = 2.0
end
end
# The combo sprite will be visible when the combo is higher than 0
@combo_sprites[3].opacity = 255 if @combo > 0
@combo_sprites[3].opacity = 0 if @combo == 0
# Sets if the combo numbers can be visible or not
@combo_sprites[0].visible = @combo > 0
@combo_sprites[1].visible = @combo > 9
@combo_sprites[2].visible = @combo > 99
for i in 0..2
# Decreases zoom if the zoom is more than 1.0
@combo_sprites[i].zoom_x -= 0.1 if @combo_sprites[i].zoom_x > 1.0
@combo_sprites[i].zoom_y -= 0.1 if @combo_sprites[i].zoom_y > 1.0
end
# Configures the index of the bitmap for the combo number
index1 = @combo % 10 if @combo >= 0
index2 = (@combo % 100)/10 if @combo >= 10
index3 = (@combo % 1000)/100 if @combo >= 100
# The height is the bitmap's width / 10
sx = @combo_sprites[0].bitmap.width / 10
# Changes the bitmap
@combo_sprites[0].src_rect.set((index1 * sx),0,sx,@combo_sprites[0].bitmap.height) if @combo >= 0
@combo_sprites[1].src_rect.set((index2 * sx),0,sx,@combo_sprites[0].bitmap.height) if @combo >= 10
@combo_sprites[2].src_rect.set((index3 * sx),0,sx,@combo_sprites[0].bitmap.height) if @combo >= 100
end
# Updates the AI's combo
def update_combo_ai
# If the last combo is not the same as now
if @ai_old_combo != @ai_combo
@ai_old_combo = @ai_combo
# Makes the combo sprite's zoom to 2.0
for i in 0..2
@ai_combo_sprites[i].zoom_x = @ai_combo_sprites[i].zoom_y = 2.0
end
end
# The combo sprite will be visible when the combo is higher than 0
@ai_combo_sprites[3].opacity = 255 if @ai_combo > 0
@ai_combo_sprites[3].opacity = 0 if @ai_combo == 0
# Sets if the combo numbers can be visible or not
@ai_combo_sprites[0].visible = @ai_combo > 0
@ai_combo_sprites[1].visible = @ai_combo > 9
@ai_combo_sprites[2].visible = @ai_combo > 99
for i in 0..2
# Decreases zoom if the zoom is more than 1.0
@ai_combo_sprites[i].zoom_x -= 0.1 if @ai_combo_sprites[i].zoom_x > 1.0
@ai_combo_sprites[i].zoom_y -= 0.1 if @ai_combo_sprites[i].zoom_y > 1.0
end
# Configures the index of the bitmap for the combo number
index1 = @ai_combo % 10 if @ai_combo >= 0
index2 = (@ai_combo % 100)/10 if @ai_combo >= 10
index3 = (@ai_combo % 1000)/100 if @ai_combo >= 100
# The height is the bitmap's width / 10
sx = @ai_combo_sprites[0].bitmap.width / 10
# Changes the bitmap
@ai_combo_sprites[0].src_rect.set((index1 * sx),0,sx,@ai_combo_sprites[0].bitmap.height) if @ai_combo >= 0
@ai_combo_sprites[1].src_rect.set((index2 * sx),0,sx,@ai_combo_sprites[0].bitmap.height) if @ai_combo >= 10
@ai_combo_sprites[2].src_rect.set((index3 * sx),0,sx,@ai_combo_sprites[0].bitmap.height) if @ai_combo >= 100
end
# Updates the player's score
def update_score
# If the last score is not the same as now
if @old_score != @score
@old_score = @score
for i in 0..5
# Makes the score sprite's zoom to 2.0
@score_sprites[i].zoom_x = @score_sprites[i].zoom_y = 2.0
end
end
# Sets if the score can be seen or not
@score_sprites[0].visible = true
@score_sprites[1].visible = @score > 9
@score_sprites[2].visible = @score > 99
@score_sprites[3].visible = @score > 999
@score_sprites[4].visible = @score > 9999
@score_sprites[5].visible = @score > 99999
for i in 0..5
# Decreases the zoom if it's higher than 1
@score_sprites[i].zoom_x -= 0.1 if @score_sprites[i].zoom_x > 1.0
@score_sprites[i].zoom_y -= 0.1 if @score_sprites[i].zoom_y > 1.0
end
# Configures the index of the bitmap for the score number
index1 = @score % 10 if @score >= 0
index2 = (@score % 100) /10 if @score >= 10
index3 = (@score % 1000) /100 if @score >= 100
index4 = (@score % 10000) /1000 if @score >= 1000
index5 = (@score % 100000) /10000 if @score >= 10000
index6 = (@score % 1000000) /100000 if @score >= 100000
# The height is the bitmap's width / 10
sx = @score_sprites[0].bitmap.width / 10
# Changes the bitmap
@score_sprites[0].src_rect.set((index1 * sx),0,sx,@score_sprites[0].bitmap.height) if @score >= 0
@score_sprites[1].src_rect.set((index2 * sx),0,sx,@score_sprites[0].bitmap.height) if @score >= 10
@score_sprites[2].src_rect.set((index3 * sx),0,sx,@score_sprites[0].bitmap.height) if @score >= 100
@score_sprites[3].src_rect.set((index4 * sx),0,sx,@score_sprites[0].bitmap.height) if @score >= 1000
@score_sprites[4].src_rect.set((index5 * sx),0,sx,@score_sprites[0].bitmap.height) if @score >= 10000
@score_sprites[5].src_rect.set((index6 * sx),0,sx,@score_sprites[0].bitmap.height) if @score >= 100000
end
def update_score_ai
# If the last score is not the same as now
if @ai_old_score != @ai_score
@ai_old_score = @ai_score
for i in 0..5
# Makes the score sprite's zoom to 2.0
@ai_score_sprites[i].zoom_x = @ai_score_sprites[i].zoom_y = 2.5
end
end
# Sets if the score can be seen or not
@ai_score_sprites[0].visible = true
@ai_score_sprites[1].visible = @ai_score > 9
@ai_score_sprites[2].visible = @ai_score > 99
@ai_score_sprites[3].visible = @ai_score > 999
@ai_score_sprites[4].visible = @ai_score > 9999
@ai_score_sprites[5].visible = @ai_score > 99999
for i in 0..5
# Decreases the zoom if it's higher than 1
@ai_score_sprites[i].zoom_x -= 0.1 if @ai_score_sprites[i].zoom_x > 1.0
@ai_score_sprites[i].zoom_y -= 0.1 if @ai_score_sprites[i].zoom_y > 1.0
end
# Configures the index of the bitmap for the score number
index1 = @ai_score % 10 if @ai_score >= 0
index2 = (@ai_score % 100) /10 if @ai_score >= 10
index3 = (@ai_score % 1000) /100 if @ai_score >= 100
index4 = (@ai_score % 10000) /1000 if @ai_score >= 1000
index5 = (@ai_score % 100000) /10000 if @ai_score >= 10000
index6 = (@ai_score % 1000000) /100000 if @ai_score >= 100000
# The height is the bitmap's width / 10
sx = @score_sprites[0].bitmap.width / 10
# Changes the bitmap
@ai_score_sprites[0].src_rect.set((index1 * sx),0,sx,@ai_score_sprites[0].bitmap.height) if @ai_score >= 0
@ai_score_sprites[1].src_rect.set((index2 * sx),0,sx,@ai_score_sprites[0].bitmap.height) if @ai_score >= 10
@ai_score_sprites[2].src_rect.set((index3 * sx),0,sx,@ai_score_sprites[0].bitmap.height) if @ai_score >= 100
@ai_score_sprites[3].src_rect.set((index4 * sx),0,sx,@ai_score_sprites[0].bitmap.height) if @ai_score >= 1000
@ai_score_sprites[4].src_rect.set((index5 * sx),0,sx,@ai_score_sprites[0].bitmap.height) if @ai_score >= 10000
@ai_score_sprites[5].src_rect.set((index6 * sx),0,sx,@ai_score_sprites[0].bitmap.height) if @ai_score >= 100000
end
# You can add the contents of the finish_game, this will be executed when
# all of the sequence is over. But remember, call terminate at the end of it
def finish_game
# Add your script here
#--------------------------
#--------------------------
terminate
end
# You can edit the contents of update_plugin, this will be executed at each
# frames while the dance is still on going
def update_plugin
# Add your script here
#--------------------------
#--------------------------
end
# You can edit the contents of get_score, this will be executed at each time
# the player presses the arrow button
def get_score(score = 0, type = 0)
case type
when 1
@cmb = [@cmb + 1, 2].min
@combo += 1 if @cmb > 1
@state_sprite.bitmap = Cache.picture(Rei::Dance::PERFECT)
ex = @combo * Rei::Dance::PERFECT_X_POINT
$game_variables[Rei::Dance::VAR_PERFECT] += 1
when 2
@state_sprite.bitmap = Cache.picture(Rei::Dance::GOOD)
ex = @combo * Rei::Dance::GOOD_X_POINT
$game_variables[Rei::Dance::VAR_GOOD] += 1
when 0
ex = @combo * Rei::Dance::MISS_X_POINT
@combo = @cmb = 0
@state_sprite.bitmap = Cache.picture(Rei::Dance::MISS)
$game_variables[Rei::Dance::VAR_MISS] += 1
end
@state_sprite.opacity = 255
@state_sprite.zoom_x = @state_sprite.zoom_y = 2.0
@combo = [@combo,999].min
@score = [[@score + score + ex,9999999].min,0].max
$game_variables[Rei::Dance::VAR_SCORE] = @score
# Add your script here
#--------------------------
#--------------------------
end
# You can edit the contents of ai_get_score, this will be executed at each
# time the ai gets a score
def ai_get_score(score = 0, type = 0)
case type
when 1
@ai_cmb = [@ai_cmb + 1, 2].min
@ai_combo += 1 if @ai_cmb > 1
@ai_state_sprite.bitmap = Cache.picture(Rei::Dance::PERFECT)
ex = @ai_combo * Rei::Dance::PERFECT_X_POINT
$game_variables[Rei::Dance::VAR_AI_PERFECT] += 1 if Rei::Dance::AI_SCORE_SAVE
when 2
@ai_state_sprite.bitmap = Cache.picture(Rei::Dance::GOOD)
ex = @ai_combo * Rei::Dance::GOOD_X_POINT
$game_variables[Rei::Dance::VAR_AI_GOOD] += 1 if Rei::Dance::AI_SCORE_SAVE
when 0
ex = @ai_combo * Rei::Dance::MISS_X_POINT
@ai_combo = @ai_cmb = 0
@ai_state_sprite.bitmap = Cache.picture(Rei::Dance::MISS)
$game_variables[Rei::Dance::VAR_AI_MISS] += 1 if Rei::Dance::AI_SCORE_SAVE
end
@ai_state_sprite.opacity = 255
@ai_state_sprite.zoom_x = @ai_state_sprite.zoom_y = 2.0
@ai_combo = [@ai_combo,999].min
@ai_score = [[@ai_score + score + ex,9999999].min,0].max
$game_variables[Rei::Dance::VAR_AI_SCORE] = @ai_score if Rei::Dance::AI_SCORE_SAVE
# Add your script here
#--------------------------
#--------------------------
end
# This will happen when the player presses the button / ai got an instruction
def score(arrow, ai = false)
return if !arrow.is_a?(Sprite)
return if arrow.clicked
arrow.clicked = true
case arrow.state
when 1
get_score(Rei::Dance::PERFECT_POINT,1) if !ai
ai_get_score(Rei::Dance::PERFECT_POINT,1) if ai
when 2
get_score(Rei::Dance::GOOD_POINT,2) if !ai
ai_get_score(Rei::Dance::GOOD_POINT,2) if ai
when 0
get_score(Rei::Dance::MISS_POINT,0) if !ai
ai_get_score(Rei::Dance::MISS_POINT,0) if ai
end
end
# Terminates the dance minigame
def terminate
# Sets the terminating flag to true
@terminating = true
# Fadeouts the screen
Graphics.fadeout(60)
# Erases all of the bitmaps and sprites
for i in 0..3
@pbutton[i].bitmap.dispose
@pbutton[i].dispose
@combo_sprites[i].bitmap.dispose
@combo_sprites[i].dispose
@panim_sprite[i].dispose
if $game_switches[Rei::Dance::AI]
@ai_anim_sprite[i].dispose
@ai_pbutton[i].bitmap.dispose rescue nil
@ai_pbutton[i].dispose rescue nil
@ai_combo_sprites[i].bitmap.dispose rescue nil
@ai_combo_sprites[i].dispose rescue nil
end
end
for i in 0..3
for j in 0..@arrows[i].size - 1
@arrows[i][j].bitmap.dispose if @arrows[i][j] != nil
@arrows[i][j].dispose if @arrows[i][j] != nil
@arrows[i][j] = nil
if $game_switches[Rei::Dance::AI]
@ai_arrows[i][j].bitmap.dispose if @ai_arrows[i][j] != nil rescue nil
@ai_arrows[i][j].dispose if @ai_arrows[i][j] != nil rescue nil
@ai_arrows[i][j] = nil
end
end
end
for i in 0..6
@score_sprites[i].bitmap.dispose
@score_sprites[i].dispose
if $game_switches[Rei::Dance::AI]
@ai_score_sprites[i].bitmap.dispose rescue nil
@ai_score_sprites[i].dispose rescue nil
end
end
@back.bitmap.dispose
@back.dispose
@pause.bitmap.dispose
@pause.dispose
@temp_bck.dispose
@state_sprite.bitmap.dispose
@state_sprite.dispose
if $game_switches[Rei::Dance::AI]
@ai_state_sprite.bitmap.dispose rescue nil
@ai_state_sprite.dispose rescue nil
end
# Erases the viewport
@viewport.dispose
# Runs the Garbage Collector
GC.start
# Fades the audio by 60 frames
v = Rei::Dance::SEQ[@id][2][1]
r = v / 60
loop do
v -= r
Rei::Audio_Player.set_volume(v)
Graphics.update
break if v <= 0
end
Rei::Audio_Player.stop
Rei::Audio_Player.close
# Change scene
$scene = Rei::Dance::SCENE
end
# Updates the user's input
def update_input
if Input.trigger?(Rei::Dance::UP)
check_input(0)
@pbutton_mask[0].zoom_x = @pbutton_mask[0].zoom_y = 2.0
@pbutton_mask[0].opacity = 255
elsif Input.trigger?(Rei::Dance::LEFT)
check_input(1)
@pbutton_mask[1].zoom_x = @pbutton_mask[1].zoom_y = 2.0
@pbutton_mask[1].opacity = 255
elsif Input.trigger?(Rei::Dance::DOWN)
check_input(2)
@pbutton_mask[2].zoom_x = @pbutton_mask[2].zoom_y = 2.0
@pbutton_mask[2].opacity = 255
elsif Input.trigger?(Rei::Dance::RIGHT)
check_input(3)
@pbutton_mask[3].zoom_x = @pbutton_mask[3].zoom_y = 2.0
@pbutton_mask[3].opacity = 255
end
end
# Updates the simple brain of the AI (NEED HELP TO IMPROVE!!!)
def update_input_ai
arry = []
once = false
for i in 0..3
for j in 0..@ai_arrows[i].size - 1
arry[j] = -165
arry[j] = @ai_arrows[i][j].y if @ai_arrows[i][j].is_a?(Dance_Arrow)
if arry[j].between?(0,34) and @ai_arrows[i][j].is_a?(Dance_Arrow) #or arry[j].between?(0,24) )
if ![-165,999].include?(arry[j]) and rand(100) <= Rei::Dance::AI_POWER[$game_temp.dance_lvl] and
!@ai_arrows[i][j].clicked and @ai_arrows[i][j].y < Graphics.height and
@ai_arrows[i][j].y.between?(0,Graphics.height - @ai_arrows[i][j].bitmap.height)
if @ai_arrows[i][arry.index(arry.min)].is_a?(Dance_Arrow) and Rei::Dance::ANI[i][@ai_arrows[i][arry.index(arry.min)].state] != 0
@ai_anim_sprite[i].start_animation($data_animations[Rei::Dance::ANI[i][@ai_arrows[i][arry.index(arry.min)].state]])
end
score(@ai_arrows[i][arry.index(arry.min)],true)
@ai_button_mask[i].zoom_x = @ai_button_mask[i].zoom_y = 2.0
@ai_button_mask[i].opacity = 255
arry[j] = 999# if !@ai_arrows[i][j].is_a?(Sprite) or @ai_arrows[i][j].clicked
else;next;end
else;next;end
end
end
arry.clear
end
# Checks the input direction
def check_input(dir)
arry = []
for i in 0..@arrows[dir].size - 1
arry[i] = @arrows[dir][i].y if @arrows[dir][i].is_a?(Dance_Arrow)
arry[i] = 999 if !@arrows[dir][i].is_a?(Sprite) or @arrows[dir][i].clicked
y = arry.min
if @arrows[dir][arry.index(y)].is_a?(Dance_Arrow) and Rei::Dance::ANI[dir][@arrows[dir][arry.index(y)].state] != 0
@panim_sprite[dir].start_animation($data_animations[Rei::Dance::ANI[dir][@arrows[dir][arry.index(y)].state]])
end
score(@arrows[dir][arry.index(y)])
end
arry.clear
end
end
#===============================================================================
# Game_Interpreter, for the dance calling shortcut
#===============================================================================
class Game_Interpreter
def dance_call(id=0)
$scene = Scene_Dance.new(id)
return true
end
end
#===============================================================================
# END OF SCRIPT
#===============================================================================
Here are the images specific to the script that are used for the arrow keys, combo words, numbers, etc
The script also requires two of Rei's other scripts that would also need to be converted.
Ruby:
#===============================================================================
# [VX/XP] Rei INI Read
# Script ini gunanya untuk membaca string yang ada di dalam sebuah file
# berekstensi .ini
# Script ini berguna kalau kamu mau player bisa merubah settingan2 tertentu
# yang kamu buat di script tanpa perlu membongkar game dan hanya perlu merubah
# data2 yang ada di dalam 1 file yang bisa dibuka oleh notepad saja.
#------------------------------------------------------------------------------
# Cara pakai :
# Rei::INI.read(field,key,ini)
#------------------------------------------------------------------------------
# Contoh, kamu punya sebuah file bernama Game.ini (Yang ada di semua game RMVX/XP)
# di dalamnya ada tulisan seperti ini :
#
# [Game]
# RTP =RPGVX
# Library =RGSS202E.dll
# Scripts =Data\Scripts.rvdata
# Title =Game Kuda
#
# Nah [Game] adalah field (Jangan pakai [] saat memanggil scriptnya!)
# RTP, Library, Scripts, dan Title adalah key
# RPGVX, RGSS202E.dll, Data\Scripts.rvdata dan Game Kuda adalah data yang akan
# dibaca oleh script ini dan dikembalikan ke script pemanggil.
# Value yang di return SELALU string, jadi kamu harus merubahnya ke bentuk lain
# kalau kamu mau menggunakannya untuk value selain string.
#
# Untuk contoh diatas, cara pemanggilang scriptnya adalah :
# Rei::INI.read("Game","RTP","Game.ini")
# script diatas akan mengembalikan "RPGVX" ke yang memanggilnya.
#
# Semoga bermanfaat !
#===============================================================================
module Rei
module INI
GPPS = Win32API.new('kernel32','GetPrivateProfileString','pppplp','l')
def self.read(field,key,ini)
GPPS.call(field,key,"",result="\0"*256,256,".//#{ini}")rescue return result=""
return result.delete!("\0")
end
end
end
Ruby:
#------------------------------------------------------
# [VX/XP]Rei Audio Player
#------------------------------------------------------
# Audio player yg bisa di pause dsb :)
# Tapi cuma bisa setel 1 file (Wajar kan)
#
# requrement : Rei INI Read
#
# Usage = Rei::Audio_Player.play(file,volume,seek time)
# Rei::Audio_Player.set_volume(volume) => 0-1000
# Rei::Audio_Player.pause
# Rei::Audio_Player.stop
# Rei::Audio_Player.resume
# Rei::Audio_Player.close
#------------------------------------------------------
# Ingat untuk selalu memanggil close saat sudah selesai dg bermain audio,
# kalau tidak Audio Playernya tidak di close dg benar
# Nama file HARUS ditambahkan dg extensinya, e.g : "Miku.mp3"
#------------------------------------------------------
module Rei
module Audio_Player
PATH = './Audio/BGM/' # Atur path dimana audio di simpan
WMP = Win32API.new('winmm','mciSendString','ppll','v')
def self.play(audio_file,volume,seek=0)
file=PATH+audio_file
rm=Rei::INI.read("Game","Title","Game.ini")
master=Win32API.new('user32','FindWindowEx','llpp','l').call(0,0,nil,rm)
WMP.call("open #{file} alias FILE type mpegvideo style child parent "+master.to_s,0,0,0)
WMP.call("play FILE from #{seek}",0,0,0)
WMP.call("setaudio File volume to #{volume}",0,0,0)
end
def self.set_volume(v=800)WMP.call("setaudio FILE volume to #{v}",0,0,0);end
def self.pause;WMP.call("pause FILE",0,0,0);end
def self.resume;WMP.call("resume FILE",0,0,0);end
def self.stop;WMP.call("stop FILE",0,0,0);end
def self.close;WMP.call("close FILE",0,0,0);end
end
end
Any help would be appreciated ^^