Does anyone know how to set @dummy_windows.each to be visible = true or = false
I'm doing it for a activate window command in Window_ActorCommand
Sorry if you don't really understand it but I'm trying not to post the script
Anyway here is a example but it gives a error
@dummy_windows.each { |window| window.visible = true }
That is a error I keep writing it wrong not just that way^
Any help? Please?
Honestly the whole thing is bugged to hell
and there are so many errors.
I'm doing it for a activate window command in Window_ActorCommand
Sorry if you don't really understand it but I'm trying not to post the script
Anyway here is a example but it gives a error
@dummy_windows.each { |window| window.visible = true }
That is a error I keep writing it wrong not just that way^
Any help? Please?
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-20, 300, 580, 200)
refresh
self.active = false
self.opacity = 0
# Make Background Dummy Window
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 136
rect.height = 24
rect.x = index * 136 + (544 - (136 * @item_max)) / 2
rect.y = 0
return rect
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
for i in 0...@item_max
x = i * 136 + (544 - (136 * @item_max)) / 2
y = self.y + 46
@dummy_windows << Window_Base.new(x, y, 136, 70)
@dummy_windows.z = self.z - 10
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.members.size
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : Item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
rect.height += 80
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
actor = $game_party.members[index]
self.contents.font.size = 16
# Draw Actors face
draw_actor_face(actor, rect.x + 20, 35 - 18)
# Draw Actors names
draw_actor_name(actor, rect.x + 10, 32)
self.contents.font.size = 14
draw_actor_hp(actor, rect.x + 10, 72 - 16, 113)
draw_actor_mp(actor, rect.x + 10, 72, 113)
# Draw Action Icon
# draw_action_icon(index)
end
#--------------------------------------------------------------------------
# * Draw Character Icon Matching their current Action
# index : Item number
#--------------------------------------------------------------------------
def draw_action_icon(index)
# Get Actor
actor = $game_party.members[index]
Return if actor action is nothing
return if actor.action.nothing?
Return if cannot act by player input
return if actor.confusion? or actor.berserker?
Set Icon Index to 0
icon_index = 0
Get Item Rect
rect = item_rect(index)
If action is to attack set main weapon icon
icon_index = actor.weapons[0] == nil ? 0 : actor.weapons[0].icon_index if actor.action.attack?
If action is to guard set shield icon
icon_index = actor.armors[0] == nil ? 0 : actor.armors[0].icon_index if actor.action.guard?
If action is to use a skill use skill icon
icon_index = actor.action.skill.icon_index if actor.action.skill?
If action is to use an item use item icon
icon_index = actor.action.item.icon_index if actor.action.item?
Action Icon
draw_icon(icon_index, rect.x + 110, 35)
end
#--------------------------------------------------------------------------
# * Update cursor
# index : window to set as active
#--------------------------------------------------------------------------
def set_active(index = @index)
# If Active Window Index is not nil
if @active_window_index != nil
@dummy_windows[@active_window_index].windowskin = Cache.system("Window")
end
# Set Active Window Index
@active_window_index = index
# Return if index is nil
return if index == nil
# Set Active Windowskin
@dummy_windows[index].windowskin = Cache.system("Active Windowskin")
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
# If the cursor position is less than 0
if @index < 0
# Empty cursor
self.cursor_rect.empty
else
# Set Cursor Position
self.cursor_rect.set(@index * 136 + (544 - (136 * @item_max)) / 2 + 10, 36, 124, 58 )
end
end
#--------------------------------------------------------------------------
# * Draw Face Graphic
# face_name : Face graphic filename
# face_index : Face graphic index
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# size : Display size
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, x, y, size = 96)
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = 96 / 2
rect.y = 96 / 2
rect.width = 78
rect.height = 78
self.contents.blt(x, y, bitmap, rect, 100)
self.contents.clear_rect(x, y, 100, 18)
bitmap.dispose
end
#--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 120)
draw_actor_hp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
self.contents.font.color = hp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
self.contents.draw_text(xr - 99, y, 44, line_height, actor.hp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, line_height, "/", 2)
self.contents.draw_text(xr - 44, y, 44, line_height, actor.mhp, 2)
end
#--------------------------------------------------------------------------
# * Draw HP gauge
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_hp_gauge(actor, x, y, width = 120)
gw = width * actor.hp / actor.mhp
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.fill_rect(x, y + line_height - 8, width, 4, gauge_back_color)
self.contents.gradient_fill_rect(x, y + line_height - 8, gw, 4, gc1, gc2)
end
#--------------------------------------------------------------------------
# * Draw MP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_mp(actor, x, y, width = 120)
draw_actor_mp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
self.contents.font.color = mp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
self.contents.draw_text(xr - 99, y, 44, line_height, actor.mp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, line_height, "/", 2)
self.contents.draw_text(xr - 44, y, 44, line_height, actor.mmp, 2)
end
#--------------------------------------------------------------------------
# * Draw MP Gauge
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_mp_gauge(actor, x, y, width = 120)
gw = width * actor.mp / [actor.mmp, 1].max
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.fill_rect(x, y + line_height - 8, width, 4, gauge_back_color)
self.contents.gradient_fill_rect(x, y + line_height - 8, gw, 4, gc1, gc2)
end
end
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Create Window Contents
#--------------------------------------------------------------------------
def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, [height - 32, row_max * 29].max)
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
return self.oy / 29
end
#--------------------------------------------------------------------------
# * Set Top Row
# row : row shown on top
#--------------------------------------------------------------------------
def top_row=(row)
row = 0 if row < 0
row = row_max - 1 if row > row_max - 1
self.oy = row * 29
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
return (self.height - 32) / 29
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = line_height
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = index / @column_max * 29
return rect
end
end
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 233, 280, 200)
self.opacity = 0
# Make Dummy Windows
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Activate Command Window
#--------------------------------------------------------------------------
def activate
# Set Command Window Visibility to true
self.visible = true
# Set dummy windows to visible
@dummy_windows.each {|window| window.visible = true }
end
#--------------------------------------------------------------------------
# * De-Activate Command Window
#--------------------------------------------------------------------------
def deactivate
# Set Command Window Visibility to true
self.visible = false
# Set dummy windows to invisible
@dummy_windows.each {|window| window.visible = false }
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
# Header Window
@dummy_windows << Window_Base.new(10, 251, 255, 41)
@dummy_windows[0].z = self.z - 10
# Text window
@dummy_windows << Window_Base.new(10, 251 + 49 , 255, 41)
@dummy_windows[1].z = self.z - 10
return
end
#--------------------------------------------------------------------------
# * Set Text
# text : character string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 1)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 59, self.width - 40, WLH, text, align)
self.contents.draw_text(4, 10, self.width - 40, WLH, text, align)
@text = text
@align = align
end
end
#--------------------------------------------------------------------------
# * Set ObjectText
# obj : Skill or item
#--------------------------------------------------------------------------
def set_object_text(obj)
if obj != @object
self.contents.clear
self.contents.font.color = normal_color
# If object is not nil
if obj != nil
# Set Header
header = "SKILL" if obj.is_a?(RPG::Skill)
header = "ITEM" if obj.is_a?(RPG::Item)
self.contents.font.color = system_color
self.contents.draw_text(4, 10, self.width - 40, line_height, header, 1)
self.contents.font.color = normal_color
self.contents.draw_text(4, 59, self.width - 40, line_height, obj.description, 1)
end
# Set object
@object = obj
end
end
end
#==============================================================================
# ** Window_BattleSkill
#------------------------------------------------------------------------------
# This window displays a list of usable skills on the skill screen, etc.
#==============================================================================
class Window_BattleSkill < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(280, 251, 255, 90)
@actor = actor
@column_max = 1
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# * Get Skill
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for skill in @actor.skills
@data.push(skill)
if skill.id == @actor.last_skill_id
self.index = @data.size - 1
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
skill = @data[index]
if skill != nil
rect.width -= 4
enabled = @actor.skill_can_use?(skill)
draw_item_name(skill, rect.x, rect.y, enabled)
self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
end
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_object_text(skill)
end
end
#==============================================================================
# ** Window_BattleItem
#------------------------------------------------------------------------------
# This window displays a list of inventory items for the item screen, etc.
#==============================================================================
class Window_BattleItem < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(280, 251, 255, 90)
@column_max = 1
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Whether or not to include in item list
# item : item
#--------------------------------------------------------------------------
def include?(item)
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
#--------------------------------------------------------------------------
# * Whether or not to display in enabled state
# item : item
#--------------------------------------------------------------------------
def enable?(item)
return $game_party.item_can_use?(item)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for item in $game_party.items
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_object_text(item)
end
end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================
class Window_PartyCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
s1 = Vocab::fight
s2 = Vocab::escape
super(544, 416)
draw_item(0, true)
draw_item(1, BattleManager.can_escape?)
self.y = 292
self.x = 5
self.opacity = 0
self.visible = false
self.active = false
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose}
end
#--------------------------------------------------------------------------
# * Activate Command Window
#--------------------------------------------------------------------------
def activate
# Set Command Window Visibility to true
self.visible = true
# Set dummy windows to visible
# @dummy_windows.each.visible = true
# Set Window To active
self.active = true
end
#--------------------------------------------------------------------------
# * De-Activate Command Window
#--------------------------------------------------------------------------
def deactivate
# Set Command Window Visibility to true
self.visible = false
# Set dummy windows to invisible
# @dummy_windows.each.visible = false
# Set Window To inactive
self.active = false
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 245
rect.height = 24
rect.x = index % 2 * 265
rect.y = index / 2 * 49
return rect
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
for i in 0...2
x = self.x + 5 + i % 2 * 270 #265
y = self.y + 8 + i / 2 * 49
@dummy_windows << Window_Base.new(x, y, 255, 41)
@dummy_windows.visible = true
@dummy_windows.z = self.z - 10
end
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
# Set Cursor Position
self.cursor_rect.set((@index % 2 * 270), (@index / 2 * 49), 233, 25)
end
end
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is used to select actor commands, such as "Attack" or "Skill".
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(540, 4)
self.y = 243
self.x = 5
self.visible = false
self.active = false
self.opacity = 0
# Make Background Dummy Window
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 245
rect.height = 24
rect.x = index % 2 * 270
rect.y = index / 2 * 49
return rect
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, command_name(index), 1)
self.contents.draw_text(item_rect_for_text(index), command_name(index), alignment)
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
for i in 0...4
x = self.x + 5 + i % 2 * 270
y = self.y + 8 + i / 2 * 49
@dummy_windows << Window_Base.new(x, y, 255, 41)
@dummy_windows.visible = true
@dummy_windows.z = self.z - 10
end
end
#--------------------------------------------------------------------------
# * Activate Command Window
#--------------------------------------------------------------------------
def activate
# Set dummy windows to visible
@dummy_windows.each {|window| window.visible = true }
# Set Command Window Visibility to true
self.visible = true
# Set Window To active
self.active = true
end
#--------------------------------------------------------------------------
# * De-Activate Command Window
#--------------------------------------------------------------------------
def deactivate
# Set dummy windows to invisible
@dummy_windows.each {|window| window.visible = false }
# Set Command Window Visibility to true
self.visible = false
# Set Window To inactive
self.active = false
end
#--------------------------------------------------------------------------
# * Setup
# actor : actor
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
# Set Cursor Position
self.cursor_rect.set((@index % 2 * 270), (@index / 2 * 49), 233, 25)
end
end
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-20, 300, 580, 200)
refresh
self.active = false
self.opacity = 0
# Make Background Dummy Window
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 136
rect.height = 24
rect.x = index * 136 + (544 - (136 * @item_max)) / 2
rect.y = 0
return rect
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
for i in 0...@item_max
x = i * 136 + (544 - (136 * @item_max)) / 2
y = self.y + 46
@dummy_windows << Window_Base.new(x, y, 136, 70)
@dummy_windows.z = self.z - 10
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.members.size
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : Item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
rect.height += 80
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
actor = $game_party.members[index]
self.contents.font.size = 16
# Draw Actors face
draw_actor_face(actor, rect.x + 20, 35 - 18)
# Draw Actors names
draw_actor_name(actor, rect.x + 10, 32)
self.contents.font.size = 14
draw_actor_hp(actor, rect.x + 10, 72 - 16, 113)
draw_actor_mp(actor, rect.x + 10, 72, 113)
# Draw Action Icon
# draw_action_icon(index)
end
#--------------------------------------------------------------------------
# * Draw Character Icon Matching their current Action
# index : Item number
#--------------------------------------------------------------------------
def draw_action_icon(index)
# Get Actor
actor = $game_party.members[index]
Return if actor action is nothing
return if actor.action.nothing?
Return if cannot act by player input
return if actor.confusion? or actor.berserker?
Set Icon Index to 0
icon_index = 0
Get Item Rect
rect = item_rect(index)
If action is to attack set main weapon icon
icon_index = actor.weapons[0] == nil ? 0 : actor.weapons[0].icon_index if actor.action.attack?
If action is to guard set shield icon
icon_index = actor.armors[0] == nil ? 0 : actor.armors[0].icon_index if actor.action.guard?
If action is to use a skill use skill icon
icon_index = actor.action.skill.icon_index if actor.action.skill?
If action is to use an item use item icon
icon_index = actor.action.item.icon_index if actor.action.item?
Action Icon
draw_icon(icon_index, rect.x + 110, 35)
end
#--------------------------------------------------------------------------
# * Update cursor
# index : window to set as active
#--------------------------------------------------------------------------
def set_active(index = @index)
# If Active Window Index is not nil
if @active_window_index != nil
@dummy_windows[@active_window_index].windowskin = Cache.system("Window")
end
# Set Active Window Index
@active_window_index = index
# Return if index is nil
return if index == nil
# Set Active Windowskin
@dummy_windows[index].windowskin = Cache.system("Active Windowskin")
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
# If the cursor position is less than 0
if @index < 0
# Empty cursor
self.cursor_rect.empty
else
# Set Cursor Position
self.cursor_rect.set(@index * 136 + (544 - (136 * @item_max)) / 2 + 10, 36, 124, 58 )
end
end
#--------------------------------------------------------------------------
# * Draw Face Graphic
# face_name : Face graphic filename
# face_index : Face graphic index
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# size : Display size
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, x, y, size = 96)
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = 96 / 2
rect.y = 96 / 2
rect.width = 78
rect.height = 78
self.contents.blt(x, y, bitmap, rect, 100)
self.contents.clear_rect(x, y, 100, 18)
bitmap.dispose
end
#--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 120)
draw_actor_hp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
self.contents.font.color = hp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
self.contents.draw_text(xr - 99, y, 44, line_height, actor.hp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, line_height, "/", 2)
self.contents.draw_text(xr - 44, y, 44, line_height, actor.mhp, 2)
end
#--------------------------------------------------------------------------
# * Draw HP gauge
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_hp_gauge(actor, x, y, width = 120)
gw = width * actor.hp / actor.mhp
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.fill_rect(x, y + line_height - 8, width, 4, gauge_back_color)
self.contents.gradient_fill_rect(x, y + line_height - 8, gw, 4, gc1, gc2)
end
#--------------------------------------------------------------------------
# * Draw MP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_mp(actor, x, y, width = 120)
draw_actor_mp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
self.contents.font.color = mp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
self.contents.draw_text(xr - 99, y, 44, line_height, actor.mp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, line_height, "/", 2)
self.contents.draw_text(xr - 44, y, 44, line_height, actor.mmp, 2)
end
#--------------------------------------------------------------------------
# * Draw MP Gauge
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : Width
#--------------------------------------------------------------------------
def draw_actor_mp_gauge(actor, x, y, width = 120)
gw = width * actor.mp / [actor.mmp, 1].max
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.fill_rect(x, y + line_height - 8, width, 4, gauge_back_color)
self.contents.gradient_fill_rect(x, y + line_height - 8, gw, 4, gc1, gc2)
end
end
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Create Window Contents
#--------------------------------------------------------------------------
def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, [height - 32, row_max * 29].max)
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
return self.oy / 29
end
#--------------------------------------------------------------------------
# * Set Top Row
# row : row shown on top
#--------------------------------------------------------------------------
def top_row=(row)
row = 0 if row < 0
row = row_max - 1 if row > row_max - 1
self.oy = row * 29
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
return (self.height - 32) / 29
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = line_height
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = index / @column_max * 29
return rect
end
end
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 233, 280, 200)
self.opacity = 0
# Make Dummy Windows
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Activate Command Window
#--------------------------------------------------------------------------
def activate
# Set Command Window Visibility to true
self.visible = true
# Set dummy windows to visible
@dummy_windows.each {|window| window.visible = true }
end
#--------------------------------------------------------------------------
# * De-Activate Command Window
#--------------------------------------------------------------------------
def deactivate
# Set Command Window Visibility to true
self.visible = false
# Set dummy windows to invisible
@dummy_windows.each {|window| window.visible = false }
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
# Header Window
@dummy_windows << Window_Base.new(10, 251, 255, 41)
@dummy_windows[0].z = self.z - 10
# Text window
@dummy_windows << Window_Base.new(10, 251 + 49 , 255, 41)
@dummy_windows[1].z = self.z - 10
return
end
#--------------------------------------------------------------------------
# * Set Text
# text : character string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 1)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 59, self.width - 40, WLH, text, align)
self.contents.draw_text(4, 10, self.width - 40, WLH, text, align)
@text = text
@align = align
end
end
#--------------------------------------------------------------------------
# * Set ObjectText
# obj : Skill or item
#--------------------------------------------------------------------------
def set_object_text(obj)
if obj != @object
self.contents.clear
self.contents.font.color = normal_color
# If object is not nil
if obj != nil
# Set Header
header = "SKILL" if obj.is_a?(RPG::Skill)
header = "ITEM" if obj.is_a?(RPG::Item)
self.contents.font.color = system_color
self.contents.draw_text(4, 10, self.width - 40, line_height, header, 1)
self.contents.font.color = normal_color
self.contents.draw_text(4, 59, self.width - 40, line_height, obj.description, 1)
end
# Set object
@object = obj
end
end
end
#==============================================================================
# ** Window_BattleSkill
#------------------------------------------------------------------------------
# This window displays a list of usable skills on the skill screen, etc.
#==============================================================================
class Window_BattleSkill < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(280, 251, 255, 90)
@actor = actor
@column_max = 1
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# * Get Skill
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for skill in @actor.skills
@data.push(skill)
if skill.id == @actor.last_skill_id
self.index = @data.size - 1
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
skill = @data[index]
if skill != nil
rect.width -= 4
enabled = @actor.skill_can_use?(skill)
draw_item_name(skill, rect.x, rect.y, enabled)
self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
end
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_object_text(skill)
end
end
#==============================================================================
# ** Window_BattleItem
#------------------------------------------------------------------------------
# This window displays a list of inventory items for the item screen, etc.
#==============================================================================
class Window_BattleItem < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(280, 251, 255, 90)
@column_max = 1
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Whether or not to include in item list
# item : item
#--------------------------------------------------------------------------
def include?(item)
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
#--------------------------------------------------------------------------
# * Whether or not to display in enabled state
# item : item
#--------------------------------------------------------------------------
def enable?(item)
return $game_party.item_can_use?(item)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for item in $game_party.items
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_object_text(item)
end
end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================
class Window_PartyCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
s1 = Vocab::fight
s2 = Vocab::escape
super(544, 416)
draw_item(0, true)
draw_item(1, BattleManager.can_escape?)
self.y = 292
self.x = 5
self.opacity = 0
self.visible = false
self.active = false
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose}
end
#--------------------------------------------------------------------------
# * Activate Command Window
#--------------------------------------------------------------------------
def activate
# Set Command Window Visibility to true
self.visible = true
# Set dummy windows to visible
# @dummy_windows.each.visible = true
# Set Window To active
self.active = true
end
#--------------------------------------------------------------------------
# * De-Activate Command Window
#--------------------------------------------------------------------------
def deactivate
# Set Command Window Visibility to true
self.visible = false
# Set dummy windows to invisible
# @dummy_windows.each.visible = false
# Set Window To inactive
self.active = false
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 245
rect.height = 24
rect.x = index % 2 * 265
rect.y = index / 2 * 49
return rect
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
for i in 0...2
x = self.x + 5 + i % 2 * 270 #265
y = self.y + 8 + i / 2 * 49
@dummy_windows << Window_Base.new(x, y, 255, 41)
@dummy_windows.visible = true
@dummy_windows.z = self.z - 10
end
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
# Set Cursor Position
self.cursor_rect.set((@index % 2 * 270), (@index / 2 * 49), 233, 25)
end
end
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is used to select actor commands, such as "Attack" or "Skill".
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(540, 4)
self.y = 243
self.x = 5
self.visible = false
self.active = false
self.opacity = 0
# Make Background Dummy Window
make_dummy_windows
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
# Dispose dummy windows
@dummy_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 245
rect.height = 24
rect.x = index % 2 * 270
rect.y = index / 2 * 49
return rect
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, command_name(index), 1)
self.contents.draw_text(item_rect_for_text(index), command_name(index), alignment)
end
#--------------------------------------------------------------------------
# * Create Background Dummy Windows
#--------------------------------------------------------------------------
def make_dummy_windows
# Dummy Windows Array
@dummy_windows = []
for i in 0...4
x = self.x + 5 + i % 2 * 270
y = self.y + 8 + i / 2 * 49
@dummy_windows << Window_Base.new(x, y, 255, 41)
@dummy_windows.visible = true
@dummy_windows.z = self.z - 10
end
end
#--------------------------------------------------------------------------
# * Activate Command Window
#--------------------------------------------------------------------------
def activate
# Set dummy windows to visible
@dummy_windows.each {|window| window.visible = true }
# Set Command Window Visibility to true
self.visible = true
# Set Window To active
self.active = true
end
#--------------------------------------------------------------------------
# * De-Activate Command Window
#--------------------------------------------------------------------------
def deactivate
# Set dummy windows to invisible
@dummy_windows.each {|window| window.visible = false }
# Set Command Window Visibility to true
self.visible = false
# Set Window To inactive
self.active = false
end
#--------------------------------------------------------------------------
# * Setup
# actor : actor
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
# Set Cursor Position
self.cursor_rect.set((@index % 2 * 270), (@index / 2 * 49), 233, 25)
end
end
Honestly the whole thing is bugged to hell
and there are so many errors.