Increase a parameter of an enemy by percent using a variable?

TenebrisCrow

Veteran
Veteran
Joined
Oct 19, 2015
Messages
115
Reaction score
13
First Language
English
Primarily Uses
RMMZ
I want an enemy that every time you fight him all of his stats increase by 20% after every fight.

I want to do this using variables which should be fine. I just can't work out if there's a way to set the parameter to go up by a percent using a variable and it seems the in built limit in the traits area is only 1000% which I want it to go up almost forever.

So basically for example:
First Battle:
Enemy HP: 100

Second Battle:
Enemy HP: 120

Does anyone have any ways to do this?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Off the top of my head, you'll need to use a plugin.

Make a state, and from VisuStella Core give it the notetag:
Code:
<JS MaxHP Plus: user.mhp * (.2 * $gameVariables.value(ID))>
where ID is the ID of the variable you want to use (no leading 0s).

Make sure you initialize that variable to 0 at the start of the game.

Then you just use a turn 0 troop event to give that enemy that state and restore its HP, then after the fight increment the variable.
 

TenebrisCrow

Veteran
Veteran
Joined
Oct 19, 2015
Messages
115
Reaction score
13
First Language
English
Primarily Uses
RMMZ
Off the top of my head, you'll need to use a plugin.

Make a state, and from VisuStella Core give it the notetag:
Code:
<JS MaxHP Plus: user.mhp * (.2 * $gameVariables.value(ID))>
where ID is the ID of the variable you want to use (no leading 0s).

Make sure you initialize that variable to 0 at the start of the game.

Then you just use a turn 0 troop event to give that enemy that state and restore its HP, then after the fight increment the variable.

It isn't working however I might be missing something, so:

Made a state (Increase Stats), added the the code to NoteTag I changed the ID to 1 so
Code:
<JS MaxHP Plus: user.mhp * (.2 * $gameVariables.value(1))>

I made a troop and applied the state (Increase Stats) to all, and then recovered the troop.

I set an event so I could input the number for variable 1.

While in game input it to 50.

I enter the battle however the stats remain the same as the default monster.


I am probably missing something, but I've had a look over it about five times and I can't seem to work it out.

You have any idea what I'm missing?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Instead of describing it all, please post screenshots of the events.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,343
Reaction score
10,194
First Language
German
Primarily Uses
RMMV
do you have the plugin installed correctly?
you'll need to use a plugin.

Make a state, and from VisuStella Core give it the notetag:
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,343
Reaction score
10,194
First Language
German
Primarily Uses
RMMV
how do you start the battle? battletest, new game, continuing savedfile?
how do you check the enemy HP value?

please give the state an icon so that you can check if the state is on the enemy until the problem is solved
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
601
Reaction score
334
First Language
English
Primarily Uses
RMMZ
One way you can get a 20% increase every encounter:
Using VS Battle core.
Add note to enemy unit:

Code:
<JS Post-Start Battle>
$gameVariables.setValue(15, $gameVariables.value(15) + 1);
user.addParam(0, Math.round(user.mhp * 0.2) * $gameVariables.value(15));
user.gainHp(Math.round(user.mhp * 0.2) * $gameVariables.value(15));
</JS Post-Start Battle>

EDIT: adjusted to add battle variable multiplier.
20% of ORIGINAL MHP, added to MHP x number of battles.
 
Last edited:

TenebrisCrow

Veteran
Veteran
Joined
Oct 19, 2015
Messages
115
Reaction score
13
First Language
English
Primarily Uses
RMMZ
One way you can get a 20% increase every encounter:
Using VS Battle core.
Add note to enemy unit:

Code:
<JS Post-Start Battle>
$gameVariables.setValue(15, $gameVariables.value(15) + 1);
user.addParam(0, Math.round(user.mhp * 0.2) * $gameVariables.value(15));
user.gainHp(Math.round(user.mhp * 0.2) * $gameVariables.value(15));
</JS Post-Start Battle>

EDIT: adjusted to add battle variable multiplier.
20% of ORIGINAL MHP, added to MHP x number of battles.

This was actually perfect. Any idea why when I add attack nothing happens? The MaxHP still continues to work but attack doesn't change, it just remains at default. I feel I must be missing something obvious? Here is the code:

Code:
<JS Post-Start Battle>
user.addParam(0, Math.round(user.mhp * 0.2) * $gameVariables.value(15));
user.addParam(0, Math.round(user.atk * 0.2) * $gameVariables.value(15));
</JS Post-Start Battle>

Edit: I worked it out! Is there any way I am able to do the same with the experience rate? Increasing it by 20% each time.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Is there any way I am able to do the same with the experience rate?
The enemy's experience value is referenced in $dataEnemies[user.enemyId()].exp

So $dataEnemies[user.enemyId()].exp+=$dataEnemies[user.enemyId()].exp*.2*$gameVariables.value(15);
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
The enemy's experience value is referenced in $dataEnemies[user.enemyId()].exp

So $dataEnemies[user.enemyId()].exp*=.2*$gameVariables.value(15);
A couple of notes: Multiplying by 0.2 will cause it to be 20% of its original value, not 120% as intended.

