#==============================================================================
# Opcje gry [XP] / Game Options [XP]
#==============================================================================
# Autor: Ayene
# Wersja: 1.1
#==============================================================================
# Skrypt pozwala dodać w menu opcje gry takie jak głośność muzyki, poziom
# trudności, czy wyłączenie animacji podczas walki.
# Instalacja: Umieść skrypt nad Main.
#==============================================================================
# By wywołać okno z opcjami gry, użyj komendy Script w zdarzeniu i wpisz:
# $scene = Scene_Option.new
#==============================================================================
module AYENE
# Nazwa pliku z opcjami gry (tworzy dodatkowy plik)
NAZWA_PLIKU = "Opcje_Gry"
# Menu, z którego przechodzi się do opcji:
# Scene_Menu - menu w grze, Scene_Title - ekran tytułowy, Scene_Map - mapa
PREVIOUS_SCENE = Scene_Title
# Główne opcje gry
OPTION_COMMANDS = [# <-- nie usuwać
"Głośność muzyki",
"Głośność efektów",
"Głośność kursora",
"Poziom trudności",
"Animacje",
"Obrażenia",
"Domyślne",
"Zatwierdź",
"Anuluj"
]# <-- nie usuwać
# Nazwy poleceń horyzontalnych
OPTION_SUBCOMMANDS = [# <-- nie usuwać
["Łatwy", "Normalny", "Trudny"], # Poziom trudności
["Włączone", "Wyłączone"], # Animacje
["Włączone", "Wyłączone"], # Obrażenia
]# <-- nie usuwać
# Treść okna pomocy
OPTION_HELP = [# <-- nie usuwać
"Dostosowuje głośność muzyki w tle (BGM i ME).",
"Dostosowuje głośność efektów dźwiękowych (BGS).",
"Dostosowuje głośność dźwięków systemowych (SE).",
"Ustawia poziom trudności bestii.(łatwy poziom więcej expa i złota)",
"Włącza/Wyłącza animacje podczas walki.",
"Kontroluje wyświetlanie obrażeń podczas walki.",
"Przywraca ustawienia domyślne.",
"Zatwierdza wprowadzone zmiany i wraca do Menu.",
"Anuluje wprowadzone zmiany i zamyka okno."
] # <-- nie usuwać
# Ustawienia trudności przeciwników (mnożnik statystyk)
ENEMY_DIF = [ # <-- nie usuwać
#hp atk str dex agi int exp złoto
[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 1.5], # poziom łatwy
[1, 1, 1, 1, 1, 1, 1, 1], # poziom normalny
[1.5, 1.5, 1.2, 1.2, 1.2, 1.2, 1, 1], # poziom trudny
]# <-- nie usuwać
end
#==============================================================================
# ** Game_Option
#==============================================================================
class Game_Option
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :bgm_volume # BGM volume
attr_accessor :bgs_volume # BGS volume
attr_accessor :se_volume # SE volume
attr_accessor :difficulty_id # difficulty
attr_accessor :animation # animation
attr_accessor :show_damage # show damage
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@bgm_volume = 100 # 0~100
@bgs_volume = 80 # 0~100
@se_volume = 60 # 0~100
@difficulty_id = 1 # 0 - łatwo, 1 - normalnie, 2 - trudno
@animation = 0 # 0 - włączone, 1 - wyłączone
@show_damage = 0 # 0 - włączone, 1 - wyłączone
@filename = AYENE::NAZWA_PLIKU + ".rxdata"
end
#--------------------------------------------------------------------------
# * Get Difficulty
#--------------------------------------------------------------------------
def difficulty
return AYENE::ENEMY_DIF[@difficulty_id]
end
#--------------------------------------------------------------------------
# * Save Option
#--------------------------------------------------------------------------
def save
file = File.open(@filename, "wb")
Marshal.dump($game_option, file)
file.close
end
#--------------------------------------------------------------------------
# * Load Option
#--------------------------------------------------------------------------
def load
if FileTest.exist?(@filename)
file = File.open(@filename, "rb")
$game_option = Marshal.load(file)
file.close
end
end
end
#==============================================================================
# ** Game_System
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Play Background Music
# bgm : background music to be played
#--------------------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/" + bgm.name, $game_option.bgm_volume, bgm.pitch)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Play Background Sound
# bgs : background sound to be played
#--------------------------------------------------------------------------
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil and bgs.name != ""
Audio.bgs_play("Audio/BGS/" + bgs.name, $game_option.bgs_volume, bgs.pitch)
else
Audio.bgs_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Play Music Effect
# me : music effect to be played
#--------------------------------------------------------------------------
def me_play(me)
if me != nil and me.name != ""
Audio.me_play("Audio/ME/" + me.name, $game_option.bgm_volume, me.pitch)
else
Audio.me_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Play Sound Effect
# se : sound effect to be played
#--------------------------------------------------------------------------
def se_play(se)
if se != nil and se.name != ""
Audio.se_play("Audio/SE/" + se.name, $game_option.se_volume, se.pitch)
end
end
end
#==============================================================================
# ** Window_HorCommand
#==============================================================================
class Window_HorCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(y, commands, type)
super(200, y, commands.size * 135 + 32, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = commands.size
@column_max = commands.size
@commands = commands
@type = type
refresh
self.index = -1
self.opacity = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
color = disabled_color
case @type
when 0
color = normal_color if i == $game_option.difficulty_id
when 1
color = normal_color if i == $game_option.animation
when 2
color = normal_color if i == $game_option.show_damage
end
x = 4 + i * 148
self.contents.font.color = color
self.contents.draw_text(x, 0, 128, 32, @commands[i])
end
end
end
#==============================================================================
# ** Window_VolCommand
#==============================================================================
class Window_VolCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(y, type)
super(200, y, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@type = type
refresh
self.index = -1
self.opacity = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
case @type
when 0
vol = $game_option.bgm_volume
when 1
vol = $game_option.bgs_volume
when 2
vol = $game_option.se_volume
end
w = 150
max = 100
rate = (vol < max ? vol * w / max : w) * (w/100)
color1 = Color.new(243, 184, 70, 192)
color2 = Color.new(0, 0, 80, 192)
self.contents.gradient_bar_volume(4, 8, w, color1, color2, rate)
text = sprintf("%d%%", vol)
self.contents.draw_text(w+20, 0, 76, 32, text, 0)
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias aye_sctitle_main main
def main
filename = AYENE::NAZWA_PLIKU + ".rxdata"
if FileTest.exist?(filename)
file = File.open(filename, "rb")
$game_option = Marshal.load(file)
file.close
else
$game_option = Game_Option.new
$game_option.save
end
aye_sctitle_main
end
end
#==============================================================================
# ** Scene_Option
#==============================================================================
class Scene_Option
include AYENE
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@dummy_window = Window_Base.new(0, 64, 640, 416)
@command_window = Window_Command.new(200, OPTION_COMMANDS)
@command_window.x = 0
@command_window.y = 64
@command_window.opacity = 0
@bgs = $game_option.bgs_volume
@bgm = $game_option.bgm_volume
@se = $game_option.se_volume
@help_window = Window_Help.new
@help_window.set_text(OPTION_HELP[@command_window.index])
@sub_command_window = []
y = 64
3.times {|i|
@sub_command_window.push(Window_VolCommand.new(y, i))
y += 32
}
3.times {|i|
@sub_command_window.push(Window_HorCommand.new(y, OPTION_SUBCOMMANDS[i], i))
y += 32
}
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@help_window.dispose
@dummy_window.dispose
for i in @sub_command_window
i.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
for i in @sub_command_window
i.update
end
@command_window.update
@help_window.set_text(OPTION_HELP[@command_window.index])
if @command_window.active
update_command
return
else
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$game_option.load
return_scene
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @command_window.index
when 0, 1, 2
@command_window.active = false
@sub_command_window[@command_window.index].active = true
when 3
@command_window.active = false
@sub_command_window[@command_window.index].active = true
@sub_command_window[@command_window.index].index = $game_option.difficulty_id
when 4
@command_window.active = false
@sub_command_window[@command_window.index].active = true
@sub_command_window[@command_window.index].index = $game_option.animation
when 5
@command_window.active = false
@sub_command_window[@command_window.index].active = true
@sub_command_window[@command_window.index].index = $game_option.show_damage
when 6
$game_option = Game_Option.new
subwindow_refresh
when 7
$game_option.save
return_scene
when 8
$game_option.load
return_scene
end
return
end
end
#--------------------------------------------------------------------------
# * Return Scene
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Window Refresh
#--------------------------------------------------------------------------
def subwindow_refresh
for i in @sub_command_window
i.refresh
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
if Input.press?(Input::RIGHT) and @command_window.index == 0 and $game_option.bgm_volume < 100
$game_option.bgm_volume += 1
@sub_command_window[@command_window.index].refresh
end
if Input.press?(Input::LEFT) and @command_window.index == 0 and $game_option.bgm_volume > 0
$game_option.bgm_volume -= 1
@sub_command_window[@command_window.index].refresh
end
if Input.press?(Input::RIGHT) and @command_window.index == 1 and $game_option.bgs_volume < 100
$game_option.bgs_volume += 1
@sub_command_window[@command_window.index].refresh
end
if Input.press?(Input::LEFT) and @command_window.index == 1 and $game_option.bgs_volume > 0
$game_option.bgs_volume -= 1
@sub_command_window[@command_window.index].refresh
end
if Input.press?(Input::RIGHT) and @command_window.index == 2 and $game_option.se_volume < 100
$game_option.se_volume += 1
@sub_command_window[@command_window.index].refresh
end
if Input.press?(Input::LEFT) and @command_window.index == 2 and $game_option.se_volume > 0
$game_option.se_volume -= 1
@sub_command_window[@command_window.index].refresh
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
if @command_window.index == 0
$game_option.bgm_volume = @bgm
@sub_command_window[@command_window.index].refresh
end
if @command_window.index == 1
$game_option.bgs_volume = @bgs
@sub_command_window[@command_window.index].refresh
end
if @command_window.index == 2
$game_option.se_volume = @se
@sub_command_window[@command_window.index].refresh
end
@command_window.active = true
@sub_command_window[@command_window.index].active = false
@sub_command_window[@command_window.index].index = -1
return
end
if Input.trigger?(Input::C)
index = @sub_command_window[@command_window.index].index
$game_system.se_play($data_system.decision_se)
case @command_window.index
when 0
@bgm = $game_option.bgm_volume
when 1
@bgs = $game_option.bgs_volume
when 2
@se = $game_option.se_volume
when 3
$game_option.difficulty_id = index
when 4
$game_option.animation = index
when 5
$game_option.show_damage = index
end
@sub_command_window[@command_window.index].refresh
@command_window.active = true
@sub_command_window[@command_window.index].active = false
@sub_command_window[@command_window.index].index = -1
return
end
end
end
#==============================================================================
# ** RPG::Sprite
#==============================================================================
class RPG::Sprite < ::Sprite
#--------------------------------------------------------------------------
# * Draw Damage
#--------------------------------------------------------------------------
alias aye_sprite_damage damage
def damage(*args)
return aye_sprite_damage(*args) if $game_option.show_damage == 0
end
#--------------------------------------------------------------------------
# * Show Animation
#--------------------------------------------------------------------------
alias aye_sprite_animation animation
def animation(*args)
return aye_sprite_animation(*args) if $game_option.animation == 0
end
end
#==============================================================================
# ** RPG::Enemy
#==============================================================================
class RPG::Enemy
#--------------------------------------------------------------------------
# * MaxHP
#--------------------------------------------------------------------------
alias aye_enemy_maxhp maxhp
def maxhp
return (aye_enemy_maxhp * $game_option.difficulty[0]).round
end
#--------------------------------------------------------------------------
# * Attack
#--------------------------------------------------------------------------
alias aye_enemy_atk atk
def atk
return (aye_enemy_atk * $game_option.difficulty[1]).round
end
#--------------------------------------------------------------------------
# * Strength
#--------------------------------------------------------------------------
alias aye_enemy_str str
def str
return (aye_enemy_str * $game_option.difficulty[2]).round
end
#--------------------------------------------------------------------------
# * Dexterity
#--------------------------------------------------------------------------
alias aye_enemy_dex dex
def dex
return (aye_enemy_dex * $game_option.difficulty[3]).round
end
#--------------------------------------------------------------------------
# * Agility
#--------------------------------------------------------------------------
alias aye_enemy_agi agi
def agi
return (aye_enemy_agi * $game_option.difficulty[4]).round
end
#--------------------------------------------------------------------------
# * Inteligence
#--------------------------------------------------------------------------
alias aye_enemy_int int
def int
return (aye_enemy_int * $game_option.difficulty[5]).round
end
#--------------------------------------------------------------------------
# * EXP
#--------------------------------------------------------------------------
alias aye_enemy_exp exp
def exp
return (aye_enemy_exp * $game_option.difficulty[6]).round
end
#--------------------------------------------------------------------------
# * Gold
#--------------------------------------------------------------------------
alias aye_enemy_gold gold
def gold
return (aye_enemy_gold * $game_option.difficulty[7]).round
end
end
#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Draw Gradient Fill Rectangle (Volume Bar)
#--------------------------------------------------------------------------
def gradient_bar_volume(x, y, w, color1, color2, rate)
fill_rect(x, y+1, w+2, 14, Color.new(0, 0, 0, 150))
(1..4).each {|i|
color = Color.new(color2.red*i/4, color2.green*i/4, color2.blue*i/4, 255)
fill_rect(x + 2, (y + i * 2)-1, w-2, 18 - i * 4, color)
color = Color.new(color1.red*i/4, color1.green*i/4, color1.blue*i/4, 255)
fill_rect(x + 2, (y + i * 2)-1, rate-2, 18 - i * 4, color)}
end
end