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

TenebrisCrow

Regular
Regular
Joined
Oct 19, 2015
Messages
119
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
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

Regular
Regular
Joined
Oct 19, 2015
Messages
119
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
First Language
English
Primarily Uses
RMMV
Instead of describing it all, please post screenshots of the events.
 

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,961
Reaction score
11,897
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

Regular
Regular
Joined
Mar 5, 2013
Messages
39,961
Reaction score
11,897
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

Regular
Regular
Joined
Feb 28, 2013
Messages
696
Reaction score
431
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

Regular
Regular
Joined
Oct 19, 2015
Messages
119
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
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
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,989
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
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
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,989
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
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
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,989
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
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
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,989
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
Regular
Joined
Jul 2, 2014
Messages
12,786
Reaction score
11,433
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
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,989
First Language
English
Primarily Uses
RMMZ
Ah, no, I'm with you now. I missed that part.
 

Latest Threads

Latest Posts

Latest Profile Posts

Thanks to my last two calendar days, the goddess can now join your heroes' party and whack your enemies with the power of love!
1702314770604.png
How are you gonna use all those new resources from the calendars?
I hate driving in games. Imagine your character profile being an exceptional individual, yet when they drive, it makes them look dumb.
The flaming skeleton visited me in my dreams again. He demands the game be finished soon. I don't like the flaming skeleton. He took my cranberry juice. He doesnt even have a stomach it just spilled all over the floor.
My Game Jam entry is a bunch of mini games wrapped within an epic story that will rival the deepest plots of the earliest CRPGs! As a small spoiler, here is one example of a game you will be able to play. Anyone want to try Brat, Krampus, Santa?
so I had two plugin that essentially overwrite each other depending on where they are in the list. so I had to edit what was overwriting one into the other and now they both work. I REALLY need to sit down and just learn JavaScript. I hate that I know just enough to know I don't know NEARLY enough lol.

Forum statistics

Threads
136,918
Messages
1,271,459
Members
180,708
Latest member
xona
Top