class Game_Actor alias initialize_for_count_actor_death initialize def initialize(actor_id) initialize_for_count_actor_death(actor_id) $game_variables[actor_id] = 0 end def add_state(state_id) if state_id == death_state_id && !death_state? BattleManager.count_actor_death(@actor_id) end super end end module BattleManager @reserved_death_count = {} def self.count_actor_death(actor_id) if $game_party.in_battle @reserved_death_count[actor_id] ||= 0 @reserved_death_count[actor_id] += 1 else $game_variables[actor_id] -= 1 end end class << self alias battle_end_for_count_actor_death battle_end def battle_end(result) @reserved_death_count.each do |k, v| $game_variables[k] -= v end @reserved_death_count.clear battle_end_for_count_actor_death(result) end end end
class Game_Actor
alias initialize_for_count_actor_death initialize
def initialize(actor_id)
initialize_for_count_actor_death(actor_id)
$game_variables[actor_id] = 0
end
def add_state(state_id)
if state_id == death_state_id && !death_state?
BattleManager.count_actor_death(@actor_id)
end
super
end
end
module BattleManager
@reserved_death_count = {}
def self.count_actor_death(actor_id)
if $game_party.in_battle
@reserved_death_count[actor_id] ||= 0
@reserved_death_count[actor_id] += 1
else
$game_variables[actor_id] -= 1
end
end
class << self
alias battle_end_for_count_actor_death battle_end
def battle_end(result)
@reserved_death_count.each do |k, v|
$game_variables[k] -= v
end
@reserved_death_count.clear
battle_end_for_count_actor_death(result)
end
end
end
脚本如上
不过要注意,这里用的是角色编号来控制对应的变量,
也就是说你用了N号角色,第N号变量就不要拿来做其他用途了 |