=begin
Front View Battle System
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
Allows you to have front view battlers for the party.
----------------------
Instructions
----------------------
By default an actor's battler will be the same as his name.
You can use notetags to set an alternate default:
<battler_name Ralph2>
Also during the game if you need to change a battler then call:
$game_actors[x].battler_name = "New Name"
You can also edit the icons and descriptions used by the actor command window
to do this edit the values in the Module FrontView at the top of the scripts.
----------------------
Known bugs
----------------------
None
=end
module ReStaff
module FrontView
# Edit the icons that display for commands here
ACTOR_COMMAND_ICONS = {}
ACTOR_COMMAND_ICONS['Attack'] = 147
ACTOR_COMMAND_ICONS['Guard'] = 160
ACTOR_COMMAND_ICONS['Items'] = 192
ACTOR_COMMAND_ICONS['Special'] = 143
ACTOR_COMMAND_ICONS['Magic'] = 112
# Edit the descriptions that display for commands here
ACTOR_COMMAND_DESC = {}
ACTOR_COMMAND_DESC['Attack'] = "Attack your foes using your weapon."
ACTOR_COMMAND_DESC['Guard'] = "Defend against attacks from your foes."
ACTOR_COMMAND_DESC['Items'] = "Use items you have collected on your journey."
ACTOR_COMMAND_DESC['Special'] = "Unleash your special attacks. Uses TP."
ACTOR_COMMAND_DESC['Magic'] = "Unleach your magical abilities. Uses MP."
def self.get_icon(command)
if ACTOR_COMMAND_ICONS[command].nil?
return 0
else
return ACTOR_COMMAND_ICONS[command]
end
end
def self.get_desc(command)
if ACTOR_COMMAND_DESC[command].nil?
return command
else
return ACTOR_COMMAND_DESC[command]
end
end
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * New attr_accessor battler_name
#--------------------------------------------------------------------------
attr_accessor:battler_name
#--------------------------------------------------------------------------
# * Aliases Setup
#--------------------------------------------------------------------------
alias restaff_frontview_setup setup
def setup(actor_id)
restaff_frontview_setup(actor_id)
@battler_name = actor.battler_name
end
#--------------------------------------------------------------------------
# * Rewrites use_sprite?
#--------------------------------------------------------------------------
def use_sprite?
return true
end
#--------------------------------------------------------------------------
# * New Method screen_x
#--------------------------------------------------------------------------
def screen_x
return (index+1) * (Graphics.width/($game_party.battle_members.size+1))
end
#--------------------------------------------------------------------------
# * New Method screen_y
#--------------------------------------------------------------------------
def screen_y
return Graphics.height
end
#--------------------------------------------------------------------------
# * New Method screen_z
#--------------------------------------------------------------------------
def screen_z
return 100
end
end
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Rewrites create_actors
#--------------------------------------------------------------------------
def create_actors
@actor_sprites = $game_party.battle_members.reverse.collect do |actor|
Sprite_Battler.new(@viewport1, actor)
end
end
end
class RPG::Actor < RPG::BaseItem
def battler_name
if @battler_name.nil?
if @note =~ /<battler_name (.*)>/i
@battler_name = $1
else
@battler_name = @name
end
end
@battler_name
end
end
class Window_PartyCommand < Window_Command
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 2
end
end
class Window_ActorHorzCommand < Window_HorzCommand
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0)
self.openness = 0
deactivate
@actor = nil
@last_index = -1
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 128
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 2
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
return unless @actor
add_attack_command
add_skill_commands
add_guard_command
add_item_command
end
#--------------------------------------------------------------------------
# * Add Attack Command to List
#--------------------------------------------------------------------------
def add_attack_command
add_command(Vocab::attack, :attack, @actor.attack_usable?)
end
#--------------------------------------------------------------------------
# * Add Skill Command to List
#--------------------------------------------------------------------------
def add_skill_commands
@actor.added_skill_types.sort.each do |stype_id|
name = $data_system.skill_types[stype_id]
add_command(name, :skill, true, stype_id)
end
end
#--------------------------------------------------------------------------
# * Add Guard Command to List
#--------------------------------------------------------------------------
def add_guard_command
add_command(Vocab::guard, :guard, @actor.guard_usable?)
end
#--------------------------------------------------------------------------
# * Add Item Command to List
#--------------------------------------------------------------------------
def add_item_command
add_command(Vocab::item, :item)
end
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(actor)
@actor = actor
clear_command_list
make_command_list
refresh
select(0)
activate
open
@help_window.show
end
#--------------------------------------------------------------------------
# * Calculate Height of Window Contents
#--------------------------------------------------------------------------
def contents_height
item_height * 2
end
#--------------------------------------------------------------------------
# * Get Number of Columns
#--------------------------------------------------------------------------
def col_max
return 4
end
#--------------------------------------------------------------------------
# * Get the space inbetween the columns
#--------------------------------------------------------------------------
def spacing
return 4
end
#--------------------------------------------------------------------------
# * Icons commands
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
draw_icon(ReStaff::FrontView.get_icon(command_name(index)), rect.x, rect.y)
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(ReStaff::FrontView.get_desc(command_name(index)))
end
#--------------------------------------------------------------------------
# * Draw the current action
#--------------------------------------------------------------------------
def refresh
super
return unless @list[index]
self.contents.font.size = 18
draw_text(ox,line_height, 104, line_height, command_name(index), 1)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
if @last_index != @index
refresh
@last_index = @index
end
end
end
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias restaff_frontview_initialize initialize
def initialize
restaff_frontview_initialize
contents.font.size = 16
end
#--------------------------------------------------------------------------
# * Spacing Between Actors
#--------------------------------------------------------------------------
def spacing
return 4
end
#--------------------------------------------------------------------------
# * Sets the maximum columns
#--------------------------------------------------------------------------
def col_max
return 4
end
#--------------------------------------------------------------------------
# * Set the item height
#--------------------------------------------------------------------------
def item_height
line_height * 2
end
#--------------------------------------------------------------------------
# * Draw HP
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
change_color(system_color)
draw_text(x, y+8, 30, line_height, Vocab::hp_a)
draw_current_and_max_values(x, y + 8, width, actor.hp, actor.mhp,
hp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# * Draw MP
#--------------------------------------------------------------------------
def draw_actor_mp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
change_color(system_color)
draw_text(x, y+8, 30, line_height, Vocab::mp_a)
draw_current_and_max_values(x, y + 8, width, actor.mp, actor.mmp,
mp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# * Draw TP
#--------------------------------------------------------------------------
def draw_actor_tp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
change_color(system_color)
draw_text(x, y+8, 30, line_height, Vocab::tp_a)
change_color(tp_color(actor))
draw_text(x + width - 42, y + 8, 42, line_height, actor.tp.to_i, 2)
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 2
end
#--------------------------------------------------------------------------
# * Get Gauge Area Rectangle
#--------------------------------------------------------------------------
def gauge_area_rect(index)
rect = item_rect_for_text(index)
rect.x += 2
rect.width -= 4
rect
end
#--------------------------------------------------------------------------
# * Draw Basic Area
#--------------------------------------------------------------------------
def draw_basic_area(rect, actor)
draw_actor_name(actor, rect.x, rect.y - 4, 66)
draw_actor_icons(actor, rect.x + 66, rect.y, 24)
end
#--------------------------------------------------------------------------
# * Draw Gauge Area (with TP)
#--------------------------------------------------------------------------
def draw_gauge_area_with_tp(rect, actor)
draw_actor_hp(actor, rect.x + 0, rect.y + 12, rect.width)
draw_actor_mp(actor, rect.x + 0, rect.y + line_height, rect.width/2)
draw_actor_tp(actor, rect.x + rect.width/2, rect.y + line_height, rect.width/2)
end
#--------------------------------------------------------------------------
# * Draw Gauge Area (without TP)
#--------------------------------------------------------------------------
def draw_gauge_area_without_tp(rect, actor)
draw_actor_hp(actor, rect.x + 0, rect.y + 12, rect.width)
draw_actor_mp(actor, rect.x + 0, rect.y + line_height, rect.width)
end
end
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization *
# info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
def initialize(info_viewport)
super(0, info_viewport.rect.y, window_width, fitting_height(2)) # just this line that was edited
refresh
self.visible = false
@info_viewport = info_viewport
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Create Actor Commands Window
#--------------------------------------------------------------------------
def create_actor_command_window
@actor_command_window = Window_ActorHorzCommand.new
@actor_command_window.viewport = @info_viewport
@actor_command_window.set_handler(:attack, method(:command_attack))
@actor_command_window.set_handler(:skill, method(:command_skill))
@actor_command_window.set_handler(:guard, method(:command_guard))
@actor_command_window.set_handler(:item, method(:command_item))
@actor_command_window.set_handler(:cancel, method(:prior_command))
@actor_command_window.x = Graphics.width
end
#--------------------------------------------------------------------------
# * Start Party Command Selection
#--------------------------------------------------------------------------
alias restaff_frontview_start_party_command_selection start_party_command_selection
def start_party_command_selection
@help_window.hide
restaff_frontview_start_party_command_selection
end
#--------------------------------------------------------------------------
# * Start Actor Command Selection
#--------------------------------------------------------------------------
alias restaff_frontview_start_actor_command_selection start_actor_command_selection
def start_actor_command_selection
@actor_command_window.help_window = @help_window unless @actor_command_window.help_window
@help_window.show
restaff_frontview_start_actor_command_selection
end
#--------------------------------------------------------------------------
# * [Attack] Command
#--------------------------------------------------------------------------
alias restaff_frontview_command_attack command_attack
def command_attack
@help_window.hide
restaff_frontview_command_attack
end
#--------------------------------------------------------------------------
# * [Guard] Command
#--------------------------------------------------------------------------
alias restaff_frontview_command_guard command_guard
def command_guard
@help_window.hide
restaff_frontview_command_guard
end
#--------------------------------------------------------------------------
# * Enemy [Cancel]
#--------------------------------------------------------------------------
alias restaff_frontview_on_enemy_cancel on_enemy_cancel
def on_enemy_cancel
restaff_frontview_on_enemy_cancel
if @actor_command_window.current_symbol == :attack
@help_window.show
end
end
#--------------------------------------------------------------------------
# * Skill [Cancel]
#--------------------------------------------------------------------------
alias restaff_frontview_on_skill_cancel on_skill_cancel
def on_skill_cancel
restaff_frontview_on_skill_cancel
@help_window.show
end
#--------------------------------------------------------------------------
# * Item [Cancel]
#--------------------------------------------------------------------------
alias restaff_frontview_on_item_cancel on_item_cancel
def on_item_cancel
restaff_frontview_on_item_cancel
@help_window.show
end
#--------------------------------------------------------------------------
# * Create Skill Window
#--------------------------------------------------------------------------
def create_skill_window
@skill_window = Window_HorzSkillList.new(@help_window, @info_viewport)
@skill_window.set_handler(:ok, method(:on_skill_ok))
@skill_window.set_handler(:cancel, method(:on_skill_cancel))
@skill_window.x = Graphics.width - @skill_window.width
@skill_window.y = Graphics.height - @skill_window.height
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_window
@item_window = Window_HorzItemList.new(@help_window, @info_viewport)
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@item_window.x = Graphics.width - @item_window.width
@item_window.y = Graphics.height - @item_window.height
end
end
class Window_HorzList < Window_HorzCommand
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x,y)
super(x, y)
deactivate
@last_index = -1
self.back_opacity = 255
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 128
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 2
end
#--------------------------------------------------------------------------
# * Calculate Height of Window Contents
#--------------------------------------------------------------------------
def contents_height
item_height * 2
end
#--------------------------------------------------------------------------
# * Get Number of Columns
#--------------------------------------------------------------------------
def col_max
return 4
end
#--------------------------------------------------------------------------
# * Get the space inbetween the columns
#--------------------------------------------------------------------------
def spacing
return 4
end
#--------------------------------------------------------------------------
# * Icons commands
#--------------------------------------------------------------------------
def draw_item(index)
return if @list[index].nil?
rect = item_rect(index)
draw_icon(@list[index].icon_index, rect.x, rect.y)
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
return if @list[index].nil?
@help_window.set_text(@list[index].description)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
if @last_index != @index
refresh
@last_index = @index
end
end
#--------------------------------------------------------------------------
# * Get Command Data of Selection Item
#--------------------------------------------------------------------------
def current_data
nil
end
#--------------------------------------------------------------------------
# * Show Window
#--------------------------------------------------------------------------
def show
select(0)
@help_window.show
super
end
#--------------------------------------------------------------------------
# * Hide Window
#--------------------------------------------------------------------------
def hide
@help_window.hide
super
end
#--------------------------------------------------------------------------
# * Set Leading Digits - BUGFIX
#--------------------------------------------------------------------------
def top_col=(col)
col = 0 if col < 0
col = item_max - (col_max - 1) if col > item_max - 1
self.ox = col * (item_width + spacing)
end
end
class Window_HorzItemList < Window_HorzList
#--------------------------------------------------------------------------
# * Object Initialization
# info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
def initialize(help_window, info_viewport)
super(0,100)
self.visible = false
@help_window = help_window
@info_viewport = info_viewport
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
@list = $game_party.all_items.select {|item| include?(item) }
@list.push(nil) if include?(nil)
end
#--------------------------------------------------------------------------
# * Include in Item List?
#--------------------------------------------------------------------------
def include?(item)
$game_party.usable?(item)
end
#--------------------------------------------------------------------------
# * Get Activation State of Selection Item
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@list[index])
end
#--------------------------------------------------------------------------
# * Get Activation State of Selection Item
#--------------------------------------------------------------------------
def item
return @list[index]
end
#--------------------------------------------------------------------------
# * Draw the current action
#--------------------------------------------------------------------------
def refresh
super
return unless @list[index]
self.contents.font.size = 18
draw_text(ox,line_height, 104, line_height, @list[index].name, 0)
draw_text(ox,line_height, 104, line_height, sprintf(":%2d", $game_party.item_number(@list[index])), 2)
end
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
$game_party.usable?(item)
end
end
class Window_HorzSkillList < Window_HorzList
#--------------------------------------------------------------------------
# * Object Initialization
# info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
def initialize(help_window, info_viewport)
super(0,100)
self.visible = false
@help_window = help_window
@info_viewport = info_viewport
@actor = nil
@stype_id = 0
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
self.ox = 0
end
#--------------------------------------------------------------------------
# * Set Skill Type ID
#--------------------------------------------------------------------------
def stype_id=(stype_id)
return if @stype_id == stype_id
@stype_id = stype_id
refresh
self.ox = 0
end
#--------------------------------------------------------------------------
# * Get Skill
#--------------------------------------------------------------------------
def item
@list && index >= 0 ? @list[index] : nil
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
@list = @actor ? @actor.skills.select {|skill| include?(skill) } : []
end
#--------------------------------------------------------------------------
# * Include in Skill List?
#--------------------------------------------------------------------------
def include?(item)
item && item.stype_id == @stype_id
end
#--------------------------------------------------------------------------
# * Get Activation State of Selection Item
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@list[index])
end
#--------------------------------------------------------------------------
# * Get Activation State of Selection Item
#--------------------------------------------------------------------------
def item
return @list[index]
end
#--------------------------------------------------------------------------
# * Draw the current action
#--------------------------------------------------------------------------
def refresh
super
return unless @list[index]
self.contents.font.size = 18
draw_item_name(@list[index], ox, line_height, enable?(@list[index]))
if @actor.skill_tp_cost(@list[index]) > 0
change_color(tp_cost_color, enable?(@list[index]))
draw_text(ox,line_height, 104, line_height, @actor.skill_tp_cost(@list[index]), 2)
elsif @actor.skill_mp_cost(@list[index]) > 0
change_color(mp_cost_color, enable?(@list[index]))
draw_text(ox,line_height, 104, line_height, @actor.skill_mp_cost(@list[index]), 2)
end
end
#--------------------------------------------------------------------------
# * Display Skill in Active State?
#--------------------------------------------------------------------------
def enable?(item)
@actor && @actor.usable?(item)
end
end