l0rdph0enix
Member
I'm using this mouse system (can't remember who wrote it.) but I'd rather use Near Fantastica's Pathfinding script then the one built into the mouse system. Can anyone tell me how I can do this?
Mouse System
Near Fantastica's Pathfinding
Edit:
Also I noticed that the cursor select function of the mouse system doesn't work for the 'Items', 'Equipment', 'Skills', and 'Misc' sections of LegACy's 1-Scene CMS (Alternate Version) script. Nor can I use the Mouse in Moghunter's Name Scene script.
Moghunter's Name Scene
Mouse System
Code:
#----------------------------------------------------------------------------
#Credits: This is an adaptation from a script created by shun ([url=http://simp.nobody.jp/]http://simp.nobody.jp/[/url])
#Also looked at Cybersam's work and Astro_mech and Mr.Mo's mouse script edits to
#learn how onmouse events work.
#----------------------------------------------------------------------------
# TO USE:
# In each map event, put the name of the cursor you want to show as a comment.
# The comment must be the first event command. Make sure that you put the cursor
# in your Icons directory (name in comment and icon name must match exactly)
#----------------------------------------------------------------------------
module Input
#--------------------------------------------------------------------------
# ● get winAPIs
#--------------------------------------------------------------------------
#gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
@mouse_status = [[0, 1], [0, 2], [0, 4]] #left, right, middle mouse
@gaks = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
@cursor_pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
@scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
@client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
@readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
@findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
show_cursor = Win32API.new('user32', 'ShowCursor', 'l', 'l')
@last_pos = [0, 0].pack('ll')
@pos_x = @pos_y = 0
@width = 0
@height = 0
n = (true ? 0 : 1)
show_cursor.call(n)
module_function
#--------------------------------------------------------------------------
# ● get the window
#--------------------------------------------------------------------------
def hwnd
game_name = "\0" * 256
@readini.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
game_name.delete!("\0")
h = @findwindow.call('RGSS Player', game_name)
if h == 0
n = 0
while h == 0
h = @findwindow.call('RGSS Player', "#{game_name} - #{n} FPS")
n += 1
end
end
return h
end
#--------------------------------------------------------------------------
# ● get the global position of the mouse
#--------------------------------------------------------------------------
def global_pos
pos = [0, 0].pack('ll')
if @cursor_pos.call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# ● Position of the mouse in the game
# catch_anywhere : get position if mouse is outside of game screen
#--------------------------------------------------------------------------
def pos(catch_anywhere = true)
if (global_pos != @last_pos)
@last_pos = *global_pos
string = global_pos.to_s + " " + @last_pos.to_s
$debug_string = string.to_s
@pos_x, @pos_y = screen_to_client(*global_pos)
@width, @height = client_size
end
if (@pos_x >= 0 and @pos_y >= 0 and @pos_x < @width and @pos_y < @height)
return @pos_x, @pos_y
else
return 0, 0
end
end
#--------------------------------------------------------------------------
# ● Position of the mouse on screen
# x : x coordinate
# y : y coordinate
#--------------------------------------------------------------------------
def screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if @scr2cli.call(hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# ● Size of the game window
#--------------------------------------------------------------------------
def client_size
rect = [0, 0, 0, 0].pack('l4')
@client_rect.call(hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
#--------------------------------------------------------------------------
# ● Check to see if the mouse is over an event
#--------------------------------------------------------------------------
def check_event(x, y)
for event in $game_map.events.values
# change icon if an event is encountered
if (event.x == x or event.x == (x-1)) and (event.y == y or event.y == (y+1))
if event.list && event.list[0].code == 108
icon = event.list[0].parameters
icon = icon.to_s
if icon == "npc" || icon == "teleport" || icon == "enemy" || icon == "chest" || icon == "quest" || icon =="vender"
$mouse_icon = icon.to_s
end
end
break
end
# if even is not encountered, use default icon
$mouse_icon = "arrow_normal"
end
end
def icon_name(name)
$msg = name.to_s
$mouse_icon = name.to_s
end
#--------------------------------------------------------------------------
# ● watch for left mouse actions
# id : Mouse (0:Left, 1:Right, 2:Center)
#--------------------------------------------------------------------------
def mouse_press?(id = 0)
if $scene.is_a?(Scene_Map)
# get the icon to display
if @mouse_status[id][0] <= 0
$hoverx = (pos[0] + $game_map.display_x / 4) / 32
$hovery = (pos[1] + $game_map.display_y / 4) / 32
icon = check_event($hoverx,$hovery)
end
# move character when mouse is pressed
if @mouse_status[id][0] > 0
$mousex = pos[0] + $game_map.display_x / 4
$mousey = pos[1] + $game_map.display_y / 4
$move = 1
end
# don't move character if message window showing
if $game_temp.message_window_showing
$move = 0
end
end
return @mouse_status[id][0] > 0
end
#--------------------------------------------------------------------------
# ● Watch for mouse button actions (especially right mouse button)
# id : mouse (0:Left, 1:Right, 2:Center)
#--------------------------------------------------------------------------
def mouse_trigger?(id = 0)
return @mouse_status[id][0] == 1
end
#--------------------------------------------------------------------------
# ● Check to see if a mouse action was repeated
# id : mouse (0:Left, 1:Right, 2:Center)
#--------------------------------------------------------------------------
def mouse_repeat?(id = 0)
if @mouse_status[id][0] <= 0
return false
else
result = @mouse_status[id][0] % 5 == 1 and @mouse_status[id][0] % 5 != 2
return result
end
end
#--------------------------------------------------------------------------
# ● Update the mouse
#--------------------------------------------------------------------------
def mouse_update
for i in @mouse_status
n = @gaks.call(i[1])
if n == 0 or n == 1
i[0] = (i[0] > 0 ? i[0] * -1 : 0)
else
i[0] = (i[0] > 0 ? i[0] + 1 : 1)
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class << Input
#--------------------------------------------------------------------------
# ● Update old input calls
#--------------------------------------------------------------------------
alias old_update update unless $@
def Input.update
old_update
mouse_update
$mouse.update
end
#--------------------------------------------------------------------------
# ● Update old input triggers
# num : A, B, C
#--------------------------------------------------------------------------
alias old_trigger? trigger? unless $@
def Input.trigger?(num)
return old_trigger?(num) if Input.pos(false) == nil
case num
when Input::A
return (old_trigger?(num) or mouse_trigger?(2))
when Input::B
return (old_trigger?(num) or mouse_trigger?(1))
when Input::C
return (old_trigger?(num) or mouse_trigger?)
else
return old_trigger?(num)
end
end
#--------------------------------------------------------------------------
# ● Check to see if an old input call was repeated
# num : B
#--------------------------------------------------------------------------
alias old_repeat? repeat? unless $@
def repeat?(num)
return old_repeat?(num) if Input.pos(false) == nil
if num == Input::B
return (old_repeat?(num) or mouse_repeat?(1))
else
return old_repeat?(num)
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● Move the player toward the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
rx = $mousex - (@real_x / 4 + 16)
ry = $mousey - (@real_y / 4 + 16)
# if an arrow key is pressed, stop path finding
$move = 0 if Input.dir4 != 0
# move to a specified area on the map, using the mouse
if $move == 1
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing or
(rx.abs <= 16 and ry.abs <= 16)
rad = -(Math.atan2(ry, rx) / Math::PI * 180)
case rad
when -157.5...-112.5
move_lower_left
when -112.5...-67.5
move_down
when -67.5...-22.5
move_lower_right
when -22.5...22.5
move_right
when 22.5...67.5
move_upper_right
when 67.5...112.5
move_up
when 112.5...157.5
move_upper_left
else
move_left
end
end
# if the path has been reached, stop moving
if (rx.abs <= 16 and ry.abs <= 16)
$move = 0
end
end
#update the mouse
mouse_update
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Sprite_Mouse < Sprite
#--------------------------------------------------------------------------
# ● Initialize the mouse
#--------------------------------------------------------------------------
def initialize
super
self.bitmap = RPG::Cache.icon($mouse_icon.to_s)
self.z = 10001
self.ox, self.oy = [16, 0]
self.visible = false
self.src_rect.set(0, 0, 32, 32)
update
end
#--------------------------------------------------------------------------
# ● Dispose of the mouse
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# ● Update the mouse
#--------------------------------------------------------------------------
def update
super
self.bitmap = RPG::Cache.icon($mouse_icon.to_s)
self.visible = true if self.visible == false and $scene != nil
self.x, self.y = Input.pos
if Input.mouse_press?
self.src_rect.set(0, 0, 32, 32)
end
return
end
end
$mouse = Sprite_Mouse.new
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# ● Initialize the mouse
#--------------------------------------------------------------------------
alias mouse_initialize initialize
def initialize(x, y, width, height)
mouse_initialize(x, y, width, height)
@scroll_wait = 0
end
#--------------------------------------------------------------------------
# ● Update the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
mouse_operation if self.active
end
#--------------------------------------------------------------------------
# ○ Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
width = self.width / @column_max - 32
height = 32
for index in 0...@item_max
x = index % @column_max * (width + 32)
y = index / @column_max * 32
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
#--------------------------------------------------------------------------
# ○ Track the position of the mouse cursor
#--------------------------------------------------------------------------
def mouse_cursor(index)
return if @index == index
@scroll_wait -= 1 if @scroll_wait > 0
row1 = @index / @column_max
row2 = index / @column_max
bottom = self.top_row + (self.page_row_max - 1)
if row1 == self.top_row and row2 < self.top_row
return if @scroll_wait > 0
@index = [@index - @column_max, 0].max
@scroll_wait = 4
elsif row1 == bottom and row2 > bottom
return if @scroll_wait > 0
@index = [@index + @column_max, @item_max - 1].min
@scroll_wait = 4
else
@index = index
end
$game_system.se_play($data_system.cursor_se)
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Window_MenuStatus < Window_Selectable
def mouse_operation
return if @index < 0
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
x = 0
width = self.width - 32
height = 96
for index in 0...@item_max
y = index * 116
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Window_Target < Window_Selectable
def mouse_operation
return if @index <= -1
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
x = 0
width = self.width - 32
height = 96
for index in 0...@item_max
y = index * 116
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Window_NameInput < Window_Base
#--------------------------------------------------------------------------
# ● Update the position of the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
mouse_operation if self.active
end
#--------------------------------------------------------------------------
# ● Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
last_index = @index
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
width = 28
height = 32
for index in 0...180
x = 4 + index / 5 / 9 * 152 + index % 5 * 28
y = index / 5 % 9 * 32
if mx > x and
mx < x + width and
my > y and
my < y + height
@index = index
break
end
end
x = 544
y = 9 * 32
width = 64
if mx > x and
mx < x + width and
my > y and
my < y + height
@index = 180
end
$game_system.se_play($data_system.cursor_se) unless @index == index
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
x = 8
width = 128
height = 32
for index in 0...@item_max
y = ($game_temp.choice_start + index) * 32
if mx > x and mx < x + width and my > y and my < y + height
mouse_cursor(index)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Window_PartyCommand < Window_Selectable
def mouse_operation
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
y = 0
width = 128
height = 32
for index in 0...@item_max
x = 160 + index * 160
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Window_MenuPosition < Window_Selectable
def mouse_operation
mx = Input.pos[0] - (self.x - self.ox + 16)
my = Input.pos[1] - (self.y - self.oy + 16)
y = 0
width = self.contents.width / @item_max - 10
height = 32
for index in 0...@item_max
x = self.contents.width / (@item_max) * index + 4
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Arrow_Base < Sprite
alias mouse_update update
def update
mouse_update
mouse_operation
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Arrow_Enemy < Arrow_Base
def mouse_operation
mx, my = Input.pos
for index in 0...$game_troop.enemies.size
enemy = $game_troop.enemies[index]
bitmap = RPG::Cache.battler(enemy.battler_name, 0)
width = bitmap.width
height = bitmap.height
x = enemy.screen_x - width / 2
y = enemy.screen_y - height
if mx > x and
mx < x + width and
my > y and
my < y + height
break if @index == index
@index = index
$game_system.se_play($data_system.cursor_se)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Arrow_Actor < Arrow_Base
def mouse_operation
mx, my = Input.pos
for index in 0...$game_party.actors.size
index = $game_party.actors.size - index - 1
actor = $game_party.actors[index]
bitmap = RPG::Cache.battler(actor.battler_name, 0)
width = bitmap.width
height = bitmap.height
x = actor.screen_x - width / 2
y = actor.screen_y - height
if mx > x and
mx < x + width and
my > y and
my < y + height
break if @index == index
@index = index
$game_system.se_play($data_system.cursor_se)
break
end
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Scene_File
#--------------------------------------------------------------------------
# ● Update the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
save = false
mx, my = Input.pos
x = 0
width = (save ? 160 : 640)
height = 104
for index in 0...4
y = 64 + index % 4 * 104
if mx > x and
mx < x + width and
my > y and
my < y + height
break if @file_index == index
@savefile_windows[@file_index].selected = false
@file_index = index
@savefile_windows[@file_index].selected = true
$game_system.se_play($data_system.cursor_se)
break
end
end
end
end
Near Fantastica's Pathfinding
Code:
#==============================================================================
# Path Finding
#==============================================================================
# Near Fantastica
# Version 1
# 29.11.05
#==============================================================================
# Lets the Player or Event draw a path from an desonation to the source. This
# method is very fast and because the palthfinding is imbeded into the Game
# Character the pathfinding can be inturputed or redrawn at any time.
#==============================================================================
# Player :: $game_player.find_path(x,y)
# Event Script Call :: self.event.find_path(x,y)
# Event Movement Script Call :: self.find_path(x,y)
#==============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("Path Finding", "Near Fantastica", 1, "29.11.05")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("Path Finding") == true
class Game_Character
#--------------------------------------------------------------------------
alias nf_pf_game_character_initialize initialize
alias nf_pf_game_character_update update
#--------------------------------------------------------------------------
attr_accessor :map
attr_accessor :runpath
#--------------------------------------------------------------------------
def initialize
nf_pf_game_character_initialize
@map = nil
@runpath = false
end
#--------------------------------------------------------------------------
def update
run_path if @runpath == true
nf_pf_game_character_update
end
#--------------------------------------------------------------------------
def run_path
return if moving?
step = @map[@x,@y]
if step == 1
@map = nil
@runpath = false
return
end
dir = rand(2)
case dir
when 0
move_right if @map[@x+1,@y] == step - 1 and step != 0
move_down if @map[@x,@y+1] == step - 1 and step != 0
move_left if @map[@x-1,@y] == step -1 and step != 0
move_up if @map[@x,@y-1] == step - 1 and step != 0
when 1
move_up if @map[@x,@y-1] == step - 1 and step != 0
move_left if @map[@x-1,@y] == step -1 and step != 0
move_down if @map[@x,@y+1] == step - 1 and step != 0
move_right if @map[@x+1,@y] == step - 1 and step != 0
end
end
#--------------------------------------------------------------------------
def find_path(x,y)
sx, sy = @x, @y
result = setup_map(sx,sy,x,y)
@runpath = result[0]
@map = result[1]
@map[sx,sy] = result[2] if result[2] != nil
end
#--------------------------------------------------------------------------
def clear_path
@map = nil
@runpath = false
end
#--------------------------------------------------------------------------
def setup_map(sx,sy,ex,ey)
map = Table.new($game_map.width, $game_map.height)
map[ex,ey] = 1
old_positions = []
new_positions = []
old_positions.push([ex, ey])
depth = 2
depth.upto(100){|step|
loop do
break if old_positions[0] == nil
x,y = old_positions.shift
return [true, map, step] if x == sx and y+1 == sy
if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
map[x,y + 1] = step
new_positions.push([x,y + 1])
end
return [true, map, step] if x-1 == sx and y == sy
if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
map[x - 1,y] = step
new_positions.push([x - 1,y])
end
return [true, map, step] if x+1 == sx and y == sy
if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
map[x + 1,y] = step
new_positions.push([x + 1,y])
end
return [true, map, step] if x == sx and y-1 == sy
if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
map[x,y - 1] = step
new_positions.push([x,y - 1])
end
end
old_positions = new_positions
new_positions = []
}
return [false, nil, nil]
end
end
class Game_Map
#--------------------------------------------------------------------------
alias pf_game_map_setup setup
#--------------------------------------------------------------------------
def setup(map_id)
pf_game_map_setup(map_id)
$game_player.clear_path
end
end
class Game_Player
#--------------------------------------------------------------------------
alias pf_game_player_update_player_movement update_player_movement
#--------------------------------------------------------------------------
def update_player_movement
$game_player.clear_path if Input.dir4 != 0
pf_game_player_update_player_movement
end
end
class Interpreter
#--------------------------------------------------------------------------
def event
return $game_map.events[@event_id]
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Edit:
Also I noticed that the cursor select function of the mouse system doesn't work for the 'Items', 'Equipment', 'Skills', and 'Misc' sections of LegACy's 1-Scene CMS (Alternate Version) script. Nor can I use the Mouse in Moghunter's Name Scene script.
Code:
#==============================================================================
# ** 1-Scene CMS (Alternate Version)
#------------------------------------------------------------------------------
# LegACy
# Version 1.00
# 12.28.07
#==============================================================================
# To put items into different catagory, simply apply
# attributes to them, you can apply more than 1 attributes
# to each item. In default, the attributes are :
# :: 19 > Recovery items
# :: 20 > Weaponry
# :: 21 > Armor
# :: 22 > Accessories
# :: 23 > Key Items
# :: 24 > Miscellanous Items
#
# For customization, look in LegACy class, further explanation's
# located there.
#
# Special thanks to Sven Kistner for his MMD3 Winamp skin
# which gives me the inspiration to make this and Squall
# (is it Selwyn now?) for his ASM.
#=============================================================
#==============================================================================
# ** LegACy's Script Customization (CMS-Alternate)
#==============================================================================
class LegACy
#--------------------------------------------------------------------------
# * Features Customization Constants
#--------------------------------------------------------------------------
CUSTOM_SAVE = true # True if you're using the custom save menu that comes with the menu.
SAVE_COUNT = 50 # Number of saves slot available for custom save menu.
BATTLE_BAR = false # True if you want to have bar for battle system.
#--------------------------------------------------------------------------
# * Item Grouping Customization Constants
#--------------------------------------------------------------------------
ITEMS = [18, 19, 20, 21, 22, 23] # Attributes ID for Item Catagory in order.
#--------------------------------------------------------------------------
# * Display Customization Constants
#--------------------------------------------------------------------------
WIN_Z = 8001 # Z value of CMS' windows.
ICON_NAME = ['stat', 'menu', 'item'] # Image name for icon,
STAT_BAR = [true, true, true] # Windows where the stat bar appears.
BAR_COLOR = [Color.new(255, 0, 0, 200), # Color for bars.
Color.new(255, 255, 0, 200),
Color.new(0, 255, 255, 200),
Color.new(200, 64, 64, 255),
Color.new(64, 128, 64, 255),
Color.new(160, 100, 160, 255),
Color.new(128, 128, 200, 255),
Color.new(64, 64, 64, 255)]
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Current Experience Points
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#--------------------------------------------------------------------------
# * Get Needed Experience Points
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Get Map Name
#--------------------------------------------------------------------------
def name
load_data('Data/MapInfos.rxdata')[@map_id].name
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------
# Draw Stat Bar
# actor : actor
# x : bar x-coordinate
# y : bar y-coordinate
# stat : stat to be displayed
#--------------------------------------------------------------------------
def draw_LegACy_bar(actor, x, y, stat, width = 156, height = 7)
bar_color = Color.new(0, 0, 0, 255)
end_color = Color.new(255, 255, 255, 255)
max = 999
case stat
when 'hp'
bar_color = Color.new(150, 0, 0, 255)
end_color = Color.new(255, 255, 60, 255)
min = actor.hp
max = actor.maxhp
when 'sp'
bar_color = Color.new(0, 0, 155, 255)
end_color = Color.new(255, 255, 255, 255)
min = actor.sp
max = actor.maxsp
when 'exp'
bar_color = Color.new(0, 155, 0, 255)
end_color = Color.new(255, 255, 255, 255)
unless actor.level == $data_actors[actor.id].final_level
min = actor.now_exp
max = actor.next_exp
else
min = 1
max = 1
end
when 'atk'
bar_color = LegACy::BAR_COLOR[0]
min = actor.atk
when 'pdef'
bar_color = LegACy::BAR_COLOR[1]
min = actor.pdef
when 'mdef'
bar_color = LegACy::BAR_COLOR[2]
min = actor.mdef
when 'str'
bar_color = LegACy::BAR_COLOR[3]
min = actor.str
when 'dex'
bar_color = LegACy::BAR_COLOR[4]
min = actor.dex
when 'agi'
bar_color = LegACy::BAR_COLOR[5]
min = actor.agi
when 'int'
bar_color = LegACy::BAR_COLOR[6]
min = actor.int
when 'eva'
bar_color = LegACy::BAR_COLOR[7]
min = actor.eva
end
max = 1 if max == 0
# Draw Border
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1,
Color.new(50, 50, 50, 255))
end
# Draw Background
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1,
Color.new(r, b, g, a))
end
# Draws Bar
for i in 1..( (min.to_f / max.to_f) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1,
Color.new(r, g, b, a))
end
end
case stat
when 'hp'
draw_actor_hp(actor, x - 1, y - 18)
when 'sp'
draw_actor_sp(actor, x - 1, y - 18)
when 'exp'
draw_actor_exp(actor, x - 1, y - 18)
end
end
#--------------------------------------------------------------------------
# * Draw Sprite
#--------------------------------------------------------------------------
def draw_LegACy_sprite(x, y, name, hue)
bitmap = RPG::Cache.character(name, hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
# Bitmap Rectange
src_rect = Rect.new(0, 0, cw, ch)
# Draws Bitmap
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# * Get Upgrade Text Color
#--------------------------------------------------------------------------
def up_color
return Color.new(74, 210, 74)
end
#--------------------------------------------------------------------------
# * Get Downgrade Text Color
#--------------------------------------------------------------------------
def down_color
return Color.new(170, 170, 170)
end
#--------------------------------------------------------------------------
# * Draw parameter
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# type : parameter type
#------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type, width = 120, bar = false)
case type
when 0
parameter_name = "Attack"
parameter_value = actor.atk
stat = 'atk'
when 1
parameter_name = "Physical Defense"
parameter_value = actor.pdef
stat = 'pdef'
when 2
parameter_name = "Magical Defense"
parameter_value = actor.mdef
stat = 'mdef'
when 3
parameter_name = "Strength"
parameter_value = actor.str
stat = 'str'
when 4
parameter_name = "Dexterity"
parameter_value = actor.dex
stat = 'dex'
when 5
parameter_name = "Agility"
parameter_value = actor.agi
stat = 'agi'
when 6
parameter_name = "Intelligence"
parameter_value = actor.int
stat = 'int'
when 7
parameter_name = 'Evasion'
parameter_value = actor.eva
stat = 'eva'
end
if bar == true #&& stat != 'eva'
draw_LegACy_bar(actor, x + 16, y + 21, stat, width - 16, 5)
end
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + width, y, 36, 32, parameter_value.to_s, 2)
end
end
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Alias Initialization
#--------------------------------------------------------------------------
alias legacy_CMS_windowselectable_update update
#--------------------------------------------------------------------------
# * Set Help Window
# name_window : new name window
#--------------------------------------------------------------------------
def name_window=(name_window)
@name_window = name_window
# Update name text (update_help is defined by the subclasses)
if self.active and @help_window != nil
update_name
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
legacy_CMS_windowselectable_update
# Update name text (update_help is defined by the subclasses)
if self.active and @name_window != nil
update_name
end
end
end
#==============================================================================
# ** Window_NewCommand
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_NewCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands, icon)
# Compute window height from command quantity
super(0, 0, width, commands.size * 48 + 48)
@item_max = commands.size
@commands = commands
@icon = icon
self.contents = Bitmap.new(width - 32, (@item_max * 48) + 16)
refresh
self.index = -1
self.active = false
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
self.contents.font.bold = false
rect = Rect.new(4, 52 * index + 2, self.contents.width - 4, 52)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(@icon + index.to_s)
self.contents.blt(4, 52 * index + 4, bitmap, Rect.new(0, 0, 24, 24))
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 32
# Calculate cursor coordinates
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 52 - self.oy - 4
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, 42)
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
# * Command Update
#--------------------------------------------------------------------------
def update_name
@name_window.set_text(@commands[self.index] == nil ? "" : @commands[self.index])
end
end
#==============================================================================
# ** Window_NewMenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_NewMenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 192, 336)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
$game_party.actors.size < 4 ? i = 14 : i = 0
$game_party.actors.size == 1 ? i = 24 : i = i
self.contents = Bitmap.new(width - 32, (@item_max * 84) + i - 32)
for i in 0...@item_max
x = 4
y = (i * 74) - 14
actor = $game_party.actors[i]
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
draw_LegACy_sprite(x + 16, y + 57, actor.character_name, actor.character_hue)
draw_actor_name(actor, x + 36, y + 10)
#draw_actor_state(actor, x + 36, y + 10)
draw_actor_class(actor, x + 36, y + 22)
draw_actor_level(actor, x + 36, y + 34)
#draw_LegACy_bar(actor, x - 3, y + 60, 'hp', 152) #HP
draw_actor_hp(actor, x + 3, y + 48)
#draw_LegACy_bar(actor, x - 3, y + 75, 'sp', 152) #SP
draw_actor_sp(actor, x + 3, y + 58)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
@index > 3 ? self.oy = (@index - 3) * 77 : self.oy = 0
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(-4, (@index * 77) - 2 - self.oy, self.width - 24, 77)
end
end
end
#==============================================================================
# ** Window_Stat
#------------------------------------------------------------------------------
# This window displays game stat on the menu screen.
#==============================================================================
class Window_Stat < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 256, 144)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.draw_text(32, -4, 120, 32, "Play Time")
cx = contents.text_size($data_system.words.gold).width
self.contents.draw_text(32, 20, 120, 32, "Step Count")
self.contents.draw_text(32, 44, cx, 32, $data_system.words.gold, 2)
self.contents.draw_text(32, 68, 120, 32, "Location")
self.contents.font.color = normal_color
self.contents.draw_text(96, -4, 120, 32, text, 2)
self.contents.draw_text(96, 20, 120, 32, $game_party.steps.to_s, 2)
self.contents.draw_text(96, 44, 120, 32, $game_party.gold.to_s, 2)
self.contents.draw_text(24, 68, 192, 32, $game_map.name.to_s, 2) #(24, 86, 192, 32,
for i in 0...4
rect = Rect.new(4, 24 * i, 24, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(LegACy::ICON_NAME[0] + i.to_s)
self.contents.blt(4, 24 * i, bitmap, Rect.new(0, 0, 24, 24))
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# ** Window_Name
#------------------------------------------------------------------------------
# This window shows command, item, and skill names .
#==============================================================================
class Window_Name < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 112, 48)
self.contents = Bitmap.new(width - 32, height - 32)
self.visible = false
end
#--------------------------------------------------------------------------
# * Set Text
# text : text string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
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.font.size = 14 #Font Size
self.contents.font.bold = false
self.contents.draw_text(0, -4, self.width - 32, 24, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
#==============================================================================
# ** Window_NewHelp
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_NewHelp < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 384, 48)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Set Text
# text : text string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# 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.font.size = 14 #Font Size
self.contents.font.bold = false
self.contents.draw_text(0, -4, self.width - 32, 24, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
#==============================================================================
# ** Window_NewItem
#------------------------------------------------------------------------------
# This window displays items in possession on the menu.
#==============================================================================
class Window_NewItem < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 384, 96)
@column_max = 12
@attribute = LegACy::ITEMS[0]
refresh
self.index = 0
self.active = false
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Updates Window With New Item Type
# attribute : new item type
#--------------------------------------------------------------------------
def update_item(attribute)
@attribute = attribute
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add item
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
$data_items[i].element_set.include?(@attribute)
@data.push($data_items[i])
end
end
# Also add weapons and items if outside of battle
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
$data_weapons[i].element_set.include?(@attribute)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
$data_armors[i].guard_element_set.include?(@attribute)
@data.push($data_armors[i])
end
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 12 * 28
y = index / 12 * 32
rect = Rect.new(x, y, self.width / @column_max - 24, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x, y + 12, 24, 20, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max
# Calculate cursor coordinates
x = @index % @column_max * 28
y = @index / @column_max * 32 - self.oy + 2
# Update cursor rectangle
self.cursor_rect.set(x + 1, y, cursor_width - 2, 28)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
#--------------------------------------------------------------------------
# * Name Text Update
#--------------------------------------------------------------------------
def update_name
@name_window.set_text(self.item == nil ? "" : self.item.name)
end
end
#==============================================================================
# ** Window_NewSkill
#------------------------------------------------------------------------------
# This window displays usable skills on the skill menu.
#==============================================================================
class Window_NewSkill < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 384, 96)
@actor = actor
@column_max = 12
refresh
self.index = 0
self.active = false
end
#--------------------------------------------------------------------------
# * Acquiring Skill
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Acquiring Actor
#--------------------------------------------------------------------------
def actor
return @actor
end
#--------------------------------------------------------------------------
# * Updates Window With New Actor
# actor : new actor
#--------------------------------------------------------------------------
def update_actor(actor)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in [email=0...@actor.skills.size]0...@actor.skills.size[/email]
skill = $data_skills[@actor.skills[i]]
if skill != nil
@data.push(skill)
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
x = 4 + index % 12 * 28
y = index / 12 * 32
rect = Rect.new(x, y, self.width / @column_max - 24, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 4, y + 12, 24, 20, skill.sp_cost.to_s, 2)
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max
# Calculate cursor coordinates
x = @index % @column_max * 28
y = @index / @column_max * 32 - self.oy + 2
# Update cursor rectangle
self.cursor_rect.set(x + 1, y, cursor_width - 2, 28)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
#--------------------------------------------------------------------------
# * Name Text Update
#--------------------------------------------------------------------------
def update_name
@name_window.set_text(self.skill == nil ? "" : self.skill.name)
end
end
#==============================================================================
# ** Window_EquipStat
#------------------------------------------------------------------------------
# This window displays actor parameter changes on the equipment screen.
#==============================================================================
class Window_EquipStat < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :changes
attr_accessor :mode
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 240, 164) #super(0, 0, 240, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
@changes = [0, 0, 0, 0, 0, 0, 0, 0]
@mode = 0
refresh
end
#--------------------------------------------------------------------------
# * Updates Window With New Actor
# actor : new actor
#--------------------------------------------------------------------------
def update_actor(actor)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
for i in 0..7
draw_actor_parameter(@actor, 16, (i * 16) - 8, i, 96, LegACy::STAT_BAR[1])
end
# Draw new attack if it's changed
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(152, -6, 32, 32, "»»", 1)
if @changes[0] == 0
self.contents.font.color = normal_color
elsif @changes[0] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, -6, 32, 32, @new_atk.to_s, 2)
end
# Draw new physical def if it's changed
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 4, 32, 32, "»»", 1)
if @changes[1] == 0
self.contents.font.color = normal_color
elsif @changes[1] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 4, 32, 32, @new_pdef.to_s, 2)
end
# Draw new magical def if it's changed
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 20, 32, 32, "»»", 1)
if @changes[2] == 0
self.contents.font.color = normal_color
elsif @changes[2] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 20, 32, 32, @new_mdef.to_s, 2)
end
# Draw new str if it's changed
if @new_str != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 36, 32, 32, "»»", 1)
if @changes[3] == 0
self.contents.font.color = normal_color
elsif @changes[3] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 36, 32, 32, @new_str.to_s, 2)
end
# Draw new dex if it's changed
if @new_dex != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 52, 32, 32, "»»", 1)
if @changes[4] == 0
self.contents.font.color = normal_color
elsif @changes[4] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 52, 32, 32, @new_dex.to_s, 2)
end
# Draw new agi if it's changed
if @new_agi != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 66, 32, 32, "»»", 1)
if @changes[5] == 0
self.contents.font.color = normal_color
elsif @changes[5] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 66, 32, 32, @new_agi.to_s, 2)
end
# Draw new int if it's changed
if @new_int != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 82, 32, 32, "»»", 1)
if @changes[6] == 0
self.contents.font.color = normal_color
elsif @changes[6] == -1
self.contents.font.color = down_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 82, 32, 32, @new_int.to_s, 2)
end
# Draw new evasion if it's changed
if @new_eva != nil
self.contents.font.color = system_color
self.contents.draw_text(152, 100, 32, 32, "»»", 1)
if @changes[7] == 0
self.contents.font.color = normal_color
elsif @changes[7] == -1
self.contents.font.color = don_color
else
self.contents.font.color = up_color
end
self.contents.draw_text(176, 100, 32, 32, @new_eva.to_s, 2)
end
end
#--------------------------------------------------------------------------
# * Set parameters after changing equipment
# new_atk : attack power after changing equipment
# new_pdef : physical defense after changing equipment
# new_mdef : magic defense after changing equipment
# new_str : strength after changing equipment
# new_dex : dexterity after changing equipment
# new_agi : agility after changing equipment
# new_int : inteligence after changing equipment
# new_eva : evasion after changing equipment
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
new_agi, new_int, new_eva)
flag = false
if new_atk != @new_atk || new_pdef != @new_pdef || new_str != @new_str ||
new_mdef != @new_mdef || new_dex != @new_dex || new_agi != @new_agi ||
new_eva != @new_eva
flag = true
end
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
@new_dex = new_dex
@new_agi = new_agi
@new_int = new_int
@new_eva = new_eva
if flag
refresh
end
end
end
#==============================================================================
# ** Window_Equipment
#------------------------------------------------------------------------------
# This window displays items the actor is currently equipped with on the
# equipment screen.
#==============================================================================
class Window_Equipment < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 240, 176) #super(0, 0, 240, 176)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
self.index = 0
self.active = false
end
#--------------------------------------------------------------------------
# * Updates Window With New Actor
# actor : new actor
#--------------------------------------------------------------------------
def update_actor(actor)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
self.contents.draw_text(0, 28 * 0, 76, 32, $data_system.words.weapon)
self.contents.draw_text(0, 28 * 1, 76, 32, $data_system.words.armor1)
self.contents.draw_text(0, 28 * 2, 76, 32, $data_system.words.armor2)
self.contents.draw_text(0, 28 * 3, 76, 32, $data_system.words.armor3)
self.contents.draw_text(0, 28 * 4, 76, 32, $data_system.words.armor4)
self.contents.font.size = 14 #Font Size
for i in 0..4
draw_item_name(@data[i], 76, 28 * i)
end
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Calculate cursor width
cursor_width = self.width / @column_max - 24
# Calculate cursor coordinates
x = @index % @column_max * (cursor_width + 24)
y = @index * 28
# Update cursor rectangle
self.cursor_rect.set(x - 4, y, cursor_width, 32)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ** Window_EquipmentItem
#------------------------------------------------------------------------------
# This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================
class Window_EquipmentItem < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
# equip_type : equip region (0-3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 0, 240, 96)
@actor = actor
@equip_type = equip_type
@column_max = 7
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Updates Window With New Actor
# actor : new actor
#--------------------------------------------------------------------------
def update_actor(actor)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Updates Window With New Equipment Type
# equip_type : new teyp of equipment
#--------------------------------------------------------------------------
def update_equipment(equip_type)
@equip_type = equip_type
refresh
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
if self.index == 0
return @data[@item_max - 1]
else
return @data[self.index - 1]
end
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def row_max
# Compute rows from number of items and columns
return (@item_max + @column_max + 5) / @column_max
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add equippable weapons
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# Add equippable armor
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# Add blank page
@data.push(nil)
# Make a bitmap and draw all items
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.draw_text(4, 0, 204, 32, 'Unequip', 1)
for i in 0...@item_max - 1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + (index ) % 7 * 30
y = 32 + ((index) / 7 * 32)
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
rect = Rect.new(x, y, self.width / @column_max - 24, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(x, y + 12, 24, 20, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If cursor is movable
if self.active and @item_max > 0 and @index >= 0
# If pressing down on the directional buttons
if Input.repeat?(Input::DOWN)
# If column count is 1 and directional button was pressed down with no
# repeat, or if cursor position is more to the front than
# (item count - column count)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
# Move cursor down
$game_system.se_play($data_system.cursor_se)
if @index == 0
@index = 1
else
@index = (@index + @column_max) % @item_max
end
end
end
# If the up directional button was pressed
if Input.repeat?(Input::UP)
# If column count is 1 and directional button was pressed up with no
# repeat, or if cursor position is more to the back than column count
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max or @index == 1
# Move cursor up
$game_system.se_play($data_system.cursor_se)
if @index == 1
@index = 0
else
@index = (@index - @column_max + @item_max) % @item_max
end
end
end
# If the right directional button was pressed
if Input.repeat?(Input::RIGHT)
# If column count is 2 or more, and cursor position is closer to front
# than (item count -1)
if @column_max >= 2 and @index < @item_max - 1
# Move cursor right
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
# If the left directional button was pressed
if Input.repeat?(Input::LEFT)
# If column count is 2 or more, and cursor position is more back than 0
if @column_max >= 2 and @index > 0
# Move cursor left
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
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
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = (@index + 6) / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max
# Calculate cursor coordinates
x = (@index + 6) % @column_max * 30
y = (@index + 6) / @column_max * 32 - self.oy + 2
if @index == 0
# Calculate cursor width
cursor_width = self.width - 30
# Calculate cursor coordinates
x = -1
y = -self.oy
end
# Update cursor rectangle
self.cursor_rect.set(x + 1, y, cursor_width - 2, 30)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? 'Unequip the current equipment.' :
self.item.description)
end
#--------------------------------------------------------------------------
# * Name Text Update
#--------------------------------------------------------------------------
def update_name
@name_window.set_text(self.item == nil ? "" : self.item.name)
self.item == nil ? @name_window.visible = false : @name_window.visible = true
end
end
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_NewStatus < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 256, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
self.active = false
end
#--------------------------------------------------------------------------
# * Updates Window With New Actor
# actor : new actor
#--------------------------------------------------------------------------
def update_actor(actor)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Draw basic stats
self.contents.clear
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
draw_actor_name(@actor, 12, 0)
draw_actor_graphic(@actor, 28, 104)
#draw_LegACy_bar(@actor, 64, 64, 'hp', 144) #HP
draw_actor_hp(@actor, 64, 38)
#draw_LegACy_bar(@actor, 64, 84, 'sp', 144) #SP
draw_actor_sp(@actor, 64, 60)
#draw_LegACy_bar(@actor, 64, 104, 'exp', 144)
draw_actor_exp(@actor, 40, 84)
draw_actor_class(@actor, 28, 24)
draw_actor_level(@actor, 136, 24)
draw_actor_state(@actor, 112, 0)
# Draw actor's parameters
self.contents.font.size = 14 #Font Size
self.contents.font.color = system_color
self.contents.draw_text(0, 116, 128, 32, "Status")
self.contents.font.size = 14 #Font Size
for i in 0..7
draw_actor_parameter(@actor, 12, (i * 20) + 140, i, 168, LegACy::STAT_BAR[2])
end
# Draw equipments
self.contents.font.size = 14 #Font Size
self.contents.font.color = system_color
self.contents.draw_text(0, 304, 128, 32, "Equipment")
self.contents.font.size = 14 #Font Size
self.contents.draw_text(12, 328, 96, 32, "Weapon")
self.contents.draw_text(12, 352, 96, 32, "Shield")
self.contents.draw_text(12, 376, 96, 32, "Helmet")
self.contents.draw_text(12, 400, 96, 32, "Armor")
self.contents.draw_text(12, 424, 96, 32, "Accessory")
equip = $data_weapons[@actor.weapon_id]
if @actor.equippable?(equip)
draw_item_name($data_weapons[@actor.weapon_id], 96, 328)
else
self.contents.font.color = knockout_color
self.contents.draw_text(96, 328, 192, 32, "Nothing equipped")
end
equip1 = $data_armors[@actor.armor1_id]
if @actor.equippable?(equip1)
draw_item_name($data_armors[@actor.armor1_id], 96, 352)
else
self.contents.font.color = crisis_color
self.contents.draw_text(96, 352, 192, 32, "Nothing equipped")
end
equip2 = $data_armors[@actor.armor2_id]
if @actor.equippable?(equip2)
draw_item_name($data_armors[@actor.armor2_id], 96, 376)
else
self.contents.font.color = crisis_color
self.contents.draw_text(96, 376, 192, 32, "Nothing equipped")
end
equip3 = $data_armors[@actor.armor3_id]
if @actor.equippable?(equip3)
draw_item_name($data_armors[@actor.armor3_id], 96, 400)
else
self.contents.font.color = crisis_color
self.contents.draw_text(96, 400, 192, 32, "Nothing equipped")
end
equip4 = $data_armors[@actor.armor4_id]
if @actor.equippable?(equip4)
draw_item_name($data_armors[@actor.armor4_id], 96, 424)
else
self.contents.font.color = crisis_color
self.contents.draw_text(96, 424, 192, 32, "Nothing equipped")
end
end
end
#==============================================================================
# ** Window_NewFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================
class Window_NewFile < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize()
super(256, 0, 384, 336)
self.contents = Bitmap.new(width - 32, 99 * 32)
index = $game_temp.last_file_index == nil ? 0 : $game_temp.last_file_index
self.index = index
self.active = false
@item_max = LegACy::SAVE_COUNT
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 14 #Font
self.contents.font.bold = false
time_stamp = Time.at(0)
for i in 0...@item_max
filename = "Save#{i + 1}.rxdata"
# Draw file number
self.contents.font.color = system_color
self.contents.draw_text(-2, i * 32, 32, 32, (i + 1).to_s, 1)
if FileTest.exist?(filename)
# Load save file size
size = File.size(filename)
if size.between?(1000, 999999)
size /= 1000
size_str = "#{size} KB"
elsif size > 999999
size /= 1000000
size_str = "#{size} MB"
else
size_str = size.to_s
end
# Loads data
file = File.open(filename, "r")
# Draw time stamp
time_stamp = file.mtime
date = time_stamp.strftime("%m/%d/%Y")
time = time_stamp.strftime("%H:%M")
self.contents.font.color = normal_color
self.contents.draw_text(24, i * 32, 80, 32, date)
self.contents.draw_text(144, i * 32, 100, 32, time)
self.contents.draw_text(272, i * 32, 72, 32, size_str, 2)
end
end
end
end
#==============================================================================
# ** Window_FileStatus
#------------------------------------------------------------------------------
# This window shows the status of the currently selected save file
#==============================================================================
class Window_FileStatus < Window_Base
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize(save_window)
super(0, 0, 384, 144)
self.contents = Bitmap.new(width - 32, height - 32)
@save_window = save_window
@index = @save_window.index
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 14 #Font Size
self.contents.font.bold = false
filename = "Save#{@index + 1}.rxdata"
return unless FileTest.exist?(filename)
file = File.open(filename, "r")
Marshal.load(file)
frame_count = Marshal.load(file)
for i in 0...6
Marshal.load(file)
end
party = Marshal.load(file)
Marshal.load(file)
map = Marshal.load(file)
for i in 0...party.actors.size
actor = party.actors[i]
x = i % 2 * 84 + 4
y = i / 2 * 56
draw_actor_name(actor, x + 22, y + 6)
#draw_actor_level(actor, x + 22, y + 22)
draw_actor_graphic(actor, x + 6, y + 50)
end
total_sec = frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
map_name = load_data("Data/MapInfos.rxdata")[map.map_id].name
self.contents.font.color = system_color
self.contents.font.size = 14 #Font Size
self.contents.draw_text(168, 2, 96, 24, "Play Time")
self.contents.draw_text(168, 30, 96, 24, $data_system.words.gold)
self.contents.draw_text(168, 58, 96, 24, "Location")
self.contents.font.color = normal_color
self.contents.draw_text(276, 2, 76, 24, text, 2)
self.contents.draw_text(276, 30, 76, 24, party.gold.to_s, 2)
self.contents.draw_text(200, 82, 152, 24, map_name, 2)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
@tilemap.update if @tilemap != nil
if @index != @save_window.index
@index = @save_window.index
refresh
end
super
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
@target = false
@exit = false
@actor = $game_party.actors[0]
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = 'Status'
s5 = 'Save'
s6 = 'Options'
t1 = 'Recovery'
t2 = 'Weapon'
t3 = 'Armor'
t4 = 'Accessory'
t5 = 'Quest'
t6 = 'Misc.'
u1 = 'To Title'
u2 = 'Options'
u3 = 'Quit'
@command_window = Window_NewCommand.new(64, [s1, s2, s3, s4, s5, s6], LegACy::ICON_NAME[1])
@command_window.x = 192
@command_window.y = -192
@command_window.active = true
@command_window.index = 0
# Make stat window
@stat_window = Window_Stat.new
# Make name window
@name_window = Window_Name.new
@name_window.x = 96
@name_window.y = 50
@name_window.opacity = 200
# Make help window
@help_window = Window_NewHelp.new
@help_window.x = -128
@command_window.name_window = @name_window
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make status window
@status_window = Window_NewMenuStatus.new
@status_window.y = -192
# Make item catagory window
@catagory_window = Window_NewCommand.new(64, [t1, t2, t3, t4, t5, t6], LegACy::ICON_NAME[2])
@catagory_window.x = 192
@catagory_window.y = -192
@catagory_window.name_window = @name_window
# Make item window
@item_window = Window_NewItem.new
@item_window.x = -128
@item_window.y = 48
@item_window.help_window = @help_window
@item_window.name_window = @name_window
# Make skill window
@skill_window = Window_NewSkill.new(@actor)
@skill_window.x = -128
@skill_window.y = 48
@skill_window.help_window = @help_window
@skill_window.name_window = @name_window
# Make equipment windows
@equipitem_window = Window_EquipmentItem.new(@actor, 0)
@equipitem_window.x = 256
@equipitem_window.y = -96
@equipitem_window.help_window = @help_window
@equipitem_window.name_window = @name_window
@equip_window = Window_Equipment.new(@actor)
@equip_window.x = 16
@equip_window.y = -32
@equip_window.help_window = @help_window
@equipstat_window = Window_EquipStat.new(@actor)
@equipstat_window.x = 16
@equipstat_window.y = -16
# Make player status window
@playerstatus_window = Window_NewStatus.new(@actor)
@playerstatus_window.height = 144
# Make file window
@file_window = Window_NewFile.new
@file_window.x = -128
@file_window.y = -192
# Make file status window
@filestat_window = Window_FileStatus.new(@file_window)
@filestat_window.x = -128
# Make end window
@end_window = Window_Command.new(120, [u1, u2, u3])
@end_window.x = 136
@end_window.active = false
# Make map image on background
@spriteset = Spriteset_Map.new
# Adjusting the z coordinates of the windows
@windows = [@command_window, @stat_window, @status_window,
@catagory_window, @name_window, @help_window, @item_window,
@skill_window, @equipstat_window, @equip_window, @equipitem_window,
@playerstatus_window, @file_window, @filestat_window, @end_window]
@windows.each {|i| i.z = LegACy::WIN_Z}
@stat_window.z = LegACy::WIN_Z + 5
@name_window.z = LegACy::WIN_Z + 10
@equipstat_window.z = LegACy::WIN_Z - 3
@equip_window.z = LegACy::WIN_Z - 5
@equipitem_window.z = LegACy::WIN_Z - 10
@file_window.z = LegACy::WIN_Z - 5
# 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
# Dispose of windows
@windows.each {|i| i.dispose}
@spriteset.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@windows.each {|i| i.update}
# Animate windows
animate
# Update actor scrolling system
update_scroll if @skill_window.active || @equip_window.active ||
@playerstatus_window.active
# Update menu system
menu_update
# Update name windows
update_name
end
#--------------------------------------------------------------------------
# * Animating windows
#--------------------------------------------------------------------------
def animate
# Animate initial windows if command window is active
if @command_window.active
@command_window.y += 28 if @command_window.y < 144
@status_window.y += 28 if @status_window.y < 144
@equipstat_window.y += 8 if @equipstat_window.y < 48
@equip_window.y += 8 if @equip_window.y < 32
# Animate initial windows upon exiting menu
elsif @exit == true
@command_window.y -= 28 if @command_window.y > -192
@status_window.y -= 28 if @status_window.y > -192
@equipstat_window.y -= 8 if @equipstat_window.y > -16
@equip_window.y -= 8 if @equip_window.y > -32
$scene = Scene_Map.new if @status_window.y == -192
end
# Animate item catagory windows if it's active
if @catagory_window.active
@command_window.y += 28 if @command_window.y < 480
@catagory_window.y += 28 if @catagory_window.y < 144
elsif @item_window.active == false && @target == false
@catagory_window.y -= 28 if @catagory_window.y > -192
@command_window.y -= 28 if @command_window.y > 144
end
# Animate item windows if it's active
if @item_window.active
@item_window.x += 48 if @item_window.x < 256
@help_window.x += 48 if @help_window.x < 256
elsif ! @command_window.active && @catagory_window.active == true &&
@command_window.index == 0
@item_window.x -= 48 if @item_window.x > -128
@help_window.x -= 48 if @help_window.x > -128
end
# Animate skill windows if it's active
if @skill_window.active
@skill_window.x += 48 if @skill_window.x < 256
@help_window.x += 48 if @help_window.x < 256
elsif ! @command_window.active &&! @target && @command_window.index == 1
@skill_window.x -= 48 if @skill_window.x > -128
@help_window.x -= 48 if @help_window.x > -128
end
# Animate equipment windows if they're active
if @equip_window.active
@equipstat_window.x += 30 if @equipstat_window.x < 256
@equip_window.x += 30 if @equip_window.x < 256
@help_window.x += 48 if @help_window.x < 256
if @equip_window.x == 256 && @equip_window.y < 208
@equip_window.y += 22
@equipitem_window.y += 48
end
elsif ! @equip_window.active && @equipitem_window.active == false && @command_window.index == 2
@equipitem_window.y -= 48 if @equipitem_window.y > -96
@equip_window.y -= 22 if @equip_window.y > 32
if @equip_window.x > 16 && @equip_window.y == 32
@equipstat_window.x -= 30 if @equipstat_window.x > 16
@equip_window.x -= 30 if @equip_window.x > 16
@help_window.x -= 48 if @help_window.x > -128
end
end
# Animate equipment item window if it's active
if @equipitem_window.active
@equipitem_window.y += 12 if @equipitem_window.y < 384
elsif @equip_window.active
@equipitem_window.y -= 12 if @equipitem_window.y > 288
end
# Animate status window if it's active
if @playerstatus_window.active
@playerstatus_window.x += 32 if @playerstatus_window.x < 256
if @playerstatus_window.x == 256
@playerstatus_window.height += 42 if @playerstatus_window.height < 480
end
else
@playerstatus_window.height -= 42 if @playerstatus_window.height > 144
if @playerstatus_window.height == 144
@playerstatus_window.x -= 32 if @playerstatus_window.x > 0
end
end
# Animate file windows if it's active
if @file_window.active
@filestat_window.x += 48 if @filestat_window.x < 256
@file_window.x += 48 if @file_window.x < 256
if @file_window.x == 256
@file_window.y += 42 if @file_window.y < 144
end
else
@file_window.y -= 42 if @file_window.y > -192
if @file_window.y == -192
@file_window.x -= 48 if @file_window.x > -128
@filestat_window.x -= 48 if @filestat_window.x > -128
end
end
# Animate end window if it's active
if @end_window.active
@end_window.x += 15 if @end_window.x < 256
else
@end_window.x -= 15 if @end_window.x > 136
end
end
#--------------------------------------------------------------------------
# * Checking Update Method Needed
#--------------------------------------------------------------------------
def menu_update
if @command_window.active && @command_window.y == 144 then update_command
elsif @item_window.x == -128 && @catagory_window.active && @catagory_window.y == 144 then update_catagory
elsif @item_window.active && @item_window.x == 256 then update_item
elsif @skill_window.active && @skill_window.x == 256 then update_skill
elsif @target then update_target
elsif @equip_window.active && @equip_window.y == 208 then update_equip
elsif @equipitem_window.active && @equipitem_window.y == 384 then update_equipment
elsif @playerstatus_window.height == 480 then update_playerstatus
elsif @status_window.active then update_status
elsif @file_window.y == 144 then update_save
elsif @end_window.x == 256 then update_end
end
end
#--------------------------------------------------------------------------
# * Name Update
#--------------------------------------------------------------------------
def update_name
# Update name window if command window is active
if @command_window.active && @command_window.y == 144
@name_window.x = @command_window.x + 36
@name_window.y = @command_window.y - 18 + (@command_window.index * 52)
@command_window.update_name
# Update name window if item catagory window is active
elsif @item_window.x == -128 && @catagory_window.active && @catagory_window.y == 144
@name_window.x = @catagory_window.x + 36
@name_window.y = @catagory_window.y - 18 + (@catagory_window.index * 52)
@catagory_window.update_name
# Update name window if item window is active
elsif @item_window.active && @item_window.x == 256
if @item_window.index % 12 < 6
@name_window.x = @item_window.x + 36 + (@item_window.index % 12 * 28)
else
@name_window.x = @item_window.x - 88 + (@item_window.index % 12 * 28)
end
@name_window.y = @item_window.y - 18 + (@item_window.index / 12 * 32)
@item_window.update_name
# Update name window if skill window is active
elsif @skill_window.active && @skill_window.x == 256
if @skill_window.index % 12 < 6
@name_window.x = @skill_window.x + 36 + (@skill_window.index % 12 * 28)
else
@name_window.x = @skill_window.x - 88 + (@skill_window.index % 12 * 28)
end
@name_window.y = @skill_window.y - 18 + (@skill_window.index / 12 * 32)
@skill_window.update_name
# Update name window if equipment window is active
elsif @equipitem_window.active && @equipitem_window.y == 384
@name_window.x = @equipitem_window.x + 36 + (@equipitem_window.index % 7 * 30)
@name_window.y = @equipitem_window.y - 18 + (@equipitem_window.index / 7 * 32)
@equipitem_window.update_name
# Hide name window if it's not needed
else
@name_window.visible = false
end
end
#--------------------------------------------------------------------------
# * Windows Actor Scrolling Update
#--------------------------------------------------------------------------
def update_scroll
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
if $game_party.actors.size - 1 == @status_window.index
@status_window.index = 0
else
@status_window.index += 1
end
actor = $game_party.actors[@status_window.index]
@skill_window.update_actor(actor) if @skill_window.active
@playerstatus_window.update_actor(actor) if @playerstatus_window.active
if @equip_window.active
@equip_window.update_actor(actor)
@equipitem_window.update_actor(actor)
@equipstat_window.update_actor(actor)
end
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
if @status_window.index == 0
@status_window.index = $game_party.actors.size - 1
else
@status_window.index -= 1
end
actor = $game_party.actors[@status_window.index]
@skill_window.update_actor(actor) if @skill_window.active
@playerstatus_window.update_actor(actor) if @playerstatus_window.active
if @equip_window.active
@equip_window.update_actor(actor)
@equipitem_window.update_actor(actor)
@equipstat_window.update_actor(actor)
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
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
@command_window.active = false
@exit = true
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)
# Make item catagory window active
@command_window.active = false
@catagory_window.active = true
@catagory_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
#Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to default save screen
if ! LegACy::CUSTOM_SAVE
$scene = Scene_Save.new
return
end
# Or switch to custom save menu
@command_window.active = false
@file_window.active = true
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
@command_window.active = false
@end_window.active = true
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
@actor = $game_party.actors[@status_window.index]
# 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 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
@skill_window.active = true
@skill_window.index = 0
@skill_window.update_actor(@actor)
@help_window.active = true
@status_window.active = false
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
@equip_window.active = true
@equip_window.index = 0
@equip_window.update_actor(@actor)
@help_window.active = true
@status_window.active = false
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
@playerstatus_window.active = true
@playerstatus_window.update_actor(@actor)
@status_window.active = false
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when catagory window is active)
#--------------------------------------------------------------------------
def update_catagory
# 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
@catagory_window.active = false
@catagory_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Branch by command window cursor position
type = LegACy::ITEMS[@catagory_window.index]
@item_window.active = true
@item_window.update_item(type)
@catagory_window.active = false
@help_window.active = true
@item_window.index = 0
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to item command window
@item_window.active = false
@catagory_window.active = true
@help_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = @item_window.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
@item_window.active = false
@target = true
@status_window.active = true
# Set cursor position to effect scope (single / all)
if @item.scope == 4 || @item.scope == 6
@status_window.index = -1
else
@status_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)
# Draw item window item
@item_window.draw_item(@item_window.index)
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (if skill window is active)
#--------------------------------------------------------------------------
def update_skill
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to main command menu
@skill_window.active = false
@help_window.active = false
@status_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the skill window
@skill = @skill_window.skill
# If unable to use
if @skill == nil or not @actor.skill_can_use?(@skill.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 ally
if @skill.scope >= 3
# Activate target window
@skill_window.active = false
@target = true
@status_window.active = true
# Set cursor position to effect scope (single / all)
if @skill.scope == 4 || @skill.scope == 6
@status_window.index = -1
elsif @skill.scope == 7
@actor_index = @status_window.index
@status_window.index = @actor_index - 10
else
@status_window.index = 0
end
# If effect scope is other than ally
else
# If common event ID is valid
if @skill.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Play use skill SE
$game_system.se_play(@skill.menu_se)
# Use up SP
@actor.sp -= @skill.sp_cost
# Remake each window content
@status_window.refresh
@skill_window.refresh
# 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 @command_window.index == 0
# Remake item window contents
@item_window.refresh
@item_window.active = true
@status_window.active = false
@status_window.index = -1
end
if @command_window.index == 1
# Remake skill window contents
@skill_window.refresh
@skill_window.active = true
@status_window.active = false
@status_window.index = @skill_window.actor.index
end
@target = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
if @command_window.index == 0
# If items are used up
if $game_party.item_number(@item.id) == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @status_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 @status_window.index >= 0
# Apply item use effects to target actor
target = $game_party.actors[@status_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)
# Redraw item window item
@item_window.refresh
end
# Remake target window contents
@status_window.refresh
# If all party members are dead
if $game_party.all_dead?
@target = false
# 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
@target = false
# 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
if @command_window.index == 1
# If unable to use because SP ran out
unless @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @status_window.index == -1
# Apply skill use effects to entire party
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
# If target is user
if @status_window.index <= -2
# Apply skill use effects to target actor
target = $game_party.actors[@status_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# If single target
if @status_window.index >= 0
# Apply skill use effects to target actor
target = $game_party.actors[@status_window.index]
used = target.skill_effect(@actor, @skill)
end
# If skill was used
if used
# Play skill use SE
$game_system.se_play(@skill.menu_se)
# Use up SP
@actor.sp -= @skill.sp_cost
# Remake each window content
@status_window.refresh
@skill_window.refresh
# If entire party is dead
if $game_party.all_dead?
# Switch to game over screen
@target = false
$scene = Scene_Gameover.new
return
end
# If command event ID is valid
if @skill.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @skill.common_event_id
@target = false
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If skill wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (when equip window is active)
#--------------------------------------------------------------------------
def update_equip
@equipitem_window.update_equipment(@equip_window.index)
@equipstat_window.mode = @equip_window.index
@equipstat_window.refresh
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
@status_window.refresh
# Switch to menu screen
@equip_window.active = false
@help_window.active = false
@status_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If equipment is fixed
if @actor.equip_fix?(@equip_window.index)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Activate item window
@equip_window.active = false
@equipitem_window.active = true
@equipitem_window.index = 0
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when equipment item window is active)
#--------------------------------------------------------------------------
def update_equipment
# Get currently item
item1 = @equip_window.item
item2 = @equipitem_window.item
last_hp = @actor.hp
last_sp = @actor.sp
old_atk = @actor.atk
old_pdef = @actor.pdef
old_mdef = @actor.mdef
old_str = @actor.str
old_dex = @actor.dex
old_agi = @actor.agi
old_int = @actor.int
old_eva = @actor.eva
@actor.equip(@equip_window.index, item2 == nil ? 0 : item2.id)
# Get parameters for after equipment change
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
new_str = @actor.str
new_dex = @actor.dex
new_agi = @actor.agi
new_int = @actor.int
new_eva = @actor.eva
@equipstat_window.changes = [0, 0, 0, 0, 0, 0, 0, 0]
@equipstat_window.changes[0] = new_atk > old_atk ? 1 : @equipstat_window.changes[0]
@equipstat_window.changes[0] = new_atk < old_atk ? -1 : @equipstat_window.changes[0]
@equipstat_window.changes[1] = new_pdef > old_pdef ? 1 : @equipstat_window.changes[1]
@equipstat_window.changes[1] = new_pdef < old_pdef ? -1 : @equipstat_window.changes[1]
@equipstat_window.changes[2] = new_mdef > old_mdef ? 1 : @equipstat_window.changes[2]
@equipstat_window.changes[2] = new_mdef < old_mdef ? -1 : @equipstat_window.changes[2]
@equipstat_window.changes[3] = new_str > old_str ? 1 : @equipstat_window.changes[3]
@equipstat_window.changes[3] = new_str < old_str ? -1 : @equipstat_window.changes[3]
@equipstat_window.changes[4] = new_dex > old_dex ? 1 : @equipstat_window.changes[4]
@equipstat_window.changes[4] = new_dex < old_dex ? -1 : @equipstat_window.changes[4]
@equipstat_window.changes[5] = new_agi > old_agi ? 1 : @equipstat_window.changes[5]
@equipstat_window.changes[5] = new_agi < old_agi ? -1 : @equipstat_window.changes[5]
@equipstat_window.changes[6] = new_int > old_int ? 1 : @equipstat_window.changes[6]
@equipstat_window.changes[6] = new_int < old_int ? -1 : @equipstat_window.changes[6]
@equipstat_window.changes[7] = new_eva > old_eva ? 1 : @equipstat_window.changes[7]
@equipstat_window.changes[7] = new_eva < old_eva ? -1 : @equipstat_window.changes[7]
# Return equipment
@actor.equip(@equip_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# Draw in left window
@equipstat_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str,
new_dex, new_agi, new_int, new_eva)
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Erase parameters for after equipment change
@equipstat_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
# Activate right window
@equip_window.active = true
@equipitem_window.active = false
@equipitem_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @equipitem_window.item
# Change equipment
@actor.equip(@equip_window.index, item == nil ? 0 : item.id)
# Erase parameters for after equipment change
@equipstat_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
# Activate right window
@equip_window.active = true
@equipitem_window.active = false
@equipitem_window.index = -1
# Remake right window and item window contents
@equip_window.refresh
@equipitem_window.refresh
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when player status window is active)
#--------------------------------------------------------------------------
def update_playerstatus
# 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
@playerstatus_window.active = false
@status_window.active = true
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when save window is active)
#--------------------------------------------------------------------------
def update_save
# 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
@file_window.active = false
@command_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play save SE
$game_system.se_play($data_system.save_se)
file = File.open("Save#{@file_window.index + 1}.rxdata", "wb")
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
# Write frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
# Increase save count by 1
$game_system.save_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($ats, file)
file.close
@file_window.refresh
@filestat_window.refresh
return
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update_end
# 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
@end_window.active = false
@command_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Branch by command window cursor position
case @end_window.index
when 0 # to title
# Switch to title screen
$scene = Scene_Title.new
when 1 # Options
$scene = Scene_ConfigurationType.new
when 2 # shutdown
# Shutdown
$scene = nil
end
return
end
end
end
#----------------------------------------------------------------------------
# Begin Window Battle Status Edit
#----------------------------------------------------------------------------
if LegACy::BATTLE_BAR
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
#draw_LegACy_bar(actor, actor_x - 4, 46, 'hp', 120) #HP
draw_actor_hp(actor, actor_x - 1, 46)
#draw_LegACy_bar(actor, actor_x - 4, 76, 'sp', 120) #SP
draw_actor_sp(actor, actor_x - 1, 76)
if @level_up_flags[i]
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
else
draw_actor_state(actor, actor_x, 96)
end
end
end
end
end
#----------------------------------------------------------------------------
# End Window Battle Status Edit
#----------------------------------------------------------------------------
if LegACy::CUSTOM_SAVE
#==============================================================================
# ** Window_File
#------------------------------------------------------------------------------
# This window shows a list of recorded save files.
#==============================================================================
class Window_File < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize()
super(0, 96, 320, 336)
self.contents = Bitmap.new(width - 32, LegACy::SAVE_COUNT * 32)
index = $game_temp.last_file_index == nil ? 0 : $game_temp.last_file_index
self.index = index
self.active = false
@item_max = LegACy::SAVE_COUNT
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
time_stamp = Time.at(0)
for i in 0...LegACy::SAVE_COUNT
filename = "Save#{i + 1}.rxdata"
self.contents.draw_text(1, i * 32, 32, 32, (i + 1).to_s, 1)
if FileTest.exist?(filename)
size = File.size(filename)
if size.between?(1000, 999999)
size /= 1000
size_str = "#{size} KB"
elsif size > 999999
size /= 1000000
size_str = "#{size} MB"
else
size_str = size.to_s
end
time_stamp = File.open(filename, "r").mtime
date = time_stamp.strftime("%m/%d/%Y")
time = time_stamp.strftime("%H:%M")
self.contents.font.size = 14 #Font
self.contents.font.bold = false
self.contents.draw_text(38, i * 32, 120, 32, date)
self.contents.draw_text(160, i * 32, 100, 32, time)
self.contents.draw_text(0, i * 32, 284, 32, size_str, 2)
end
end
end
end
#==============================================================================
# ** Window_FileStat
#------------------------------------------------------------------------------
# This window shows the status of the currently selected save file
#==============================================================================
class Window_FileStat < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# save_window : current save file
#--------------------------------------------------------------------------
def initialize(save_window)
super(0, 96, 320, 336)
self.contents = Bitmap.new(width - 32, height - 32)
@save_window = save_window
@index = @save_window.index
refresh
end
#--------------------------------------------------------------------------
# # Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
filename = "Save#{@index + 1}.rxdata"
return unless FileTest.exist?(filename)
file = File.open(filename, "r")
Marshal.load(file)
frame_count = Marshal.load(file)
for i in 0...6
Marshal.load(file)
end
party = Marshal.load(file)
Marshal.load(file)
map = Marshal.load(file)
self.contents.font.size = 14 #Font
self.contents.font.bold = false
for i in 0...party.actors.size
actor = party.actors[i]
x = 4
y = i * 56
#draw_LegACy_bar(actor, x + 112, y + 14, 'hp', 160) #HP
draw_actor_hp(actor, x + 112, y + 14)
#draw_LegACy_bar(actor, x + 112, y + 36, 'sp', 160) #SP
draw_actor_sp(actor, x + 112, y + 36)
draw_actor_name(actor, x + 40, y - 2)
draw_actor_level(actor, x + 40, y + 22)
draw_actor_graphic(actor, x + 10, y + 48)
end
total_sec = frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
map_name = load_data("Data/MapInfos.rxdata")[map.map_id].name
self.contents.font.color = system_color
self.contents.draw_text(4, 224, 96, 32, "Play Time ")
self.contents.draw_text(4, 252, 96, 32, $data_system.words.gold)
self.contents.draw_text(4, 280, 96, 32, "Location ")
self.contents.draw_text(104, 224, 16, 32, ":")
self.contents.draw_text(104, 252, 16, 32, ":")
self.contents.draw_text(104, 280, 16, 32, ":")
self.contents.font.color = normal_color
self.contents.draw_text(120, 224, 144, 32, text)
self.contents.draw_text(120, 252, 144, 32, party.gold.to_s)
self.contents.draw_text(120, 280, 144, 32, map_name)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
if @index != @save_window.index
@index = @save_window.index
refresh
end
super
end
end
#----------------------------------------------------------------------------
# Begin Scene Load Edit
#----------------------------------------------------------------------------
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..LegACy::SAVE_COUNT
filename = "Save#{i + 1}.rxdata"
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text('Select a file to load.')
@file_window = Window_File.new
@file_window.y = 64
@file_window.height = 416
@file_window.width = 320
@file_window.active = true
@status_window = Window_FileStat.new(@file_window)
@status_window.x = 320
@status_window.y = 64
@status_window.height = 416
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@file_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@help_window.update
@file_window.update
@status_window.update
# If C button was pressed
if Input.trigger?(Input::C)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
$game_temp.last_file_index = @file_index
return
end
# If B button was pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new
return
end
end
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
# Read character data for drawing save file
characters = Marshal.load(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
# Read each type of game object
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$game_bank = Marshal.load(file)
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
# Load map
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# Refresh party members
$game_party.refresh
end
#--------------------------------------------------------------------------
# * return the selected file's name
#--------------------------------------------------------------------------
def filename
return "Save#{@file_window.index + 1}.rxdata"
end
end
#----------------------------------------------------------------------------
# End Scene Load Edit
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Begin Scene Save Edit
#----------------------------------------------------------------------------
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..LegACy::SAVE_COUNT
filename = "Save#{i + 1}.rxdata"
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text('Which file would you like to save to?')
@file_window = Window_File.new
@file_window.y = 64
@file_window.height = 416
@file_window.width = 320
@file_window.active = true
@status_window = Window_FileStat.new(@file_window)
@status_window.x = 320
@status_window.y = 64
@status_window.height = 416
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@file_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@help_window.update
@file_window.update
@status_window.update
# If C button was pressed
if Input.trigger?(Input::C)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open(filename, 'wb')
write_save_data(file)
file.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(4)
return
end
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(4)
end
end
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# Write character data for drawing save file
Marshal.dump(characters, file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
# Increase save count by 1
$game_system.save_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($game_bank, file)
end
#--------------------------------------------------------------------------
# * return the selected file's name
#--------------------------------------------------------------------------
def filename
return 'Save#{@file_window.index + 1}.rxdata'
end
end
#----------------------------------------------------------------------------
# End Scene Save Edit
#----------------------------------------------------------------------------
end
Moghunter's Name Scene
Code:
#_______________________________________________________________________________
# MOG Scene Name Iris V1.0
#_______________________________________________________________________________
# By Moghunter
# [url=http://www.atelier-rgss.com]http://www.atelier-rgss.com[/url]
#_______________________________________________________________________________
# Scene Name com layout e movimento.
# (Crie seu próprio estilo.)
#_______________________________________________________________________________
module MOG
# Tempo de transição.
MSNTT1 = 30
# Definição do tipo de transição.
MSNTT2 = "pathways"
end
$mogscript = {} if $mogscript == nil
$mogscript["Scene_Name_Iris"] = true
###############
# Window_Base #
###############
class Window_Base < Window
def draw_battler(actor,x,y)
battler = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = battler.width
ch = battler.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x , y - ch, battler, src_rect)
end
def draw_actor_level_name(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x , y, 24, 32, actor.level.to_s, 1)
end
def draw_actor_class_name(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 120, 32, actor.class_name,1)
end
def draw_actr_name(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 120, 32, actor.name,1)
end
end
######################
# Window_Status_Name #
######################
class Window_Status_Name < Window_Base
def initialize(actor)
super(0, 0, 320, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "pix Chicago"
@actor = actor
self.opacity = 0
refresh
end
def refresh
self.contents.clear
draw_actor_graphic(@actor, 50, 110)
draw_actor_class_name(@actor, 55, 395)
draw_actor_level_name(@actor, 20, 120)
draw_battler(@actor, 20, 350)
end
end
####################
# Window_NameEdit2 #
####################
class Window_NameEdit2 < Window_Base
attr_reader :name
attr_reader :index
def initialize(actor, max_char)
super(0, 25, 640, 128)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
@name = actor.name
@max_char = max_char
name_array = @name.split(//)[0...@max_char]
@name = ""
for i in 0...name_array.size
@name += name_array[i]
end
@default_name = @name
@index = name_array.size
refresh
update_cursor_rect
end
def restore_default
@name = @default_name
@index = @name.split(//).size
refresh
update_cursor_rect
end
def add(character)
if @index < @max_char and character != ""
@name += character
@index += 1
refresh
update_cursor_rect
end
end
def back
if @index > 0
name_array = @name.split(//)
@name = ""
for i in 0...name_array.size-1
@name += name_array[i]
end
@index -= 1
refresh
update_cursor_rect
end
end
def refresh
self.contents.clear
name_array = @name.split(//)
for i in 0...@max_char
c = name_array[i]
if c == nil
c = "_"
end
x = 320 - @max_char * 14 + i * 28
self.contents.draw_text(x + 32, 64, 28, 32, c, 1)
end
draw_actr_name(@actor, 295, 20)
end
def update_cursor_rect
x = 320 - @max_char * 14 + @index * 28
self.cursor_rect.set(x + 32, 64, 28, 32)
end
def update
super
update_cursor_rect
end
end
#####################
# Window_NameInput2 #
#####################
class Window_NameInput2 < Window_Base
CHARACTER_TABLE =
[
"A","B","C","D","E",
"F","G","H","I","J",
"K","L","M","N","O",
"P","Q","R","S","T",
"U","V","W","X","Y",
"Z"," "," "," "," ",
"+","-","*","/","!",
"1","2","3","4","5",
" "," "," "," "," ",
"a","b","c","d","e",
"f","g","h","i","j",
"k","l","m","n","o",
"p","q","r","s","t",
"u","v","w","x","y",
"z"," "," "," "," ",
"#","$","%","&","@",
"6","7","8","9","0",
" "," "," "," "," ",
]
def initialize
super(64, 140, 640, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@index = 0
refresh
update_cursor_rect
end
def character
return CHARACTER_TABLE[@index]
end
def refresh
self.contents.clear
for i in 0...90
x = 140 + i / 5 / 9 * 180 + i % 5 * 32
y = i / 5 % 9 * 32
self.contents.draw_text(x, y, 32, 32, CHARACTER_TABLE[i], 1)
end
self.contents.draw_text(421, 264, 48, 32, "OK", 1) #(428, 9 * 32, 48, 32, "OK", 1)
end
def update_cursor_rect
if @index >= 90
self.cursor_rect.set(421, 264, 48, 32) #(428, 9 * 32, 48, 32)
else
x = 140 + @index / 5 / 9 * 180 + @index % 5 * 32
y = @index / 5 % 9 * 32
self.cursor_rect.set(x, y, 32, 32)
end
end
def update
super
if @index >= 90
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@index -= 90
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@index -= 90 - 40
end
else
if Input.repeat?(Input::RIGHT)
if Input.trigger?(Input::RIGHT) or
@index / 45 < 3 or @index % 5 < 4
$game_system.se_play($data_system.cursor_se)
if @index % 5 < 4
@index += 1
else
@index += 45 - 4
end
if @index >= 90
@index -= 90
end
end
end
if Input.repeat?(Input::LEFT)
if Input.trigger?(Input::LEFT) or
@index / 45 > 0 or @index % 5 > 0
$game_system.se_play($data_system.cursor_se)
if @index % 5 > 0
@index -= 1
else
@index -= 45 - 4
end
if @index < 0
@index += 90
end
end
end
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
if @index % 45 < 40
@index += 5
else
@index += 90 - 40
end
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @index % 45 >= 5
$game_system.se_play($data_system.cursor_se)
if @index % 45 >= 5
@index -= 5
else
@index += 90
end
end
end
if Input.repeat?(Input::L) or Input.repeat?(Input::R)
$game_system.se_play($data_system.cursor_se)
if @index < 45
@index += 45
else
@index -= 45
end
end
end
update_cursor_rect
end
end
##############
# Scene_Name #
##############
class Scene_Name
def main
@actor = $game_actors[$game_temp.name_actor_id]
@edit_window = Window_NameEdit2.new(@actor, $game_temp.name_max_char)
@edit_window.opacity = 0
@input_window = Window_NameInput2.new
@input_window.opacity = 0
@name_back = Plane.new
@name_back.bitmap = RPG::Cache.picture("fog")
@name_back.z = 10
@name_back.opacity = 255
@name_lay = Plane.new
@name_lay.bitmap = RPG::Cache.picture("Name_Lay")
@name_lay.z = 15
@name_lay.opacity = 255
@name_status_window = Window_Status_Name.new(@actor)
@name_status_window.x -= 300
@name_status_window.contents_opacity = 0
Graphics.transition(MOG::MSNTT1, "Graphics/Transitions/" + MOG::MSNTT2)
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@edit_window.dispose
@input_window.dispose
@name_back.dispose
@name_lay.dispose
@name_status_window.dispose
end
def update
@name_back.ox += 1
if @name_status_window.x < 0
@name_status_window.x += 15
@name_status_window.contents_opacity += 5
elsif @name_status_window.x >= 0
@name_status_window.x = 0
@name_status_window.contents_opacity = 255
end
@edit_window.update
@input_window.update
if Input.repeat?(Input::B)
if @edit_window.index == 0
return
end
$game_system.se_play($data_system.cancel_se)
@edit_window.back
return
end
if Input.trigger?(Input::C)
if @input_window.character == nil
if @edit_window.name == ""
@edit_window.restore_default
if @edit_window.name == ""
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
return
end
@actor.name = @edit_window.name
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
return
end
if @edit_window.index == $game_temp.name_max_char
$game_system.se_play($data_system.buzzer_se)
return
end
if @input_window.character == ""
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@edit_window.add(@input_window.character)
return
end
end
end