Version 1.0
Author: Kendorei
Release Date: 1/13/09
Exclusive to RPG RPG Revolution
This is a CMS with only one scene that processes all the menu options. I have found no bugs with this so far,
but it's not very customizable without some scripting experience. If you have the experience to change windows, you can customize this fairly easily. And if any scripters want to make an improved version of this, be my guest. ;)
Features:
1.) Processes all menu options in one scene
2.) The map is visible behind the menu
3.) Supports all standard menu functions
4.) No bugs, and little lag when entering menu
5.) Alters no windows, instead, creates copies that were edited specifically for the menu.
The Script (Spoilers arn't working, sorry. D:)
CODE
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Kendorei's One-Scene CMS
#-------------------------------------------------------------------------------
# Author: Kendorei Version 1.0
#-------------------------------------------------------------------------------
#Instructions: Simply paste this above Main.
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# ** Window_Selectable_H
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable_H < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :index # cursor position
attr_reader :help_window # help window
#--------------------------------------------------------------------------
# * Object Initialization
# x : window x-coordinate
# y : window y-coordinate
# width : window width
# height : window height
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 6
@index = -1
end
#--------------------------------------------------------------------------
# * Set Cursor Position
# index : new cursor position
#--------------------------------------------------------------------------
def index=(index)
@index = index
# 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
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def row_max
# Compute rows from number of items and columns
return (@item_max + @column_max - 1) / @column_max
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
# Divide y-coordinate of window contents transfer origin by 1 row
# height of 32
return self.oy / 32
end
#--------------------------------------------------------------------------
# * Set Top Row
# row : row shown on top
#--------------------------------------------------------------------------
def top_row=(row)
# If row is less than 0, change it to 0
if row < 0
row = 0
end
# If row exceeds row_max - 1, change it to row_max - 1
if row > row_max - 1
row = row_max - 1
end
# Multiply 1 row height by 32 for y-coordinate of window contents
# transfer origin
self.oy = row * 32
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
# Subtract a frame height of 32 from the window height, and divide it by
# 1 row height of 32
return (self.height - 32) / 32
end
#--------------------------------------------------------------------------
# * Get Number of Items Displayable on 1 Page
#--------------------------------------------------------------------------
def page_item_max
# Multiply row count (page_row_max) times column count (@column_max)
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# * Set Help Window
# help_window : new help window
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# Update help text (update_help is defined by the subclasses)
if self.active and @help_window != nil
update_help
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
# 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 * 32 - self.oy
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, 32)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# 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)
@index = (@index + @column_max) % @item_max
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
# Move cursor up
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
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
# If R button was pressed
if Input.repeat?(Input::R)
# If bottom row being displayed is more to front than bottom data row
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
# Move cursor 1 page back
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
# If L button was pressed
if Input.repeat?(Input::L)
# If top row being displayed is more to back than 0
if self.top_row > 0
# Move cursor 1 page forward
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
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
end
#==============================================================================
# ** Window_Command_H
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command_H < Window_Selectable_H
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(commands)
# Compute window width and height from command quantity
super(0, 0, commands.size * 64 + 36, commands.size * 8 + 15)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(@item_max * 64, @item_max * 8)
self.opacity = 160
self.contents.font.size = 15
refresh
self.index = 0
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
rect = Rect.new(70 * index + 4, 10, self.contents.width - 8, 15)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
#==============================================================================
# ** Window_Help_M
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help_M < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 420, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
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 = 15
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
#--------------------------------------------------------------------------
# * Set Actor
# actor : status displaying actor
#--------------------------------------------------------------------------
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
#--------------------------------------------------------------------------
# * Set Enemy
# enemy : name and status displaying enemy
#--------------------------------------------------------------------------
def set_enemy(enemy)
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end
#==============================================================================
# ** Window_PTSGL
#------------------------------------------------------------------------------
# This window displays play time, steps, gold, and location on the menu screen.
#==============================================================================
class Window_PTSGL < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 200, 95)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 15
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 160, 15, "Play Time")
@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.font.color = normal_color
self.contents.draw_text(0, 0, 160, 15, text, 2)
self.contents.font.color = system_color
self.contents.draw_text(0, 15, 160, 15, "Step Count")
self.contents.font.color = normal_color
self.contents.draw_text(0, 15, 160, 15, $game_party.steps.to_s, 2)
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(0, 30, 160, 15, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(0, 30, cx, 15, $data_system.words.gold)
@map = load_data("Data/MapInfos.rxdata")
@name = @map[$game_map.map_id].name
self.contents.font.color = system_color
self.contents.draw_text(0, 45, 160, 15, "Location")
self.contents.font.color = normal_color
self.contents.draw_text(0, 45, 160, 15, @name.to_s, 2)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# ** Window_MenuStatus_M
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 210, $game_party.actors.size * 90)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
refresh
self.active = false
self.visible = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 86
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 60)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + 15)
draw_actor_state(actor, x, y + 30)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 86, self.width - 32, 64)
end
end
end
#==============================================================================
# ** Window_MenuStatus_M
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 210, $game_party.actors.size * 90)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
refresh
self.active = false
self.visible = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 86
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 60)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + 15)
draw_actor_state(actor, x, y + 30)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 86, self.width - 32, 64)
end
end
end
#==============================================================================
# ** Window_Item_M
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
#==============================================================================
class Window_Item_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 420, 350)
self.opacity = 160
@column_max = 1
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
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
@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
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@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 = 15
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 % 1 * (288 + 32)
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 15)
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 + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ** Window_Skill_M
#------------------------------------------------------------------------------
# This window displays usable skills on the skill and battle screens.
#==============================================================================
class Window_Skill_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 128, 420, 292)
self.opacity = 160
@actor = actor
@column_max = 1
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Acquiring Skill
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...@actor.skills.size
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]
self.contents.font.size = 15
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
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 + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end
#==============================================================================
# ** Window_SkillStatus_M
#------------------------------------------------------------------------------
# This window displays the skill user's status on the skill screen.
#==============================================================================
class Window_SkillStatus_M < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 420, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_state(@actor, 50, 0)
draw_actor_hp(@actor, 104, 0)
draw_actor_sp(@actor, 250, 0)
end
end
#==============================================================================
# ** Window_Target_M
#------------------------------------------------------------------------------
# This window selects a use target for the actor on item and skill screens.
#==============================================================================
class Window_Target_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 210, $game_party.actors.size * 90)
self.contents = Bitmap.new(width - 32, height - 32)
self.z += 10
self.contents.font.size = 15
@item_max = $game_party.actors.size
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 64
y = i * 86
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 60)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + 15)
draw_actor_state(actor, x, y + 30)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
# Cursor position -1 = all choices, -2 or lower = independent choice
# (meaning the user's own choice)
if @index <= -2
self.cursor_rect.set(0, @index * 86, self.width - 32, 64)
elsif @index == -1
self.cursor_rect.set(0, 0, self.width - 32, @item_max * 64 - 20)
else
self.cursor_rect.set(0, @index * 86, self.width - 32, 64)
end
end
end
#==============================================================================
# ** Window_EquipLeft_M
#------------------------------------------------------------------------------
# This window displays actor parameter changes on the equipment screen.
#==============================================================================
class Window_EquipLeft_M < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 272, 192)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 4, 32)
draw_actor_parameter(@actor, 4, 64, 0)
draw_actor_parameter(@actor, 4, 96, 1)
draw_actor_parameter(@actor, 4, 128, 2)
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 64, 40, 32, "->", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 64, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 96, 40, 32, "->", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 96, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 128, 40, 32, "->", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 128, 36, 32, @new_mdef.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
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
refresh
end
end
end
#==============================================================================
# ** Window_EquipRight_M
#------------------------------------------------------------------------------
# This window displays items the actor is currently equipped with on the
# equipment screen.
#==============================================================================
class Window_EquipRight_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(272, 64, 368, 192)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
@actor = actor
refresh
self.index = 0
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.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
draw_item_name(@data[0], 92, 32 * 0)
draw_item_name(@data[1], 92, 32 * 1)
draw_item_name(@data[2], 92, 32 * 2)
draw_item_name(@data[3], 92, 32 * 3)
draw_item_name(@data[4], 92, 32 * 4)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ** Window_EquipItem_M
#------------------------------------------------------------------------------
# This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================
class Window_EquipItem_M < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
# equip_type : equip region (0-3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 311, 640, 170)
self.opacity = 160
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
return @data[self.index]
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 bit map and draw all items
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
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 % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.font.size = 15
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ** Window_Status_M
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Status_M < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 420, 335)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_graphic(@actor, 20, 90)
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 4 + 100, 0)
draw_actor_level(@actor, 66, 32)
draw_actor_state(@actor, 66, 58)
draw_actor_hp(@actor, 20, 100, 142)
draw_actor_sp(@actor, 20, 116, 142)
draw_actor_parameter(@actor, 20, 142, 0)
draw_actor_parameter(@actor, 20, 158, 1)
draw_actor_parameter(@actor, 20, 174, 2)
draw_actor_parameter(@actor, 20, 210, 3)
draw_actor_parameter(@actor, 20, 226, 4)
draw_actor_parameter(@actor, 20, 242, 5)
draw_actor_parameter(@actor, 20, 258, 6)
self.contents.font.color = system_color
self.contents.draw_text(155, 40, 80, 15, "EXP")
self.contents.draw_text(155, 66, 80, 15, "NEXT")
self.contents.font.color = normal_color
self.contents.draw_text(155 + 40, 40, 40, 15, @actor.exp_s, 2)
self.contents.draw_text(155 + 40, 66, 40, 15, @actor.next_rest_exp_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(190, 90, 96, 15, "Equipment")
draw_item_name($data_weapons[@actor.weapon_id], 190 + 16, 120)
draw_item_name($data_armors[@actor.armor1_id], 190 + 16, 150)
draw_item_name($data_armors[@actor.armor2_id], 190 + 16, 180)
draw_item_name($data_armors[@actor.armor3_id], 190 + 16, 210)
draw_item_name($data_armors[@actor.armor4_id], 190 + 16, 240)
end
def dummy
self.contents.font.color = system_color
self.contents.draw_text(230, 120, 96, 15, $data_system.words.weapon)
self.contents.draw_text(230, 150, 96, 15, $data_system.words.armor1)
self.contents.draw_text(230, 180, 96, 15, $data_system.words.armor2)
self.contents.draw_text(230, 210, 96, 15, $data_system.words.armor3)
self.contents.draw_text(230, 240, 96, 15, $data_system.words.armor4)
draw_item_name($data_weapons[@actor.weapon_id], 230 + 24, 120)
draw_item_name($data_armors[@actor.armor1_id], 230 + 24, 150)
draw_item_name($data_armors[@actor.armor2_id], 230 + 24, 180)
draw_item_name($data_armors[@actor.armor3_id], 230 + 24, 210)
draw_item_name($data_armors[@actor.armor4_id], 230 + 24, 240)
end
end
#==============================================================================
# ** Window_SaveFile_M
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================
class Window_SaveFile_M < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :filename # file name
attr_reader :selected # selected
#--------------------------------------------------------------------------
# * Object Initialization
# file_index : save file index (0-3)
# filename : file name
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, 124 + file_index % 4 * 87, 420, 87)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
self.contents.font.size = 15
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draw file number
self.contents.font.color = normal_color
name = "File#{@file_index + 1}"
self.contents.draw_text(4, 5, 400, 15, name)
@name_width = contents.text_size(name).width
# If save file exists
if @file_exist
# Draw characters
for i in 0...@characters.size
bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 200 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 55 - ch, bitmap, src_rect)
end
# Draw play time
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 8, 400, 15, time_string, 2)
# Draw timestamp
self.contents.font.color = normal_color
time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
self.contents.draw_text(4, 32, 400, 15, time_string, 2)
end
end
#--------------------------------------------------------------------------
# * Set Selected
# selected : new selected (true = selected, false = unselected)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @selected
self.cursor_rect.set(0, 0, @name_width + 8, 32)
else
self.cursor_rect.empty
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Menu Call
#--------------------------------------------------------------------------
def call_menu
# Clear menu call flag
$game_temp.menu_calling = false
# If menu beep flag is set
if $game_temp.menu_beep
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Clear menu beep flag
$game_temp.menu_beep = false
end
# Straighten player position
$game_player.straighten
# Switch to menu screen
$scene = Scene_OSM.new # <-- Edit
end
end
#==============================================================================
# ** Scene_OSM
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_OSM
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
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 = "Quit"
@command_window = Window_Command_H.new([s1, s2, s3, s4, s5, s6])
@command_window.x = 0
@command_window.y = 0
@command_window.index = @menu_index
# 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 the end command window
s7 = "To Title"
s8 = "Shutdown"
s9 = "Cancel"
@end_command_window = Window_Command.new(192, [s7, s8, s9])
@end_command_window.x = 320 - @command_window.width / 2
@end_command_window.y = 240 - @command_window.height / 2
@end_command_window.opacity = 160
@end_command_window.active = false
@end_command_window.visible = false
# Make background
@spriteset = Spriteset_Map.new
# Make play time, steps, gold, and location window
@ptsgl_window = Window_PTSGL.new
@ptsgl_window.x = 427
# Make status window
@status_window = Window_MenuStatus_M.new
@status_window.x = 427
@status_window.y = 95
# Make item windows
@item_window = Window_Item_M.new
@item_window.y = 124
@item_window.active = false
@item_window.visible = false
@item_target_window = Window_Target_M.new
@item_target_window.visible = false
@item_target_window.active = false
@item_target_window.opacity = 160
# Make char status window
@char_status_window = Window_Status_M.new($game_party.actors[0])
@char_status_window.visible = false
@char_status_window.y = 60
# Make skill windows
@skill_window = Window_Skill_M.new($game_party.actors[0])
@skillstatus_window = Window_SkillStatus_M.new($game_party.actors[0])
@skill_target_window = Window_Target_M.new
@skill_target_window.active = false
@skill_target_window.visible = false
@skill_target_window.opacity = 160
@skill_window.y = 188
@skillstatus_window.y = 124
@skillstatus_window.visible = false
@skill_window.active = false
@skill_window.visible = false
# Make equip windows
@actor_e = $game_party.actors[0]
@left_equip_window = Window_EquipLeft.new(@actor_e)
@right_equip_window = Window_EquipRight.new(@actor_e)
@item_equip_window1 = Window_EquipItem.new(@actor_e, 0)
@item_equip_window2 = Window_EquipItem.new(@actor_e, 1)
@item_equip_window3 = Window_EquipItem.new(@actor_e, 2)
@item_equip_window4 = Window_EquipItem.new(@actor_e, 3)
@item_equip_window5 = Window_EquipItem.new(@actor_e, 4)
@left_equip_window.visible = false
@right_equip_window.visible = false
@right_equip_window.active = false
@item_equip_window1.visible = false
@item_equip_window2.visible = false
@item_equip_window3.visible = false
@item_equip_window4.visible = false
@item_equip_window5.visible = false
refresh_equip
# Make save windows
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile_M.new(i, make_filename(i)))
end
for i in @savefile_windows
i.visible = false
end
@file_index = $game_temp.last_file_index
@savefile_windows[@file_index].selected = true
# 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
@command_window.dispose
@spriteset.dispose
@ptsgl_window.dispose
@status_window.dispose
@item_window.dispose
@item_target_window.dispose
@end_command_window.dispose
@char_status_window.dispose
@skill_window.dispose
@skillstatus_window.dispose
@skill_target_window.dispose
@left_equip_window.dispose
@right_equip_window.dispose
@item_equip_window1.dispose
@item_equip_window2.dispose
@item_equip_window3.dispose
@item_equip_window4.dispose
@item_equip_window5.dispose
for i in @savefile_windows
i.dispose
end
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@ptsgl_window.update
@status_window.update
@item_window.update
@item_target_window.update
@end_command_window.update
@char_status_window.update
@skill_window.update
@skillstatus_window.update
@skill_target_window.update
@left_equip_window.update
@right_equip_window.update
@item_equip_window.update
for i in @savefile_windows
i.update
end
refresh_equip
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
# If item window is active: call update_item
if @item_window.active
update_item
return
end
# If item target window is active: call update_target_item
if @item_target_window.active
update_target_item
return
end
# If end command window is active: call update_end_command
if @end_command_window.active
update_end_command
return
end
# If char status window is visible: call update_char_window
if @char_status_window.visible
update_char_window
return
end
# If skill window is active: call update_skill
if @skill_window.active
update_skill
return
end
# If skill target is active: call update_target
if @skill_target_window.active
update_skill_target
return
end
# If right equip window is active: call update_right_equip
if @right_equip_window.active
update_right_equip
return
end
# If equip item window is active: call update_equip_item
if @item_equip_window.active
update_equip_item
return
end
# If save windows are visible: call update_savefiles
if for i in @savefile_windows
i.visible
end
update_savefiles
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
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
@item_help_window = Window_Help_M.new
@item_window.help_window = @item_help_window
@item_help_window.y = 60
@command_window.active = false
@item_window.active = true
@item_window.visible = true
@item_help_window.visible = true
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save window
@command_window.active = false
@help_text = "Which file would you like to save to?"
@save_help_window = Window_Help_M.new
@save_help_window.set_text(@help_text)
@save_help_window.y = 60
for i in @savefile_windows
i.visible = true
end
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end command window
@command_window.active = false
@end_command_window.active = true
@end_command_window.visible = true
@end_command_window.index = 0
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
@status_window.visible = true
# 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
@status_window.visible = false
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)
# Make and switch to skill windows
@actor_index = @status_window.index
@actor = $game_party.actors[@actor_index]
@skill_window = Window_Skill_M.new(@actor)
@skillstatus_window = Window_SkillStatus_M.new(@actor)
@skill_help_window = Window_Help_M.new
@skill_window.help_window = @skill_help_window
@skill_help_window.y = 60
@skill_window.y = 188
@skillstatus_window.y = 124
@skill_window.active = true
@skill_window.visible = true
@skill_help_window.visible = true
@skillstatus_window.visible = true
@status_window.active = false
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment window
@actor_e = $game_party.actors[@status_window.index]
@help_equip_window = Window_Help_M.new
@left_equip_window = Window_EquipLeft_M.new(@actor_e)
@right_equip_window = Window_EquipRight_M.new(@actor_e)
@item_equip_window1 = Window_EquipItem_M.new(@actor_e, 0)
@item_equip_window2 = Window_EquipItem_M.new(@actor_e, 1)
@item_equip_window3 = Window_EquipItem_M.new(@actor_e, 2)
@item_equip_window4 = Window_EquipItem_M.new(@actor_e, 3)
@item_equip_window5 = Window_EquipItem_M.new(@actor_e, 4)
@right_equip_window.help_window = @help_equip_window
@item_equip_window1.help_window = @help_equip_window
@item_equip_window2.help_window = @help_equip_window
@item_equip_window3.help_window = @help_equip_window
@item_equip_window4.help_window = @help_equip_window
@item_equip_window5.help_window = @help_equip_window
@help_equip_window.y = 60
@right_equip_window.y = 124
@left_equip_window.y = 124
@item_equip_window.y = 311
@right_equip_window.index = 0
@right_equip_window.active = true
@right_equip_window.visible = true
@status_window.active = false
@status_window.visible = false
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make char status window visible and turn off the status window
@member = $game_party.actors[@status_window.index]
@char_status_window = Window_Status_M.new(@member)
@char_status_window.visible = true
@char_status_window.y = 60
@status_window.active = false
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
@item_help_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to the command window
@item_window.active = false
@item_window.visible = false
@command_window.active = true
@item_help_window.dispose
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
@item_target_window.x = 427
@item_target_window.y = 95
@item_target_window.visible = true
@item_target_window.active = true
# Set cursor position to effect scope (single / all)
if @item.scope == 4 || @item.scope == 6
@item_target_window.index = -1
else
@item_target_window.index = 0
end
# If effect scope is other than an ally
else
# If command event ID is valid
if @item.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @item.common_event_id
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# 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 (when item target window is active)
#--------------------------------------------------------------------------
def update_target_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If unable to use because items ran out
unless $game_party.item_can_use?(@item.id)
# Remake item window contents
@item_window.refresh
end
# Erase target window
@item_window.active = true
@item_target_window.visible = false
@item_target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# 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 @item_target_window.index == -1
# Apply item effects to entire party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If single target
if @item_target_window.index >= 0
# Apply item use effects to target actor
target = $game_party.actors[@item_target_window.index]
used = target.item_effect(@item)
end
# If an item was used
if used
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# Redraw item window item
@item_window.draw_item(@item_window.index)
end
# Remake target window contents
@item_target_window.refresh
# If all party members are dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If common event ID is valid
if @item.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If item wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when char status window is visible)
#--------------------------------------------------------------------------
def update_char_window
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to command window
@status_window.active = true
@char_status_window.visible = false
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when end command window is active)
#--------------------------------------------------------------------------
def update_end_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to command window
@end_command_window.active = false
@end_command_window.visible = false
@command_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @end_command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # cancel
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [To Title] Command
#--------------------------------------------------------------------------
def command_to_title
# 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)
# Switch to title screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# * Process When Choosing [Shutdown] Command
#--------------------------------------------------------------------------
def command_shutdown
# 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)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
def command_cancel
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to command window
@end_command_window.active = false
@end_command_window.visible = false
@command_window.active = true
end
#--------------------------------------------------------------------------
# * Frame Update (if skill window is active)
#--------------------------------------------------------------------------
def update_skill
@skill_help_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to status window
@skill_window.active = false
@skill_window.visible = false
@skill_help_window.dispose
@skillstatus_window.visible = 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
@skill_target_window.x = 427
@skill_target_window.y = 95
@skill_target_window.visible = true
@skill_target_window.active = true
@status_window.visible = false
# Set cursor position to effect scope (single / all)
if @skill.scope == 4 || @skill.scope == 6
@skill_target_window.index = -1
elsif @skill.scope == 7
@skill_target_window.index = @actor_index - 10
else
@skill_target_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
@skillstatus_window.refresh
@skill_window.refresh
@skill_target_window.refresh
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when skill target window is active)
#--------------------------------------------------------------------------
def update_skill_target
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Erase target window
@skill_window.active = true
@skill_target_window.visible = false
@skill_target_window.active = false
@status_window.visible = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# 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 @skill_target_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 @skill_target_window.index <= -2
# Apply skill use effects to target actor
target = $game_party.actors[@skill_target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# If single target
if @skill_target_window.index >= 0
# Apply skill use effects to target actor
target = $game_party.actors[@skill_target_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
@skillstatus_window.refresh
@skill_window.refresh
@skill_target_window.refresh
# If entire party is dead
if $game_party.all_dead?
# Switch to game over screen
$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
# 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
#--------------------------------------------------------------------------
# * Refresh equip windows
#--------------------------------------------------------------------------
def refresh_equip
# Set item window to visible
if (@right_equip_window.index == 0) and
(@right_equip_window.visible == true)
@item_equip_window1.visible = true
else
@item_equip_window1.visible = false
end
if (@right_equip_window.index == 1) and
(@right_equip_window.visible == true)
@item_equip_window2.visible = true
else
@item_equip_window2.visible = false
end
if (@right_equip_window.index == 2) and
(@right_equip_window.visible == true)
@item_equip_window3.visible = true
else
@item_equip_window3.visible = false
end
if (@right_equip_window.index == 3) and
(@right_equip_window.visible == true)
@item_equip_window4.visible = true
else
@item_equip_window4.visible = false
end
if (@right_equip_window.index == 4) and
(@right_equip_window.visible == true)
@item_equip_window5.visible = true
else
@item_equip_window5.visible = false
end
# Get currently equipped item
item1 = @right_equip_window.item
# Set current item window to @item_equip_window
case @right_equip_window.index
when 0
@item_equip_window = @item_equip_window1
when 1
@item_equip_window = @item_equip_window2
when 2
@item_equip_window = @item_equip_window3
when 3
@item_equip_window = @item_equip_window4
when 4
@item_equip_window = @item_equip_window5
end
# If right window is active
if @right_equip_window.active
# Erase parameters for after equipment change
@left_equip_window.set_new_parameters(nil, nil, nil)
end
# If item window is active
if @item_equip_window.active
# Get currently selected item
item2 = @item_equip_window.item
# Change equipment
last_hp = @actor_e.hp
last_sp = @actor_e.sp
@actor_e.equip(@right_equip_window.index, item2 == nil ? 0 : item2.id)
# Get parameters for after equipment change
new_atk = @actor_e.atk
new_pdef = @actor_e.pdef
new_mdef = @actor_e.mdef
# Return equipment
@actor_e.equip(@right_equip_window.index, item1 == nil ? 0 : item1.id)
@actor_e.hp = last_hp
@actor_e.sp = last_sp
# Draw in left window
@left_equip_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
#--------------------------------------------------------------------------
# * Frame Update (when right equip window is active)
#--------------------------------------------------------------------------
def update_right_equip
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to status window
@right_equip_window.active = false
@right_equip_window.visible = false
@left_equip_window.visible = false
@item_equip_window1.visible = false
@item_equip_window2.visible = false
@item_equip_window3.visible = false
@item_equip_window4.visible = false
@item_equip_window5.visible = false
@help_equip_window.dispose
@status_window.visible = true
@status_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If equipment is fixed
if @actor_e.equip_fix?(@right_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
@right_equip_window.active = false
@item_equip_window.active = true
@item_equip_window.index = 0
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item equip window is active)
#--------------------------------------------------------------------------
def update_equip_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate right equip window
@right_equip_window.active = true
@item_equip_window.active = false
@item_equip_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 = @item_equip_window.item
# Change equipment
@actor_e.equip(@right_equip_window.index, item == nil ? 0 : item.id)
# Activate right window
@right_equip_window.active = true
@item_equip_window.active = false
@item_equip_window.index = -1
# Remake right window and item window contents
@right_equip_window.refresh
@item_equip_window.refresh
return
end
end
#--------------------------------------------------------------------------
# * Make File Name
# file_index : save file index (0-3)
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
#--------------------------------------------------------------------------
# * Frame Update (when save window is visible)
#--------------------------------------------------------------------------
def update_savefiles
# If C button was pressed
if Input.trigger?(Input::C)
# Call method: on_decision
on_decision_s(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
end
# If B button was pressed
if Input.trigger?(Input::B)
# Call method: on_cancel
on_cancel_s
return
end
# If the down directional button was pressed
if Input.repeat?(Input::DOWN)
# If the down directional button pressed down is not a repeat,
# or cursor position is more in front than 3
if Input.trigger?(Input::DOWN) or @file_index < 3
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Move cursor down
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % 4
@savefile_windows[@file_index].selected = true
return
end
end
# If the up directional button was pressed
if Input.repeat?(Input::UP)
# If the up directional button pressed down is not a repeat、
# or cursor position is more in back than 0
if Input.trigger?(Input::UP) or @file_index > 0
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Move cursor up
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 3) % 4
@savefile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision_s(filename)
# 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 map
@save_help_window.dispose
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel_s
# 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 command window
@save_help_window.dispose
@command_window.active = true
for i in @savefile_windows
i.visible = false
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)
end
end
Compatability:It'd be easy to alter this a bit to make it so multiple CMS-es could be used. Just gotta make a "switch". ;)
It's compatable with the SDK, but must be placed below the SDK.
Here's a demo of the CMS and Dargor's Party Changer integrated:
KenCMS + Dargor's Party Changer
OSCMS_Shot_1.png ( 155.93K )
Number of downloads: 409
OSCMS_Shot_2.png ( 278.12K )
Number of downloads: 358
OSCMS_Shot_3.png ( 489.41K )
Number of downloads: 357
OSCMS_Shot_4.png ( 415.77K )
Number of downloads: 250Kendorei's One-Scene CMS DemoTo use this right away, just paste the script above Main. Below the SDK, if you use it.
Credits:Me, Kendorei, for taking the time to make this. ^^
Atoa and sandy for telling me how to show the map behind the menu. ;D
This post has been edited by Kendorei: Feb 5 2009, 10:15 PM