Sorry, here's a more readable versoin.
You need to decide the following things to prepare for each combat sequence.
1. How many enemies there are.
2. What species the enemies are.
3. The stats of the different enemies based on a range of values.
4. The initiative checks for each character and enemy.
1. How many enemies there are.
For each area the player can explore you should have a value defining the range of the amount of enemies that they can encounter in any given combat sequence.
Randomize the value. Something you'll need to remember, however, the Rnd() command can only go from 0 to another number. You'll need to have your own function to fix this problem. Here's something that will work(or at least it should, might need some tweaking):
function Rand(num1,num2)
if num1<>num2 and num2>num1
num=num2-num1
new=Rnd(num)
new=new+num1
endif
endfunction new
You will want to store this value into a variable with a meaningful name.
2. What species the enemies are.
This is where more planning comes into play. You will need to make a table of all monsters in the game, and then a separate table for monsters available in each area(and depending on how in depth you want to go you might want different tables for each area depending on how far the player is in the game).
Organize this table into an array. It should include:
1. D number that can be identified with the monster(this should be the index of the array).
2. Name of the monster.
3-x. All statistics for the monster (strength, hp, etc.) Should be presented as a range.
Create a temporary array to store monster battle info.
Now with a for loop for i=1 to amount returned by Rand() randomly generate a monster ID for each monster in the battle. This value should be the first element in the array. The index would be between 1 and however many monsters there are.
3. The stats of the different enemies based on a range of values.
for i=1 to [the number of monsters]
Randomize all statistics for each monster in the battle based on the monster ID associated with them and the table of monster statistics.
For doing ranges you will need to use strings. I recommend making all your arrays strings, and remembering which elements you need to convert to ints or floats.
For ranges:
1.Your range should be described in the array like so: "[num1]-[num2]" ie: "1-10".
2. Use a for i=1 to len() loop. Take each character in the string starting from the left and if it is not a "-" add it to the end of a string(you'll keep adding to the same string).
3. When the program does read a "-" do not store that to any string, just start another for loop reading the left$() 1 place after the "-" until you reach the end of the string (using len() ). Then convert the two strings you have into numbers and you have two numbers to plug into your Rand() function.
4. The initiative checks for each character and enemy.
This is really dependent on how you want to do your battle system.
If you want a battle timer like Final Fantasy or Chrono Trigger you're going to want to generate a speed in pixels per second dependent on the statistics, and also depending on some random values generated before the combat that are biased by a statistic or two you will want to pick a random starting point for the battle timer.
If you want traditional queues you can generate an initiative modifier based on statistics (a la Dungeons & Dragons) and randomly generate a number for each character/monster, add the modifier to it and who ever has the highest goes first, then the next highest, and so on.
It might be worth your while to pick up a player's handbook for a tabletop RPG (I recommend D&D) if you don't already have one. It provides some great insight on how RPGs operate mathematically.
I hope that helps you, and good luck.
Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!