Garden is boring so I'll share some tricks~
RMVX's auto battle is most times silly and unreliable.
So I decided to try and fix that.
First, I need to make my own AI, but I'm not that much of a scripter to be able to code advanced stuff like that, so a workaround is in order.
I decided to make my partner's AI the same way I make enemy AI:
This not only allows me to control it's behavior to an extent, but it also allows the AI to be a little more wary of his/her own status instead of mindlessly using the highest damage skill over and over. His/her actions will change according to how much Hp/Mp he/she has, and whether a state is active, or what turn he/she is on, etcetera. Much more control than previous AI, much more flexibility, much more character.
Now for the more difficult part: Using an Enemy's behavior for an Actor.
This goes a bit into Scripting, so don't hurt me :<
Game_Actor has something called "def make_action" to determine it's action for Auto-Battle actors.
Game_Enemy also has that method! However, it's different than the one on Game_Actor.
What I first did was copy over the Enemy's method to Actor's method.
def make_action
@action.clear
return unless movable?
available_actions =
rating_max = 0
for action in enemy.actions
next unless conditions_met?(action)
if action.kind == 1
next unless skill_can_use?($data_skills)
end
available_actions.push(action)
rating_max = .max
end
ratings_total = 0
rating_zero = rating_max - 3
for action in available_actions
next if action.rating <= rating_zero
ratings_total += action.rating - rating_zero
end
return if ratings_total == 0
value = rand(ratings_total)
for action in available_actions
next if action.rating <= rating_zero
if value < action.rating - rating_zero
@action.kind = action.kind
@action.basic = action.basic
@action.skill_id = action.skill_id
@action.decide_random_target
return
else
value -= action.rating - rating_zero
end
end
end
But this brings up a problem: the definition tries to find "enemy".
Which is averted by adding:
enemy = $data_enemies[ENEMY_AI_ID]
after the line
ENEMY_AI_ID being the ID of the Enemy you used to store AI in.
Now the method looks for "conditions_met?". This is much easier:
I copied the entire
def conditions_met?(action)
method from Game_Enemy and pasted it in Game_Actor.
It didn't seem to require any modification!
After that, assuming that everything has gone correctly, we now have smarter AI!
It's actually an effective workaround!