#==============================================================================
# ■ VXAce-RGSS3-6 击破数计算器 [Ver.1.0.0] by Claimh 汉化:疾风怒涛
#------------------------------------------------------------------------------
# 各角色击倒敌人数量计算。
#------------------------------------------------------------------------------
#・窗口显示设定
#Widow_Status备注记录内容。
#<记述>
# draw_defeat_count(actor_id, enemy_id, x, y)
# actor_id :对象角色ーID(为0则指代全体角色)
# enemy_id :对象敌人ーID(为0则指定全体敌人)
# x :横方向表示位置
# y :纵方向表示位置
#------------------------------------------------------------------------------
#・变量记录
#在事件设定中的脚本作如下格式的描述。
#<记述>
# input_defeat_count(actor_id, enemy_id, variable_id)
# actor_id :对象角色ーID(为0则指代全体角色)
# enemy_id :对象敌人ーID(为0则指定全体敌人)
# variable_id :击破数记录变量
#==============================================================================
module DefeatCounter ## 与其他脚本合并使用
#--------------------------------------------------------------------------
# ● 指定角色的击破数
# actor_id :对象角色ーID(为0则指代全体角色)
# enemy_id :对象敌人ーID(为0则指定全体敌人)
#--------------------------------------------------------------------------
def self.defeat_count(actor_id=0, enemy_id=0)
return $game_actors.defeat(enemy_id, actor_id)
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● object初期化
#--------------------------------------------------------------------------
alias initialize_defeat_count initialize
def initialize(actor_id)
initialize_defeat_count(actor_id)
@defeat = {}
end
#--------------------------------------------------------------------------
# ● 击破数取得
#--------------------------------------------------------------------------
def defeat(enemy_id=0)
return defeat_all if enemy_id == 0
@defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
return @defeat[enemy_id]
end
#--------------------------------------------------------------------------
# ● 击破数取得
#--------------------------------------------------------------------------
def defeat_all
@defeat.keys.inject(0) { |n, id| n += @defeat[id] }
end
#--------------------------------------------------------------------------
# ● 击破数计算
#--------------------------------------------------------------------------
def defeat_cnt(enemy_id)
return if enemy_id == 0
@defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
@defeat[enemy_id] += 1
end
end
class Game_Actors
#--------------------------------------------------------------------------
# ● 击破数取得
#--------------------------------------------------------------------------
def defeat(enemy_id=0, actor_id=0)
return defeat_all(enemy_id) if actor_id == 0
return self.[](actor_id).defeat(enemy_id)
end
#--------------------------------------------------------------------------
# ● 击破数取得
#--------------------------------------------------------------------------
def defeat_all(enemy_id=0)
@data.inject(0) { |n, actor| n += (actor.nil? ? 0 : actor.defeat(enemy_id)) }
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● 伤害处理
# 在调用之前 @result.hp_damage @result.mp_damage @result.hp_drain
# @result.mp_drain 已被设置。
#--------------------------------------------------------------------------
alias execute_damage_defeat execute_damage
def execute_damage(user)
execute_damage_defeat(user)
return if actor? or !dead? or user.enemy?
return if $game_troop.enable_dead_count?(self.index)
$game_troop.defeat_dead_count(self.index)
user.defeat_cnt(self.enemy_id)
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● 建立[set up]
#--------------------------------------------------------------------------
alias setup_defeat setup
def setup(troop_id)
setup_defeat(troop_id)
@enemy_defeat = []
end
#--------------------------------------------------------------------------
# ● 击破時的计算
#--------------------------------------------------------------------------
def defeat_dead_count(index)
@enemy_defeat[index] = true
end
#--------------------------------------------------------------------------
# ● 已完成计算?
#--------------------------------------------------------------------------
def enable_dead_count?(index)
@enemy_defeat[index] || false
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 指定变量时角色击破数储存
# actor_id :对象角色ー(为0则指代全体角色)
# enemy_id :对象敌人ー(为0则指代全体敌人)
# variable_id :击破数存储的变量
#--------------------------------------------------------------------------
def input_defeat_count(actor_id, enemy_id, variable_id)
$game_variables[variable_id] = $game_actors.defeat(enemy_id, actor_id)
return true
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 指定变量时角色击破数表示
# actor_id :对象角色ー(为0则指代全体角色)
# enemy_id :对象敌人ー(为0则指代全体敌人)
# x :横方向表示位置
# y :纵方向表示位置
#--------------------------------------------------------------------------
def draw_defeat_count(actor_id, enemy_id, x, y)
draw_text(x, y, 200, line_height, $game_actors.defeat(enemy_id, actor_id), 2)
end
end