Mam taki problem:
Mam taki skrypt na "fajne" okno "Plecaka"...
Spoiler:
Cytat:
#==============================================================================
# Item System Diablo Style
#------------------------------------------------------------------------------
# By DarkSchneider
# www.rpg2s.net
#------------------------------------------------------------------------------
# Credit to Schwarz for draw_line
#==============================================================================
class Scene_Item2
def initialize(actor_index = 0)
@actor_index = actor_index
end
def main
# Make help window, item window
s1 = "Urzyj"
s2 = "Przesuń"
s3 = "Wyrzuć"
@command_window = Window_Command.new(193, [s1, s2 , s3])
@command_window.y = 64
@help_window = Window_Help.new
@grid = Window_Grid.new(@actor_index)
@grid.active = false
# Associate help window
@grid.help_window = @help_window
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@window_pc = Window_Base.new(0,192,193,287)
@window_pc.contents = Bitmap.new(161,255)
@window_pc.draw_actor_name($game_party.actors[@actor_index], 10, 0)
@window_pc.draw_actor_picture($game_party.actors[@actor_index], 80, 250)
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
@cursor_icon.dispose if @cursor_icon != nil
# Dispose of windows
@command_window.dispose
@help_window.dispose
#@item_window.dispose
@target_window.dispose
@grid.dispose
@window_pc.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@help_window.update
@target_window.update
@grid.update
if @command_window.active
update_command
return
end
# If item window is active: call update_item
if @grid.active
case @grid.mode
when 0
update_usa
when 1
@cursor_icon = Cursor_Icon.new if @cursor_icon == nil
@cursor_icon.visible = false
update_muovi
when 2
update_lascia
when 3
@cursor_icon.update
update_muovi2
end
return
end
# If target window is active: call update_target
if @target_window.active
update_target
return
end
end
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(0)
return
end
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # use
# Play decision SE
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@grid.active = true
@grid.set = 0
@grid.mode = @command_window.index
when 1 # move
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@grid.active = true
@grid.set = 0
@grid.mode = @command_window.index
when 2 # drop
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@grid.active = true
@grid.set = 0
@grid.mode = @command_window.index
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_usa
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@command_window.active = true
@grid.active = false
@grid.set = - 1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = @grid.item
# If not a use item
unless @item.is_a?(RPG::Item)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If it can't be used
unless $game_party.item_can_use?(@item.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If effect scope is an ally
if @item.scope >= 3
# Activate target window
@grid.active = false
#@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Set cursor position to effect scope (single / all)
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# If effect scope is other than an ally
else
# If command event ID is valid
if @item.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @item.common_event_id
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1, false)
# Draw item window item
@grid.delete_item
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
def update_target
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If unable to use because items ran out
unless $game_party.item_can_use?(@item.id)
# Remake item window contents
@grid.refresh
end
# Erase target window
@grid.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If items are used up
if @grid.item_del?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply item effects to entire party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If single target
if @target_window.index >= 0
# Apply item use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# If an item was used
if used
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1, false)
# Redraw item window item
@grid.delete_item
end
# Remake target window contents
@target_window.refresh
# If all party members are dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If common event ID is valid
if @item.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If item wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
def update_muovi
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@command_window.active = true
@grid.active = false
@grid.set = - 1
return
end
if Input.trigger?(Input::C)
if @grid.item != nil
@grid.get_item
bitmap = Bitmap.new(32,32)
x = 4 + (@grid.cursor_rect.width == 32 ? 0 : 18)
y = 4 + (@grid.cursor_rect.height == 32 ? 0 : 32)
bitmap.blt(0,0,@grid.contents,Rect.new(@grid.cursor_rect.x + x,
@grid.cursor_rect.y + y,@grid.cursor_rect.width,@grid.cursor_rect.height))
def update_lascia
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@command_window.active = true
@grid.active = false
@grid.set = - 1
return
end
if Input.trigger?(Input::C)
if @grid.item != nil
@grid.delete_item
end
return
end
end
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@grid.redraw_item(false)
@grid.mode = 1
return
end
if Input.trigger?(Input::C)
if @grid.empty?
@grid.redraw_item
@cursor_icon.visible = false
@grid.mode = 1
end
return
end
end
end
class Window_Selectable < Window_Base
alias old_initialize initialize
def initialize(x, y, width, height)
old_initialize(x, y, width, height)
if self.is_a?(Window_Grid)
@x = 0
@y = 0
end
end
alias old_update update
def update
if !self.is_a?(Window_Grid)
old_update
return
end
super
item = $game_party.actors[@actor_index].item_grid
# If cursor is movable
if self.active and @item_max > 0 and @x >= 0
# If pressing down on the directional buttons
if Input.repeat?(Input::DOWN)
@y = -1 if @y == item.size - (self.cursor_rect.height == 96 ? 3 : 1)
@y += 2 if item[@y][@x][1] == "w" or item[@y][@x][1] == "a"
if item[@y + 1][@x][1] == "r" and item[@y + 1][@x - 1][1] == "a"
@x -= 1
end
@y += 1
$game_system.se_play($data_system.cursor_se)
end
# If the up directional button was pressed
if Input.repeat?(Input::UP)
@y = item.size if @y - 1 == -1
@y -= 2 if item[@y - 1][@x][1] == "e" or item[@y - 1][@x][1] == "r"
@x -= 1 if item[@y - 1][@x - 1][1] == "a"
@y -= 1
$game_system.se_play($data_system.cursor_se)
end
# If the right directional button was pressed
if Input.repeat?(Input::RIGHT)
if @x + (self.cursor_rect.width == 64 ? 2 : 1) == item[@y].size
@x = 0
@y -= 1 if item[@y - 1][@x][1] == "a"
@y -= 2 if item[@y - 2][@x][1] == "a"
else
@x += 1 if item[@y][@x][1] == "a"
if item[@y][@x + 1][1] == "r"
@y -= 1 if item[@y - 1][@x + 1][1] == "a"
@y -= 2 if item[@y - 2][@x + 1][1] == "a"
end
if item[@y][@x + 1][1] == "e"
@y -= 1
@y -= 1 if item[@y - 1][@x + 1][1] == "w"
end
@x += 1
end
$game_system.se_play($data_system.cursor_se)
end
# If the left directional button was pressed
if Input.repeat?(Input::LEFT)
@x = item[@y].size if @x - 1 == -1
if item[@y][@x - 1][1] == "r"
@x -= 1
@y -= 1 if item[@y - 1][@x - 1][1] == "a"
@y -= 2 if item[@y - 2][@x - 1][1] == "a"
end
if item[@y][@x - 1][1] == "e"
@y -= 1
@y -= 1 if item[@y - 1][@x - 1][1] == "w"
end
@x -= 1
$game_system.se_play($data_system.cursor_se)
end
end
# Update help text (update_help is defined by the subclasses)
if self.active and @help_window != nil
update_help
end
# Update cursor rectangle
update_cursor_rect
end
end
def draw_grid
@window.contents.fill_rect(0, 0, width - 32, height - 32, Color.new(255,255,255))
i = 0
color = Color.new(0,0,0)
while i < self.contents.height
draw_line(0, i, self.contents.width, i, color)
i += 32
end
i = 0
while i < self.contents.width
draw_line(i, 0, i, self.contents.width, color)
i += 32
end
end
def draw_line(sx, sy, ex, ey, color)
rad = Math.atan2(ey-sy, ex-sx)
dx = Math.cos(rad)
dy = Math.sin(rad)
while (sx - ex).abs > 1 || (sy - ey).abs > 1
sx += dx
sy += dy
@window.contents.set_pixel(sx, sy, color)
end
end
def refresh
@item_max = 0
item = $game_party.actors[@actor_index].item_grid
for i in 0..item.size - 1
for j in 0..item[i].size - 1
if item[i][j][0]!= 0 and item[i][j][1] != "r" and item[i][j][1] != "e"
@item_max += 1
end
end
end
for i in 0..item.size - 1
for j in 0..item[i].size - 1
draw_item(item[i][j][0], item[i][j][1], i , j)
end
end
end
def update_cursor_rect
# If cursor position is less than 0
if @x < 0
self.cursor_rect.empty
return
end
# Calculate cursor width
case $game_party.actors[@actor_index].item_grid[@y][@x][1]
when "i"
cursor_width = 32
cursor_height = 32
when "w"
cursor_width = 32
cursor_height = 96
when "a"
cursor_width = 64
cursor_height = 96
else
cursor_width = 32
cursor_height = 32
end
# Calculate cursor coordinates
x = @x * 32
y = @y * 32
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, cursor_height)
end
def item
i = $game_party.actors[@actor_index].item_grid[@y][@x][0]
case $game_party.actors[@actor_index].item_grid[@y][@x][1]
when "i"
return $data_items[i]
when "w"
return $data_weapons[i]
when "a"
return $data_armors[i]
else return nil
end
end
def item_del?
if $game_party.actors[@actor_index].item_grid[@y][@x][0] == 0
# Unusable
return true
else
return false
end
end
def dispose
super
@window.dispose
@grid_color.dispose
@mini_help.dispose
end
def get_item
@item_saved = [$game_party.actors[@actor_index].item_grid[@y][@x][0],
$game_party.actors[@actor_index].item_grid[@y][@x][1], @x, @y]
end
def redraw_item(f = true)
if f
x = 4 + (@x * 32)
y = @y * 32
else
x = 4 + (@item_saved[2] * 32)
y = @item_saved[3] * 32
tx = @x
ty = @y
@x = @item_saved[2]
@y = @item_saved[3]
end
draw_item(@item_saved[0], @item_saved[1], @y , @x)
case @item_saved[1]
when "i"
$game_party.actors[@actor_index].item_grid[@y][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y][@x][1] = @item_saved[1]
when "w"
$game_party.actors[@actor_index].item_grid[@y][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y][@x][1] = @item_saved[1]
$game_party.actors[@actor_index].item_grid[@y + 1][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y + 1][@x][1] = "e"
$game_party.actors[@actor_index].item_grid[@y + 2][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y + 2][@x][1] = "e"
when "a"
$game_party.actors[@actor_index].item_grid[@y][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y][@x][1] = @item_saved[1]
$game_party.actors[@actor_index].item_grid[@y + 1][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y + 1][@x][1] = "r"
$game_party.actors[@actor_index].item_grid[@y + 2][@x][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y + 2][@x][1] = "r"
$game_party.actors[@actor_index].item_grid[@y][@x + 1][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y][@x + 1][1] = "r"
$game_party.actors[@actor_index].item_grid[@y + 1][@x + 1][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y + 1][@x + 1][1] = "r"
$game_party.actors[@actor_index].item_grid[@y + 2][@x + 1][0] = @item_saved[0]
$game_party.actors[@actor_index].item_grid[@y + 2][@x + 1][1] = "r"
end
@x = tx if @x != tx and tx != nil
@y = ty if @y != ty and ty != nil
end
def empty?
case @item_saved[1]
when "i"
return true if $game_party.actors[@actor_index].item_grid[@y][@x][1] == ""
when "w"
if $game_party.actors[@actor_index].item_grid[@y][@x][1] == "" and
$game_party.actors[@actor_index].item_grid[@y + 1][@x + 1][1] == "" and
$game_party.actors[@actor_index].item_grid[@y + 2][@x + 1][1] == ""
return true
end
when "a"
if $game_party.actors[@actor_index].item_grid[@y][@x][1] == "" and
$game_party.actors[@actor_index].item_grid[@y + 1][@x + 1][1] == "" and
$game_party.actors[@actor_index].item_grid[@y + 2][@x + 1][1] == "" and
$game_party.actors[@actor_index].item_grid[@y][@x + 1][1] == "" and
$game_party.actors[@actor_index].item_grid[@y + 1][@x][1] == "" and
$game_party.actors[@actor_index].item_grid[@y + 2][@x][1] == ""
return true
end
end
return false
end
def set=(set)
@x = set
@y = set
@mini_help.visible = (set == 0 ? true : false)
end
def draw_item(item_id, type, i , j)
if type == "i" and
$game_party.item_can_use?($data_items[item_id].id)
opacity = 255
else
opacity = 128
end
if item_id != 0
case type
when "i"
x = 4 + (j * 32)
y = i * 32
bitmap = RPG::Cache.icon($data_items[item_id].icon_name)
@grid_color.bitmap.fill_rect(j*32+1, i*32+1, 31, 31, Color.new(0,0,200))
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
when "w"
x = 4 + (j * 32)
y = i * 32
bitmap = RPG::Cache.icon($data_weapons[item_id].icon_name)
@grid_color.bitmap.fill_rect(j*32+1, i*32+1, 31, 95, Color.new(200,0,0))
self.contents.blt(x, y + 4 + 32, bitmap, Rect.new(0, 0, 24, 24), opacity)
when "a"
x = 4 + (j * 32)
y = i * 32
bitmap = RPG::Cache.icon($data_armors[item_id].icon_name)
@grid_color.bitmap.fill_rect(j*32+1, i*32+1, 63, 95, Color.new(0,200,0))
self.contents.blt(x + 18, y + 4 + 32, bitmap, Rect.new(0, 0, 24, 24), opacity)
end
end
end
end
def set_text(text, align = 1)
# If at least one part of text and alignment differ from last time
if text != @text or align != @align
# Redraw text
self.contents.clear
#self.contents.font.color = normal_color
self.contents.draw_text(4, -12, self.width - 40, 32, text, align)
#self.width = self.contents.text_size(text).width
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
class Game_Actor < Game_Battler
attr_accessor :item_grid
alias old_initialize initialize
def initialize(actor_id)
old_initialize(actor_id)
@item_grid = Array.new(12)
for i in 0..@item_grid.size - 1
@item_grid[i] = Array.new(13)
for k in 0..@item_grid[i].size - 1
@item_grid[i][k] = Array.new(2)
@item_grid[i][k][0] = 0
@item_grid[i][k][1] = ""
end
end
end
end
class Game_Party
def gain_item(item_id, n)
if item_id > 0
for k in 1..n
for i in 0..self.actors.size - 1
break if set_item(item_id, "i", i) == nil
end
end
end
end
def gain_weapon(weapon_id, n)
if weapon_id > 0
for k in 1..n
for i in 0..self.actors.size - 1
break if set_item(weapon_id, "w", i) == nil
end
end
end
end
def gain_armor(armor_id, n)
if armor_id > 0
for k in 1..n
for i in 0..self.actors.size - 1
break if set_item(armor_id, "a", i) == nil
end
end
end
end
def lose_item(item_id, n, random = true)
if random == true
if item_id > 0
for k in 1..n
del_item(item_id, "i")
end
end
end
@items[item_id] = [[item_number(item_id) + -n, 0].max, 99].min
end
def lose_weapon(weapon_id, n, random = true)
if random == true
if weapon_id > 0
for k in 1..n
del_item(weapon_id, "w")
end
end
end
@weapons[weapon_id] = [[weapon_number(weapon_id) + -n, 0].max, 99].min
end
def lose_armor(armor_id, n, random = true)
if random == true
if armor_id > 0
for k in 1..n
del_item(armor_id, "a")
end
end
end
@armors[armor_id] = [[armor_number(armor_id) + -n, 0].max, 99].min
end
def set_item(item_id, type, i)
for a in 0..self.actors[i].item_grid.size - 1
for b in 0..self.actors[i].item_grid[a].size - 1
if self.actors[i].item_grid[a][b][0] == 0
case type
when "i"
self.actors[i].item_grid[a][b][0] = item_id
self.actors[i].item_grid[a][b][1] = type
@items[item_id] = [[item_number(item_id) + 1, 0].max, 99].min
return
when "w"
if a < self.actors[i].item_grid.size - 2
if self.actors[i].item_grid[a + 1][b][0] == 0 and
self.actors[i].item_grid[a + 2][b][0] == 0
self.actors[i].item_grid[a][b][0] = item_id
self.actors[i].item_grid[a][b][1] = type
self.actors[i].item_grid[a + 1][b][0] = item_id
self.actors[i].item_grid[a + 1][b][1] = "e"
self.actors[i].item_grid[a + 2][b][0] = item_id
self.actors[i].item_grid[a + 2][b][1] = "e"
@weapons[item_id] = [[weapon_number(item_id) + 1, 0].max, 99].min
return
end
end
when "a"
if b < self.actors[i].item_grid[a].size - 1 and a < self.actors[i].item_grid.size - 2
if self.actors[i].item_grid[a + 1][b][0] == 0 and self.actors[i].item_grid[a + 2][b][0] == 0 and
self.actors[i].item_grid[a][b + 1][0] == 0 and
self.actors[i].item_grid[a + 1][b + 1][0] == 0 and self.actors[i].item_grid[a + 2][b + 1][0] == 0
self.actors[i].item_grid[a][b][0] = item_id
self.actors[i].item_grid[a][b][1] = type
self.actors[i].item_grid[a + 1][b][0] = item_id
self.actors[i].item_grid[a + 1][b][1] = "r"
self.actors[i].item_grid[a + 2][b][0] = item_id
self.actors[i].item_grid[a + 2][b][1] = "r"
self.actors[i].item_grid[a][b + 1][0] = item_id
self.actors[i].item_grid[a][b + 1][1] = "r"
self.actors[i].item_grid[a + 1][b + 1][0] = item_id
self.actors[i].item_grid[a + 1][b + 1][1] = "r"
self.actors[i].item_grid[a + 2][b + 1][0] = item_id
self.actors[i].item_grid[a + 2][b + 1][1] = "r"
@armors[item_id] = [[armor_number(item_id) + 1, 0].max, 99].min
return
end
end
end
end
end
end
end
def del_item(item_id, type)
for i in 0..self.actors.size - 1
for a in 0..self.actors[i].item_grid.size - 1
for b in 0..self.actors[i].item_grid[a].size - 1
if self.actors[i].item_grid[a][b][0] == item_id and
self.actors[i].item_grid[a][b][1] == type
case type
when "i"
self.actors[i].item_grid[a][b][0] = 0
self.actors[i].item_grid[a][b][1] = ""
return
when "w"
self.actors[i].item_grid[a][b][0] = 0
self.actors[i].item_grid[a][b][1] = ""
self.actors[i].item_grid[a + 1][b][0] = 0
self.actors[i].item_grid[a + 1][b][1] = ""
self.actors[i].item_grid[a + 2][b][0] = 0
self.actors[i].item_grid[a + 2][b][1] = ""
return
when "a"
self.actors[i].item_grid[a][b][0] = 0
self.actors[i].item_grid[a][b][1] = ""
self.actors[i].item_grid[a + 1][b][0] = 0
self.actors[i].item_grid[a + 1][b][1] = ""
self.actors[i].item_grid[a + 2][b][0] = 0
self.actors[i].item_grid[a + 2][b][1] = ""
self.actors[i].item_grid[a][b + 1][0] = 0
self.actors[i].item_grid[a][b + 1][1] = ""
self.actors[i].item_grid[a + 1][b + 1][0] = 0
self.actors[i].item_grid[a + 1][b + 1][1] = ""
self.actors[i].item_grid[a + 2][b + 1][0] = 0
self.actors[i].item_grid[a + 2][b + 1][1] = ""
return
end
end
end
end
end
end
end
class Cursor_Icon < RPG::Sprite
def initialize
super
@color = Color.new(255,255,0,150)
@rect = Rect.new(0, 0, 24, 24)
end
def refresh(bitmap, item)
case item
when "i"
x = 4
y = 4
width = 32
height = 32
when "w"
x = 4
y = 36
width = 32
height = 96
when "a"
x = 22
y = 36
width = 64
height = 96
end
if self.bitmap == nil or (self.bitmap.width != width or self.bitmap.height != height)
self.bitmap = Bitmap.new(width, height)
else
self.bitmap.clear
end
self.bitmap.fill_rect(0,0,width,height, @color)
self.bitmap.blt(x, y , bitmap, @rect)
self.z = 9999
end
end
class Window_Base
def draw_actor_picture(actor, x, y)
bitmap = RPG::Cache.battler(actor.character_name, actor.character_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
class Scene_Menu
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item2.new(@status_window.index)
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
I wyskakuje mi błąd jak "przesuwam" np. broń do krawędzi(broń i zbroję linijka 687):
Cytat:
Script 'System przedmiotów' line 680: NoMethodError occurred.
undefined method `[] for nil:NilClass
...
Jakby co to linijka 680 jest tak:
Cytat:
$game_party.actors[@actor_index].item_grid[@y + 1][@x + 1][1] == "" and
#===============================================================================
# ** Registry
#-------------------------------------------------------------------------------
# This class reads the windows registry.
#===============================================================================
dw.unpack('V')[0]
end
def packqw(qw)
[ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
end
def unpackqw(qw)
qw = qw.unpack('VV')
(qw[1] << 32) | qw[0]
end
def OpenKey(hkey, name, opt, desired)
result = packdw(0)
check RegOpenKeyExA.call(hkey, name, opt, desired, result)
unpackdw(result)
end
def CreateKey(hkey, name, opt, desired)
result = packdw(0)
disp = packdw(0)
check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
0, result, disp)
[ unpackdw(result), unpackdw(disp) ]
end
def EnumValue(hkey, index)
name = ' ' * Constants::MAX_KEY_LENGTH
size = packdw(Constants::MAX_KEY_LENGTH)
check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
name[0, unpackdw(size)]
end
def EnumKey(hkey, index)
name = ' ' * Constants::MAX_KEY_LENGTH
size = packdw(Constants::MAX_KEY_LENGTH)
wtime = ' ' * 8
check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
[ name[0, unpackdw(size)], unpackqw(wtime) ]
end
def QueryValue(hkey, name)
type = packdw(0)
size = packdw(0)
check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
data = ' ' * unpackdw(size)
check RegQueryValueExA.call(hkey, name, 0, type, data, size)
[ unpackdw(type), data[0, unpackdw(size)] ]
end
def SetValue(hkey, name, type, data, size)
check RegSetValueExA.call(hkey, name, 0, type, data, size)
end
def FlushKey(hkey)
check RegFlushKey.call(hkey)
end
def CloseKey(hkey)
check RegCloseKey.call(hkey)
end
def QueryInfoKey(hkey)
subkeys = packdw(0)
maxsubkeylen = packdw(0)
values = packdw(0)
maxvaluenamelen = packdw(0)
maxvaluelen = packdw(0)
secdescs = packdw(0)
wtime = ' ' * 8
check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
[ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
unpackdw(secdescs), unpackqw(wtime) ]
end
end
def self.expand_environ(str)
str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
end
@@type2name = { }
%w[
REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
].each do |type|
@@type2name[Constants.const_get(type)] = type
end
def self.type2name(type)
@@type2name[type] || type.to_s
end
def self.wtime2time(wtime)
Time.at((wtime - 116444736000000000) / 10000000)
end
def self.time2wtime(time)
time.to_i * 10000000 + 116444736000000000
end
private_class_method :new
def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
subkey = subkey.chomp('\\')
newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
if block_given?
begin
yield obj
ensure
obj.close
end
else
obj
end
end
def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = 0x0000)
newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
obj = new(newkey, hkey, subkey, disp)
if block_given?
begin
yield obj
ensure
obj.close
end
else
obj
end
end
@@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
def initialize(hkey, parent, keyname, disposition)
@hkey = hkey
@parent = parent
@keyname = keyname
@disposition = disposition
@hkeyfinal = [ hkey ]
ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
end
attr_reader :hkey, :parent, :keyname, :disposition
def created?
@disposition == REG_CREATED_NEW_KEY
end
def open?
!@hkey.nil?
end
def name
parent = self
name = @keyname
while parent = parent.parent
name = parent.keyname + '\\' + name
end
name
end
def inspect
"\#<Win32::Registry key=#{name.inspect}>"
end
def _dump(depth)
raise TypeError, "can't dump Win32::Registry"
end
def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
self.class.open(self, subkey, desired, opt, &blk)
end
def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
self.class.create(self, subkey, desired, opt, &blk)
end
def close
API.CloseKey(@hkey)
@hkey = @parent = @keyname = nil
@hkeyfinal[0] = nil
end
def each_value
index = 0
while true
begin
subkey = API.EnumValue(@hkey, index)
rescue Error
break
end
begin
type, data = read(subkey)
rescue Error
next
end
yield subkey, type, data
index += 1
end
index
end
alias each each_value
def each_key
index = 0
while true
begin
subkey, wtime = API.EnumKey(@hkey, index)
rescue Error
break
end
yield subkey, wtime
index += 1
end
index
end
def keys
keys_ary = []
each_key { |key,| keys_ary << key }
keys_ary
end
def read(name, *rtype)
type, data = API.QueryValue(@hkey, name)
unless rtype.empty? or rtype.include?(type)
string = "Type mismatch (expect #{rtype.inspect} but #{type} present)"
raise TypeError, string
end
case type
when REG_SZ, REG_EXPAND_SZ
[ type, data.chop ]
when REG_MULTI_SZ
[ type, data.split(/\0/) ]
when REG_BINARY
[ type, data ]
when REG_DWORD
[ type, API.unpackdw(data) ]
when REG_DWORD_BIG_ENDIAN
[ type, data.unpack('N')[0] ]
when REG_QWORD
[ type, API.unpackqw(data) ]
else
raise TypeError, "Type #{type} is not supported."
end
end
def [](name, *rtype)
type, data = read(name, *rtype)
case type
when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
data
when REG_EXPAND_SZ
Registry.expand_environ(data)
else
raise TypeError, "Type #{type} is not supported."
end
end
def read_s(name)
read(name, REG_SZ)[1]
end
def read_s_expand(name)
type, data = read(name, REG_SZ, REG_EXPAND_SZ)
if type == REG_EXPAND_SZ
Registry.expand_environ(data)
else
data
end
end
def read_i(name)
read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
end
def read_bin(name)
read(name, REG_BINARY)[1]
end
def write(name, type, data)
case type
when REG_SZ, REG_EXPAND_SZ
data = data.to_s + "\0"
when REG_MULTI_SZ
data = data.to_a.join("\0") + "\0\0"
when REG_BINARY
data = data.to_s
when REG_DWORD
data = API.packdw(data.to_i)
when REG_DWORD_BIG_ENDIAN
data = [data.to_i].pack('N')
when REG_QWORD
data = API.packqw(data.to_i)
else
raise TypeError, "Unsupported type #{type}"
end
API.SetValue(@hkey, name, type, data, data.length)
end
def []=(name, rtype, value = nil)
if value
write name, rtype, value
else
case value = rtype
when Integer
write name, REG_DWORD, value
when String
write name, REG_SZ, value
when Array
write name, REG_MULTI_SZ, value
else
raise TypeError, "Unexpected type #{value.class}"
end
end
value
end
def write_s(name, value)
write name, REG_SZ, value.to_s
end
def write_i(name, value)
write name, REG_DWORD, value.to_i
end
def write_bin(name, value)
write name, REG_BINARY, value.to_s
end
def flush
API.FlushKey @hkey
end
def info
API.QueryInfoKey(@hkey)
end
%w[
num_keys max_key_length
num_values max_value_name_length max_value_length
descriptor_length wtime
].each_with_index do |s, i|
eval <<-__END__
def #{s}
info[#{i}]
end
__END__
end
end
end
=begin -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Aleworks Options Menu(AO)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Created by: Aleworks
Version: 2.50
Date: 26/12/06
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
History of the version:
-1.00
First version
-2.00
Better code
New interface
More options
-2.10
Font changing improved
Game speed bug fixed
Autosaving bug fixed
Lag reduction
-2.50
Font changing improved
Autosaving improved
Windowskin change bug fixed
Scene_Options improved
New options: Font Color, Font Brightness, Font Opacity, Windowskin Color,
Brightness, Battle Animations, Difficulty
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*** How to use ***
- For call the menu use:
$scene = Scene_AOptions.new($scene)
- For edit the initial options and the menu options see ** Editable options **
and ** Types of options **
- For refer to AOptions use: $ao
- For edit the values of AO, while playing the game, use:
$ao.something
something can be a method or a variable
For a list of the editable variables see the attr_accessors down the AOptions.
- For add a new option, see in the script, there are the instructions.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*** AO RGSS Classes and Modules definitions edits ***
*** Color ***
replace: initialize
*** Font ***
alias: initialize; alias name: aleworks_optionsmenu_font_initialize
*** RPG::Cache ***
replace: self.windowskin
*** Win32::Registry ***
add: value_time_index
*** Game_Enemy ***
replace: base_maxhp
replace: base_maxsp
replace: base_str
replace: base_dex
replace: base_agi
replace: base_int
replace: base_atk
replace: base_pdef
replace: base_mdef
replace: base_eva
*** Game_System ***
replace: bgm_play
replace: bgs_play
replace: me_play
replace: se_play
*** Sprite_Battler ***
replace: update
*** Window_Base ***
alias: normal_color, alias name: aleworks_optionsmenu_window_base_normal_color
replace: initialize
replace: dispose
replace: update
add: hue_to_color
*** Window_SaveFile ***
replace: initialize
replace: refresh
*** Scene_Title ***
replace: main
*** Scene_Map ***
alias: update; alias name: aleworks_optionsmenu_scene_map_update
alias: transfer_player; alias name: aleworks_optionsmenu_scene_map_transfer
*** Scene_Load ***
alias: on_decision; alias name: aleworks_optionsmenu_load_on_decision
*** Scene_File ***
replace: main
replace: update
replace: make_filename
add: make_name
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=end
* , where # determinates the number of the group of options
# - A is the name of the group of options
# - [B,C] is a option of the group of options
# - B is the name of the option
# - C is the type of option (See Type of options for more info)
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@options[0] = ['Visual', [ ['Font', 0],
['Letters Size', 1],
['Letters Color', 10],
['Letters Brightness', 11],
['Letters Opacity', 12],
['Windowskin', 2],
['Windowskin Color', 13],
['Window Opacity', 3],
['Brightness', 14]
] ]
@options[2] = ['Game', [ ['Game speed', 9],
['Autosave', 8],
['Battle Animations', 15],
['Difficulty', 16]
] ]
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# If it is true AO, will include the 001-Blue01.png skin of the Standart RTP
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@winskin_rtp = true
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Selectable fonts *
# You have to put the names of the selectable fonts here.
# If you want that all font be selectable, put:
# @fonts = fonts_entries
# If you want to specify the fonts put an Array. It may be like this:
# @fonts = ['Comic Sans MS', 'Lucida Sans', 'Times New Roman']
# ~~~~~ Warning ~~~~~~
# If you use 'fonts_entries', some fonts maybe dont work well, and in some
# systems, maybe the script cant read the fonts.
# Tested only in Window XP.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@fonts = ['Comic Sans MS', 'Lucida Sans', 'Times New Roman']
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Selectable Ranges => [Min,Max] *
# ~~~~~ Warning ~~~~~~
# It may throw errors, if the ranges are out of the max. and min.
# All the defaults ranges will not throw errors.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@font_size_range = [6, 36] # Letter Size Min = 6 Max = 96
@audio_volume_range = [0, 150] # Audio Volume(in %) Min = 0 Max = 150
@audio_speed_range = [1, 500] # Audio Speed(in %) Min = 0 Max = ?
@game_speed_range = [10, 120] # Game Speed(in frames) Min = 10 Max = 120
@opacity_range = [0, 100] # Opacity Min = 0 Max = 100
@color_range = [-1, 360] # Hue color Min = 0 Max = 360
@brightness_range = [-255, 255] # Brightness Min = -255 Max = 255
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Auto save options *
# There are two types of autosaving, one that save after some time and one
# that save after somes changes of maps.
# For the first form, use:
# @auto_save = ['map', #]
# - Where # is the number of map changes for save.
# For the second form, use:
# @auto_save = ['time', #]
# - Where # is the number of seconds that need to pass for save.
# You can put too, any other thing like nil, and call the autosave when
# you want.
# It may be like:
# @auto_save = [nil, 0]
# And dor call autosave:
# $ao.autosave
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@auto_save = ['map', 2]
@auto_save_file = 'Autosave.rxdata' # Name of thme autosave file.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Dificulty options *
# @difficulty_values
# This values are the percentage of the atributes of the enemies.
# @difficulty_names
# This are the names of the corresponding percentages of @difficulty_values
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@difficulty_values = [60, 85, 100, 115, 130, 200]
@difficulty_names = ['Very Easy', 'Easy', 'Normal', 'Hard', 'Hardest',
'Imposible']
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Initials values of the options *
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@font_name = "Lucida Console" # Font name
@font_size = 22 # Size of the letters
@font_color = -1 # Color of the Window_Base normal_color (-1 = Normal Color)
@font_brightness = 0 # Brightness of the letters
@font_opacity = 100 # Opacity of the letters
@winskin = $data_system.windowskin_name # Windowskin
@window_opacity = 100 # Opacity of windows
@windowskin_color = -1 # Color of the windows (-1 = Normal Color)
@brightness = 0 # Brightness of all sprites
@bgm_volume = 80 # Volume of BGM
@bgs_volume = 100 # Volume of BGS
@me_volume = 80 # Volume of ME
@se_volume = 100 # Volume of SE
@bgm_speed = 100 # Speed of BGM
@bgs_speed = 100 # Speed of BGS
@me_speed = 100 # Speed of ME
@se_speed = 100 # Speed of SE
@auto_save_status = false # The status of the autosave
@game_speed = 40 # Speed of the game(Frames)
@battle_animations = true # Animations of Battle
@difficulty = 100 # Difficulty of the game
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Internal variables **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$defaultfonttype = $fontface = $fontname=Font.default_name = @font_name
$defaultfontsize = $fontsize = Font.default_size = @font_size
@brightness_class = Brightness.new(@brightness)
@auto_save_count = @auto_save[1]
@window_autosave = nil
@window_autosave_timer = 0
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Types of options **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# For easy editing, the AO options are divided by types. You can edit, add
# or remove types for your own options.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def win_options(e)
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Types values *
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Here you can edit the value that each type of option shows.
# options.push([i[0],A])
#
# You only need to edit A, options.push and i[0], have to be ever the same
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
options = []
for i in e
case i[1]
when 0 # Type 0 (Font)
options.push([i[0], @font_name])
when 1 # Type 1 (Size of letters)
options.push([i[0], @font_size])
when 2 # Type 2 (Windoskin)
options.push([i[0], @winskin])
when 3 # Type 3 (Opacity of windows)
options.push([i[0], "#{@window_opacity} %"])
when 4 # Type 4 (BGM & ME volume)
options.push([i[0], "#{@bgm_volume} %"])
when 5 # Type 5 (BGS & SE volume)
options.push([i[0], "#{@bgs_volume} %"])
when 6 # Type 6 (BGM & ME speed)
options.push([i[0], "#{@bgm_speed} %"])
when 7 # Type 7 (BGS & SE speed)
options.push([i[0], "#{@bgs_speed} %"])
when 8 # Type 8 (Autosave)
if @auto_save_status
a = 'ON'
else
a = 'OFF'
end
options.push([i[0], a])
when 9 # Type 9 (Game speed)
options.push([i[0], @game_speed])
when 10 # Type 10 (Font Color)
a = @font_color
a = 'Normal' if @font_color == -1
options.push([i[0], a])
when 11 # Type 11 (Font Brightness)
a = "- #{@font_brightness.abs}" if @font_brightness < 0
a = 'Normal' if @font_brightness == 0
a = "+ #{@font_brightness}" if @font_brightness > 0
options.push([i[0], a])
when 12 # Type 12 (Font Opacity)
options.push([i[0], "#{@font_opacity} %"])
when 13 # Type 13 (Windowskin Color)
a = @windowskin_color
a = 'Normal' if @windowskin_color == -1
options.push([i[0], a])
when 14 # Type 14 (Brightness)
a = '- #{@brightness.abs}' if @brightness < 0
a = 'Normal' if @brightness == 0
a = '+ #{@brightness}' if @brightness > 0
options.push([i[0], @brightness])
when 15 # Type 15 (Battle Animations)
if @battle_animations
a = 'ON'
else
a = 'OFF'
end
options.push([i[0], a])
when 16 # Type 16 (Game Difficulty)
a = @difficulty_names[@difficulty_values.index(@difficulty)]
options.push([i[0], a])
end
end
return options
end
def command_options(index, index_com, type)
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Types effect *
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Here you can edit what each type will do when the player change it.
# - If your option is a switch, you can put:
# if @switch
# @switch = false
# else
# @switch = true
# end
# - If your option is a range of numbers
# @variable = range(@variable, [min, max], type)
# For more info see range
# - If your option has differents strings values, like the font type, use:
# if @option_value == nil or Arraywithstrings.include?(@option_value) == false
# @font_name = Arraywithstrings[0]
# return
# end
# if type == -1
# if @option_value == Arraywithstrings[0]
# @option_value = Arraywithstrings[Arraywithstrings.size - 1]
# else
# @option_value = Arraywithstrings[Arraywithstrings.index(@option_value) - 1]
# end
# elsif type == 1
# if @option_value == Arraywithstrings[Arraywithstrings.size - 1]
# @option_value = Arraywithstrings[0]
# else
# @option_value = Arraywithstrings[Arraywithstrings.index(@option_value) + 1]
# end
# end
# - If your option need to refresh the options group window use:
# $scene.command_left.refresh
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
case @options[index][1][index_com][1]
when 0 # Type 0 (Font)
return nil if type < -1 and type > 1 or type == 0
if @font_name == nil or @fonts.include?(@font_name) == false
@font_name = @fonts[0]
return
end
if type == -1
if @font_name == @fonts[0]
@font_name = @fonts[@fonts.size - 1]
else
@font_name = @fonts[@fonts.index(@font_name) - 1]
end
elsif type == 1
if @font_name == @fonts[@fonts.size - 1]
@font_name = @fonts[0]
else
@font_name = @fonts[@fonts.index(@font_name) + 1]
end
end
$defaultfonttype = $fontface = $fontname=Font.default_name = @font_name
$scene.command_left_refresh
when 1 # Type 1 (Size of letters)
return nil if type == 0
@font_size = range(@font_size, @font_size_range, type)
$defaultfontsize = $fontsize = Font.default_size = @font_size
$scene.command_left_refresh
when 2 # Type 2 (Windoskin)
return nil if type < -1 and type > 1 or type == 0
w = ws_entries
w.push('001-Blue01') if @winskin_rtp == true
winskin=@winskin
if ws_entries.size == 0
@winskin = winskin
return
end
if type == -1 and w.size >= 1
if @winskin == nil or w.include?(@winskin) == false or @winskin == w[0]
winskin = w[w.size - 1] unless w[w.size - 1] == nil
elsif w[w.index(@winskin)-1] != nil
winskin = w[w.index(@winskin) - 1]
end
elsif type == 1 and w.size >= 1
if @winskin == nil or w.include?(@winskin) == false or
@winskin == w[w.size - 1]
winskin=w[0] unless w[0] == nil
elsif w[w.index(@winskin) + 1] != nil
winskin=w[w.index(@winskin) + 1]
end
end
@winskin = winskin
when 3 # Type 3 (Opacity of windows)
return nil if type == 0
@window_opacity = range(@window_opacity, @opacity_range, type)
$scene.command_left_refresh
when 4 # Type 4 (BGM & ME volume)
return nil if type == 0
@bgm_volume = range(@bgm_volume, @audio_volume_range, type)
@me_volume = range(@me_volume, @audio_volume_range, type)
$game_system.bgm_memorize
$game_system.bgm_restore
when 5 # Type 5 (BGS & SE volume)
return nil if type == 0
@bgs_volume = range(@bgs_volume, @audio_volume_range, type)
@se_volume = range(@se_volume, @audio_volume_range, type)
$game_system.bgs_memorize
$game_system.bgs_restore
when 6 # Type 6 (BGM & ME speed)
return nil if type == 0
@bgm_speed = range(@bgm_speed, @audio_speed_range, type)
@me_speed = range(@me_speed, @audio_speed_range, type)
$game_system.bgm_memorize
$game_system.bgm_restore
when 7 # Type 7 (BGS & SE speed)
return nil if type == 0
@bgs_speed = range(@bgs_speed, @audio_speed_range, type)
@se_speed = range(@se_speed, @audio_speed_range, type)
$game_system.bgs_memorize
$game_system.bgs_restore
when 8 # Type 8 (Autosave)
return nil if type != 0
if @auto_save_status
@auto_save_status = false
else
@auto_save_status = true
end
when 9 # Type 9 (Game speed)
return nil if type == 0
@game_speed = range(@game_speed , @game_speed_range, type)
Graphics.frame_rate = @game_speed
when 10 # Type 10 (Font Color)
return nil if type == 0
@font_color = range(@font_color , @color_range, type)
$scene.command_left_refresh
when 11 # Type 11 (Font Brightness)
return nil if type == 0
@font_brightness = range(@font_brightness , @brightness_range, type)
$scene.command_left_refresh
when 12 # Type 12 (Font Opacity)
return nil if type == 0
@font_opacity = range(@font_opacity , @opacity_range, type)
$scene.command_left_refresh
when 13 # Type 13 (Windowskin Color)
return nil if type == 0
@windowskin_color = range(@windowskin_color , @color_range, type)
when 14 # Type 14 (Brightness)
return nil if type == 0
@brightness = range(@brightness , @brightness_range, type)
@brightness_class.refresh
when 15 # Type 15 (Battle Animations)
return nil if type != 0
if @battle_animations
@battle_animations = false
else
@battle_animations = true
end
when 16 # Type 16 (Game Difficulty)
return nil if type < -1 and type > 1 or type == 0
d = @difficulty_values
difficulty = @difficulty
if d.size == 0
@difficulty = difficulty
return
end
if type == -1 and d.size >= 1
if @difficulty == d[0]
difficulty = d[d.size - 1] unless d[d.size - 1] == nil
elsif d[d.index(@difficulty)-1] != nil
difficulty = d[d.index(@difficulty) - 1]
end
elsif type == 1 and d.size >= 1
if @difficulty == nil or d.include?(@difficulty) == false or
@difficulty == d[d.size - 1]
difficulty = d[0] unless d[0] == nil
elsif d[d.index(@difficulty) + 1] != nil
difficulty = d[d.index(@difficulty) + 1]
end
end
@difficulty = difficulty
end
return true
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Range **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# range(value,range,cant)
# - value is the actual value of the variable
# - range is the min and the max value of the range
# - cant is the cant that will be modified. The AO menu, use for the right
# and left arrowkey +1 and -1, and for the R and L buttons, +10 and -10.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def range(value, range, cant)
value += cant
if cant < -1 and value < range[0] and value != range[0] + cant
value = range[0]
elsif cant > 1 and value > range[1] and value != range[1] + cant
value = range[1]
elsif value < range[0]
value = range[1]
elsif value > range[1]
value = range[0]
end
return value
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Windowskin entries **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Return the name of all the windowskins
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def ws_entries
skin = Dir.entries('Graphics/Windowskins')
skin.delete_at(0)
skin.delete_at(0)
skin.sort!
c = 0
for i in 0..skin.size - 1
n=File.extname(skin[i - c])
if n != '.bmp' and n != '.png' and n != '.jpg' and n != '.jpge' and
n != '.jif'
skin.delete_at(i - c)
c += 1
end
end
for i in 0..skin.size - 1
size = File.extname(skin).size
skin.slice!(skin.size - size, size)
end
return skin
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Autosave **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def load_game(file)
if @auto_save[0] == 'map' or @auto_save[0] == 'time'
@auto_save_count = @auto_save[1]
end
@auto_save_count *= @game_speed if @auto_save[0] == 'time'
end
def autosave
return if @auto_save_file == nil
@auto_save_count = @auto_save[1]
@auto_save_count *= @game_speed if @auto_save[0] == 'time'
scene = $scene
a = Scene_Save.new
file = File.open(@auto_save_file, 'wb')
a.write_save_data(file)
file.close
$scene = scene
@window_autosave = Window_Help.new
@window_autosave.x = 505
@window_autosave.y = -16
@window_autosave.width = 160
@window_autosave.height = 64
@window_autosave.opacity = 0
@window_autosave.back_opacity = 0
@window_autosave.set_text('Autosaving')
@window_autosave_timer = @game_speed * 2.5
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Fonts entries **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Return the name of all fonts
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def fonts_entries
fonts = []
dir = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
Win32::Registry::HKEY_LOCAL_MACHINE.open(dir) do |reg|
entries_count = reg.each_value { | | }
for index in 0..entries_count-1
fonts.push(reg.value_time_index(index))
end
end
c=0
for i in 0..fonts.size-1
n = fonts.scan(/ (TrueType)/)
if n == nil
fonts.delete_at(i - c)
c += 1
end
end
for i in 0..fonts.size - 1
fonts.slice!(fonts.size - 11,11)
end
return fonts.sort
end
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# *** Load/Save options data ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module AO
def AO.load
file=File.open('Options.rxdata', 'rb')
$ao = Marshal.load(file)
file.close
Graphics.frame_rate = $ao.game_speed
$defaultfonttype = $fontface = $fontname = Font.default_name = $ao.font_name
$defaultfontsize = $fontsize = Font.default_size = $ao.font_size
$ao.brightness_class = Brightness.new($ao.brightness)
end
def AO.save
$ao.brightness_class.dispose
$ao.brightness_class = nil
file = File.open('Options.rxdata', 'wb')
Marshal.dump($ao, file)
file.close
$ao.brightness_class = Brightness.new($ao.brightness)
end
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# *** Menu of Options ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Scene_AOptions
attr_accessor :command_left
attr_accessor :index
attr_accessor :scene
def initialize(scene)
@scene = scene
end
def main
o = []
for i in $ao.options
o.push(i[0])
end
@command_left = Window_Command.new(140, o)
@command_left.width = 140
@command_left.height = o.size * 32 + 32
@command_left.x = 0
@command_left.y = 0
@index = 0
@window_right = Window_AOptions.new
options = $ao.win_options($ao.options[@command_left.index][1])
@window_right.refresh(options, @index)
@window_right.cursor_rect.set(0, -32, 16, 16)
Graphics.transition
while $scene == self
Graphics.update
Input.update
update_left if @command_left.active
update_right if @command_left.active == false
end
Graphics.freeze
AO.save
@command_left.dispose
@window_right.dispose
end
def update_left
@command_left.update
options = $ao.win_options($ao.options[@command_left.index][1])
@window_right.refresh(options, @index)
@window_right.cursor_rect.set(0, -32, 16, 16)
if Input.trigger?(Input::C)
@command_left.active = false
$game_system.se_play($data_system.decision_se)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = @scene
end
end
def update_right
@window_right.update
@command_left.update
options_size = $ao.options[@command_left.index][1].size - 1
if Input.trigger?(Input::C)
sound = $ao.command_options(@command_left.index, @index, 0)
$game_system.se_play($data_system.decision_se) if sound == true
options = $ao.win_options($ao.options[@command_left.index][1])
@window_right.refresh(options, @index)
return
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @index > 0
$game_system.se_play($data_system.cursor_se)
if @index == 0
@index = options_size
else
@index -= 1
end
options = $ao.win_options($ao.options[@comman
Pomogła: 232 razy Dołączyła: 18 Wrz 2007 Posty: 2424
Wysłany: Sro 31 Mar, 2010 07:44
Melvin, to nie jest ten skrypt. Napisałam Tobie, abyś poszukał skryptu Grid Inventory. Może znajdziesz na innych stronach po prostu googlując. Temat zamykam.
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum