Auteur: Yukihiro matsumoto
#============================================
# ‘ Game_Troop
#--------------------------------------------
# @g[vπ΅€NXΕ·B±ΜNXΜCX^XΝ $game_troop ΕQΖ³
# κά·B
#============================================
class Game_Troop
#------------------------------------------
# IuWFNgϊ»
#------------------------------------------
def initialize
# Gl~[Μzρπμ¬
@enemies = []
end
#------------------------------------------
# Gl~[ΜζΎ
#------------------------------------------
def enemies
return @enemies
end
#------------------------------------------
# ZbgAbv
# troop_id : g[v ID
#------------------------------------------
def setup(troop_id)
# g[vΙέθ³κΔ’ιGl~[πzρΙέθ
@enemies = []
troop = $data_troops[troop_id]
for i in 0...troop.members.size
enemy = $data_enemies[troop.members[i].enemy_id]
if enemy != nil
@enemies.push(Game_Enemy.new(troop_id, i))
end
end
end
#------------------------------------------
# ΞΫGl~[Μ_Θθ
# hp0 : HP 0 ΜGl~[Ιΐι
#------------------------------------------
def random_target_enemy(hp0 = false)
# [bgπϊ»
roulette = []
# [v
for enemy in @enemies
# πΙY·ικ
if (not hp0 and enemy.exist?) or (hp0 and enemy.hp0?)
# [bgΙGl~[πΗΑ
roulette.push(enemy)
end
end
# [bgΜTCYͺ 0 Μκ
if roulette.size == 0
return nil
end
# [bgπρ΅AGl~[πθ
return roulette[rand(roulette.size)]
end
#------------------------------------------
# ΞΫGl~[Μ_Θθ (HP 0)
#------------------------------------------
def random_target_enemy_hp0
return random_target_enemy(true)
end
#------------------------------------------
# ΞΫGl~[ΜX[YΘθ
# enemy_index : Gl~[CfbNX
#------------------------------------------
def smooth_target_enemy(enemy_index)
# Gl~[πζΎ
enemy = @enemies[enemy_index]
# Gl~[ͺΆέ·ικ
if enemy != nil and enemy.exist?
return enemy
end
# [v
for enemy in @enemies
# Gl~[ͺΆέ·ικ
if enemy.exist?
return enemy
end
end
end
end |
|