Random Enemies in each Troop

nickfitzgerald3

Villager
Member
Joined
May 5, 2014
Messages
24
Reaction score
3
First Language
english
Primarily Uses
So I know random enemy encounters is obviously an easy task, but in my case i have about 12 different enemies that I want to appear randomly in troops of 3 but I cant find any way other than putting each individual possible combination of enemies into troops, which is VERY time and data consuming is their ANY way to do this easier, maybe a script or something im not seeing, please help 
 

Mouser

Veteran
Veteran
Joined
Aug 19, 2012
Messages
1,245
Reaction score
264
First Language
English
Primarily Uses
My gut tells me no, because of the way the troop graphic is made - and even if you could do that randomly, it would look horrible unless you set it up with specific parameters for each combination. Do you really need every possible combination of three enemies? As you say, thats 12x12x12 = 1,728 combinations, some of which will probably be over or under powered anyway.  I can't think of any game off hand that's gone that far in generating random encounters.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Actually, yes, you could do it via scripts, and it would be pretty easy (Mouser, just find the line that creates the enemy in the troop, and pass a random number in the appropriate range instead of the id specified in the troop setup - the position on the screen would be the same).


I can't give you the code as I don't have Ace in front of me.


Would you ALWAYS want it to choose randomly? Is it only in certain areas? Is there anything that would cause a particular enemy to be more likely (or less likely) to be chosen?
 

Mouser

Veteran
Veteran
Joined
Aug 19, 2012
Messages
1,245
Reaction score
264
First Language
English
Primarily Uses
Actually, yes, you could do it via scripts, and it would be pretty easy (Mouser, just find the line that creates the enemy in the troop, and pass a random number in the appropriate range instead of the id specified in the troop setup - the position on the screen would be the same).
Good to know - although you'd still need the battlers to be pretty close to the same size and shape though or I would think the picture would start to look 'off'. Great for thinks like different element flans and stuff like that though.
 

nickfitzgerald3

Villager
Member
Joined
May 5, 2014
Messages
24
Reaction score
3
First Language
english
Primarily Uses
Actually, yes, you could do it via scripts, and it would be pretty easy (Mouser, just find the line that creates the enemy in the troop, and pass a random number in the appropriate range instead of the id specified in the troop setup - the position on the screen would be the same).

I can't give you the code as I don't have Ace in front of me.

Would you ALWAYS want it to choose randomly? Is it only in certain areas? Is there anything that would cause a particular enemy to be more likely (or less likely) to be chosen?
It would only be in certain areas, no rush on it just whenever you happen to be in front of ace I have other things in my game to work on for now :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top