$data_states ||= load_data("Data/States.rvdata2")
$data_system ||= load_data("Data/System.rvdata2")
#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================
module KMS
module EnemyGuide
# ◆ 図鑑に背景画像を使用する
# true : 背景画像をウィンドウ代わりに使用。
# false : 通常のウィンドウを使用。
USE_BACKGROUND_IMAGE = false
# ◆ 背景画像ファイル名
# "Graphics/System/" から読み込む。
BACKGROUND_FILENAME = "EnemyGuideBack"
# ◆ 完成度表示のインターバル [フレーム]
INFO_INTERVAL = 180
# ◆ 名前の前に通し番号を表示
# true : 001: スライム
# false : スライム
SHOW_SERIAL_NUMBER = false
# ◆ 通し番号をリストの並び順にする
# true : ID を無視して表示順の番号を付ける。
# false : 通し番号として ID を使用。
SERIAL_NUM_FOLLOW = true
# ◆ 通し番号の書式
# ヘルプの sprintf フォーマットを参照。
SERIAL_NUM_FORMAT = "%03d: "
# ◆ 未遭遇の敵の名前
# 1文字だけ指定すると、敵の名前と同じ文字数に拡張されます。
UNKNOWN_ENEMY_NAME = "?"
# ◆ 未遭遇の敵のデータ表示
UNENCOUNTERED_DATA = "- 无数据 -"
# ◆ 図鑑のパラメータ名
PARAMETER_NAME = {
:defeat_count => "击败数",
:weak_element => "弱点属性",
:resist_element => "耐性属性",
:weak_state => "弱点异常",
:resist_state => "无效异常",
:exp => "经验值",
:treasure => "道具",
:drop_prob => "掉落率",
} # ← これは消さないこと!
# ◆ 未撃破の敵のパラメータ表示
UNDEFEATED_PARAMETER = "???"
# ◆ 未ドロップのアイテム名
# 1文字だけ指定すると、アイテム名と同じ文字数に拡張されます。
UNDROPPED_ITEM_NAME = "?"
# ◆ 属性耐性を調べる範囲
# 耐性を調べる属性の ID を配列に格納。
# .. や ... を使用した範囲指定も可能。
ELEMENT_RANGE = [3, 4, 5, 6, 7, 8, 9,10,11]#$data_system.elements.size]
# ◆ 属性のアイコン
# 各属性に対応するアイコンの番号を指定。
# 配列の添字が属性 ID に対応。
ELEMENT_ICON = [nil, # ID:0 はダミー
nil, nil, 96, 97, 98, 99, 100, 101, 102, 103, 104, # ID: 3 ~ 11
nil, nil, nil, 105, 129, # ID: 12 ~ 16
] # ← これは消さないこと!
# ◆ ステート耐性を調べる範囲
# 耐性を調べるステートの ID を配列に格納。
# 記述方法は ELEMENT_RANGE と同様。
STATE_RANGE = [32,34,37,42,114...129]
# ◆ 弱点属性の行数
ELEMENT_ROWS_WEAK = 2
# ◆ 耐性属性の行数
ELEMENT_ROWS_RESIST = 2
# ◆ 弱点ステートの行数
STATE_ROWS_WEAK = 1
# ◆ 無効ステートの行数
STATE_ROWS_RESIST = 2
# ◆ ドロップアイテムを表示
# true : 表示する
# false : 表示しない
SHOW_DROP_ITEM = true
# ◆ 図鑑から隠す敵
# 図鑑から隠したい敵の ID を配列に格納。
# ID と範囲 (1..10 など) のどちらでも可。
# <例> HIDDEN_ENEMIES = [2, 4, 8, 16..32]
HIDDEN_ENEMIES = [1,81,84,97,121,66,67,41,17,75,131,132,109..111]
# ◆ 敵の並び順
# 表示する敵の ID を、表示したい順に配列に格納。
# .. や ... を使用した範囲指定も可能。
# 指定しなかった敵、または HIDDEN_ENEMIES に指定した敵は表示しない。
# (この機能を使用しない場合は nil)
ENEMY_ORDER = nil
# ENEMY_ORDER = [1..5, 8..13, 6, 7, 14, 15]
# ↑使用例
# ◆ 変身前の敵も撃破
# true : 変身前の敵も撃破したと見なす。
# false : 変身前の敵は未撃破 (遭遇のみ) と見なす。
ORIGINAL_DEFEAT = true
# ◆ メニュー画面に「モンスター図鑑」コマンドを追加する
# 追加する場所は「セーブ」の上 (独自コマンド部分) です。
USE_MENU_ENEMY_GUIDE_COMMAND = false
# ◆ メニュー画面の「モンスター図鑑」コマンドの名称
VOCAB_MENU_ENEMY_GUIDE = "怪物图鉴"
# ◆ VX 互換モード
# true : ウィンドウの配置が VX 互換になる。背景画像を流用できる
# false : VXAce 仕様のレイアウトになる。VX の背景画像を使用するとズレる
VX_COMPATIBLE = false
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$kms_imported ||= {}
$kms_imported["EnemyGuide"] = true
module KMS
module_function
#--------------------------------------------------------------------------
# ○ 文字列をマスク
# str : マスク対象の文字列
# mask : マスク文字列
#--------------------------------------------------------------------------
def mask_string(str, mask)
text = mask
if mask.scan(/./).size == 1
text = mask * str.scan(/./).size
end
return text
end
end
module KMS::EnemyGuide
# ◆ 盗めるものを表示 (一時退避)
# ≪盗む≫ 導入時のみ。
SHOW_STEAL_OBJ = false
# ◆ 図鑑のパラメータ名 (一時退避)
PARAMETER_NAME[:steal_obj] = "盗めるもの"
PARAMETER_NAME[:steal_prob] = "成功率"
module Regexp
module Enemy
# 図鑑説明開始
BEGIN_GUIDE_DESCRIPTION = /<(?:GUIDE_DESCRIPTION|図鑑説明)>/i
# 図鑑説明終了
END_GUIDE_DESCRIPTION = /<\/(?:GUIDE_DESCRIPTION|図鑑説明)>/i
end
end
#--------------------------------------------------------------------------
# ○ Range と Integer の配列を Integer の配列に変換 (重複要素は排除)
#--------------------------------------------------------------------------
def self.convert_integer_array(array, type = nil)
result = array.inject([]) do |ret, i|
case i
when Range; ret | i.to_a
when Integer; ret | [i]
else; ret
end
end
case type
when :element
result.delete_if { |x| x >= $data_system.elements.size }
when :state
result.delete_if do |x|
x >= $data_states.size ||
$data_states[x].priority == 0
end
end
result
end
#--------------------------------------------------------------------------
# ○ 敵を表示するか
#--------------------------------------------------------------------------
def self.enemy_show?(enemy_id)
if HIDDEN_ENEMY_LIST.include?(enemy_id)
false
elsif ENEMY_ORDER_ID != nil
false unless ENEMY_ORDER_ID.include?(enemy_id)
else
true
end
end
# 非表示モンスターリスト
HIDDEN_ENEMY_LIST = convert_integer_array(HIDDEN_ENEMIES)
# 表示順の敵 ID
ENEMY_ORDER_ID = (ENEMY_ORDER == nil ? nil :
convert_integer_array(ENEMY_ORDER))
# チェックする属性リスト
CHECK_ELEMENT_LIST = convert_integer_array(ELEMENT_RANGE, :element)
# チェックするステートリスト
CHECK_STATE_LIST = convert_integer_array(STATE_RANGE, :state)
# VX 互換ウィンドウのパディング
VX_WINDOW_PADDING = 16
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ KMS::Commands
#==============================================================================
module KMS
module Commands
module_function
#--------------------------------------------------------------------------
# ○ 遭遇状態取得
# enemy_id : 敵 ID
#--------------------------------------------------------------------------
def enemy_encountered?(enemy_id)
$game_system.enemy_encountered[enemy_id]
end
#--------------------------------------------------------------------------
# ○ 撃破状態取得
# enemy_id : 敵 ID
#--------------------------------------------------------------------------
def enemy_defeated?(enemy_id)
$game_system.enemy_defeated[enemy_id]
end
#--------------------------------------------------------------------------
# ○ アイテムドロップ状態取得
# enemy_id : 敵 ID
# item_index : ドロップアイテム番号
#--------------------------------------------------------------------------
def enemy_item_dropped?(enemy_id, item_index)
return false if $game_system.enemy_item_dropped[enemy_id] == nil
result = $game_system.enemy_item_dropped[enemy_id] & (1 << item_index)
result != 0
end
#--------------------------------------------------------------------------
# ○ 盗み成功済み状態取得
# enemy_id : 敵 ID
# obj_index : オブジェクト番号
#--------------------------------------------------------------------------
def enemy_object_stolen?(enemy_id, obj_index)
return false if $game_system.enemy_object_stolen[enemy_id] == nil
result = $game_system.enemy_object_stolen[enemy_id] & (1 << obj_index)
result != 0
end
#--------------------------------------------------------------------------
# ○ 遭遇状態設定
# enemy_id : 敵 ID
# enabled : true..遭遇済み false..未遭遇
#--------------------------------------------------------------------------
def set_enemy_encountered(enemy_id, enabled = true)
$game_system.enemy_encountered[enemy_id] = enabled
p enabled
unless enabled
# 未遭遇なら撃破済みフラグも解除
set_enemy_defeated(enemy_id)
#set_enemy_defeated(enemy_id, false)
end
end
#--------------------------------------------------------------------------
# ○ 撃破状態設定
# enemy_id : 敵 ID
# enabled : true..撃破済み false..未撃破
#--------------------------------------------------------------------------
def set_enemy_defeated(enemy_id, enabled = true)
$game_system.enemy_defeated[enemy_id] = enabled
if enabled
# 撃破済みなら遭遇フラグもセット
set_enemy_encountered(enemy_id)
end
end
#--------------------------------------------------------------------------
# ○ アイテムドロップ状態設定
# enemy_id : 敵 ID
# item_index : ドロップアイテム番号
# enabled : true..ドロップ済み false..未ドロップ
#--------------------------------------------------------------------------
def set_enemy_item_dropped(enemy_id, item_index, enabled = true)
$game_system.enemy_item_dropped[enemy_id] ||= 0
if enabled
$game_system.enemy_item_dropped[enemy_id] |= (1 << item_index)
else
$game_system.enemy_item_dropped[enemy_id] &= ~(1 << item_index)
end
end
#--------------------------------------------------------------------------
# ○ 盗み成功状態設定
# enemy_id : 敵 ID
# obj_index : オブジェクト番号
# enabled : true..成功済み false..未成功
#--------------------------------------------------------------------------
def set_enemy_object_stolen(enemy_id, obj_index, enabled = true)
$game_system.enemy_object_stolen[enemy_id] ||= 0
if enabled
$game_system.enemy_object_stolen[enemy_id] |= (1 << obj_index)
else
$game_system.enemy_object_stolen[enemy_id] &= ~(1 << obj_index)
end
end
#--------------------------------------------------------------------------
# ○ 図鑑リセット
#--------------------------------------------------------------------------
def reset_enemy_guide
$game_system.enemy_encountered = []
$game_system.enemy_defeated = []
$game_system.enemy_item_dropped = []
$game_system.enemy_object_stolen = []
end
#--------------------------------------------------------------------------
# ○ 図鑑完成
#--------------------------------------------------------------------------
def complete_enemy_guide
(1...$data_enemies.size).each do |i|
set_enemy_encountered(i)
set_enemy_defeated(i)
enemy = $data_enemies[i]
items = enemy.drop_items.dup
if $kms_imported["ExtraDropItem"]
items += enemy.extra_drop_items
end
items.each_index { |j| set_enemy_item_dropped(i, j) }
if $kms_imported["Steal"]
objs = enemy.steal_objects
objs.each_index { |j| set_enemy_object_stolen(i, j) }
end
end
end
#--------------------------------------------------------------------------
# ○ 図鑑に含めるか
# enemy_id : 敵 ID
#--------------------------------------------------------------------------
def enemy_guide_include?(enemy_id)
return false unless KMS::EnemyGuide.enemy_show?(enemy_id)
enemy = $data_enemies[enemy_id]
enemy != nil && enemy.name != ""
end
#--------------------------------------------------------------------------
# ○ 存在する敵の種類数取得
# variable_id : 取得した値を代入する変数の ID
#--------------------------------------------------------------------------
def get_all_enemies_number(variable_id = 0)
total = (1...$data_enemies.size).inject(0) do |n, i|
enemy_guide_include?(i) ? n + 1 : n
end
if variable_id > 0
$game_variables[variable_id] = total
$game_map.need_refresh = true
end
total
end
#--------------------------------------------------------------------------
# ○ 遭遇した敵の種類数取得
# variable_id : 取得した値を代入する変数の ID
#--------------------------------------------------------------------------
def get_encountered_enemies_number(variable_id = 0)
total = (1...$data_enemies.size).inject(0) do |n, i|
enemy_guide_include?(i) && $game_system.enemy_encountered[i] ? n + 1 : n
end
if variable_id > 0
$game_variables[variable_id] = total
$game_map.need_refresh = true
end
total
end
#--------------------------------------------------------------------------
# ○ 撃破した敵の種類数取得
# variable_id : 取得した値を代入する変数の ID
#--------------------------------------------------------------------------
def get_defeated_enemies_number(variable_id = 0)
total = (1...$data_enemies.size).inject(0) do |n, i|
if enemy_guide_include?(i) &&
$game_system.enemy_encountered[i] &&
$game_system.enemy_defeated[i]
n + 1
else
n
end
end
if variable_id > 0
$game_variables[variable_id] = total
$game_map.need_refresh = true
end
total
end
#--------------------------------------------------------------------------
# ○ モンスター図鑑完成度の取得
# variable_id : 取得した値を代入する変数の ID
#--------------------------------------------------------------------------
def get_enemy_guide_completion(variable_id = 0)
num = get_all_enemies_number
value = (num > 0 ? (get_defeated_enemies_number * 100 / num) : 0)
#value = (num > 0 ? (get_encountered_enemies_number * 100 / num) : 0)
if variable_id > 0
$game_variables[variable_id] = value
$game_map.need_refresh = true
end
value
end
end # module Commands
end # module KMS
class Game_Interpreter
include KMS::Commands
#--------------------------------------------------------------------------
# ○ モンスター図鑑呼び出し
#--------------------------------------------------------------------------
def call_enemy_guide
command_call_enemy_guide
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Vocab
#==============================================================================
module Vocab
# モンスター図鑑
def self.enemy_guide
KMS::EnemyGuide::VOCAB_MENU_ENEMY_GUIDE
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::Enemy
#==============================================================================
class RPG::Enemy
#--------------------------------------------------------------------------
# ○ モンスター図鑑のキャッシュ生成
#--------------------------------------------------------------------------
def create_enemy_guide_cache
@__enemy_guide_description = ""
description_flag = false
self.note.each_line do |line|
case line
when KMS::EnemyGuide::Regexp::Enemy::BEGIN_GUIDE_DESCRIPTION
# 説明文開始
description_flag = true
when KMS::EnemyGuide::Regexp::Enemy::END_GUIDE_DESCRIPTION
# 説明文終了
description_flag = false
else
if description_flag
@__enemy_guide_description += line
end
end
end
end
#--------------------------------------------------------------------------
# ○ 図鑑説明文
#--------------------------------------------------------------------------
def enemy_guide_description
create_enemy_guide_cache if @__enemy_guide_description == nil
@__enemy_guide_description
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_writer :enemy_encountered # 遭遇済みフラグ
attr_writer :enemy_defeated # 撃破済みフラグ
attr_writer :enemy_item_dropped # アイテムドロップ済みフラグ
attr_writer :enemy_object_stolen # 盗み成功済みフラグ
#--------------------------------------------------------------------------
# ○ 遭遇済みフラグ取得
#--------------------------------------------------------------------------
def enemy_encountered
@enemy_encountered ||= []
end
#--------------------------------------------------------------------------
# ○ 撃破済みフラグ取得
#--------------------------------------------------------------------------
def enemy_defeated
@enemy_defeated ||= []
end
#--------------------------------------------------------------------------
# ○ アイテムドロップ済みフラグ取得
#--------------------------------------------------------------------------
def enemy_item_dropped
@enemy_item_dropped ||= []
end
#--------------------------------------------------------------------------
# ○ 盗み成功済みフラグ取得
#--------------------------------------------------------------------------
def enemy_object_stolen
@enemy_object_stolen ||= []
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# index : 敵グループ内インデックス
# enemy_id : 敵キャラ ID
#--------------------------------------------------------------------------
alias initialize_KMS_EnemyGuide initialize
def initialize(index, enemy_id)
initialize_KMS_EnemyGuide(index, enemy_id)
@original_ids = [] # 変身前の ID
end
#--------------------------------------------------------------------------
# ● コラプスの実行
#--------------------------------------------------------------------------
alias perform_collapse_effect_KMS_EnemyGuide perform_collapse_effect
def perform_collapse_effect
perform_collapse_effect_KMS_EnemyGuide
# 撃破済みフラグをオン
KMS::Commands.set_enemy_defeated(enemy_id)
# 変身前の敵も撃破済みにする
if KMS::EnemyGuide::ORIGINAL_DEFEAT
@original_ids.compact.each do |i|
KMS::Commands.set_enemy_defeated(i)
end
end
end
#--------------------------------------------------------------------------
# ● 変身
# enemy_id : 変身先の敵キャラ ID
#--------------------------------------------------------------------------
alias transform_KMS_EnemyGuide transform
def transform(enemy_id)
# 変身前のIDを保存
@original_ids << @enemy_id
transform_KMS_EnemyGuide(enemy_id)
# 変身後の敵も遭遇済みにする
KMS::Commands.set_enemy_encountered(enemy_id)
end
#--------------------------------------------------------------------------
# ● 現れる
#--------------------------------------------------------------------------
def appear
# 遭遇済みフラグをオン
KMS::Commands.set_enemy_encountered(enemy_id)
super
end
#--------------------------------------------------------------------------
# ● ドロップアイテムの配列作成 ※ 上書き
#--------------------------------------------------------------------------
def make_drop_items
enemy.drop_items.inject([]) do |r, di|
if di.kind > 0 && rand * di.denominator < drop_item_rate
# ドロップ済みフラグをセット
KMS::Commands.set_enemy_item_dropped(enemy_id, enemy.drop_items.index(di))
r.push(item_object(di.kind, di.data_id))
else
r
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
alias setup_KMS_EnemyGuide setup
def setup(troop_id)
setup_KMS_EnemyGuide(troop_id)
# メンバーのうち、出現済みなら遭遇フラグを立てる
members.each do |enemy|
KMS::Commands.set_enemy_encountered(enemy.enemy_id) unless enemy.hidden?
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ○ モンスター図鑑を開く
#--------------------------------------------------------------------------
def command_call_enemy_guide
return if $game_party.in_battle
SceneManager.call(Scene_EnemyGuide)
Fiber.yield
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_MenuCommand
#==============================================================================
if KMS::EnemyGuide::USE_MENU_ENEMY_GUIDE_COMMAND
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# ● 独自コマンドの追加用
#--------------------------------------------------------------------------
alias add_original_commands_KMS_EnemyGuide add_original_commands
def add_original_commands
add_original_commands_KMS_EnemyGuide
add_command(Vocab::enemy_guide, :enemy_guide)
end
end
end # if KMS::EnemyGuide::USE_MENU_ENEMY_GUIDE_COMMAND
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_EnemyGuideTop
#------------------------------------------------------------------------------
# モンスター図鑑画面で、完成度を表示するウィンドウです。
#==============================================================================
class Window_EnemyGuideTop < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, window_height)
@duration = 0
@interval = KMS::EnemyGuide::INFO_INTERVAL
refresh
if KMS::EnemyGuide::USE_BACKGROUND_IMAGE
self.opacity = 0
end
# ウィンドウスキンのスクロールマーカーを削除
if windowskin != nil
bitmap = Bitmap.new(windowskin.width, windowskin.height)
bitmap.blt(0, 0, windowskin, windowskin.rect)
bitmap.clear_rect(80, 16, 32, 32)
self.windowskin = bitmap
end
end
#--------------------------------------------------------------------------
# ● 破棄
#--------------------------------------------------------------------------
def dispose
self.windowskin.dispose if windowskin
super
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
240
end
#--------------------------------------------------------------------------
# ● ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
fitting_height(1)
end
#--------------------------------------------------------------------------
# ● 標準パディングサイズの取得
#--------------------------------------------------------------------------
def standard_padding
KMS::EnemyGuide::VX_WINDOW_PADDING
end if KMS::EnemyGuide::VX_COMPATIBLE
#--------------------------------------------------------------------------
# ● ウィンドウ内容の高さを計算
#--------------------------------------------------------------------------
def contents_height
line_height * 4
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
total = KMS::Commands.get_all_enemies_number
encountered = KMS::Commands.get_encountered_enemies_number
defeated = KMS::Commands.get_defeated_enemies_number
text = sprintf("已遭遇: %3d/%3d ",encountered, total)
draw_text(0, line_height * 0, contents_width, line_height, text, 1)
draw_text(0, line_height * 3, contents_width, line_height, text, 1)
text = sprintf("已击破: %3d/%3d", defeated, total)
draw_text(0, line_height * 1, contents_width, line_height, text, 1)
text = sprintf("完成度: %3d%%", defeated * 100 / total)
draw_text(0, line_height * 2, contents_width, line_height, text, 1)
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
update_animation
end
#--------------------------------------------------------------------------
# ○ アニメーション更新
#--------------------------------------------------------------------------
def update_animation
@duration += 1
case @duration
when @interval...(@interval + line_height)
self.oy += 1
when (@interval + line_height)
@duration = 0
if self.oy >= line_height * 3
self.oy = 0
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_EnemyGuideList
#------------------------------------------------------------------------------
# モンスター図鑑画面で、モンスター一覧を表示するウィンドウです。
#==============================================================================
class Window_EnemyGuideList < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@data = []
super(0, line_height + standard_padding * 2, window_width, window_height)
self.index = 0
refresh
if KMS::EnemyGuide::USE_BACKGROUND_IMAGE
self.opacity = 0
self.height -= (self.height - 32) % line_height
end
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
240
end
#--------------------------------------------------------------------------
# ● ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
Graphics.height - (line_height + standard_padding * 2)
end
#--------------------------------------------------------------------------
# ● 標準パディングサイズの取得
#--------------------------------------------------------------------------
def standard_padding
KMS::EnemyGuide::VX_WINDOW_PADDING
end if KMS::EnemyGuide::VX_COMPATIBLE
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@data.size
end
#--------------------------------------------------------------------------
# ○ 選択モンスターの取得
#--------------------------------------------------------------------------
def item
@data[self.index]
end
#--------------------------------------------------------------------------
# ○ エネミーをリストに含めるか
# enemy_id : 敵 ID
#--------------------------------------------------------------------------
def include?(enemy_id)
KMS::Commands.enemy_guide_include?(enemy_id)
end
#--------------------------------------------------------------------------
# ○ エネミーリストの作成
#--------------------------------------------------------------------------
def make_enemy_list
@data.clear
if KMS::EnemyGuide::ENEMY_ORDER_ID == nil
# ID順
enemy_list = 1...$data_enemies.size
else
# 指定順
enemy_list = KMS::EnemyGuide::ENEMY_ORDER_ID
end
enemy_list.each do |i|
@data << $data_enemies[i] if include?(i)
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
make_enemy_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
enemy = @data[index]
return if enemy == nil
#change_color(normal_color, KMS::Commands.enemy_defeated?(enemy.id))
change_color(normal_color, KMS::Commands.enemy_encountered?(enemy.id))
rect = item_rect_for_text(index)
contents.clear_rect(rect)
if KMS::EnemyGuide::SHOW_SERIAL_NUMBER
text = sprintf(KMS::EnemyGuide::SERIAL_NUM_FORMAT,
KMS::EnemyGuide::SERIAL_NUM_FOLLOW ? (index + 1) : enemy.id)
else
text = ""
end
if KMS::Commands.enemy_encountered?(enemy.id)
# 遭遇済み
text += enemy.name
else
# 未遭遇
mask = KMS::EnemyGuide::UNKNOWN_ENEMY_NAME
if mask.scan(/./).size == 1
mask = mask * enemy.name.scan(/./).size
end
text += mask
end
draw_text(rect, text)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_EnemyGuideStatus
#------------------------------------------------------------------------------
# モンスター図鑑画面で、ステータスを表示するウィンドウです。
#==============================================================================
class Window_EnemyGuideStatus < Window_Base
#--------------------------------------------------------------------------
# ○ 定数
#--------------------------------------------------------------------------
PARAM2_COUNT = 6 # 第2パラメータの数
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :enemy # 表示エネミー
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(240, 0, window_width, window_height)
self.enemy = nil
self.z = 100
if KMS::EnemyGuide::USE_BACKGROUND_IMAGE
self.opacity = 0
end
@show_sprite = false
@enemy_sprite = Sprite.new
@enemy_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@enemy_sprite.x = 0
@enemy_sprite.y = 0
@enemy_sprite.z = self.z + 100
@enemy_sprite.visible = false
@enemy_object = nil
end
#--------------------------------------------------------------------------
# ● 破棄
#--------------------------------------------------------------------------
def dispose
@enemy_sprite.bitmap.dispose
@enemy_sprite.dispose
super
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
Graphics.width - 240
end
#--------------------------------------------------------------------------
# ● ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
Graphics.height
end
#--------------------------------------------------------------------------
# ● 標準パディングサイズの取得
#--------------------------------------------------------------------------
def standard_padding
KMS::EnemyGuide::VX_WINDOW_PADDING
end if KMS::EnemyGuide::VX_COMPATIBLE
#--------------------------------------------------------------------------
# ● ウィンドウ内容の幅を計算
#--------------------------------------------------------------------------
def contents_width
page_width * pages
end
#--------------------------------------------------------------------------
# ○ ページ幅
#--------------------------------------------------------------------------
def page_width
return window_width - standard_padding * 2
end
#--------------------------------------------------------------------------
# ○ アイテム用ページを表示するか
#--------------------------------------------------------------------------
def item_page_show?
return true if KMS::EnemyGuide::SHOW_DROP_ITEM
return true if $kms_imported["Steal"] && KMS::EnemyGuide::SHOW_STEAL_OBJ
false
end
#--------------------------------------------------------------------------
# ○ ページ数取得
#--------------------------------------------------------------------------
def pages
item_page_show? ? 3 : 2
end
#--------------------------------------------------------------------------
# ○ 表示エネミー設定
#--------------------------------------------------------------------------
def enemy=(enemy)
@enemy = enemy
if enemy
@enemy_object = Game_Enemy.new(0, enemy.id)
else
@enemy_object = nil
end
refresh
end
#--------------------------------------------------------------------------
# ○ 表示情報切り替え
# amount : 移動ページ数
#--------------------------------------------------------------------------
def shift_info_type(amount)
n = self.ox + page_width * amount
self.ox = [[n, 0].max, page_width * (pages - 1)].min
end
#--------------------------------------------------------------------------
# ○ スプライト表示切替
#--------------------------------------------------------------------------
def switch_sprite
@show_sprite = !@show_sprite
@enemy_sprite.visible = @show_sprite
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_enemy_sprite
return if enemy == nil
# 遭遇していない
unless KMS::Commands.enemy_encountered?(enemy.id)
change_color(normal_color, false)
dy = contents_height / 2
dy -= dy % line_height
pages.times do |i|
dx = i * page_width
draw_text(dx, dy, page_width, line_height,
KMS::EnemyGuide::UNENCOUNTERED_DATA, 1)
end
return
end
change_color(normal_color)
draw_status
end
#--------------------------------------------------------------------------
# ○ ステータス描画
#--------------------------------------------------------------------------
def draw_status
# Page 1
dy = draw_basic_info( 4, 0)
dy = draw_parameter2( 4, dy)
dy = draw_weak_element( 4, dy, KMS::EnemyGuide::ELEMENT_ROWS_WEAK)
dy = draw_resist_element(4, dy, KMS::EnemyGuide::ELEMENT_ROWS_RESIST)
dy = draw_weak_state( 4, dy, KMS::EnemyGuide::STATE_ROWS_WEAK)
dy = draw_resist_state( 4, dy, KMS::EnemyGuide::STATE_ROWS_RESIST)
draw_prize(4, dy)
# Page 2 (アイテム関連を表示する場合のみ)
if item_page_show?
dx = page_width + 4
dy = draw_basic_info(dx, 0)
max_rows = (contents_height - dy) / line_height
rows = (max_rows + 1) / (pages - 1)
dy = draw_drop_item(dx, dy, rows)
draw_steal_object(dx, dy, max_rows - rows)
end
# Page 3
dx = page_width * (pages - 1) + 4
dy = draw_basic_info(dx, 0)
draw_description(dx, dy)
end
#--------------------------------------------------------------------------
# ○ 基本情報画
# dx, dy : 描画先 X, Y
#--------------------------------------------------------------------------
def draw_basic_info(dx, dy)
draw_graphic(dx, dy)
draw_parameter1(dx + 112, dy)
return dy + 96
end
#--------------------------------------------------------------------------
# ○ グラフィック描画
# dx, dy : 描画先 X, Y
#--------------------------------------------------------------------------
def draw_graphic(dx, dy)
return if enemy == nil || !KMS::Commands.enemy_encountered?(enemy.id)
buf = Bitmap.new(108, 96)
bitmap = Cache.battler(enemy.battler_name, enemy.battler_hue)
rect = Rect.new(0, 0, bitmap.width / 3, bitmap.height / 3)
rect.x = (108 - rect.width) / 2
rect.y = ( 96 - rect.height) / 2
buf.stretch_blt(rect, bitmap, bitmap.rect)
contents.blt(dx, dy, buf, buf.rect)
buf.dispose
end
#--------------------------------------------------------------------------
# ○ エネミースプライト描画
#--------------------------------------------------------------------------
def draw_enemy_sprite
return if @enemy_sprite == nil
@enemy_sprite.bitmap.fill_rect(@enemy_sprite.bitmap.rect,
Color.new(255, 255, 255, 150))
return if enemy == nil || !KMS::Commands.enemy_encountered?(enemy.id)
bitmap = Cache.battler(enemy.battler_name, enemy.battler_hue)
dx = (Graphics.width - bitmap.width) / 2
dy = (Graphics.height - bitmap.height) / 2
@enemy_sprite.bitmap.blt(dx, dy, bitmap, bitmap.rect)
end
#--------------------------------------------------------------------------
# ○ パラメータ描画 - 1
# dx, dy : 描画先 X, Y
#--------------------------------------------------------------------------
def draw_parameter1(dx, dy)
# 名前, HP, MP
param = {}
#if KMS::Commands.enemy_defeated?(enemy.id)
if KMS::Commands.enemy_encountered?(enemy.id)
param[:maxhp] = enemy.params[0]
param[:maxmp] = enemy.params[1]
if $kms_imported["BattleCount"]
param[:defeat_count] = KMS::Commands.get_defeat_count(enemy.id)
end
else
param[:maxhp] = param[:maxmp] = KMS::EnemyGuide::UNDEFEATED_PARAMETER
param[:defeat_count] = 0
end
change_color(normal_color)
draw_text(dx, dy, width - 144, line_height, enemy.name)
change_color(system_color)
draw_text(dx, dy + line_height, 80, line_height, Vocab.hp)
draw_text(dx, dy + line_height * 2, 80, line_height, Vocab.mp)
if $kms_imported["BattleCount"]
draw_text(dx, dy + line_height * 3, 80, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:defeat_count])
end
change_color(normal_color)
draw_text(dx + 88, dy + line_height, 64, line_height, param[:maxhp], 2)
draw_text(dx + 88, dy + line_height * 2, 64, line_height, param[:maxmp], 2)
if $kms_imported["BattleCount"]
draw_text(dx + 88, dy + line_height * 3, 64, line_height,
param[:defeat_count], 2)
end
end
#--------------------------------------------------------------------------
# ○ パラメータ描画 - 2
# dx, dy : 描画先 X, Y
#--------------------------------------------------------------------------
def draw_parameter2(dx, dy)
# ATK ~ LUK
param = {}
#if KMS::Commands.enemy_defeated?(enemy.id)
if KMS::Commands.enemy_encountered?(enemy.id)
param = enemy.params
else
param = Array.new(PARAM2_COUNT) { KMS::EnemyGuide::UNDEFEATED_PARAMETER }
end
dw = page_width / 2
PARAM2_COUNT.times do |i|
dx2 = dx + (i % 2) * dw
dy2 = dy + (i / 2) * line_height
change_color(system_color)
draw_text(dx2, dy2, 80, line_height, Vocab.param(i + 2))
change_color(normal_color)
draw_text(dx2 + 80, dy2, 48, line_height, param[i + 2], 2)
end
dy + (PARAM2_COUNT + 1) / 2 * line_height
end
#--------------------------------------------------------------------------
# ○ アイコンリスト描画
# dx, dy : 描画先 X, Y
# rows, cols : アイコン行/列数
# item_list : 描画対象のリスト
# cond_proc : 描画条件 Proc
# index_proc : アイコン index 取得用 Proc
# enable_proc : 有効判定用 Proc
#--------------------------------------------------------------------------
def draw_icon_list(dx, dy, rows, cols, item_list,
cond_proc, index_proc, enable_proc = nil)
nc = 0 # 現在の列数
nr = 0 # 現在の行数
item_list.each do |item|
next if item == nil
next if enable_proc != nil && !enable_proc.call(item)
next unless cond_proc.call(item)
icon_index = index_proc.call(item)
next if icon_index == nil || icon_index == 0
draw_icon(icon_index, dx + nc * 24, dy + nr * 24)
nc += 1
if nc == cols
# 次の行へ
nc = 0
nr += 1
break if nr == rows # 行制限オーバー
end
end # each
end
#--------------------------------------------------------------------------
# ○ 弱点属性描画
# dx, dy : 描画先 X, Y
# rows : 行数
#--------------------------------------------------------------------------
def draw_weak_element(dx, dy, rows = 1)
change_color(system_color)
draw_text(dx, dy, 80, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:weak_element])
new_dy = dy + line_height * rows
#return new_dy unless KMS::Commands.enemy_defeated?(enemy.id)
return new_dy unless KMS::Commands.enemy_encountered?(enemy.id)
cols = (page_width - 88) / 24
draw_icon_list(dx + 80, dy, rows, cols,
KMS::EnemyGuide::CHECK_ELEMENT_LIST,
Proc.new { |i| @enemy_object.element_rate(i) > 1.0 },
Proc.new { |i| KMS::EnemyGuide::ELEMENT_ICON[i] },
Proc.new { |i| i < $data_system.elements.size })
new_dy
end
#--------------------------------------------------------------------------
# ○ 耐性属性描画
# dx, dy : 描画先 X, Y
# rows : 行数
#--------------------------------------------------------------------------
def draw_resist_element(dx, dy, rows = 1)
change_color(system_color)
draw_text(dx, dy, 80, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:resist_element])
new_dy = dy + line_height * rows
#return new_dy unless KMS::Commands.enemy_defeated?(enemy.id)
return new_dy unless KMS::Commands.enemy_encountered?(enemy.id)
cols = (page_width - 88) / 24
# 耐性属性
draw_icon_list(dx + 80, dy, rows, cols,
KMS::EnemyGuide::CHECK_ELEMENT_LIST,
Proc.new { |i| @enemy_object.element_rate(i) < 1.0 },
Proc.new { |i| KMS::EnemyGuide::ELEMENT_ICON[i] },
Proc.new { |i| i < $data_system.elements.size })
new_dy
end
#--------------------------------------------------------------------------
# ○ 弱点ステート描画
# dx, dy : 描画先 X, Y
# rows : 行数
#--------------------------------------------------------------------------
def draw_weak_state(dx, dy, rows = 1)
change_color(system_color)
draw_text(dx, dy, 80, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:weak_state])
new_dy = dy + line_height * rows
#return new_dy unless KMS::Commands.enemy_defeated?(enemy.id)
return new_dy unless KMS::Commands.enemy_encountered?(enemy.id)
cols = (page_width - 88) / 24
draw_icon_list(dx + 80, dy, rows, cols,
KMS::EnemyGuide::CHECK_STATE_LIST,
Proc.new { |i| @enemy_object.state_rate(i) > 1.0 },
Proc.new { |i| $data_states[i].icon_index },
Proc.new { |i| i < $data_states.size })
new_dy
end
#--------------------------------------------------------------------------
# ○ 耐性ステート描画
# dx, dy : 描画先 X, Y
# rows : 行数
#--------------------------------------------------------------------------
def draw_resist_state(dx, dy, rows = 1)
change_color(system_color)
draw_text(dx, dy, 80, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:resist_state])
new_dy = dy + line_height * rows
#return new_dy unless KMS::Commands.enemy_defeated?(enemy.id)
return new_dy unless KMS::Commands.enemy_encountered?(enemy.id)
cols = (page_width - 88) / 24
draw_icon_list(dx + 80, dy, rows, cols,
KMS::EnemyGuide::CHECK_STATE_LIST,
#~ Proc.new { |i| @enemy_object.state_resist?(i) ||
#~ @enemy_object.state_rate(i) == 0.0 },
Proc.new { |i| @enemy_object.state_resist?(i) },
Proc.new { |i| $data_states[i].icon_index },
Proc.new { |i| i < $data_states.size })
new_dy
end
#--------------------------------------------------------------------------
# ○ EXP, Gold 描画
# dx, dy : 描画先 X, Y
#--------------------------------------------------------------------------
def draw_prize(dx, dy)
param = {}
#if KMS::Commands.enemy_defeated?(enemy.id)
if KMS::Commands.enemy_encountered?(enemy.id)
param[:exp] = enemy.exp
param[:gold] = enemy.gold
param[:ap] = enemy.ap if $kms_imported["EquipLearnSkill"]
else
param[:exp] = param[:gold] = param[:ap] =
KMS::EnemyGuide::UNDEFEATED_PARAMETER
end
dw = page_width / 2
change_color(system_color)
draw_text(dx, dy, 80, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:exp])
draw_text(dx + dw, dy, 80, line_height, Vocab.currency_unit)
if $kms_imported["EquipLearnSkill"]
draw_text(dx, dy + line_height, 80, line_height, Vocab.ap)
end
# EXP, Gold
dx += 76
change_color(normal_color)
draw_text(dx, dy, 52, line_height, param[:exp], 2)
draw_text(dx + dw, dy, 52, line_height, param[:gold], 2)
if $kms_imported["EquipLearnSkill"]
draw_text(dx, dy + line_height, 52, line_height, param[:ap], 2)
end
return dy + line_height * 2
end
#--------------------------------------------------------------------------
# ○ ドロップアイテム描画
# dx, dy : 描画先 X, Y
# rows : 行数
#--------------------------------------------------------------------------
def draw_drop_item(dx, dy, rows)
return dy unless KMS::EnemyGuide::SHOW_DROP_ITEM
dw = page_width / 2
change_color(system_color)
draw_text(dx, dy, 128, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:treasure], 1)
draw_text(dx + dw, dy, 128, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:drop_prob], 2)
new_dy = dy + line_height * rows
return new_dy unless KMS::Commands.enemy_defeated?(enemy.id)
# リスト作成
drop_items = enemy.drop_items.dup
if $kms_imported["ExtraDropItem"]
drop_items += enemy.extra_drop_items
end
dy += line_height
count = 0
drop_items.each_with_index do |item, i|
# アイテム名描画
case item.kind
when 1; list = $data_items
when 2; list = $data_weapons
when 3; list = $data_armors
else; next
end
drop_item = list[item.data_id]
if KMS::Commands.enemy_item_dropped?(enemy.id, i)
draw_item_name(drop_item, dx, dy)
else
draw_masked_item_name(drop_item, dx, dy)
end
# ドロップ率描画
if $kms_imported["ExtraDropItem"] && item.drop_prob > 0
text = sprintf("%d%%", item.drop_prob)
else
text = "1/#{item.denominator}"
end
draw_text(dx + dw, dy, 128, line_height, text, 2)
dy += line_height
count += 1
break if count == rows
end
return new_dy
end
#--------------------------------------------------------------------------
# ○ アイテム名をマスクして描画
# item : アイテム (スキル、武器、防具でも可)
# x : 描画先 X 座標
# y : 描画先 Y 座標
# enabled : 有効フラグ。false のとき半透明で描画
#--------------------------------------------------------------------------
def draw_masked_item_name(item, x, y, enabled = true)
return if item == nil
draw_icon(item.icon_index, x, y, enabled)
change_color(normal_color, enabled)
mask = KMS::EnemyGuide::UNDROPPED_ITEM_NAME
text = KMS.mask_string(item.name, mask)
draw_text(x + 24, y, 172, line_height, text)
end
#--------------------------------------------------------------------------
# ○ 盗めるオブジェクト描画
# dx, dy : 描画先 X, Y
# rows : 行数
#--------------------------------------------------------------------------
def draw_steal_object(dx, dy, rows)
return dy unless $kms_imported["Steal"] && KMS::EnemyGuide::SHOW_STEAL_OBJ
new_dy = dy + line_height * rows
dw = page_width / 2
change_color(system_color)
draw_text(dx, dy, 128, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:steal_obj], 1)
draw_text(dx + dw, dy, 128, line_height,
KMS::EnemyGuide::PARAMETER_NAME[:steal_prob], 2)
return new_dy unless KMS::Commands.enemy_defeated?(enemy.id)
# リスト作成
steal_objects = enemy.steal_objects.clone
if steal_objects.size >= rows
steal_objects = steal_objects[0...(rows - 1)]
end
dy += line_height
steal_objects.each_with_index do |obj, i|
if obj.kind == 4
# Gold
if KMS::Commands.enemy_object_stolen?(enemy.id, i)
text = sprintf("%d%s", obj.gold, Vocab.gold)
else
mask = KMS::EnemyGuide::UNDROPPED_ITEM_NAME
text = KMS.mask_string("aaa", mask)
end
draw_text(dx + 24, dy, dw, line_height, text)
else
# Item
case obj.kind
when 1
item = $data_items[obj.item_id]
when 2
item = $data_weapons[obj.weapon_id]
when 3
item = $data_armors[obj.armor_id]
end
if KMS::Commands.enemy_object_stolen?(enemy.id, i)
draw_item_name(item, dx, dy)
else
draw_masked_item_name(item, dx, dy)
end
end
# 成功率描画
if obj.success_prob > 0
text = sprintf("%d%%", obj.success_prob)
else
text = "1/#{obj.denominator}"
end
draw_text(dx + dw, dy, 128, line_height, text, 2)
dy += line_height
end
return new_dy
end
#--------------------------------------------------------------------------
# ○ 説明文描画
# dx, dy : 描画先 X, Y
#--------------------------------------------------------------------------
def draw_description(dx, dy)
#return unless KMS::Commands.enemy_defeated?(enemy.id)
return unless KMS::Commands.enemy_encountered?(enemy.id)
dx += 4
enemy.enemy_guide_description.each_line do |line|
draw_text(dx, dy, page_width, line_height, line.chomp)
dy += line_height
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Menu
#==============================================================================
if KMS::EnemyGuide::USE_MENU_ENEMY_GUIDE_COMMAND
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# ● コマンドウィンドウの作成
#--------------------------------------------------------------------------
alias create_command_window_KMS_EnemyGuide create_command_window
def create_command_window
create_command_window_KMS_EnemyGuide
@command_window.set_handler(:enemy_guide, method(:command_enemy_guide))
end
#--------------------------------------------------------------------------
# ○ コマンド[モンスター図鑑]
#--------------------------------------------------------------------------
def command_enemy_guide
SceneManager.call(Scene_EnemyGuide)
end
end
end # if KMS::EnemyGuide::USE_MENU_ENEMY_GUIDE_COMMAND
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Scene_EnemyGuide
#------------------------------------------------------------------------------
# モンスター図鑑画面の処理を行うクラスです。
#==============================================================================
class Scene_EnemyGuide < Scene_MenuBase
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# menu_index : コマンドのカーソル初期位置
# host_scene : 呼び出し元 (0..メニュー 1..マップ)
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_background_sprite
create_windows
end
#--------------------------------------------------------------------------
# ○ 背景スプライトの作成
#--------------------------------------------------------------------------
def create_background_sprite
return unless KMS::EnemyGuide::USE_BACKGROUND_IMAGE
@back_sprite = Sprite.new(@viewport)
begin
@back_sprite.bitmap = Cache.system(KMS::EnemyGuide::BACKGROUND_FILENAME)
rescue
@back_sprite.bitmap = Bitmap.new(32, 32)
end
end
#--------------------------------------------------------------------------
# ○ ウィンドウの作成
#--------------------------------------------------------------------------
def create_windows
@top_window = Window_EnemyGuideTop.new
@enemy_window = Window_EnemyGuideList.new
@status_window = Window_EnemyGuideStatus.new
@top_window.viewport = @viewport
@enemy_window.viewport = @viewport
@status_window.viewport = @viewport
@status_window.enemy = @enemy_window.item
@enemy_window.set_handler(:cancel, method(:return_scene))
@enemy_window.activate
end
#--------------------------------------------------------------------------
# ● 終了処理
#--------------------------------------------------------------------------
def terminate
Graphics.freeze
dispose_background_sprite
super
end
#--------------------------------------------------------------------------
# ○ 背景スプライトの解放
#--------------------------------------------------------------------------
def dispose_background_sprite
if @back_sprite != nil
@back_sprite.bitmap.dispose
@back_sprite.dispose
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
update_background_sprite
update_enemy_selection
end
#--------------------------------------------------------------------------
# ○ 背景スプライトの更新
#--------------------------------------------------------------------------
def update_background_sprite
return if @back_sprite == nil
@back_sprite.update
end
#--------------------------------------------------------------------------
# ○ エネミー選択の更新
#--------------------------------------------------------------------------
def update_enemy_selection
if @last_index != @enemy_window.index
@status_window.enemy = @enemy_window.item
@last_index = @enemy_window.index
end
if Input.trigger?(Input::A) || Input.trigger?(Input::C)
# スプライト表示切替
Sound.play_ok
@status_window.switch_sprite
elsif Input.trigger?(Input::LEFT)
# 左ページ
Sound.play_cursor
@status_window.shift_info_type(-1)
elsif Input.trigger?(Input::RIGHT)
# 右ページ
Sound.play_cursor
@status_window.shift_info_type(1)
end
end
end