Randomizing enemy stats

Wondering if there's a way to randomize enemy parameters at the beginning of a battle.
Have a troop event that adds a random value into each stat based on the value of another variable - which determines how far int he game you are. done. 🙂

The script code within the aforementioned event might look like this:

Code:
var id  = 0;var val = 50; $gameTroop.members(1).addParam(id, val);
Have a troop event that adds a random value into each stat based on the value of another variable - which determines how far int he game you are. done. 🙂

The script code within the aforementioned event might look like this:

var id = 0;var val = 50; $gameTroop.members(1).addParam(id, val);
So my understanding of this would be:

  • Var id = 0; 
  1. Will be the RNG variable?
  2. How would this work if I want multiple stats randomized but not increased by the same amount?
  • Var val = 50;
  1. It can only go up to 50?
  2. I'm assuming it can be a range starting from a negative number, right? If so, then I cut a few stats down so I don't have enemies that are too strong?
The id variable would be for the id of the stat, 0 is mhp, 1 is mmp, 2 is atk and so on.. The value of 50, is purely a randomized value I chose for this example, it could be higher, or lower (even negative, yes)
Thank you Dark Dekita, but I get Undefined is not an option.
I dont have Mv opened or anything atm, working on another project entirely. Its likely a problem with how the troop member is selected, cause i wasnt sure of that syntax.
Let me know when you get around to it.
Have a troop event that adds a random value into each stat based on the value of another variable - which determines how far int he game you are. done. 🙂

The script code within the aforementioned event might look like this:

var id = 0;var val = 50; $gameTroop.members(1).addParam(id, val);
var id = Math.randomInt(X)

var val = Math.randomInt(50)
Still didn't do anything.

var id = Math.randomInt(X)

var val = Math.randomInt(50)
Still didn't do anything.
Sorry I just correct the random value

I didn't tried his solution

I will figured the solution after the work 😉

EDIT: 

var id = Math.randomInt(X)

var val = Math.randomInt(Y)

$gameTroop.members()[id].addState(val);

X for enemies number

Y for How many state you have
Sorry I just correct the random value

I didn't tried his solution

I will figured the solution after the work 😉

EDIT: 

var id = Math.randomInt(X)

var val = Math.randomInt(Y)

$gameTroop.members()[id].addState(val);

X for enemies number

Y for How many state you have
rJust adds status effects
r

Just adds status effects
sorry my mistake

$gameTroop.members()[id].addParam(0, val);

0 is for maxhp
sorry my mistake

$gameTroop.members()[id].addParam(0, val);

0 is for maxhp
I'm sorry, but could you explain this as in what I modify for each enemy and stat?
I'm sorry, but could you explain this as in what I modify for each enemy and stat?
before that there is two questions

1- which parameters you want randomize?

2- you want it for all enemies or random enemy or single enemy?
before that there is two questions

1- which parameters you want randomize?

2- you want it for all enemies or random enemy or single enemy?
For all enemies and parameters.
Edit:

Deleted post. Example I went with did not align up sufficiently with what OP was looking for.
SpellcraftQuill

Just to clarify, as this may fall in line with something I'd like to know as well, you're looking to have ever so slight differences in your everyday monsters.

Like a battle with three slimes. But each slime may, or may not, have a tiny bit difference in their stats?

So, would there be a way to put in a troop event a way to increase or decrease those stats by a percentage or establish a range?

As an example:

HP 100

I want each time the player battles the slime, for the slime to have between 80 and 120 max HP.

Do this same concept but for other stats as well.

Edit: If this is not the case, I will double back and remove this post (so there isn't a risk of it being hijacked).
I would rather add random numbers than a percentage as lower numbers won't result to much while higher numbers increase exponentially. Each enemy will have randomized stats. 
No problemo. I got the wrong idea. Maybe you could post a mockup of an enemies stats. And how you would like them to be affected?

I was under the impression that you wanted a way to change them for positive or negative but remaining close enough to the original stat so as to not cause to much flux. (20% + or -) such as in the example with the HP (100 HP as the base stat. In battle it would be between 80 and 120 due to the 20% variance).

I'll update my comment as I mentioned so that they can focus on what you're trying to achieve.
try this in troop event

for (var i = 0; i < $gameTroop.members().length; i++) {

var val = Math.randomInt(X);

var id = Math.randomInt(8);

$gameTroop.members().addParam(id, val);

}

 

X for the maximum number you want add
try this in troop event

for (var i = 0; i < $gameTroop.members().length; i++) {

var val = Math.randomInt(X);

var id = Math.randomInt(8);

$gameTroop.members().addParam(id, val);

}

 

X for the maximum number you want add
Ah perfect. If I may make one more request though, it's that I know how to start at 2 for attack. What if I wanted the HP range to be higher? var "i" would = 0, but where do I go from there?

Original thread: https://forums.rpgmakerweb.com/threads/randomizing-enemy-stats.52375/