class Scene_Equip
#==============================================================================
# Closes extra windows
#==============================================================================
alias g7_ms_scene_equip_main main
def main
@additional_initialize_done = false
g7_ms_scene_equip_main
for i in 5...@item_windows.size
@item_windows[i].dispose unless @item_windows[i].nil?
end
end
#==============================================================================
# Initialize the extra right windows
#==============================================================================
def g7_ms_scene_equip_additional_initialize
unless @additional_initialize_done
@item_windows = []
@item_windows[0] = @item_window1 #weapon
@item_windows[1] = @item_window2 #shield
@item_windows[2] = @item_window3 #helmet
@item_windows[3] = @item_window4 #armor
@item_windows[4] = @item_window5 #acc
nb_old_windows = @item_windows.size
for i in nb_old_windows...@actor.armor_slots.max+1
@item_windows.push(Window_EquipItem.new(@actor, i) ) #add the remaining
#windows for extra slots
@item_windows[i].help_window = @help_window
end
@item_windows.push(Window_EquipOffHand.new(@actor, 0))
@item_windows[-1].help_window = @help_window
if G7_MS_MOD::WINDOWS_STRETCH #if windows_stretch is true, stretch window
h = (@actor.weapon_slots.size + @actor.armor_slots.size + 1) * 32
h2 = (G7_MS_MOD::MAX_SHOW_SLOTS+1) * 32
h = [h, h2].min
@right_window.height = h
if @right_window.index > @actor.weapon_slots.size + @actor.armor_slots.size - 1
@right_window.index = @actor.weapon_slots.size + @actor.armor_slots.size - 1
end
if @left_window.y + @left_window.height == 256
@left_window.height = @right_window.height
elsif G7_MS_MOD::HELP_AT_BOTTOM == true and @left_window.height == 416 then
@left_window.height -= 64 #make left window shorter
end
y_pos = (@right_window.y + @right_window.height)
y_space = 480 - y_pos
#if help at bottom, reduce bottom item window size
if G7_MS_MOD::HELP_AT_BOTTOM == true then y_space -= 64 end
for item_window in @item_windows
next if item_window.nil?
item_window.y = y_pos
item_window.height = y_space
end
end
@additional_initialize_done = true
end
end
alias g7_ms_scene_equip_refresh refresh
#==============================================================================
# Refresh and make visible the correct right window
#==============================================================================
def refresh
#this part is used to refresh the equipped item at the right window
g7_ms_scene_equip_additional_initialize
@actor.translucent_texts.fill(false)
@actor.equip_type_force = index_to_equip_part(@right_window.index)
@right_window.item_fix_on
@right_window.scroll_fix_on
save = @right_window.index
@right_window.index = index_to_equip_kind(@right_window.index)
if @right_window.index == 0 and @actor.ignore_offhand? != true then
if @actor.nb_offhand_required(save) > 0 then
@right_window.index = @item_windows.size-1
end
end
@actor.equip_from_menu = true
@actor.equip_mode = 'STORE' #ensure current equipment will get properly stored
# and reequiped
@item_window = @item_windows[@right_window.index]
@item_windows[@right_window.index].visible = true
for i in 0...@item_windows.size
if i != @right_window.index then
@item_windows[i].visible = false
end
end
#equip and remove item
g7_ms_scene_equip_refresh
@actor.equip_from_menu = false
@actor.equip_mode = nil
@actor.equip_type_force = nil
@right_window.index = save
@right_window.scroll_fix_off
@right_window.item_fix_off
if @item_window.index != @old_index
@right_window.refresh
end
@old_index = @item_window.index
end
#==============================================================================
# Convert the right_window.index to equip_type
#==============================================================================
alias g7_ms_scene_equip_update_item update_item
def update_item #this changes the @right_window.index to the correct value
#to take account of extra slots
@actor.equip_type_force = index_to_equip_part(@right_window.index)
@right_window.item_fix_on
@right_window.scroll_fix_on
save = @right_window.index
@right_window.index = index_to_equip_kind(@right_window.index)
@actor.equip_from_menu = true
g7_ms_scene_equip_update_item #equip item
@actor.equip_from_menu = false
@actor.equip_type_force = nil
# if not in item_window screen
if @item_window.index == -1
#if shield-weapon can modify each other
if @actor.shield_hand_wield == true and
if @right_window.index == @actor.shield_hand_slot then
@item_windows[0].refresh
@item_windows[-1].refresh
elsif @right_window.index == 0
@item_windows[@actor.shield_hand_slot].refresh #refresh shield slot
end
end
if @right_window.index == 0 and @actor.ignore_offhand? != true then
if @item_window == @item_windows[-1] then
@item_windows[0].refresh
elsif @item_window == @item_windows[0] then
@item_windows[-1].refresh
end
end
end
@right_window.index = save
@right_window.scroll_fix_off
@right_window.item_fix_off
@actor.equip_type_force = nil
end
#==============================================================================
# Convert index to equip part
#==============================================================================
def index_to_equip_part(index)
#return index of slot in the array [0, @actor.armor_slots, actor.weapon_slots]
if index >= @actor.weapon_slots.size #if armor
return index - (@actor.weapon_slots.size - 1)
elsif index >= 1 #if extra weapon
return index + [@actor.armor_slots.size, 4].max #make it last
else
return 0
end
end
#==============================================================================
# Convert index to equip kind
#==============================================================================
def index_to_equip_kind(index)
#return index of slot in either actor.weapon_slots or actor.armor_slots
i = index_to_equip_part(index)
if index >= @actor.weapon_slots.size #if armor
set = @actor.armor_slots[i-1]
else #if weapon
i = i == 0 ? 0 : i - [@actor.armor_slots.size, 4].max
set = @actor.weapon_slots[i]
end
return set != nil ? set : 0
end
end #end scene_equip
#==============================================================================
# Window_EquipRight
#==============================================================================
class Window_EquipRight < Window_Selectable
def item_fix_on
#fix window
@fixed_item = @data[self.index]
@fixed = true
end
def item_fix_off
#stop fixing window
@fixed_item = nil
@fixed = false
end
#==============================================================================
# Dont scroll right window if you press L or R
#==============================================================================
def update
if Input.repeat?(Input::R) or Input.repeat?(Input::L) then
return
else
super
end
end
#==============================================================================
# Draws equipped items with support of translucent and cursed items
#==============================================================================
def draw_item_name(item, x, y, translucent = false)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
if item.cursed
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = G7_MS_MOD::CURSED_COLOR
elsif translucent
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 128)
self.contents.font.color = disabled_color
else
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
end
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
alias g7_ms_window_equipright_item item
#==============================================================================
# Prevent needless update of item quantities in item window
#==============================================================================
def item
#this ensures that the number of items doesn't get updated if you move
#cursor in item window
return @fixed_item if @fixed
return g7_ms_window_equipright_item
end
#==============================================================================
# Change the height of right windows to fit the slots
#==============================================================================
alias g7_ms_window_equipright_initialize initialize
def initialize(actor) #init with a different height
g7_ms_window_equipright_initialize(actor)
h = (actor.weapon_slots.size + actor.armor_slots.size) * 32 #total height
#of right window
self.contents = Bitmap.new(width - 32, h) #change the height
refresh
end
#==============================================================================
# Shows the slot names and the name of the items you have equipped
#==============================================================================
def refresh #remplaced method to show caption of all items and slot
self.contents.clear
@data = []
#------------------------------------------------------------------------------
#Begin Multi-slot equipment script Edit
#------------------------------------------------------------------------------
self.contents.font.name = G7_MS_MOD::FONT_NAME
for i in 0...@actor.weapon_slots.size
@data.push($data_weapons[@actor.weapon_ids[i]]) #push name of weapon
end
for i in 0...@actor.armor_slots.size
@data.push($data_armors[@actor.armor_ids[i]]) #push name of armor
end
@caption = []
for i in 0...@actor.weapon_slots.size
@caption.push(@actor.weapon_slot_names[i]) #push name of weapon slots
end
for i in 0...@actor.armor_slots.size
@caption.push(@actor.armor_slot_names[@actor.armor_slots[i]-1]) #push name of armor slot
end
@item_max = @data.size
if @actor.translucent_texts == nil then @actor.translucent_texts = Array.new end
for i in 0...@data.size
if @caption[i] != nil
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * i, 92, 32, @caption[i]) #draw name of slots
end
draw_item_name(@data[i], 92, 32 * i, @actor.translucent_texts[i]) #draw name of equipment
end
#support for other script
if defined? xrxs_additional_refresh
xrxs_additional_refresh
end
#------------------------------------------------------------------------------
# End Multi-slot equipment script Edit
#------------------------------------------------------------------------------
end
end
#==============================================================================
# New class to show equipitem in offhand
#==============================================================================
class Window_EquipOffHand < Window_EquipItem
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add equippable weapons
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
weapon = $data_weapons[i]
if weapon.needs_offhand == false
if G7_MS_MOD::TWOHANDED_IN_OFFHAND != false and weapon.nb_hands <= 1 then
@data.push(weapon)
end
end
end
end
# Add blank page
@data.push(nil)
# Make a bit map and draw all items
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = G7_MS_MOD::FONT_NAME
#self.contents.font.size = 24
for i in 0...@item_max-1
draw_item(i)
end
if G7_MS_MOD::SHOW_REMOVE then
i += 1
x = 4 + i % @column_max * (288 + 32)
y = i / @column_max * 32
self.contents.draw_text(x+4, y, 100, 32, '[Remove]')
end
end
end
class Window_Selectable < Window_Base
def scroll_fix_on
@scroll_fixed = true
end
def scroll_fix_off
@scroll_fixed = false
update_cursor_rect
end
#==============================================================================
# Prevents unwanted scrolling
#==============================================================================
alias g7_ms_update_cursor_rect update_cursor_rect
def update_cursor_rect
#This prevents the windows from scrolling if scroll is fixed
#This was added to ensure that if there are few slots, the right equip
#screen doesn't scroll needlessly
return if @scroll_fixed
g7_ms_update_cursor_rect
end
end
#==============================================================================
# Shows a new status window if Status_window_arrange is true
#==============================================================================
if G7_MS_MOD::STATUS_WINDOW_ARRANGE
class Window_Status < Window_Base
def refresh
#------------------------------------------------------------------------------
#Begin Multi-slot equipment script Edit
#------------------------------------------------------------------------------
self.contents.font.name = G7_MS_MOD::FONT_NAME
#------------------------------------------------------------------------------
# End Multi-slot equipment script Edit
#------------------------------------------------------------------------------
self.contents.clear
draw_actor_face(@actor, 4, 30)
draw_actor_name(@actor, 4, 0)
#draw_actor_class(@actor, 4 + 144, 0)
draw_actor_level(@actor, 106, 32)
draw_actor_state(@actor, 106, 64)
draw_actor_hp(@actor, 106, 112, 172)
draw_actor_sp(@actor, 106, 144, 172)
draw_actor_parameter(@actor, 106, 192, 0)
draw_actor_parameter(@actor, 106, 224, 1)
draw_actor_parameter(@actor, 106, 256, 2)
draw_actor_parameter(@actor, 106, 304, 3)
draw_actor_parameter(@actor, 106, 336, 4)
draw_actor_parameter(@actor, 106, 368, 5)
draw_actor_parameter(@actor, 106, 400, 6)
#------------------------------------------------------------------------------
#Begin Multi-slot equipment script Edit
#------------------------------------------------------------------------------
if G7_MS_MOD::EVADE
draw_actor_parameter(@actor, 106, 432, 7) # activate if you have a draw_actor_paramter method that draw evade
end
self.contents.font.color = system_color
self.contents.draw_text(320, 16, 80, 32, 'EXP')
self.contents.draw_text(320, 48, 80, 32, 'NEXT')
self.contents.font.color = normal_color
self.contents.draw_text(320 + 80, 16, 84, 32, @actor.exp_s, 2)
self.contents.draw_text(320 + 80, 48, 84, 32, @actor.next_rest_exp_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(320, 80, 96, 32, 'Equipment')
for i in 0...@actor.weapon_slots.size
draw_item_name($data_weapons[@actor.weapon_ids[i]], 320 + 16, 80 + 24 * (i+1))
end
for i in 0...@actor.armor_slots.size
draw_item_name($data_armors[@actor.armor_ids[i]], 320 + 16, 200 + 24 * (i - 4 + @actor.weapon_slots.size))
end
#------------------------------------------------------------------------------
# End Multi-slot equipment script Edit
#------------------------------------------------------------------------------
end
end
end