def make_action
self.current_action.clear
unless self.movable?
return
end
available_actions = []
rating_max = 0
for action in self.actions
n = $game_temp.battle_turn
a = action.condition_turn_a
b = action.condition_turn_b
if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
if self.hp * 100.0 / self.maxhp > action.condition_hp
next
end
if $game_party.max_level < action.condition_level
next
end
switch_id = action.condition_switch_id
if switch_id > 0 and $game_switches[switch_id] == false
next
end
available_actions.push(action)
if action.rating > rating_max
rating_max = action.rating
end
end
ratings_total = 0
for action in available_actions
if action.rating > rating_max - 3
ratings_total += action.rating - (rating_max - 3)
end
end
if ratings_total > 0
value = rand(ratings_total)
for action in available_actions
if action.rating > rating_max - 3
if value < action.rating - (rating_max - 3)
self.current_action.kind = action.kind
self.current_action.basic = action.basic
self.current_action.skill_id = action.skill_id
self.current_action.decide_random_target_for_enemy
return
else
value -= action.rating - (rating_max - 3)
end
end
end
end
end