#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# メニュー画面でパーティメンバーのステータスを表示す�
#=============================================================================
class Window_MenuStatus4 < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
@item_max = 3
@column_max = 3
@commands = [" ", " ", " "]
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
end
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 160, -3, 130, 22)
end
end
end#==============================================================================
# Kingdom Hearts Menu
# -Scripted by: Leon Blade-
#------------------------------------------------------------------------------
# This menu was scripted by Leon Blade for FinalXemnas
# Created after Kingdom Hearts Menu
#==============================================================================
#================================
# Windows
#================================
#----------------------------------------------------------------
# Window Base Add On(Used for displaying battlers)
#----------------------------------------------------------------
class Window_Base < Window
def draw_actor_battler_graphic(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
#----------------------------------------------------------------
# Extra Window(Contains Playtime and Step Counter)
#----------------------------------------------------------------
class Window_Extra < Window_Base
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 104)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Play Time" window font
self.contents.font.size = $defaultfontsize
refresh
end
#--------------------------------------------------------------------------
# ● Displays
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "Play Time")
self.contents.draw_text(300, 0, 120, 32, "Number of Steps")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
self.contents.draw_text(300, 32, 120, 32, $game_party.steps.to_s, 2)
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#----------------------------------------------------------------
# Gold(Displays your curency and how much)
#----------------------------------------------------------------
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 168)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Gold" window font
self.contents.font.size = $defaultfontsize
refresh
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#----------------------------------------------------------------
# Map(Lets $map_infos = @map_id)
#----------------------------------------------------------------
class Game_Map
def name
$map_infos[@map_id]
end
end
#----------------------------------------------------------------
# Title(Checks your map in data files)
#----------------------------------------------------------------
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
#----------------------------------------------------------------
# Mapname(Displays current location)
#----------------------------------------------------------------
class Window_Mapname < Window_Base
#--------------------------------------------------------------------------
# Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 56)
self.contents = Bitmap.new(width - 52, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
end
#--------------------------------------------------------------------------
# Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
new_name = $game_map.name.tr("/*","")
self.contents.draw_text(500, -5, 320, 32, new_name.to_s)
self.contents.draw_text(5, -5, 320, 32, "Location")
end
end
#----------------------------------------------------------------
# Menu Status 1(Displays stats for hero in slot 1)
#----------------------------------------------------------------
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 0
actor = $game_party.actors[0]
draw_actor_battler_graphic(actor, 55, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Menu Status 2(Displays stats for hero in slot 2)
#----------------------------------------------------------------
class Window_MenuStatus2 < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 1
actor = $game_party.actors[1]
draw_actor_battler_graphic(actor, 55, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Menu Status 3(Displays stats for hero in slot 3)
#----------------------------------------------------------------
class Window_MenuStatus3 < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 2
actor = $game_party.actors[2]
draw_actor_battler_graphic(actor, 60, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Item(Item window to not display items of synthesis)
#
# To make an item synthesis make a new attribute in the
# systems tab ID: 17 and select it to all synthesis items.
#----------------------------------------------------------------
class Window_Item < Window_Selectable
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def item
return @data[self.index]
end
def refresh(item_kind = 0)
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case item_kind
when 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
not $data_items[i].element_set.include?(17)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
not $data_weapons[i].element_set.include?(17)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
not $data_armors[i].guard_element_set.include?(17)
@data.push($data_armors[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#----------------------------------------------------------------
# Item2(Item window to display items of synthesis)
#
# To make an item synthesis make a new attribute in the
# systems tab ID: 17 and select it to all synthesis items.
#----------------------------------------------------------------
class Window_Item2 < Window_Selectable
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def item
return @data[self.index]
end
def refresh(item_kind = 0)
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case item_kind
when 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
$data_items[i].element_set.include?(17)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
$data_weapons[i].element_set.include?(17)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
$data_armors[i].guard_element_set.include?(17)
@data.push($data_armors[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#================================
# Scenes
#================================
#----------------------------------------------------------------
# Item 1(Used for regular items)
#----------------------------------------------------------------
class Scene_Item
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@item_window = Window_Item.new
# ヘルプウィンドウを関連付け
@item_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @item_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$game_switches[2] = false
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @item_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@item_window.refresh
end
# ターゲットウィンドウを消去
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#----------------------------------------------------------------
# Item 2(Used for Materials scene)
#----------------------------------------------------------------
class Scene_Item2
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@item_window = Window_Item2.new
# ヘルプウィンドウを関連付け
@item_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @item_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$game_switches[2] = false
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @item_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@item_window.refresh
end
# ターゲットウィンドウを消去
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#----------------------------------------------------------------
# Menu
#----------------------------------------------------------------
class Scene_Menu
#--------------------------------------------------------------------------
# ● Initialize the menus
# menu_index : The index of the initial selected item on the command menu
# (0 = the first item on the menu, with the number increasing
# by one for each command below the top command)
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● Set up the menu, processes the user's actions in the main loop,
# and then disposes of the objects
#--------------------------------------------------------------------------
def main
# Set up command window
if $game_switches[1] == true
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Materials"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.y = 56
@command_window.index = @menu_index
else
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Materials"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.y = 56
@command_window.index = @menu_index
end
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# Set up play mapname window
@map_window = Window_Mapname.new
@map_window.x = 0
@map_window.y = 0
# Set up extra window
@extra_window = Window_Extra.new
@extra_window.x = 160
@extra_window.y = 376
# Set up gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 312
# Set up status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 56
# Set up status window 2
@status_window2 = Window_MenuStatus2.new
@status_window2.x = 320
@status_window2.y = 56
# Set up status window 2
@status_window3 = Window_MenuStatus3.new
@status_window3.x = 480
@status_window3.y = 56
# Set up status
@window_status = Window_MenuStatus4.new
@window_status.x = 160
@window_status.y = 56
@window_status.opacity = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# Clean up
@command_window.dispose
@map_window.dispose
@gold_window.dispose
@status_window.dispose
@status_window2.dispose
@status_window3.dispose
@window_status.dispose
@extra_window.dispose
end
#--------------------------------------------------------------------------
# ● Update the contents of all five windows on the main menu
#--------------------------------------------------------------------------
def update
@command_window.update
@gold_window.update
@status_window.update
@map_window.update
@status_window2.update
@status_window3.update
@extra_window.update
@window_status.update
if @command_window.active
update_command
return
end
if @window_status.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● Update the command menu window in response to user input
#--------------------------------------------------------------------------
def update_command
# Cancel key is pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
# Decision key is pressed
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0 # Item selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # Skill selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 2 # Equipment selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 3 # Status selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 4 # Materials selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item2.new
end
return
end
end
#--------------------------------------------------------------------------
# ● Update the status of a menu opened through the main menu
#--------------------------------------------------------------------------
def update_status
# Cancel key pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@window_status.active = false
@window_status.index = -1
return
end
# Make a decision
if Input.trigger?(Input::C)
case @command_window.index
when 1 # Skill Window
if $game_party.actors[@window_status.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@window_status.index)
when 2 # Equipment Window
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@window_status.index)
when 3 # Staus Window
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@window_status.index)
end
return
end
end
end
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# メニュー画面でパーティメンバーのステータスを表示す�
#=============================================================================
#================================
# Config
#================================
#change these to increase ore decrease the size of the fonts
KHM_SIZE = 16
#end config
class Window_MenuStatus4 < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_SIZE
@item_max = 3
@column_max = 3
@commands = [" ", " ", " "]
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
end
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 160, -3, 130, 22)
end
end
end
#==============================================================================
# Kingdom Hearts Menu
# -Scripted by: Leon Blade-
# Edit bij jackolas (full credit go's to Leon Blade)
#------------------------------------------------------------------------------
# This menu was scripted by Leon Blade for FinalXemnas
# Created after Kingdom Hearts Menu
#==============================================================================
#================================
# Config
#================================
#change these to increase ore decrease the size of the fonts
KHM_PLAYTIME_SIZE = 16
KHM_GOLD_SIZE = 16
KHM_MAPNAME_SIZE = 16
KHM_STATS1_SIZE = 16
KHM_STATS2_SIZE = 16
KHM_STATS3_SIZE = 16
KHM_ITEM_SIZE = 16
KHM_ITEM2_SIZE = 16
#end config
#================================
# Windows
#================================
#----------------------------------------------------------------
# Window Base Add On(Used for displaying battlers)
#----------------------------------------------------------------
class Window_Base < Window
def draw_actor_battler_graphic(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
#----------------------------------------------------------------
# Extra Window(Contains Playtime and Step Counter)
#----------------------------------------------------------------
class Window_Extra < Window_Base
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 104)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_PLAYTIME_SIZE
refresh
end
#--------------------------------------------------------------------------
# ● Displays
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "Play Time")
self.contents.draw_text(300, 0, 120, 32, "Number of Steps")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
self.contents.draw_text(300, 32, 120, 32, $game_party.steps.to_s, 2)
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#----------------------------------------------------------------
# Gold(Displays your curency and how much)
#----------------------------------------------------------------
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 168)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_GOLD_SIZE
refresh
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#----------------------------------------------------------------
# Map(Lets $map_infos = @map_id)
#----------------------------------------------------------------
class Game_Map
def name
$map_infos[@map_id]
end
end
#----------------------------------------------------------------
# Title(Checks your map in data files)
#----------------------------------------------------------------
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
#----------------------------------------------------------------
# Mapname(Displays current location)
#----------------------------------------------------------------
class Window_Mapname < Window_Base
#--------------------------------------------------------------------------
# Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 56)
self.contents = Bitmap.new(width - 52, height - 32)
self.contents.font.size = KHM_MAPNAME_SIZE
refresh
end
#--------------------------------------------------------------------------
# Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
new_name = $game_map.name.tr("/*","")
self.contents.draw_text(500, -5, 320, 32, new_name.to_s)
self.contents.draw_text(5, -5, 320, 32, "Location")
end
end
#----------------------------------------------------------------
# Menu Status 1(Displays stats for hero in slot 1)
#----------------------------------------------------------------
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_STATS1_SIZE
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 0
actor = $game_party.actors[0]
draw_actor_battler_graphic(actor, 55, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Menu Status 2(Displays stats for hero in slot 2)
#----------------------------------------------------------------
class Window_MenuStatus2 < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_STATS2_SIZE
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 1
actor = $game_party.actors[1]
draw_actor_battler_graphic(actor, 55, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Menu Status 3(Displays stats for hero in slot 3)
#----------------------------------------------------------------
class Window_MenuStatus3 < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_STATS3_SIZE
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 2
actor = $game_party.actors[2]
draw_actor_battler_graphic(actor, 60, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Item(Item window to not display items of synthesis)
#
# To make an item synthesis make a new attribute in the
# systems tab ID: 17 and select it to all synthesis items.
#----------------------------------------------------------------
class Window_Item < Window_Selectable
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_ITEM_SIZE
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def item
return @data[self.index]
end
def refresh(item_kind = 0)
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case item_kind
when 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
not $data_items[i].element_set.include?(17)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
not $data_weapons[i].element_set.include?(17)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
not $data_armors[i].guard_element_set.include?(17)
@data.push($data_armors[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.size = KHM_ITEM_SIZE
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#----------------------------------------------------------------
# Item2(Item window to display items of synthesis)
#
# To make an item synthesis make a new attribute in the
# systems tab ID: 17 and select it to all synthesis items.
#----------------------------------------------------------------
class Window_Item2 < Window_Selectable
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_ITEM2_SIZE
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def item
return @data[self.index]
end
def refresh(item_kind = 0)
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case item_kind
when 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
$data_items[i].element_set.include?(17)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
$data_weapons[i].element_set.include?(17)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
$data_armors[i].guard_element_set.include?(17)
@data.push($data_armors[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.size = KHM_ITEM2_SIZE
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#================================
# Scenes
#================================
#----------------------------------------------------------------
# Item 1(Used for regular items)
#----------------------------------------------------------------
class Scene_Item
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@item_window = Window_Item.new
# ヘルプウィンドウを関連付け
@item_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @item_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$game_switches[2] = false
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @item_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@item_window.refresh
end
# ターゲットウィンドウを消去
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#----------------------------------------------------------------
# Item 2(Used for Materials scene)
#----------------------------------------------------------------
class Scene_Item2
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@item_window = Window_Item2.new
# ヘルプウィンドウを関連付け
@item_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @item_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$game_switches[2] = false
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @item_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@item_window.refresh
end
# ターゲットウィンドウを消去
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#----------------------------------------------------------------
# Menu
#----------------------------------------------------------------
class Scene_Menu
#--------------------------------------------------------------------------
# ● Initialize the menus
# menu_index : The index of the initial selected item on the command menu
# (0 = the first item on the menu, with the number increasing
# by one for each command below the top command)
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● Set up the menu, processes the user's actions in the main loop,
# and then disposes of the objects
#--------------------------------------------------------------------------
def main
# Set up command window
if $game_switches[1] == true
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Materials"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.y = 56
@command_window.index = @menu_index
else
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Materials"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.y = 56
@command_window.index = @menu_index
end
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# Set up play mapname window
@map_window = Window_Mapname.new
@map_window.x = 0
@map_window.y = 0
# Set up extra window
@extra_window = Window_Extra.new
@extra_window.x = 160
@extra_window.y = 376
# Set up gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 312
# Set up status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 56
# Set up status window 2
@status_window2 = Window_MenuStatus2.new
@status_window2.x = 320
@status_window2.y = 56
# Set up status window 2
@status_window3 = Window_MenuStatus3.new
@status_window3.x = 480
@status_window3.y = 56
# Set up status
@window_status = Window_MenuStatus4.new
@window_status.x = 160
@window_status.y = 56
@window_status.opacity = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# Clean up
@command_window.dispose
@map_window.dispose
@gold_window.dispose
@status_window.dispose
@status_window2.dispose
@status_window3.dispose
@window_status.dispose
@extra_window.dispose
end
#--------------------------------------------------------------------------
# ● Update the contents of all five windows on the main menu
#--------------------------------------------------------------------------
def update
@command_window.update
@gold_window.update
@status_window.update
@map_window.update
@status_window2.update
@status_window3.update
@extra_window.update
@window_status.update
if @command_window.active
update_command
return
end
if @window_status.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● Update the command menu window in response to user input
#--------------------------------------------------------------------------
def update_command
# Cancel key is pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
# Decision key is pressed
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0 # Item selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # Skill selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 2 # Equipment selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 3 # Status selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 4 # Materials selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item2.new
end
return
end
end
#--------------------------------------------------------------------------
# ● Update the status of a menu opened through the main menu
#--------------------------------------------------------------------------
def update_status
# Cancel key pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@window_status.active = false
@window_status.index = -1
return
end
# Make a decision
if Input.trigger?(Input::C)
case @command_window.index
when 1 # Skill Window
if $game_party.actors[@window_status.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@window_status.index)
when 2 # Equipment Window
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@window_status.index)
when 3 # Staus Window
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@window_status.index)
end
return
end
end
end
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# The status of party members in the menu
#=============================================================================
#================================
# Config
#================================
#change these to increase ore decrease the size of the fonts
KHM_SIZE = 16
#end config
class Window_MenuStatus4 < Window_Selectable
#--------------------------------------------------------------------------
# ● Object initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = KHM_SIZE
@item_max = 3
@column_max = 3
@commands = [" ", " ", " "]
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
end
end
#--------------------------------------------------------------------------
# ● Rectangular cursor update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 160, -3, 130, 22)
end
end
end
#==============================================================================
# Kingdom Hearts Menu
# -Scripted by: Leon Blade-
# Edit bij jackolas (full credit go's to Leon Blade)
#------------------------------------------------------------------------------
# This menu was scripted by Leon Blade for FinalXemnas
# Created after Kingdom Hearts Menu
#==============================================================================
#================================
# Config
#================================
#change these to increase ore decrease the size of the fonts and to change the
# font type
# change these for the playtime window
KHM_PLAYTIME_SIZE = 16
KHM_PLAYTIME_FONT = 'Arial'
# change these for the gold window
KHM_GOLD_SIZE = 16
KHM_GOLD_FONT = 'Arial'
# change these for the map name window
KHM_MAPNAME_SIZE = 16
KHM_MAPNAME_FONT = 'Arial'
# change these for the Player window 1
KHM_STATS1_SIZE = 16
KHM_STATS1_FONT = 'Arial'
# change these for the Player window 2
KHM_STATS2_SIZE = 16
KHM_STATS2_FONT = 'Arial'
# change these for the player window 3
KHM_STATS3_SIZE = 16
KHM_STATS3_FONT = 'Arial'
# change these for the item window
KHM_ITEM_SIZE = 16
KHM_ITEM_FONT = 'Arial'
# change these for the material window
KHM_ITEM2_SIZE = 16
KHM_ITEM2FONT = 'Arial'
#================================
# END Config
#================================
#================================
# Windows
#================================
#----------------------------------------------------------------
# Window Base Add On(Used for displaying battlers)
#----------------------------------------------------------------
class Window_Base < Window
def draw_actor_battler_graphic(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
#----------------------------------------------------------------
# Extra Window(Contains Playtime and Step Counter)
#----------------------------------------------------------------
class Window_Extra < Window_Base
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 104)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_PLAYTIME_FONT
self.contents.font.size = KHM_PLAYTIME_SIZE
refresh
end
#--------------------------------------------------------------------------
# ● Displays
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "Play Time")
self.contents.draw_text(300, 0, 120, 32, "Number of Steps")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
self.contents.draw_text(300, 32, 120, 32, $game_party.steps.to_s, 2)
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#----------------------------------------------------------------
# Gold(Displays your curency and how much)
#----------------------------------------------------------------
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 168)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_GOLD_FONT
self.contents.font.size = KHM_GOLD_SIZE
refresh
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#----------------------------------------------------------------
# Map(Lets $map_infos = @map_id)
#----------------------------------------------------------------
class Game_Map
def name
$map_infos[@map_id]
end
end
#----------------------------------------------------------------
# Title(Checks your map in data files)
#----------------------------------------------------------------
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata ")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
#----------------------------------------------------------------
# Mapname(Displays current location)
#----------------------------------------------------------------
class Window_Mapname < Window_Base
#--------------------------------------------------------------------------
# Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 56)
self.contents = Bitmap.new(width - 52, height - 32)
self.contents.font.name = KHM_MAPNAME_FONT
self.contents.font.size = KHM_MAPNAME_SIZE
refresh
end
#--------------------------------------------------------------------------
# Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
new_name = $game_map.name.tr("/*","")
self.contents.draw_text(500, -5, 320, 32, new_name.to_s)
self.contents.draw_text(5, -5, 320, 32, "Location")
end
end
#----------------------------------------------------------------
# Menu Status 1(Displays stats for hero in slot 1)
#----------------------------------------------------------------
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_STATS1_FONT
self.contents.font.size = KHM_STATS1_SIZE
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 0
actor = $game_party.actors[0]
draw_actor_battler_graphic(actor, 55, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Menu Status 2(Displays stats for hero in slot 2)
#----------------------------------------------------------------
class Window_MenuStatus2 < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_STATS2_FONT
self.contents.font.size = KHM_STATS2_SIZE
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 1
actor = $game_party.actors[1]
draw_actor_battler_graphic(actor, 55, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Menu Status 3(Displays stats for hero in slot 3)
#----------------------------------------------------------------
class Window_MenuStatus3 < Window_Selectable
#--------------------------------------------------------------------------
# ● Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_STATS3_FONT
self.contents.font.size = KHM_STATS3_SIZE
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● Display
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max > 2
actor = $game_party.actors[2]
draw_actor_battler_graphic(actor, 60, 190)
draw_actor_name(actor, 40, -8)
draw_actor_level(actor, 0, 190)
draw_actor_hp(actor, 0, 212)
draw_actor_sp(actor, 0, 234)
draw_actor_state(actor, 0, 256)
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#----------------------------------------------------------------
# Item(Item window to not display items of synthesis)
#
# To make an item synthesis make a new attribute in the
# systems tab ID: 17 and select it to all synthesis items.
#----------------------------------------------------------------
class Window_Item < Window_Selectable
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_ITEM_FONT
self.contents.font.size = KHM_ITEM_SIZE
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def item
return @data[self.index]
end
def refresh(item_kind = 0)
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case item_kind
when 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
not $data_items[i].element_set.include?(17)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
not $data_weapons[i].element_set.include?(17)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
not $data_armors[i].guard_element_set.include?(17)
@data.push($data_armors[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.size = KHM_ITEM_SIZE
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#----------------------------------------------------------------
# Item2(Item window to display items of synthesis)
#
# To make an item synthesis make a new attribute in the
# systems tab ID: 17 and select it to all synthesis items.
#----------------------------------------------------------------
class Window_Item2 < Window_Selectable
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = KHM_ITEM2_FONT
self.contents.font.size = KHM_ITEM2_SIZE
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def item
return @data[self.index]
end
def refresh(item_kind = 0)
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
case item_kind
when 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
$data_items[i].element_set.include?(17)
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and
$data_weapons[i].element_set.include?(17)
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and
$data_armors[i].guard_element_set.include?(17)
@data.push($data_armors[i])
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
self.contents.font.name = KHM_ITEM2_SIZE
self.contents.font.size = KHM_ITEM2_SIZE
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#================================
# Scenes
#================================
#----------------------------------------------------------------
# Item 1(Used for regular items)
#----------------------------------------------------------------
class Scene_Item
#--------------------------------------------------------------------------
# ● ME process
#--------------------------------------------------------------------------
def main
# Help window, the window created items
@help_window = Window_Help.new
@item_window = Window_Item.new
# Associated with the Help window
@item_window.help_window = @help_window
# Create a target window (set to invisible, non-active)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Run transition
Graphics.transition
# Main loop
loop do
# Update the game screen
Graphics.update
# Updated input
Input.update
# Update frame
update
# Interrupt the loop ??? screen
if $scene != self
break
end
end
# Transition Preparation
Graphics.freeze
# Release the window
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● Update frame
#--------------------------------------------------------------------------
def update
# Windows update
@help_window.update
@item_window.update
@target_window.update
# If the window is active item: update_item Calling
if @item_window.active
update_item
return
end
# If the target window is active: update_target Calling
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● Update frame (if the item window is active)
#--------------------------------------------------------------------------
def update_item
# If the button B is pressed
if Input.trigger?(Input::B)
# SE Cancellation play
$game_system.se_play($data_system.cancel_se)
# Switch to the menu screen
$game_switches[2] = false
$scene = Scene_Menu.new(0)
return
end
# C If the button is pressed
if Input.trigger?(Input::C)
# Get the data that is currently selected item in the window
@item = @item_window.item
# Item is not in use
unless @item.is_a?(RPG::Item)
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
return
end
# If you can not use
unless $game_party.item_can_use?(@item.id)
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
return
end
# SE decided to play
$game_system.se_play($data_system.decision_se)
# If the range of side effects
if @item.scope >= 3
# Activate the target window
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Effective range (single / total) set the cursor position in response to
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# Otherwise, the range of side effects
else
# If a valid ID KOMONIBENTO
if @item.common_event_id > 0
# Book call KOMONIBENTO
$game_temp.common_event_id = @item.common_event_id
# Play when using an item SE
$game_system.se_play(@item.menu_se)
# For Supplies
if @item.consumable
# Items with a decrease
$game_party.lose_item(@item.id, 1)
# Item window redraw items
@item_window.draw_item(@item_window.index)
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● Update frame (if the target window is active)
#--------------------------------------------------------------------------
def update_target
# B If the button is pressed
if Input.trigger?(Input::B)
# SE Cancellation play
$game_system.se_play($data_system.cancel_se)
# Can not be used in items such as the Out of
unless $game_party.item_can_use?(@item.id)
# Re-create the contents of the item window
@item_window.refresh
end
# Clear the target window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C If the button is pressed
if Input.trigger?(Input::C)
# If the item gone
if $game_party.item_number(@item.id) == 0
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
return
end
# If the overall target
if @target_window.index == -1
# Effects of items used throughout the party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If the target is a stand-alone
if @target_window.index >= 0
# Effects of items used in the target actors
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# If you use an item
if used
# Play when using an item SE
$game_system.se_play(@item.menu_se)
# For Supplies
if @item.consumable
# Items with a decrease
$game_party.lose_item(@item.id, 1)
# Item window redraw items
@item_window.draw_item(@item_window.index)
end
# Re-create the contents of the target window
@target_window.refresh
# If the annihilation
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If a valid ID KOMONIBENTO
if @item.common_event_id > 0
# Book call KOMONIBENTO
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If lack of use of the item
unless used
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#----------------------------------------------------------------
# Item 2(Used for Materials scene)
#----------------------------------------------------------------
class Scene_Item2
#--------------------------------------------------------------------------
# ● ME process
#--------------------------------------------------------------------------
def main
# Help window, the window created items
@help_window = Window_Help.new
@item_window = Window_Item2.new
# Associated with the Help window
@item_window.help_window = @help_window
# Create a target window (set to invisible, non-active)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Run transition
Graphics.transition
# Main loop
loop do
# Update the game screen
Graphics.update
# Updated input
Input.update
# Update frame
update
# Interrupt the loop screen
if $scene != self
break
end
end
# Transition Preparation
Graphics.freeze
# Release the window
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● Update frame
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@target_window.update
# If item window is active: update_item calls
if @item_window.active
update_item
return
end
# If the target window is active: update_target calls
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● Update frame (if the item window is active)
#--------------------------------------------------------------------------
def update_item
# B If the button is pressed
if Input.trigger?(Input::B)
# SE Cancellation play
$game_system.se_play($data_system.cancel_se)
# Switch to the menu screen
$game_switches[2] = false
$scene = Scene_Menu.new(0)
return
end
# C If the button is pressed
if Input.trigger?(Input::C)
# Get the data that is currently selected item in the window
@item = @item_window.item
# Item is not in use
unless @item.is_a?(RPG::Item)
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
return
end
# If you can not use
unless $game_party.item_can_use?(@item.id)
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
return
end
# SE decided to play
$game_system.se_play($data_system.decision_se)
# If the range of side effects
if @item.scope >= 3
# Activate the target window
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Effective range (single / total) set the cursor position in response to
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# Otherwise, the range of side effects
else
# If a valid ID KOMONIBENTO
if @item.common_event_id > 0
# Book call KOMONIBENTO
$game_temp.common_event_id = @item.common_event_id
# Play when using an item SE
$game_system.se_play(@item.menu_se)
# For Supplies
if @item.consumable
# Items with a decrease
$game_party.lose_item(@item.id, 1)
# Item window redraw items
@item_window.draw_item(@item_window.index)
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● Update frame (if the target window is active)
#--------------------------------------------------------------------------
def update_target
# B If the button is pressed
if Input.trigger?(Input::B)
# SE Cancellation play
$game_system.se_play($data_system.cancel_se)
# Can not be used in items such as the Out of
unless $game_party.item_can_use?(@item.id)
# Re-create the contents of the item window
@item_window.refresh
end
# Clear the target window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C If the button is pressed
if Input.trigger?(Input::C)
# If the item gone
if $game_party.item_number(@item.id) == 0
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
return
end
# If the overall target
if @target_window.index == -1
# Effects of items used throughout the party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If the target is a stand-alone
if @target_window.index >= 0
# Effects of items used in the target actors
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# If you use an item
if used
# Play when using an item SE
$game_system.se_play(@item.menu_se)
# For Supplies
if @item.consumable
# Items with a decrease
$game_party.lose_item(@item.id, 1)
# Item window redraw items
@item_window.draw_item(@item_window.index)
end
# Re-create the contents of the target window
@target_window.refresh
# If the annihilation
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If a valid ID KOMONIBENTO
if @item.common_event_id > 0
# Book call KOMONIBENTO
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If lack of use of the item
unless used
# Buzzer SE play
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#----------------------------------------------------------------
# Menu
#----------------------------------------------------------------
class Scene_Menu
#--------------------------------------------------------------------------
# ● Initialize the menus
# menu_index : The index of the initial selected item on the command menu
# (0 = the first item on the menu, with the number increasing
# by one for each command below the top command)
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● Set up the menu, processes the user's actions in the main loop,
# and then disposes of the objects
#--------------------------------------------------------------------------
def main
# Set up command window
if $game_switches[1] == true
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Materials"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.y = 56
@command_window.index = @menu_index
else
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Materials"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.y = 56
@command_window.index = @menu_index
end
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# Set up play mapname window
@map_window = Window_Mapname.new
@map_window.x = 0
@map_window.y = 0
# Set up extra window
@extra_window = Window_Extra.new
@extra_window.x = 160
@extra_window.y = 376
# Set up gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 312
# Set up status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 56
# Set up status window 2
@status_window2 = Window_MenuStatus2.new
@status_window2.x = 320
@status_window2.y = 56
# Set up status window 2
@status_window3 = Window_MenuStatus3.new
@status_window3.x = 480
@status_window3.y = 56
# Set up status
@window_status = Window_MenuStatus4.new
@window_status.x = 160
@window_status.y = 56
@window_status.opacity = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# Clean up
@command_window.dispose
@map_window.dispose
@gold_window.dispose
@status_window.dispose
@status_window2.dispose
@status_window3.dispose
@window_status.dispose
@extra_window.dispose
end
#--------------------------------------------------------------------------
# ● Update the contents of all five windows on the main menu
#--------------------------------------------------------------------------
def update
@command_window.update
@gold_window.update
@status_window.update
@map_window.update
@status_window2.update
@status_window3.update
@extra_window.update
@window_status.update
if @command_window.active
update_command
return
end
if @window_status.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● Update the command menu window in response to user input
#--------------------------------------------------------------------------
def update_command
# Cancel key is pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
# Decision key is pressed
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0 # Item selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # Skill selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 2 # Equipment selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 3 # Status selected
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@window_status.active = true
@window_status.index = 0
when 4 # Materials selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item2.new
end
return
end
end
#--------------------------------------------------------------------------
# ● Update the status of a menu opened through the main menu
#--------------------------------------------------------------------------
def update_status
# Cancel key pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@window_status.active = false
@window_status.index = -1
return
end
# Make a decision
if Input.trigger?(Input::C)
case @command_window.index
when 1 # Skill Window
if $game_party.actors[@window_status.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@window_status.index)
when 2 # Equipment Window
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@window_status.index)
when 3 # Staus Window
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@window_status.index)
end
return
end
end
end
Quote from: WhiteDemon15 on March 07, 2009, 11:46:46 am
OH MY ZEUS! :o YOU'RE AWESOME! :haha: You WILL be credited greatly for fixing this!
Quote from: WcW on March 07, 2009, 07:28:30 pm
I can make this more actually KH like if you want. (As in, it shows the map behind it and doesn't use windows)
@spriteset = Spriteset_Map.new
Quote from: WcW on March 07, 2009, 07:28:30 pm
I can make this more actually KH like if you want. (As in, it shows the map behind it and doesn't use windows)