Also changes to data aren't stored in saves, so if you fought the enemy, fought the enemy again, saved, loaded and fought them a third time, you're going to end up with a different value for the stats than you would if you hadn't closed and reopened the game due to the exp value resetting on load.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
A couple of notes: Multiplying by 0.2 will cause it to be 20% of its original value, not 120% as intended.
You could just provide the corrected line when I type garbage because I'm rushing :stickytongue:

Code:
$dataEnemies[user.enemyId()].exp+=$dataEnemies[user.enemyId()].exp*.2*$gameVariables.value(15);

Also changes to data aren't stored in saves...
I don't think that's relevant - the OP is incrementing the game variable and performing this calculation at the beginning of every fight. So they actually want the value to reset (which means they probably want to reset it at the end of the fight, in case it's fought more than once without the playing saving and quitting).

I'm not sure of an awesome way to do that beyond rigging up an autorun on the map where the enemy appears that sets the original exp value after every fight.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
You could just provide the corrected line when I type garbage because I'm rushing :stickytongue:

Code:
$dataEnemies[user.enemyId()].exp+=$dataEnemies[user.enemyId()].exp*.2*$gameVariables.value(15);


I don't think that's relevant - the OP is incrementing the game variable and performing this calculation at the beginning of every fight. So they actually want the value to reset (which means they probably want to reset it at the end of the fight, in case it's fought more than once without the playing saving and quitting).

I'm not sure of an awesome way to do that beyond rigging up an autorun on the map where the enemy appears that sets the original exp value after every fight.
But then it's not increasing by 20% every fight. I figured OP wanted it to ramp up multiplicatively.

And okay. XD

JavaScript:
let exp = $dataEnemies[user.enemyId()].exp;
exp += exp * 0.2 * $gameVariables.value(15);
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
But then it's not increasing by 20% every fight. I figured OP wanted it to ramp up multiplicatively.
Yes it is? It's multiplying .2 * the variable 15, which is being incremented each fight per the scripts higher in this thread. How is your code not identical to mine, except you created a variable?

I'm confused by your correction.
Code:
exp += exp * 0.2 * $gameVariables.value(15);
Code:
$dataEnemies[user.enemyId()].exp+=$dataEnemies[user.enemyId()].exp*.2*$gameVariables.value(15);
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
Yes it is? It's multiplying .2 * the variable 15, which is being incremented each fight per the scripts higher in this thread. How is your code not identical to mine, except you created a variable?

I'm confused by your correction.
What you originally had was

$dataEnemies[user.enemyId()].exp*=.2*$gameVariables.value(15);

That was what I was correcting; if you changed it after the original comment I didn't see it.

And no, it doesn't quite work the same.

Let's say the enemy gives 200 exp. After the first fight, it's increased by 20% (200 * 0.2 = 40), so becomes 240. After the second, it increases by 20% again (240 * 0.2 = 48) and is now 288. The third time, (288 * 0.2 = 57.6, rounded to 58) and is now 346.

But if you reset that every time...first fight adds 20% (40), for 240. Second fight adds 40% (80), for 280. Third fight adds 60% (120), for 320. Every time you fight, the gap will get bigger.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
What you originally had was...if you changed it after the original comment I didn't see it.
I did correct it after your first post - look at what you quoted in post #14 :guffaw:

But if you reset that every time...first fight adds 40, for 240. Second fight adds 40, for 280. Third fight adds 40, for 320. Every time you fight, the gap will get bigger.
Going off of the OP's prior posts and how they're treating the parameters, I'm assuming this is what they want. 20% of the original value each time.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
I did correct it after your first post - look at what you quoted in post #14 :guffaw:


Going off of the OP's prior posts and how they're treating the parameters, I'm assuming this is what they want. 20% of the original value each time.
Then the way you're doing it won't work, because you'll be taking the current exp value and then adding an increasingly higher percentage to it. The more you fight without saving/loading, the larger that value will become. It won't reset until you close the game and reopen it.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Then the way you're doing it won't work, because you'll be taking the current exp value and then adding an increasingly higher percentage to it. The more you fight without saving/loading, the larger that value will become. It won't reset until you close the game and reopen it.
Which is why I said in post #13 they should create an event that would reset the exp value after each fight...

Am I being stupid and missing it somehow?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
Ah, no, I'm with you now. I missed that part.
 

Latest Threads

Latest Posts

Latest Profile Posts

KDS
Hey guys! Iam currently updating my free digital art shop , let me know if you need anything done :) https://forums.rpgmakerweb.com/index.php?threads/kds-free-open-digital-art-shop.17097/
Hello! I’d like to ask where is a good place to start logging about my game dev progress as production of my game goes forth
In one of our campus classrooms was a bag full of stuff people forgot there... my bag. That I forgot there xD
You know your room is too tiny for how much stuff you have when it gives you literal insomnia. I just cleared a bunch of stuff out and man it feels good!
1670381555475.png
Meet the Kernel. You encounter him in cyberspace. He's important!

Forum statistics

Threads
127,098
Messages
1,183,961
Members
167,026
Latest member
silverbell
Top