class Bitmap
def draw_text(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
# if x2 is a rectangle
if x2.is_a?(Rect)
# set temporary variables
x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
else
# set temporary variables
x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
end
# save old font color
save_color = self.font.color.clone
# set new font color (black)
self.font.color =
Color.new(128, 128, 128)
# restore original color
self.font.color = save_color
# drw text at normal postion
draw_text_shaded_later(x, y, w, h, text, a)
end
end
#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
# This window displays amount of gold.
#==============================================================================
class Window_Gold_Location < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents =
Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = true
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# set font color
self.contents.font.color = system_color
# draw "G"
self.contents.draw_text_full(90, 12, 20, 20, 'G')
# set font color
self.contents.font.color = normal_color
# draw party's gold
self.contents.draw_text_full(10, 12, 80, 20, $game_
party.gold.to_s, 2)
# draw party's location
self.contents.draw_text_full(10, 32, 100, 20, $game_
map.name, 1)
end
end
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 256)
self.contents =
Bitmap.new(width, height)
# set font
self.contents.font.name = 'Arial'
# set font size
self.contents.font.size = 16
# set font to bold
self.contents.font.bold = true
refresh
self.active = 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 = 0
y = i * 64
actor = $game_party.actors
self.contents.font.size = 16
self.contents.draw_text_full(x+13, y+8, 102, 20, actor.name.to_s, 1)
self.contents.font.size = 14
color = Color.new(255, 255, 255, 127)
self.contents.fill_rect(x+13, y+28, 102, 13, color)
self.contents.fill_rect(x+13, y+42, 102, 13, color)
# set current variables
hp = actor.hp
maxhp = actor.maxhp
sp = actor.sp
maxsp = actor.maxsp
rate = (maxhp > 0 ? hp.to_f / maxhp : 0)
# draw gradient bar
self.contents.gradient_bar_hud(x+13, y+28, 100, rate, 'hud_green_bar', 0)
# draw HP
self.contents.draw_text_full(x+13, y+28, 102, 11, hp.to_s, 1)
rate = (maxsp > 0 ? sp.to_f / maxsp : 0)
# draw gradient bar
self.contents.gradient_bar_hud(x+13, y+42, 100, rate, 'hud_blue_bar', 0)
# draw HP
self.contents.draw_text_full(x+13, y+42, 102, 11, sp.to_s, 1)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(6, @index * 64 + 6, self.width - 44, 52)
end
end
end
#==============================================================================
# ** Window_Selectable_FE
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable_FE < 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
@row_max = 1
@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 Col Count
#--------------------------------------------------------------------------
def col_max
# Compute rows from number of items and columns
return (@item_max + @row_max - 1) / @row_max
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def left_col
# Divide y-coordinate of window contents transfer origin by 1 row
# height of 32
return self.ox / 32
end
#--------------------------------------------------------------------------
# * Set Top Row
# row : row shown on top
#--------------------------------------------------------------------------
def left_col=(col)
# If row is less than 0, change it to 0
if col < 0
col = 0
end
# If row exceeds row_max - 1, change it to row_max - 1
if col > col_max - 1
col = col_max - 1
end
# Multiply 1 row height by 32 for y-coordinate of window contents
# transfer origin
self.ox = col * 32
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_col_max
# Subtract a frame height of 32 from the window height, and divide it by
# 1 row height of 32
return (self.width - 28) / 28
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_col_max * @row_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
col = @index / @row_max
# If current row is before top row
if col < self.left_col
# Scroll so that current row becomes top row
self.left_col = col
end
# If current row is more to back than back row
if col > self.left_col + (self.page_col_max - 1)
# Scroll so that current row becomes back row
self.left_col = col - (self.page_col_max - 1)
end
# Calculate cursor width
cursor_height = self.height / @row_max - 32
# Calculate cursor coordinates
x = @index / @row_max * 28 + 4
y = 18
# Update cursor rectangle
self.cursor_rect.set(x, y, 28, 28)
#UPDATE TEXT
self.contents.font.color = normal_color
self.contents.font.size = 17
self.contents.font.bold = true
rect = Rect.new(32, 2, 224, 16)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[@index], 1)
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::RIGHT)
# 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 (@row_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @row_max
# Move cursor down
$game_system.se_play($data_system.cursor_se)
@index = (@index + @row_max) % @item_max
end
end
# If the up directional button was pressed
if Input.repeat?(Input::LEFT)
# 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 (@row_max == 1 and Input.trigger?(Input::UP)) or
@index >= @row_max
# Move cursor up
$game_system.se_play($data_system.cursor_se)
@index = (@index - @row_max + @item_max) % @item_max
end
end
# If the right directional button was pressed
if Input.repeat?(Input::DOWN)
# If column count is 2 or more, and cursor position is closer to front
# than (item count -1)
if @row_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::UP)
# If column count is 2 or more, and cursor position is more back than 0
if @row_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.left_col + (self.page_col_max - 1) < (self.col_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.left_col += self.page_col_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.left_col > 0
# Move cursor 1 page forward
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.left_col -= self.page_col_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_FE
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command_FE < Window_Selectable_FE
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(height, commands)
# Compute window height from command quantity
super(0, 0, commands.size * 32, height)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width, height)
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)
bitmap = RPG::Cache.icon('CMSFE_'+index.to_s+'.png')
src_rect = Rect.new(0, 0, 24, 24)
self.contents.blt(28 * index+6, 20, bitmap, src_rect)
if @index == index
self.contents.font.color = normal_color
self.contents.font.size = 16
rect = Rect.new(32, 4, 168, 16)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
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)
$game_system.windowskin_name = 'AppleMilkNOBG'
@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 = "Your Status"
s5 = "Set Keys"
s6 = "Save"
s7 = "Load"
s8 = "Exit"
@command_window = Window_Command_FE.new(96,
[s1, s2, s3, s4, s5, s6, s7, s8,])
@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
@command_window.x = 128
@command_window.y = -16
@command_window.z = 1000
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
@goldtime_window = Window_Gold_Location.new
@goldtime_window.x = -16
@goldtime_window.y = -16
@goldtime_window.z = 1000
# set in_battle flag
$game_temp.in_battle = true
# if MINIMAP is turned on and minimap active
if BlizzABS::Config::MINIMAP && $game_system.minimap > 0
# create HUD
@minimap = Minimap.new
# create HUD
@minimap.update
end
# create spriteset
@spriteset = Spriteset_Map.new
@hudbg = HudBG.new(4)
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = -16
@status_window.y = 48
@status_window.z = 1000
# 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
$game_system.windowskin_name = 'AppleMilkNOBG'
# delete spriteset
@spriteset.dispose
[@hud, @parhud, @hotkeys, @minimap].each {|s| s.dispose if s != nil}
# Dispose of windows
@command_window.dispose
@status_window.dispose
@goldtime_window.dispose
@hudbg.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@status_window.update
# 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
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
$scene = Scene_Item.new
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 # Hotkeys
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Hotkeys screen
$scene = Scene_Hotkeys.new
when 5 # AI Behavior
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Save screen
$scene = Scene_Save.new
when 6 # AI Triggers
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Load screen
$scene = Scene_Load_Menu.new
when 7 # Save
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to End Game screen
$scene = Scene_End.new
end
return
else
# iterate through all number keys
BlizzABS::Cache::Keys.each {|i|
# if number key i was triggered
if Input.trigger?(Input::Key[i.to_s])
@command_window.index = (i+9)%10
case @command_window.index
when 0 # Item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Item screen
$scene = Scene_Item.new
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 # Hotkeys
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Hotkeys screen
$scene = Scene_Hotkeys.new
when 5 # Save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Save screen
$scene = Scene_Save.new
when 6 # Load
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Load screen
$scene = Scene_Load_Menu.new
when 7 # End Game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to End Game screen
$scene = Scene_End.new
end
return
end}
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs item screen processing.
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias main_FE_later main
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
main_FE_later
@spriteset.dispose
end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs skill screen processing.
#==============================================================================
class Scene_Skill
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
# Get actor
@actor = $game_party.actors[@actor_index]
# Make help window, status window, and skill window
@help_window = Window_Help.new
@status_window = Window_SkillStatus.new(@actor)
@skill_window = Window_Skill.new(@actor)
# Associate help window
@skill_window.help_window = @help_window
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@status_window.visible = false
@status_window.active = false
# 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
@spriteset.dispose
@help_window.dispose
@status_window.dispose
@skill_window.dispose
@target_window.dispose
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs equipment screen processing.
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias main_FE_later main
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
main_FE_later
@spriteset.dispose
end
end
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
# This class performs status screen processing.
#==============================================================================
class Scene_Status
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias main_FE_later main
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
main_FE_later
@spriteset.dispose
end
end
#==============================================================================
# Scene_Hotkeys
#------------------------------------------------------------------------------
# This class handles the skill/item hotkey processing.
#==============================================================================
class Scene_Hotkeys
def initialize
super
end
#----------------------------------------------------------------------------
# main
# The main processing method.
#----------------------------------------------------------------------------
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
# create HUD if HUD is turned on and HUD active
@hud = Hud.new if BlizzABS::Config::HUD_ENABLED && $game_system.hud
# if ASSIGNMENT is turned
if BlizzABS::Config::HOTKEYS
# create assignment display
@hotkeys = Hotkey_Assignment.new
# set z position
@hotkeys.z = 5000
end
# if MINIMAP is turned on and minimap active
if BlizzABS::Config::MINIMAP && $game_system.minimap > 0
# create HUD
@minimap = Minimap.new
end
# create sprite
@choice = Sprite.new
# create bitmap
@choice.bitmap = $BlizzABS.cache.image('menu_arrow')
# set x, y and z positions
@choice.x, @choice.y, @choice.z, @choice.opacity = 160, 40, 500, 128
# set x position offset
@choice.ox = -8
# set active flag
@active = true
# set index
@index = 0
# set up mode flag
@up_mode = true
# create modified skill window
@skill_window = Window_Skill_Hotkey.new($game_player.battler)
# create modified item window
@item_window = Window_Item_Hotkey.new
# set last active
@last_active = true
# transtition
Graphics.transition
# loop
loop do
# update game screen
Graphics.update
# update input
Input.update
# frame update
update
# stop if chosen an option
break if $scene != self
end
# freeze screen
Graphics.freeze
# delet spriteset
@spriteset.dispose
# delete HUD elements that exist
[@hud, @hotkeys, @minimap].each {|s| s.dispose if s != nil}
# delete choice sprite
@choice.dispose
# delete skill window
@skill_window.dispose
# delete item window
@item_window.dispose
# delete viewport
@view.dispose
end
#----------------------------------------------------------------------------
# update
# The update processing method.
#----------------------------------------------------------------------------
def update
# update choice sprite
@choice.update
# update skill window
@skill_window.update
# update item window
@item_window.update
# update hotkey assignment display if existing
@hotkeys.update if @hotkeys != nil
# move by 2 or 1 whether active in direction depending on @up_mode
@choice.oy += (@up_mode ? (@active ? 2 : 1) : (@active ? -2 : -1))
# set new @up_mode if necesseray depending on @up_mode
@up_mode = (@up_mode ? (@choice.oy < : (@choice.oy <= -8))
# if select button pressed
if $game_system.select_button && Input.trigger?(Input::Select)
# switch to next actor
@skill_window.switch_actor
# if active
elsif @active
# set choice offset always to a number dividable with 2
@choice.oy = @choice.oy / 2 * 2
# update hotkey selection
update_choice
# if skill window is active
elsif @skill_window.active
# update skill selection
update_skill
# if item window is active
elsif @item_window.active
# update item selection
update_item
end
end
#----------------------------------------------------------------------------
# update_choice
# Updates input during the hotkey selection.
#----------------------------------------------------------------------------
def update_choice
# set x position
@choice.x = 146 + @index * 28
# if pressed B
if Input.trigger?(Input::B)
# play cancel sound
$game_system.se_play($data_system.cancel_se)
# go back to menu
$scene = Scene_Menu.new(4)
# if C is pressed
elsif Input.trigger?(Input::C)
# play sound
$game_system.se_play($data_system.decision_se)
# not active
@active = false
# the one that was active the last time is now active
@skill_window.active = @last_active
@item_window.active = (!@last_active)
# if RIGHT is being pressed
elsif Input.repeat?(Input::RIGHT)
# if RIGHT is pressed or index is less than 9
if Input.trigger?(Input::RIGHT) || @index < 9
# play sound
$game_system.se_play($data_system.cursor_se)
# set new index
@index = (@index + 1) % 10
end
# if LEFT is being pressed
elsif Input.repeat?(Input::LEFT)
# if LEFT is pressed or index is equal or greater than 1
if Input.trigger?(Input::LEFT) || @index >= 1
# play sound
$game_system.se_play($data_system.cursor_se)
# set new index
@index = (@index + 9) % 10
end
end
end
#----------------------------------------------------------------------------
# update_skill
# Updates input during the skill selection.
#----------------------------------------------------------------------------
def update_skill
# set last active
@last_active = true
# if B is pressed
if Input.trigger?(Input::B)
# play cancel sound
$game_system.se_play($data_system.cancel_se)
# set active
@active = true
# skill window is not active
@skill_window.active = false
# delete cursor
@skill_window.cursor_rect.empty
# if C is pressd
elsif Input.trigger?(Input::C)
# play sound
$game_system.se_play($data_system.decision_se)
# if last position
if @skill_window.index == @skill_window.item_max - 1
# remove hotkey assigmnent from skill
$game_player.skill_hotkeys[(@index+1)%10] = 0
else
# set skill to hotkey
$game_player.skill_hotkeys[(@index+1)%10] = @skill_window.skill.id
end
# remove hotkey assigmnent from item
$game_player.item_hotkeys[(@index+1)%10] = 0
# draw hotkey display if hotkey display exists
@hotkeys.draw(@index+1) if @hotkeys != nil
# set active
@active = true
# skill window is not active
@skill_window.active = false
# delete cursor
@skill_window.cursor_rect.empty
# if RIGHT or LEFT is pressed
elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
# play sound
$game_system.se_play($data_system.cursor_se)
# item window is active
@item_window.active = true
# skill window is not active
@skill_window.active = false
# delete cursor
@skill_window.cursor_rect.empty
end
end
#----------------------------------------------------------------------------
# update_item
# Updates input during the item selection.
#----------------------------------------------------------------------------
def update_item
# set last active
@last_active = false
# if B is pressed
if Input.trigger?(Input::B)
# play cancel sound
$game_system.se_play($data_system.cancel_se)
# set active
@active = true
# item window is not active
@item_window.active = false
# delete cursor
@item_window.cursor_rect.empty
# if C is pressed
elsif Input.trigger?(Input::C)
# play sound
$game_system.se_play($data_system.decision_se)
# if last position
if @item_window.index == @item_window.item_max - 1
# remove hotkey assigmnent from item
$game_player.item_hotkeys[(@index+1)%10] = 0
else
# set item to hotkey
$game_player.item_hotkeys[(@index+1)%10] = @item_window.item.id
end
# remove hotkey assigmnent from skill
$game_player.skill_hotkeys[(@index+1)%10] = 0
# draw hotkey display if hotkey display exists
@hotkeys.draw(@index+1) if @hotkeys != nil
# set active
@active = true
# item window is not active
@item_window.active = false
# delete cursor
@item_window.cursor_rect.empty
# if RIGHT or LEFT is pressed
elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
# play sound
$game_system.se_play($data_system.cursor_se)
# skill window is active
@skill_window.active = true
# item window is not active
@item_window.active = false
# delete cursor
@item_window.cursor_rect.empty
end
end
end
#==============================================================================
# Scene_AI_Behavior
#------------------------------------------------------------------------------
# This class processes handling of the scene where ally behavior can be set
# up which is used by the Ally Combat AI.
#==============================================================================
class Scene_AI_Behavior
#----------------------------------------------------------------------------
# Initialization
# tone - screen background tone
# index - actor party index
#----------------------------------------------------------------------------
def initialize(index = 0, command_window_index = 0)
# base data
@index = index
# get battler
@actor = $BlizzABS.battlers[index].battler
# command window index
@command_window_index = command_window_index
end
#----------------------------------------------------------------------------
# main
# The main processing method.
#----------------------------------------------------------------------------
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
# create command window
@command_window = Window_Command.new(160, BlizzABS::Cache::CommandsAIBehavior)
# command window coordinates
@command_window.x = 480
# command window initial index
@command_window.index = @command_window_index
# get map actor
map_actor = $BlizzABS.battlers[@index]
# create behavior window
@behavior_window = Window_Behavior.new(@actor, map_actor)
# transition
Graphics.transition
# loop
loop do
# update game screen
Graphics.update
# update input
Input.update
# update the scene
update
# stop if frame update
break if $scene != self
end
# freeze screen
Graphics.freeze
# delete command window
@command_window.dispose
# delete behavior window
@behavior_window.dispose
# delete spriteset
@spriteset.dispose
# delete viewport
@view.dispose
end
#----------------------------------------------------------------------------
# update_command
# The command window update processing method.
#----------------------------------------------------------------------------
def update_command
# update command window
@command_window.update
# if B is pressed
if Input.trigger?(Input::B)
# play cancel sound
$game_system.se_play($data_system.cancel_se)
# create map scene
$scene = Scene_Menu.new(5)
# if C is pressed
elsif Input.trigger?(Input::C)
# which option
case @command_window.index
when 0
# play sound
$game_system.se_play($data_system.decision_se)
# deactivate command window
@command_window.active = false
# activate behavior window
@behavior_window.active = true
when 1
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set next index
@index = (@index + 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Behavior.new(@index, @command_window.index)
when 2
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set previous index
@index = (@index + battlers.size - 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + battlers.size - 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Behavior.new(@index, @command_window.index)
when 3
# play sound
$game_system.se_play($data_system.decision_se)
# create map scene
$scene = Scene_Map.new
end
# if R is pressed
elsif Input.trigger?(Input::R)
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set next index
@index = (@index + 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Behavior.new(@index, @command_window.index)
# if L is pressed
elsif Input.trigger?(Input::L)
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set previous index
@index = (@index + battlers.size - 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + battlers.size - 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Behavior.new(@index, @command_window.index)
end
end
end
#==============================================================================
# Scene_AI_Triggers
#------------------------------------------------------------------------------
# This class processes handling of the scene where ally action triggers can be
# set up which is used by the Ally Trigger AI.
#==============================================================================
class Scene_AI_Triggers
#----------------------------------------------------------------------------
# Initialization
# tone - screen background tone
# index - actor party index
#----------------------------------------------------------------------------
def initialize(index = 0, command_window_index = 0)
# data
@index, @actor = index, $BlizzABS.battlers[index].battler
# command window index
@command_window_index = command_window_index
# status effect names
@states = [BlizzABS::Cache::WORDNormalState]
(1...$data_states.size).each {|id| @states.push($data_states[id].name)}
end
#----------------------------------------------------------------------------
# main
# The main processing method.
#----------------------------------------------------------------------------
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
# create command window
@command_window = Window_Command.new(160, BlizzABS::Cache::CommandsAITrigger)
# command window coordinates
@command_window.x = 480
# command window initial index
@command_window.index = @command_window_index
# create trigger command window
@tcommand_window = Window_Command.new(160, BlizzABS::Cache::CommandsTrigger)
# trigger command window coordinates
@tcommand_window.x = 480
@tcommand_window.y = @command_window.height
# trigger command window no cursor
@tcommand_window.index = -1
# trigger command window not active
@tcommand_window.active = false
# create name window
@name_window = Window_Base.new(480, 416, 160, 64)
# create bitmap
@name_window.contents = Bitmap.new(@name_window.width - 32,
@name_window.height - 32)
# if using Dyna Edition scripts
if $fontface != nil
# set font name and size
@name_window.contents.font.name = $fontface
@name_window.contents.font.size = $fontsize
# if using PK Edition 2
elsif $defaultfonttype != nil
# set font name and size
@name_window.contents.font.name = $defaultfonttype
@name_window.contents.font.size = $defaultfontsize
end
# draw actor name
@name_window.draw_actor_name(@actor, 4, 0)
# update trigger command display
check_triggers
# creat triggers window
@triggers_window = Window_Triggers.new(@actor)
# transition
Graphics.transition
# loop
loop do
# update game screen
Graphics.update
# update input
Input.update
# update the scene
update
# stop if frame update
break if $scene != self
end
# freeze screen
Graphics.freeze
# delete command window
@command_window.dispose
# delete trigger command window
@tcommand_window.dispose
# delete triggers window
@triggers_window.dispose
# delete name window
@name_window.dispose
# delete spriteset
@spriteset.dispose
# delete viewport
@view.dispose
end
#----------------------------------------------------------------------------
# update_command
# The command window update processing method.
#----------------------------------------------------------------------------
def update_command
# update command window
@command_window.update
# if B is pressed
if Input.trigger?(Input::B)
# play cancel sound
$game_system.se_play($data_system.cancel_se)
# create map scene
$scene = Scene_Menu.new(6)
# if C is pressed
elsif Input.trigger?(Input::C)
# which option
case @command_window.index
when 0
# play sound
$game_system.se_play($data_system.decision_se)
# deactivate command window
@command_window.active = false
# activate trigger command window
@tcommand_window.active = true
# set cursor
@tcommand_window.index = 0
when 1
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set next index
@index = (@index + 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Triggers.new(@index, @command_window.index)
when 2
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set next index
@index = (@index + battlers.size - 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + battlers.size - 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Triggers.new(@index, @command_window.index)
when 3
# play sound
$game_system.se_play($data_system.decision_se)
# create map scene
$scene = Scene_Map.new
end
# if R is pressed
elsif Input.trigger?(Input::R)
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set next index
@index = (@index + 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Triggers.new(@index, @command_window.index)
# if L is pressed
elsif Input.trigger?(Input::L)
# play sound
$game_system.se_play($data_system.decision_se)
# get all AI actors
battlers = $BlizzABS.battlers
# set next index
@index = (@index + battlers.size - 1) % battlers.size
# if battler not valid
while battlers[@index].battler == nil
# try to find one that is
@index = (@index + battlers.size - 1) % battlers.size
end
# create hotkey assignment scene with the current screen tint
$scene = Scene_AI_Triggers.new(@index, @command_window.index)
end
end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This is a superclass for the save screen and load screen.
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# * Object Initialization
# help_text : text string shown in the help window
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# create spriteset
# @spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
# Make help window
@help_window = Window_Help.new
@help_window.set_text(@help_text)
# Make save file window
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
end
# Select last file to be operated
@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
@help_window.dispose
# @spriteset.dispose
for i in @savefile_windows
i.dispose
end
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# 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(7)
end
end
#==============================================================================
# ** Scene_End
#------------------------------------------------------------------------------
# This class performs game end screen processing.
#==============================================================================
class Scene_End
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 640, 480)
# Make command window
s1 = "Title"
s2 = "Exite"
s3 = "Cancel"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
# 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
@spriteset.dispose
# Dispose of window
@command_window.dispose
# 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 command window
@command_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 menu screen
$scene = Scene_Menu.new(9)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
def command_cancel
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to menu screen
$scene = Scene_Menu.new(9)
end
end
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load_Menu < Scene_File
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Remake temporary object
$game_temp = Game_Temp.new
# Timestamp selects new file
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
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
super("Which file would you like to load?")
end
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(filename)
# If file doesn't exist
unless FileTest.exist?(filename)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play load SE
$game_system.se_play($data_system.load_se)
# Read save data
file = File.open(filename, "rb")
read_save_data(file)
file.close
# Restore BGM and BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to title screen
$scene = Scene_Menu.new(
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)
# 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
end