06-09-2012, 03:48 AM
(06-08-2012, 03:29 PM)Taylor Wrote: What determines an enemy's target with regards to single targets? Or the party, at least....If you look at the 'CLASS' database, you'll see a dropdown called 'Positions' over the available armors list. Position values are Front/Middle/Rear. Front positions are more likely to be hit while Rear are least likely. So they figure you want your magis and clerics in the back and fighters up front.
Now, the code... Game_Party:
Code:
def random_target_actor(hp0 = false)
# Initialize roulette
roulette = []
# Loop
for actor in @actors
# If it fits the conditions
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
# Get actor class [position]
position = $data_classes[actor.class_id].position
# Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
n = 4 - position
# Add actor to roulette n times
n.times do
roulette.push(actor)
end
end
end
# If roulette size is 0
if roulette.size == 0
return nil
end
# Spin the roulette, choose an actor
return roulette[rand(roulette.size)]
end
I know... you'd figure it would be in _Battler or _BattleAction.