module_function
#--------------------------------------------------------------------------
# ○ Range と Integer の配列を Integer の配列に変換 (重複要素は排除)
#--------------------------------------------------------------------------
def convert_integer_array(array)
result = []
array.each { |i|
case i
when Range
result |= i.to_a
when Integer
result |=
end
}
return result
end
#--------------------------------------------------------------------------
# ○ 敵を表示するか
#--------------------------------------------------------------------------
def enemy_show?(enemy_id)
return false if HIDDEN_ENEMY_LIST.include?(enemy_id)
if ENEMY_ORDER_ID != nil
return false unless ENEMY_ORDER_ID.include?(enemy_id)
end
description_flag = false
self.note.each_line { |line|
case line
when KGC::EnemyGuide::Regexp::Enemy::BEGIN_GUIDE_DESCRIPTION
# 説明文開始
description_flag = true
when KGC::EnemyGuide::Regexp::Enemy::END_GUIDE_DESCRIPTION
# 説明文終了
description_flag = false
else
if description_flag
@__enemy_guide_description += line
end
end
}
end
#--------------------------------------------------------------------------
# ○ 図鑑説明文
#--------------------------------------------------------------------------
def enemy_guide_description
create_enemy_guide_cache if @__enemy_guide_description == nil
return @__enemy_guide_description
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# index : 敵グループ内インデックス
# enemy_id : 敵キャラ ID
#--------------------------------------------------------------------------
alias initialize_KGC_EnemyGuide initialize
def initialize(index, enemy_id)
initialize_KGC_EnemyGuide(index, enemy_id)
@original_ids = [] # 変身前の ID
# 遭遇済みフラグをオン
KGC::Commands.set_enemy_encountered(enemy_id) unless hidden
end
#--------------------------------------------------------------------------
# ● コラプスの実行
#--------------------------------------------------------------------------
alias perform_collapse_KGC_EnemyGuide perform_collapse
def perform_collapse
last_collapsed = @collapse
perform_collapse_KGC_EnemyGuide
if !last_collapsed && @collapse
# 撃破済みフラグをオン
KGC::Commands.set_enemy_defeated(enemy_id)
# 変身前の敵も撃破済みにする
if KGC::EnemyGuide::ORIGINAL_DEFEAT
@original_ids.compact.each { |i|
KGC::Commands.set_enemy_defeated(i)
}
end
end
end
#--------------------------------------------------------------------------
# ● 変身
# enemy_id : 変身先の敵キャラ ID
#--------------------------------------------------------------------------
alias transform_KGC_EnemyGuide transform
def transform(enemy_id)
# 変身前のIDを保存
@original_ids << @enemy_id
transform_KGC_EnemyGuide(enemy_id)
# 変身後の敵も遭遇済みにする
KGC::Commands.set_enemy_encountered(enemy_id)
end
#--------------------------------------------------------------------------
# ● 隠れ状態設定
#--------------------------------------------------------------------------
alias hidden_equal_KGC_EnemyGuide hidden= unless $@
def hidden=(value)
hidden_equal_KGC_EnemyGuide(value)
# 出現した場合は遭遇済みフラグをオン
KGC::Commands.set_enemy_encountered(enemy_id) unless value
end
end
class Window_EnemyGuideList < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, WLH + 32, 240, Graphics.height - (WLH + 32))
self.index = 0
refresh
if KGC::EnemyGuide::USE_BACKGROUND_IMAGE
self.opacity = 0
self.height -= (self.height - 32) % WLH
end
end
#--------------------------------------------------------------------------
# ○ 選択モンスターの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ○ エネミーをリストに含めるか
# enemy_id : 敵 ID
#--------------------------------------------------------------------------
def include?(enemy_id)
return KGC::Commands.enemy_guide_include?(enemy_id)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
@data = []
if KGC::EnemyGuide::ENEMY_ORDER_ID == nil
# ID順
enemy_list = 1...$data_enemies.size
else
# 指定順
enemy_list = KGC::EnemyGuide::ENEMY_ORDER_ID
end
enemy_list.each { |i|
@data << $data_enemies if include?(i)
}
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
enemy = @data[index]
self.contents.font.color = normal_color
unless KGC::Commands.enemy_defeated?(enemy.id)
self.contents.font.color.alpha = 128
end
rect = item_rect(index)
self.contents.clear_rect(rect)
if KGC::EnemyGuide::SHOW_SERIAL_NUMBER
s_num = sprintf(KGC::EnemyGuide::SERIAL_NUM_FORMAT,
KGC::EnemyGuide::SERIAL_NUM_FOLLOW ? (index + 1) : enemy.id)
end
text = (KGC::EnemyGuide::SHOW_SERIAL_NUMBER ? s_num : "")
if KGC::Commands.enemy_encountered?(enemy.id)
# 遭遇済み
text += enemy.name
else
# 未遭遇
mask = KGC::EnemyGuide::UNKNOWN_ENEMY_NAME
if mask.scan(/./).size == 1
mask = mask * enemy.name.scan(/./).size
end
text += mask
end
self.contents.draw_text(rect, text)
end
end