Okay, the easiest way, I think, is just to set up a troop that will be your "random enemy" troop. Whenever that troop appears in battle processing, it will choose the enemies that make up the troop randomly from your specified list.
I'm going to give you a hard-coded solution. It is not the ideal way to go about it - in fact if I was doing this
properly I would set it up so you could use note tags or something to say which battles should have random enemies. But that would take longer to do.
So, allocate a troop id to your "random enemies" group, and choose any 3 enemies and place them on the battle background just like you were making a regular troop. Let's assume, for this example, you're going to use the 008 slot. (In the script we'll just use 8 - leave off the leading zeros). And let's say the enemies you want included in this troop will be chosen from 1, 2, 4, 5, 8, 9, 10, 11, 15, 16, 23 and 24. If the enemy ids were all in a continuous sequence the script could be altered slightly, but I'm leaving gaps so you're not restricted to having to set them all up in a row.
In your Game_Troop script, find this method:
Code:
def setup(troop_id) clear @troop_id = troop_id @enemies = [] troop.members.each do |member| next unless $data_enemies[member.enemy_id] enemy = Game_Enemy.new(@enemies.size, member.enemy_id) enemy.hide if member.hidden enemy.screen_x = member.x enemy.screen_y = member.y @enemies.push(enemy) end init_screen_tone make_unique_names end
and insert a new line (change the troop id and change the enemy ids to suit your needs) right before the
next unless $data_enemies[...] line:
Code:
def setup(troop_id) clear @troop_id = troop_id @enemies = [] troop.members.each do |member| member.enemy_id = [1,2,4,5,8,9,10,11,15,16,23,24][rand(12)] if @troop_id == 8 # <<<<< insert this line next unless $data_enemies[member.enemy_id] enemy = Game_Enemy.new(@enemies.size, member.enemy_id) enemy.hide if member.hidden enemy.screen_x = member.x enemy.screen_y = member.y @enemies.push(enemy) end init_screen_tone make_unique_names end