#--------------------------------------------------------------------------
# □ RPG::Enemy
#--------------------------------------------------------------------------
module RPG
class Enemy
def name
name = @name.split(/,/)[0]
return name != nil ? name : ""
end
def treasure2
treasure = @name.split(/,/)[1]
return treasure.to_s
end
def treasure3
treasure = @name.split(/,/)[2]
return treasure.to_s
end
def treasure4
treasure = @name.split(/,/)[3]
return treasure.to_s
end
end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
# 处理敌人的类。本类在 Game_Troop 类 ($game_troop) 的
# 内部使用。
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 获取物品 ID2
#--------------------------------------------------------------------------
def item2_id
if $data_enemies[@enemy_id].treasure2 == ""
return item_id
elsif $data_enemies[@enemy_id].treasure2[0,1] != "I"
return 0
else
return $data_enemies[@enemy_id].treasure2[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取武器 ID2
#--------------------------------------------------------------------------
def weapon2_id
if $data_enemies[@enemy_id].treasure2 == ""
return weapon_id
elsif $data_enemies[@enemy_id].treasure2[0,1] != "W"
return 0
else
return $data_enemies[@enemy_id].treasure2[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取防具 ID2
#--------------------------------------------------------------------------
def armor2_id
if $data_enemies[@enemy_id].treasure2 == ""
return armor_id
elsif $data_enemies[@enemy_id].treasure2[0,1] != "A"
return 0
else
return $data_enemies[@enemy_id].treasure2[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取物品 ID3
#--------------------------------------------------------------------------
def item3_id
if $data_enemies[@enemy_id].treasure3 == ""
return item2_id
elsif $data_enemies[@enemy_id].treasure3[0,1] != "I"
return 0
else
return $data_enemies[@enemy_id].treasure3[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取武器 ID3
#--------------------------------------------------------------------------
def weapon3_id
if $data_enemies[@enemy_id].treasure3 == ""
return weapon2_id
elsif $data_enemies[@enemy_id].treasure3[0,1] != "W"
return 0
else
return $data_enemies[@enemy_id].treasure3[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取防具 ID3
#--------------------------------------------------------------------------
def armor3_id
if $data_enemies[@enemy_id].treasure3 == ""
return armor2_id
elsif $data_enemies[@enemy_id].treasure3[0,1] != "A"
return 0
else
return $data_enemies[@enemy_id].treasure3[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取物品 ID4
#--------------------------------------------------------------------------
def item4_id
if $data_enemies[@enemy_id].treasure4 == ""
return item3_id
elsif $data_enemies[@enemy_id].treasure4[0,1] != "I"
return 0
else
return $data_enemies[@enemy_id].treasure4[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取武器 ID4
#--------------------------------------------------------------------------
def weapon4_id
if $data_enemies[@enemy_id].treasure4 == ""
return weapon3_id
elsif $data_enemies[@enemy_id].treasure4[0,1] != "W"
return 0
else
return $data_enemies[@enemy_id].treasure4[/[0-9]+/].to_i
end
end
#--------------------------------------------------------------------------
# ● 获取防具 ID4
#--------------------------------------------------------------------------
def armor4_id
if $data_enemies[@enemy_id].treasure4 == ""
return armor3_id
elsif $data_enemies[@enemy_id].treasure4[0,1] != "A"
return 0
else
return $data_enemies[@enemy_id].treasure4[/[0-9]+/].to_i
end
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 开始结束战斗回合
#--------------------------------------------------------------------------
def start_phase5
# 转移到回合 5
@phase = 5
# 演奏战斗结束 ME
$game_system.me_play($game_system.battle_end_me)
# 还原为战斗开始前的 BGM
$game_system.bgm_play($game_temp.map_bgm)
# 初始化 EXP、金钱、宝物
exp = 0
gold = 0
treasures = []
# 循环
for enemy in $game_troop.enemies
# 敌人不是隐藏状态的情况下
unless enemy.hidden
# 获得 EXP、增加金钱
exp += enemy.exp
gold += enemy.gold
# 出现宝物判定
if rand(100) < enemy.treasure_prob
rarity = [30, 30, 15, 15, 10, 5, 2, 1]
case rand(rarity[0] + rarity[1] + rarity[2] + rarity[3])
when 0..rarity[0] - 1
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
when rarity[0]..rarity[0] + rarity[1] - 1
if enemy.item2_id > 0
treasures.push($data_items[enemy.item2_id])
end
if enemy.weapon2_id > 0
treasures.push($data_weapons[enemy.weapon2_id])
end
if enemy.armor2_id > 0
treasures.push($data_armors[enemy.armor2_id])
end
when rarity[0] + rarity[1]..rarity[0] + rarity[1] + rarity[2] - 1
if enemy.item3_id > 0
treasures.push($data_items[enemy.item3_id])
end
if enemy.weapon3_id > 0
treasures.push($data_weapons[enemy.weapon3_id])
end
if enemy.armor3_id > 0
treasures.push($data_armors[enemy.armor3_id])
end
else
if enemy.item4_id > 0
treasures.push($data_items[enemy.item4_id])
end
if enemy.weapon4_id > 0
treasures.push($data_weapons[enemy.weapon4_id])
end
if enemy.armor4_id > 0
treasures.push($data_armors[enemy.armor4_id])
end
end
end
end
end
# 限制宝物数为 8 个
treasures = treasures[0..7]
# 获得 EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# 获得金钱
$game_party.gain_gold(gold)
# 获得宝物
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
# 生成战斗结果窗口
@result_window = Window_BattleResult.new(exp, gold, treasures)
# 设置等待计数
@phase5_wait_count = 100
end
end