#==============================================================================
# ** Shard Equip
#------------------------------------------------------------------------------
# Allows each character to equip two Weapon Shards and three Armor Shards.
#==============================================================================
class Window_EquipShardLeft < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 256, 368, 224)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 80, 0)
draw_actor_level(@actor, 250, 0)
self.contents.draw_text(4, 32, 64, 32, "ATK")
self.contents.draw_text(170, 32, 64, 32, "PDef")
self.contents.draw_text(4, 64, 64, 32, "MDef")
self.contents.draw_text(170, 64, 64, 32, "EVA")
self.contents.draw_text(4, 118, 64, 32, "STR")
self.contents.draw_text(170, 118, 64, 32, "DEX")
self.contents.draw_text(4, 150, 64, 32, "AGI")
self.contents.draw_text(170, 150, 64, 32, "INT")
self.contents.draw_text(60, 32, 36, 32, @actor.atk.to_s, 2)
self.contents.draw_text(226, 32, 36, 32, @actor.pdef.to_s, 2)
self.contents.draw_text(60, 64, 36, 32, @actor.mdef.to_s, 2)
self.contents.draw_text(226, 64, 36, 32, @actor.eva.to_s, 2)
self.contents.draw_text(60, 118, 36, 32, @actor.str.to_s, 2)
self.contents.draw_text(226, 118, 36, 32, @actor.dex.to_s, 2)
self.contents.draw_text(60, 150, 36, 32, @actor.agi.to_s, 2)
self.contents.draw_text(226, 150, 36, 32, @actor.int.to_s, 2)
if @new_atk != nil
self.contents.font.color = system_color
if @new_atk == @actor.atk
self.contents.draw_text(110, 32, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_atk > @actor.atk
self.contents.draw_text(110, 32, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_atk < @actor.atk
self.contents.draw_text(110, 32, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(126, 32, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
if @new_pdef == @actor.pdef
self.contents.draw_text(276, 32, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_pdef > @actor.pdef
self.contents.draw_text(276, 32, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_pdef < @actor.pdef
self.contents.draw_text(276, 32, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(292, 32, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
if @new_mdef == @actor.mdef
self.contents.draw_text(110, 64, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_mdef > @actor.mdef
self.contents.draw_text(110, 64, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_mdef < @actor.mdef
self.contents.draw_text(110, 64, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(126, 64, 36, 32, @new_mdef.to_s, 2)
end
if @new_eva != nil
self.contents.font.color = system_color
if @new_eva == @actor.eva
self.contents.draw_text(276, 64, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_eva > @actor.eva
self.contents.draw_text(276, 64, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_eva < @actor.eva
self.contents.draw_text(276, 64, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(292, 64, 36, 32, @new_eva.to_s, 2)
end
if @new_str != nil
self.contents.font.color = system_color
if @new_str == @actor.str
self.contents.draw_text(110, 118, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_str > @actor.str
self.contents.draw_text(110, 118, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_str < @actor.str
self.contents.draw_text(110, 118, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(126, 118, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
self.contents.font.color = system_color
if @new_dex == @actor.dex
self.contents.draw_text(276, 118, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_dex > @actor.dex
self.contents.draw_text(276, 118, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_dex < @actor.dex
self.contents.draw_text(276, 118, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(292, 118, 36, 32, @new_dex.to_s, 2)
end
if @new_agi != nil
self.contents.font.color = system_color
if @new_agi == @actor.agi
self.contents.draw_text(110, 150, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_agi > @actor.agi
self.contents.draw_text(110, 150, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_agi < @actor.agi
self.contents.draw_text(110, 150, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(126, 150, 36, 32, @new_agi.to_s, 2)
end
if @new_int != nil
self.contents.font.color = system_color
if @new_int == @actor.int
self.contents.draw_text(276, 150, 20, 32, "=")
self.contents.font.color = normal_color
elsif @new_int > @actor.int
self.contents.draw_text(276, 150, 20, 32, "↑")
self.contents.font.color = text_color(3)
elsif @new_int < @actor.int
self.contents.draw_text(276, 150, 20, 32, "↓")
self.contents.font.color = text_color(2)
end
self.contents.draw_text(292, 150, 36, 32, @new_int.to_s, 2)
end
end
#--------------------------------------------------------------------------
# * Set parameters after changing equipment
# new_atk : attack power after changing equipment
# new_pdef : physical defense after changing equipment
# new_mdef : magic defense after changing equipment
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_eva, new_str, new_dex, new_agi, new_int)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_eva != new_eva or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_eva = new_eva
@new_str = new_str
@new_dex = new_dex
@new_agi = new_agi
@new_int = new_int
refresh
end
end
end
class Window_EquipShardRight < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 368, 192)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_shard1_id])
@data.push($data_weapons[@actor.weapon_shard2_id])
@data.push($data_armors[@actor.armor_shard1_id])
@data.push($data_armors[@actor.armor_shard2_id])
@data.push($data_armors[@actor.armor_shard3_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, "Weapon Shard")
self.contents.draw_text(4, 32 * 1, 92, 32, "Weapon Shard")
self.contents.draw_text(4, 32 * 2, 92, 32, "Armor Shard")
self.contents.draw_text(4, 32 * 3, 92, 32, "Armor Shard")
self.contents.draw_text(4, 32 * 4, 92, 32, "Armor Shard")
if @data[5] != nil
draw_item_name(@data[5], 92, 32 * 0)
else
self.contents.font.color = text_color(7)
self.contents.draw_text(100, 32 * 0, 120, 32, "No Equipment")
end
if @data[6] != nil
draw_item_name(@data[6], 92, 32 * 1)
else
self.contents.font.color = text_color(7)
self.contents.draw_text(100, 32 * 1, 120, 32, "No Equipment")
end
if @data[7] != nil
draw_item_name(@data[7], 92, 32 * 2)
else
self.contents.font.color = text_color(7)
self.contents.draw_text(100, 32 * 2, 120, 32, "No Equipment")
end
if @data[8] != nil
draw_item_name(@data[8], 92, 32 * 3)
else
self.contents.font.color = text_color(7)
self.contents.draw_text(100, 32 * 3, 120, 32, "No Equipment")
end
if @data[9] != nil
draw_item_name(@data[9], 92, 32 * 4)
else
self.contents.font.color = text_color(7)
self.contents.draw_text(100, 32 * 4, 120, 32, "No Equipment")
end
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Window_EquipShard < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
# equip_type : equip region (0-3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(368, 64, 272, 416)
@actor = actor
@equip_type = equip_type
@item_max = 1
@column_max = 1
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add equippable weapons
if @equip_type == 5
element = SEG_LEGACY::SHARD::WELEMENT
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and $data_weapons[i].element_set.include?(element)
@data.push($data_weapons[i])
end
end
elsif @equip_type == 6
element = SEG_LEGACY::SHARD::WELEMENT
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and $data_weapons[i].element_set.include?(element)
@data.push($data_weapons[i])
end
end
elsif @equip_type != 0..6
element = SEG_LEGACY::SHARD::AELEMENT
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and $data_armors[i].guard_element_set.include?(element)
@data.push($data_armors[i])
end
end
end
# Add blank page
@data.push(nil)
# Make a bit map and draw all items
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 1 * (288 + 32)
y = index * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 190, y, 16, 32, ":", 1)
self.contents.draw_text(x + 210, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Scene_EquipShard
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
# equip_index : equipment index
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@equip_index = equip_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
# Get actor
@actor = $game_party.actors[@actor_index]
# Make windows
@help_window = Window_Help.new
@left_window = Window_EquipShardLeft.new(@actor)
@right_window = Window_EquipShardRight.new(@actor)
@item_window1 = Window_EquipShard.new(@actor, 5)
@item_window2 = Window_EquipShard.new(@actor, 6)
@item_window3 = Window_EquipShard.new(@actor, 7)
@item_window4 = Window_EquipShard.new(@actor, 8)
@item_window5 = Window_EquipShard.new(@actor, 9)
# Associate help window
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# Set cursor position
@right_window.index = @equip_index
refresh
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@spriteset.dispose
@help_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Set item window to visible
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
# Get currently equipped item
item1 = @right_window.item
# Set current item window to @item_window
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# If right window is active
if @right_window.active
# Erase parameters for after equipment change
@left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
end
# If item window is active
if @item_window.active
# Get currently selected item
item2 = @item_window.item
# Change equipment
last_hp = @actor.hp
last_sp = @actor.sp
@actor.equip(@right_window.index+5, item2 == nil ? 0 : item2.id)
# Get parameters for after equipment change
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
new_eva = @actor.eva
new_str = @actor.str
new_dex = @actor.dex
new_agi = @actor.agi
new_int = @actor.int
# Return equipment
@actor.equip(@right_window.index+5, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# Draw in left window
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_eva, new_str, new_dex, new_agi, new_int)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@left_window.update
@right_window.update
@item_window.update
refresh
# If right window is active: call update_right
if @right_window.active
update_right
return
end
# If item window is active: call update_item
if @item_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when right window is active)
#--------------------------------------------------------------------------
def update_right
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(1)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If equipment is fixed
if @actor.equip_fix?(@right_window.index)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Activate item window
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# If R button was pressed
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.actors.size
# Switch to different equipment screen
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# Switch to different equipment screen
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @item_window.item
# Change equipment
@actor.equip(@right_window.index+5, item == nil ? 0 : item.id)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
return
end
end
end