[SOLVED] Disable Parameter Curve/Built in Parameter level up system

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Hello all.

I'm looking to use Yanfly's Level Up Growth Effects plugin to give players stats based on a specific formula that involves a certain degree of randomization, using variables that, at specific thresholds, will give the player different amounts of a stat on level up. Basically, it's going to look something like this (not actual JS code):

On level-up:
1. MHPlevelupvariable +rand.(5-40)
2. rand. (1-100) + MHPlevelupvariable
3. if (result = 0-99), MHP +0, MHPlevelupvariable stays at value given at step 1
4. else if (result = 100-199), MHP+1, reset MHPlevelupvariable to 0
5. else if (result = 200+), MHP+2, reset MHPlevelupvariable to 0

It seems fairly straight forward enough to enable this custom code using Yanfly's plugin (the obvious issues being that I need to actually learn the proper JS tags and how to set these specific variables for each actor), however it isn't clear in the plugin's help settings whether this will completely overwrite the game's parameter gain on level up, or if it adds to the gain. I want to completely ignore the engine's built-in stat gain on levels and use only this formula.

Can anyone with experience with this plugin give me advice on how best to work this out? It's very frustrating that you can't disable the exp/stat curves in this engine, or at least make it so that the amounts provided are static/randomized to a certain degree. I have the idea and a basic understanding of how to make part of it work, but it won't work at all if it's being interfered with by the game's built-in system.

Edit 1: Can confirm, this plugin works WITH the engine's default curve. I need to figure out a way to disable this entirely, or possibly alter my formula so that it takes into account the stats gained by the engine's built-in system and removes it.

Edit 2: Figured out how to disable the parameters entirely; if you set both the lvl 1 and level 99 parameters to 1, the game will not add any stat per level. So that issue is fixed.

However, as I know very little about javascript, I'm having issues getting the following code to work, added in via notetags as explained in Yanfly's Level Up Growth Effects:

