随手写的,不太满意。
方法是尽量保持 Game_Enemy 然后黑掉 Game_Troop#setup
class Game_Enemy alias :rb_initialize_20170131 :initialize def initialize(troop_id, member_index, suffix = "") rb_initialize_20170131(troop_id, member_index) @suffix = suffix end def name sprintf("%s%s", $data_enemies[@enemy_id].name, @suffix) end end class Game_Troop def setup(troop_id) # Set array of enemies who are set as troops @enemies = [] @enemy_count = {} troop = $data_troops[troop_id] for i in 0...troop.members.size enemy = $data_enemies[troop.members[i].enemy_id] if enemy != nil @enemy_count[enemy.id] ||= 0 suffix = (@enemy_count[enemy.id] += 1).to_s @enemies.push(Game_Enemy.new(troop_id, i, suffix)) end end end end
class Game_Enemy
alias :rb_initialize_20170131 :initialize
def initialize(troop_id, member_index, suffix = "")
rb_initialize_20170131(troop_id, member_index)
@suffix = suffix
end
def name
sprintf("%s%s", $data_enemies[@enemy_id].name, @suffix)
end
end
class Game_Troop
def setup(troop_id)
# Set array of enemies who are set as troops
@enemies = []
@enemy_count = {}
troop = $data_troops[troop_id]
for i in 0...troop.members.size
enemy = $data_enemies[troop.members[i].enemy_id]
if enemy != nil
@enemy_count[enemy.id] ||= 0
suffix = (@enemy_count[enemy.id] += 1).to_s
@enemies.push(Game_Enemy.new(troop_id, i, suffix))
end
end
end
end
标题我给你改了,原来的有点随便。 |