[RMVX ACE] HOW CAN I RANDOMIZE?

Posts

Pages: 1
I use a script to divide enemies into two groups.
One group is in a front row and the other group is in a back row.
The script is simple but I don't know how randomly move enemies to front rows and back rows.
Please tell me if you can make events or scripts to solve the problem.

Mr Trivel's Simple Battle Rows http://pastebin.com/MHG0HuZL
Marrend
Guardian of the Description Thread
21806
The only piece of code that I see that even mentions enemies is...

# )-------------------------(
# )--  Class: Game_Enemy  --(
# )-------------------------(
class Game_Enemy < Game_Battler
 
  # )---------------------------------(
  # )--  Alias To: initialize       --(
  # )---------------------------------(
  alias mrts_initialize initialize
  def initialize(*args)
    mrts_initialize(*args)
    @battle_row = enemy.note =~ /<backrow>/i ? 1 : 0
  end
end


...this part. The line I'm looking at is...

@battle_row = enemy.note =~ /<backrow>/i ? 1 : 0


...this one. I'm aware that this is something of an if/then statement, but, I'm not quite familiar with this syntax. However, my guess is that it looks at the "Notes" field of the enemy to see if "<backrow>" is written there. If it is, return 1. If it's not, return 0.

So, to make this random... er, I'm not quite sure!
Deltree
doesn't live here anymore
4556
The question mark is a ternary operator, and is pretty much exactly like you said. If it's true (in this case, if the note contains <backrow>), it equates to 1; if it's false, 0. I'm guessing 1 is the flag for the back row.

I'm not familiar with the script, but it seems like replacing the whole line with @battle_row = rand(2) will always force it to either row 0 or row 1 randomly. That may not be the behavior you want for instances such as boss fights, where you may want to force the enemy to a specific row. In that case, I'd replace the line with this:


@battle_row = enemy.note =~ /<randomrow>/i ? rand(2) : enemy.note =~ /<backrow>/i ? 1 : 0


Then, you can add <randomrow> to the note and the enemy will pick a random row. If it's not in the note, then it will check if <backrow> exists in the note. If neither exists, it will stay in the front row.

Disclaimer: I haven't tested this since I'm on a computer without RM, but it seems straightforward.
The problem is solved by Deltree's solution.
Thank you for your answers!
You seem to have a lot of knowledge about scripts and I want to ask a question.
There's no visual clue if an enemy is in a front row or in a back row.
So I want to put icons to enemies in a front row.
I asked the creator of the script about this and he answered

Each battler (enemy and ally) has battle_row variable, which hold it's row. 0 is Front and 1 is back.
So something like this would check if first member of the party is in front row

if $game_party.members.battle_row == 0
# 1st member is in front. Do stuff
end

I still don't know how to put icons to enemies in a front row...
Please tell if you know how to add visual clues to enemies in a front row.
Marrend
Guardian of the Description Thread
21806
Probably the easiest way to perform a visual cue is to manipulate the enemies in the Troop tab to give the appearance of who's in front, and who's in back. Though, this tactic would, essentially, involve generating two copies of various enemies. Though, in the interest of keeping things interesting, perhaps certain enemies have different abilities/stats when they are in the back row as opposed to the front?
Deltree
doesn't live here anymore
4556
Glad it helped!

You could probably also scale the enemy battler graphic by a certain percentage based on the row. So, enemy battlers in the front row can have normal 100% scale, and the ones in the back row can have something like 80% scale. This is assuming the battles are from the head-on perspective, of course.

Someone more capable would have to answer how to do that exactly. I'm on a laptop all weekend and can't try it for myself, unfortunately.
I'm satisfied that I successfully randomize the system.
Thank you for your advices!
Pages: 1