<Custom Level Up Effect>
var randomnumber = console.log(Math.round(Math.random() * 100))
if (randomnumber >= 29) {
$gameActors.actor(1).addParam(0, 0);
} else {
if ((randomnumber < 30) && (randomnumber >= 59)) {
$gameActors.actor(1).addParam(0, 1);
} else {
$gameActors.actor(1).addParam(0, 2);
}
</Custom Level Up Effect>

I'm still trying to figure out how to set a permanent variable for the example I provided above (MHPlevelupvariable), but at the moment if I can just figure out how to give a random stat per level without it for now as a proof of concept it'd still be progress. I know the logic of the idea is sound, I'm just not at all certain how to actually successfully do so. Really need some help on this one.

Edit 3: So I've managed to strip it down for testing purposes. This works:

<Custom Level Up Effect>
$gameActors.actor(1).addParam(0, 1);
</Custom Level Up Effect>

The issue lie in the fact that I need it to be different based on the random number that is generated at the start of the code. Still researching to see if I can't figure it out on my own.

Edit 4: Final update for tonight, I don't think there's much more I can do on this for now. I've managed to get the code working in a way that it rolls a random number, then based on what that number is gives either 0, 1 or 2 stats (noticed that for some reason, spoiler kills indentation; please note that everything is properly indented on my end):

//HP//
<Custom Level Up Effect>
var rnum = Math.floor(Math.random() * 100);
if (rnum <= 29) {
$gameActors.actor(1).addParam(0, 0);
} else {
if (rnum >= 30 && rnum <= 69) {
$gameActors.actor(1).addParam(0, 1);
} else {
$gameActors.actor(1).addParam(0, 2);
}
}
</Custom Level Up Effect>

The only step that is left is to figure out how to set a hidden variable for this stat (MHP in this case), that is tied to one actor, as I need to be able to have the number be different for every single levelable stat for each character, and then add that into the above code to be called, compared and reset within the code. If anyone can give assistance on this it would be greatly appreciated.
 
Last edited:

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
70
Reaction score
36
First Language
English
Primarily Uses
RMMV
Put this into your class notebox. I copied the steps you wanted from your initial post and it should work how it does there. If anything doesn't work right or you want something different just let me know, I'll get to it when I'm back from work.

Code:
<Custom Level Up Effect>
actor._hpLevelMod = actor._hpLevelMod || 0;
actor._hpLevelMod += Math.floor(Math.random() * 134 + 6);

if(actor._hpLevelMod > 99 && actor._hpLevelMod < 200){
    actor.addParam(0,1);
    actor._hpLevelMod  = 0;
  } else if(actor._hpLevelMod >= 200){
   actor.addParam(0,2);
   actor._hpLevelMod = 0;
}

</Custom Level Up Effect>
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,778
Reaction score
5,206
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Thank you. I wasn't sure where this needed to go since my original question wasn't just plugin-related, but how to disable an engine mechanic as well. I'll try to keep this in mind in the future.

This almost works, though I have a few concerns that I'm hoping you might be able to answer.

1. The _hpLevelMod needs to be a permanent variable/parameter that can store a number and be referenced at any other point in the game. The number should be free to change of course, but the variable itself needs to keep the same number between level ups. (So, based on what I outlined, if the player gets 1 or 2 stats, it is reset to 0 and will be 0 at the next level up, however if they get no stats the figure will keep the random 5-40 amount that was rolled into the first step to increase the odds of a better stat gain on next level-up). If that is how your code functions, then it's fine.

2. The above leads me into my second issue. The two random number generations can't be combined like that. It needs to be "generate random 5-40 > add to _hpLevelMod > generate random 1-100 > add _hpLevelMod and 2nd random number > result = 0/1/2 points". The purpose of the first random number, like I stated previously, is to be a figure that gets added to the mod to improve chances of a better stat next time. Combining them together like this doesn't seem like it has this result of making the chances of higher stats better.

In my testing (going from lvl 1 to lvl 99 via battles), out of the 98 battles I only gained 2 HP on level up 3 times, gained 1 hp 48 times, and gained 0 44 times (for a total of 55 HP, starting at 1 HP for testing). As you can imagine, the chance of 2 is much too low, and the chance of 0 is much too high, which is why the first random number generation is separate from the second 1-100 and does not get erased on 0. While this could be solved by lowering the thresholds for when a stat is gained, it's somewhat important that I stick to the design outlined in the original post.

I don't have a lot of time to work on it today due to social obligations, but I have an idea as to how I might figure it out. Any assistance you can give in the meantime would be appreciated, and I'll let you know what, if anything, I'm able to figure out on my own. Greatly appreciate the assistance thus far, your if/elseif block is much more refined than mine was.
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
70
Reaction score
36
First Language
English
Primarily Uses
RMMV
In my testing (going from lvl 1 to lvl 99 via battles), out of the 98 battles I only gained 2 HP on level up 3 times, gained 1 hp 48 times, and gained 0 44 times (for a total of 55 HP, starting at 1 HP for testing). As you can imagine, the chance of 2 is much too low, and the chance of 0 is much too high, which is why the first random number generation is separate from the second 1-100 and does not get erased on 0. While this could be solved by lowering the thresholds for when a stat is gained, it's somewhat important that I stick to the design outlined in the original post.
That's on your numbers, not mine. In fact, erasing the second number actually lowers your odds of getting 2 in the long run and increases your odds of not getting any HP on level up. You'd be better off keeping the second number and adjusting your parameters as needed to get the stat gain you want. Hell, you could even force an HP gain after so many 0 HP gain levels

1. The _hpLevelMod needs to be a permanent variable/parameter that can store a number and be referenced at any other point in the game. The number should be free to change of course, but the variable itself needs to keep the same number between level ups. (So, based on what I outlined, if the player gets 1 or 2 stats, it is reset to 0 and will be 0 at the next level up, however if they get no stats the figure will keep the random 5-40 amount that was rolled into the first step to increase the odds of a better stat gain on next level-up). If that is how your code functions, then it's fine.
It is accessible, at least once a character's level uped once. You can reference it with $gameActors.actor(x)._hpLevelMod once they've gained a level, or initialize it in a startup script and reference it whenever.
 
Last edited:

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
It is accessible, at least once a character's level uped once. You can reference it with $gameActors.actor(x)._hpLevelMod once they've gained a level, or initialize it in a startup script and reference it whenever.
Is there a way to set up an event where, on activation, it outputs in a message what the value of $gameActors.actor(x)._hpLevelMod is? It would help me troubleshoot the values better if I could see what exactly this variable is after each level up.
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
70
Reaction score
36
First Language
English
Primarily Uses
RMMV
Put this in a script
Code:
console.log($gameActors.actor(1)._hpLevelMod);
then press F8 to see it

Alternatively, you could use
Code:
$gameVariables.set(1,$gameActors.get(1)._hpLevelMod);
to set a variable to Actor 1's hpLevelMod value
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Is there a way to set up an event where, on activation, it outputs in a message what the value of $gameActors.actor(x)._hpLevelMod is? It would help me troubleshoot the values better if I could see what exactly this variable is after each level up.
If you press F8, it opens the game console. You can enter any valid JavaScript in there to evaluate it; if you enter $gameActors.actor(id of an actor)._hpLevelMod before and after levelling, it'll show you what the value is.
 

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Yep, that's exactly what I needed, thank you both.

Definitely seems to be working as intended, but there does appear to be an issue with the numbers, which is unfortunate. We can probably consider this thread solved after this question:

(Math.random() * 134 + 6) is set up to be random (5-40) + random (1-100). If, say, I wanted to do random (15-50), would I just change it to be (Math.random() * 144 + 16)? It makes sense that I would just add the extra 10 to each, but I just want to make sure I'm changing the numbers correctly.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
Yep, that's exactly what I needed, thank you both.

Definitely seems to be working as intended, but there does appear to be an issue with the numbers, which is unfortunate. We can probably consider this thread solved after this question:

(Math.random() * 134 + 6) is set up to be random (5-40) + random (1-100). If, say, I wanted to do random (15-50), would I just change it to be (Math.random() * 144 + 16)? It makes sense that I would just add the extra 10 to each, but I just want to make sure I'm changing the numbers correctly.
Is this a bad time to tell you that MV's rpg_core.js added a Math.randomInt() function so that you don't have to faff about with multiplying the return value from random()?
 

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Is this a bad time to tell you that MV's rpg_core.js added a Math.randomInt() function so that you don't have to faff about with multiplying the return value from random()?
I actually wasn't 100% sure about that, though I did look into it. That's part of what I was considering to begin with, generating that random between x-y and then adding the random 1-100 ontop of it and that being what the result was, but based on what rainyday said the end result would be the same, so I didn't delve into it too much.

I would assume at that point that an additional variable would need to be created? Something akin to:

hpLevelrandom += _hpLevelMod * Math.floor(math.random() * 10), where in this case the _hpLevelMod would previously have Math.randomInt(5, 40) added to it in the script?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
What exactly are you trying to do with the random values?
 

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Taken from the first post:

On level-up:
1. MHPlevelupvariable +rand.(5-40)
2. rand. (1-100) + MHPlevelupvariable
3. if (result = 0-99), MHP +0, MHPlevelupvariable stays at value given at step 1
4. else if (result = 100-199), MHP+1, reset MHPlevelupvariable to 0
5. else if (result = 200+), MHP+2, reset MHPlevelupvariable to 0

This is the system I'm trying to emulate. The purpose of the first random number is to be a figure that gets added to the mod to improve chances of a better stat next time. rainyday's formula appears to emulate this properly on the surface, but I'm willing to explore other options if they would function better.
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
70
Reaction score
36
First Language
English
Primarily Uses
RMMV
Is this a bad time to tell you that MV's rpg_core.js added a Math.randomInt() function so that you don't have to faff about with multiplying the return value from random()?
lol how did I not know this.

This is the system I'm trying to emulate. The purpose of the first random number is to be a figure that gets added to the mod to improve chances of a better stat next time. rainyday's formula appears to emulate this properly on the surface, but I'm willing to explore other options if they would function better.
Like I said, resetting the value to the initial random value of 5-40 does the opposite of what you intend, and makes an empty level or a level where you gain 1 HP more common in the long run. If you're insistent on having it that way though, use this
Code:
<Custom Level Up Effect>
actor._hpLevelMod = actor._hpLevelMod || 0;
actor._hpLevelMod += Math.randomInt(36) + 5;
var tempMod = Math.randomInt(100) + 1;

if(actor._hpLevelMod + tempMod > 99 && actor._hpLevelMod + tempMod < 200){
    actor.addParam(0,1);
    actor._hpLevelMod  = 0;
  } else if(actor._hpLevelMod + tempMod >= 200){
   actor.addParam(0,2);
   actor._hpLevelMod = 0;
}

</Custom Level Up Effect>
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
When you add instance variables like that do they persist on saves rainyday? I can't remember.
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
70
Reaction score
36
First Language
English
Primarily Uses
RMMV
Yeah they're saved by saves, so he can save, quit, then reload and still be able to reference them.
 

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Like I said, resetting the value to the initial random value of 5-40 does the opposite of what you intend, and makes an empty level or a level where you gain 1 HP more common in the long run. If you're insistent on having it that way though, use this
Currently testing this out. Is there a way to output var temp's output in the console log for monitoring purposes?

Also, I apologize if I seem too stubborn, I'm honestly just trying to learn and see what would work best, not meaning to sound too insistent that it be "this way or no way".
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
70
Reaction score
36
First Language
English
Primarily Uses
RMMV
console.log(input) writes to the console. So you could use something like
Code:
console.log("The Temp Value is " + tempMod + ", and " + actor.name() + "'s hpMod is " + actor._hpLevelMod);
to print both.
 

SirDhyne

Villager
Member
Joined
Jun 21, 2020
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Everything appears to be working as intended, though I will most likely (on the balancing side of things) lower the threshold needed for the best stat gain on level up. I also needed to add in a second 'else' statement, as I forgot the stat spread for HP needs to be 1-3, not 0-2 (be a pretty big kick in the pants to get no HP up on your first level, huh?).

The final code is as follows, for anyone interested in emulating this in the future:

JavaScript:
<Custom Level Up Effect>
actor._hpLevelMod = actor._hpLevelMod || 0;
actor._hpLevelMod += Math.randomInt(36) + 5;
var tempMod = Math.randomInt(100) + 1;

if(actor._hpLevelMod + tempMod > 99 && actor._hpLevelMod + tempMod < 200){
    actor.addParam(0,2);
    actor._hpLevelMod  = 0;
    } else if(actor._hpLevelMod + tempMod >= 200){
        actor.addParam(0,3);
        actor._hpLevelMod = 0;
    } else {
        actor.addParam(0,1);
}

</Custom Level Up Effect>

Many thanks to both rainyday and Trihan, it would've taken me a lot longer to figure this out entirely on my own and my code would have looked extremely janky. I deeply appreciate the assistance. This issue is solved.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,956
First Language
English
Primarily Uses
RMMV
I didn't help massively with this one but I'll take the thanks! :D
 

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

Latest Threads

Latest Profile Posts

I made some sideview closets for MV!
You can find them in my MV resource thread.
People1.png & SF_People1.png added!!!!

Adventurer:
"Why your body looks like a bird?"

Stranger:
"Because I'm harpy"

Adventurer:
"Clap along if you feel like a room without a roof"

*Both dancing to Pharrell Williams song*
Stream will be live shortly with a make-up session of the Interactive Text Adventure! Feel free to drop by!

Forum statistics

Threads
105,508
Messages
1,014,285
Members
137,183
Latest member
thecatinaction
Top