class Window_EquipBaseInfo < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# x : ウィンドウの X 座標
# y : ウィンドウの Y 座標
# actor : アクター
#--------------------------------------------------------------------------
def initialize(x, y, actor)
super(x, y, Graphics.width / 2, WLH + 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 0, 0)
# EP 制を使用する場合は EP を描画
if $imported["EquipExtension"] && KGC::EquipExtension::USE_EP_SYSTEM
draw_actor_ep(@actor, 116, 0, Graphics.width / 2 - 148)
end
end
end
@caption_cache = Bitmap.new(self.contents.width, self.contents.height)
@caption_cache.blt(0, 0, self.contents, self.contents.rect)
end
#--------------------------------------------------------------------------
# ○ 能力値名の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
# type : 能力値の種類
#--------------------------------------------------------------------------
def draw_parameter_name(x, y, type)
case type
when :maxhp
name = Vocab.hp
when :maxmp
name = Vocab.mp
when :atk
name = Vocab.atk
when :def
name = Vocab.def
when :spi
name = Vocab.spi
when :agi
name = Vocab.agi
when :mdef
name = Vocab.mdef
when :hit
name = Vocab.hit
when :eva
name = Vocab.eva
when :cri
name = Vocab.cri
end
self.contents.font.color = system_color
self.contents.draw_text(x + 4, y, 96, WLH, name)
self.contents.font.color = system_color
self.contents.draw_text(x + 156, y, 20, WLH, "→", 1)
end
#--------------------------------------------------------------------------
# ● 装備変更後の能力値設定
# new_param : 装備変更後のパラメータの配列
# new_item : 変更後の装備
#--------------------------------------------------------------------------
def set_new_parameters(new_param, new_item)
changed = false
# パラメータ変化判定
KGC::ExtendedEquipScene::EQUIP_PARAMS.each { |k|
if @new_param[k] != new_param[k]
changed = true
break
end
}
changed |= (@new_item != new_item)
if changed
@new_item = new_item
@new_param = new_param
refresh
end
end
#--------------------------------------------------------------------------
# ● 能力値の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
# type : 能力値の種類
#--------------------------------------------------------------------------
def draw_parameter(x, y, type)
case type
when :maxhp
value = @actor.maxhp
when :maxmp
value = @actor.maxmp
when :atk
value = @actor.atk
when :def
value = @actor.def
when :spi
value = @actor.spi
when :agi
value = @actor.agi
when :mdef
value = @actor.mdef
when :hit
value = @actor.hit
when :eva
value = @actor.eva
when :cri
value = @actor.cri
end
new_value = @new_param[type]
self.contents.font.color = normal_color
self.contents.draw_text(x + 106, y, 48, WLH, value, 2)
if new_value != nil
self.contents.font.color = new_parameter_color(value, new_value)
self.contents.draw_text(x + 176, y, 48, WLH, new_value, 2)
end
end
end
# 装備固定なら「最強装備」「すべて外す」を無効化
if @actor.fix_equipment
@command_window.draw_item(1, false)
@command_window.draw_item(2, false)
end
end
#--------------------------------------------------------------------------
# ● 終了処理
#--------------------------------------------------------------------------
alias terminate_KGC_ExtendedEquipScene terminate
def terminate
terminate_KGC_ExtendedEquipScene
@command_window.dispose
@base_info_window.dispose
end
#--------------------------------------------------------------------------
# ○ ウィンドウをリフレッシュ
#--------------------------------------------------------------------------
def refresh_window
@base_info_window.refresh
@equip_window.refresh
@status_window.refresh
@item_windows.each { |window| window.refresh }
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias update_KGC_ExtendedEquipScene update
def update
update_command_window
if @command_window.active
update_KGC_ExtendedEquipScene
update_command_selection
else
update_KGC_ExtendedEquipScene
end
end
#--------------------------------------------------------------------------
# ○ コマンドウィンドウの更新
#--------------------------------------------------------------------------
def update_command_window
@command_window.update
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの更新
#--------------------------------------------------------------------------
def update_status_window
@base_info_window.update
@status_window.update
if @command_window.active || @equip_window.active
@status_window.set_new_parameters({}, nil)
elsif @item_window.active
return if @last_item == @item_window.item
@last_item = @item_window.item
temp_actor = Marshal.load(Marshal.dump(@actor))
temp_actor.change_equip(@equip_window.index, @item_window.item, true)
param = {
:maxhp => temp_actor.maxhp,
:maxmp => temp_actor.maxmp,
:atk => temp_actor.atk,
:def => temp_actor.def,
:spi => temp_actor.spi,
:agi => temp_actor.agi,
:mdef => temp_actor.mdef,
:hit => temp_actor.hit,
:eva => temp_actor.eva,
:cri => temp_actor.cri,
}
@status_window.equip_type = @equip_window.index
@status_window.set_new_parameters(param, @last_item)
Graphics.frame_reset
end
end
#--------------------------------------------------------------------------
# ○ コマンド選択の更新
#--------------------------------------------------------------------------
def update_command_selection
update_window_position_for_equip_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::R)
Sound.play_cursor
next_actor
elsif Input.trigger?(Input::L)
Sound.play_cursor
prev_actor
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # 装備変更
Sound.play_decision
# 装備部位ウィンドウに切り替え
@equip_window.active = true
@command_window.active = false
@command_window.close
when 1 # 最強装備
if @actor.fix_equipment
Sound.play_buzzer
return
end
Sound.play_equip
process_equip_strongest
when 2 # すべて外す
if @actor.fix_equipment
Sound.play_buzzer
return
end
Sound.play_equip
process_remove_all
end
end
end
#--------------------------------------------------------------------------
# ● 装備部位選択の更新
#--------------------------------------------------------------------------
alias update_equip_selection_KGC_ExtendedEquipScene update_equip_selection
def update_equip_selection
update_window_position_for_equip_selection
if Input.trigger?(Input::A)
if @actor.fix_equipment
Sound.play_buzzer
return
end
# 選択している装備品を外す
Sound.play_equip
@actor.change_equip(@equip_window.index, nil)
@base_info_window.refresh
@equip_window.refresh
@item_window.refresh
elsif Input.trigger?(Input::B)
Sound.play_cancel
# コマンドウィンドウに切り替え
@equip_window.active = false
@command_window.active = true
@command_window.open
return
elsif Input.trigger?(Input::R) || Input.trigger?(Input::L)
# アクター切り替えを無効化
return
elsif Input.trigger?(Input::C)
# 前回のアイテムをダミーにする
@last_item = RPG::Weapon.new
end
update_equip_selection_KGC_ExtendedEquipScene
end
#--------------------------------------------------------------------------
# ● アイテム選択の更新
#--------------------------------------------------------------------------
alias update_item_selection_KGC_ExtendedEquipScene update_item_selection
def update_item_selection
update_window_position_for_item_selection
update_item_selection_KGC_ExtendedEquipScene
if Input.trigger?(Input::C)
@base_info_window.refresh
end
end
#--------------------------------------------------------------------------
# ○ ウィンドウ位置の更新 (装備部位選択)
#--------------------------------------------------------------------------
def update_window_position_for_equip_selection
return if @item_window.x == @equip_window.width
# 最強装備
type.each_index { |i|
case i
when weapon_range # 武器
weapon = strongest_item(i, -1)
next if weapon == nil
@actor.change_equip(i, weapon)
else # 防具
armor = strongest_item(i, type)
next if armor == nil
@actor.change_equip(i, armor)
end
}
refresh_window
end
#--------------------------------------------------------------------------
# ○ 最も強力なアイテムを取得
# equip_type : 装備部位
# kind : 種別 (-1..武器 0~..防具)
# 該当するアイテムがなければ nil を返す。
#--------------------------------------------------------------------------
def strongest_item(equip_type, kind)
result = nil
case kind
when -1 # 武器
# 装備可能な武器を取得
weapons = $game_party.items.find_all { |item|
valid = item.is_a?(RPG::Weapon) && @actor.equippable?(item)
if valid && $imported["EquipExtension"]
valid = @actor.ep_condition_clear?(equip_type, item)
end
valid
}
# 最も atk が高い武器を取得
weapons.each { |item|
if result == nil || result.atk <= item.atk
result = item
end
}
else # 防具
# 装備可能な防具を取得
armors = $game_party.items.find_all { |item|
valid = item.is_a?(RPG::Armor) && item.kind == kind &&
@actor.equippable?(item)
if valid && $imported["EquipExtension"]
valid = @actor.ep_condition_clear?(equip_type, item)
end
valid
}
# 最も def が高い防具を取得
armors.each { |item|
if result == nil || result.def <= item.def
result = item
end
}
end
return result
end
#--------------------------------------------------------------------------
# ○ すべて外す処理
#--------------------------------------------------------------------------
def process_remove_all
type_max = ($imported["EquipExtension"] ? @actor.equip_type.size : 3) + 1
type_max.times { |i| @actor.change_equip(i, nil) }
refresh_window
end
end
[/ code]