I have never seen much resources on this subject either, but the best one I've found is probably the:
It provides insight into the enemies AI such as this:
AI: Setup
{
TempVar:TurnsUntilGrenade = 3
TempVar:GrenadeAmmo = 4
}
AI: Main
{
If (Stage == 0) Then
{
If (TempVar:TurnsUntilGrenade == 0) Then
{
If (TempVar:GrenadeAmmo > 0) Then
{
Choose Random Opponent with Lowest HP
Use Hand Grenade on Target
TempVar:GrenadeAmmo = TempVar:GrenadeAmmo - 1
TempVar:TurnsUntilGrenade = 3
} Else {
Choose Random Opponent with Lowest HP
Use <Machine Gun> on Target
}
} Else {
Choose Random Opponent
Use <Machine Gun> on Target
TempVar:TurnsUntilGrenade = TempVar:TurnsUntilGrenade - 1
}
} Else {
If (TempVar:GrenadeAmmo > 0) Then
{
Choose Random Opponent with Lowest HP
Use Hand Grenade on Target
TempVar:GrenadeAmmo = TempVar:GrenadeAmmo - 1
} Else {
Choose Random Opponent
Use <Machine Gun> on Target
}
}
}
AI: Counter - General
{
If (Grenade Combatant's HP <= 3 * [Grenade Combatant's Max HP / 4]) Then
{
Stage = 1
} Else {
Stage = 0
}
}
With this you can see that your enemies will probably need a state machine to manage the different states they can be in, and each state will have its own behavior to execute each turn, either hardcoded into the enemy, or data-driven by a scripting language.
There's a lot of variation even between turn based JRPGs, so there is no set of rules for all of them. For instance, you can issue all party commands before any of them taking place, or they can take place immediately after choosing. Attack order might be random, or more often determined by the Speed stat.
But for instance, let's say you have a purely turn based battle system, where you issue all party commands first, and then all the action happens at the end of the turn. You could approach it like:
- Store all entities (players + enemies) participating in the battle in a list.
- For each player in the list get input and store it.
- Sort the entity list by the Speed attribute.
- For each entity in the list, if it's a player execute the stored action, otherwise run the AI script for the current state.
- Advance turn and repeat.
The Battle Mechanics FAQ also has a lot of useful information, in particular about time management in the battles. But unfortunately this system (aka ATB or Active Time Battle) is patented so you can't make anything similar.
EDIT I also recently found this website which provides a lot of technical information about the implementation of FF7. Unfortunately the battle module sections does not seem to be completely written yet.