Negative parameters, how to avoid it ?

Did you know there's a hidden negative value for each parameters (attack, HP, agility and so on) ?

How to lock a parameter to NOT go below zero ? Note that it will stay at zero in game despite the negative value (except for max HP which will stay at 1).

Example for a better explanation : let's say I want to create a poisonous consumable item that lowers your agility parameter by 5, but the character has only 4 agility. In the menu, it will be at zero, but in the engine it will be at -1. Afterwards, the character finds a new consumable item that gives you +1 agility. If the player consumes it, the stat will stay at 0 in the menu so the player will think it didn't work.

Don't know if I'm clear enough.


Note : armors have the same bias for the defense stat. If defense of the character is at -100 in the game engine, putting on a +100 defense armor will NOT up defense, it will stay at zero.
let's say I want to create a poisonous consumable item that lowers your agility parameter by 5, but the character has only 4 agility. In the menu, it will be at zero, but in the engine it will be at -1.
That's a backwards way to think about it. It's not -1 "in the engine" - it's 0. Your menu is displaying the same number that gets used in all other places in the game.
Afterwards, the character finds a new consumable item that gives you +1 agility. If the player consumes it, the stat will stay at 0 in the menu so the player will think it didn't work.
So what do you want to happen? Are you saying that debuffs (the poisonous consumable) actually change their value depending on what the player's current parameters are?

You would have to use something like an Item Core or a State plugin with JavaScript attached to the consumable so that the negative value it applies is less than the parameter's value, and take into consideration any current negative value. Otherwise you can always get a situation like this, where the cumulative value of a few debuffs are negative values, so just one buff might not start to counteract them.

The function that gives you a parameter's value is:
Code:
Game_BattlerBase.prototype.paramBasePlus = function(paramId) {
    return Math.max(0, this.paramBase(paramId) + this.paramPlus(paramId));
};

Notice how paramPlus() is one thing - the engine isn't tracking individual sources that affect a parameter.

That is, there's no internal list saying "The poison is taking away 5, this bottle of soda gives 2," etc. It's just one number that modifies the parameter.

The other way to approach this is to not specify values, but to use the engine's built in debuff/buff traits. Those are hard-coded to stack and counter each other.
Did you know there's a hidden negative value for each parameters (attack, HP, agility and so on) ?

How to lock a parameter to NOT go below zero ? Note that it will stay at zero in game despite the negative value (except for max HP which will stay at 1).

Example for a better explanation : let's say I want to create a poisonous consumable item that lowers your agility parameter by 5, but the character has only 4 agility. In the menu, it will be at zero, but in the engine it will be at -1. Afterwards, the character finds a new consumable item that gives you +1 agility. If the player consumes it, the stat will stay at 0 in the menu so the player will think it didn't work.

Don't know if I'm clear enough.


Note : armors have the same bias for the defense stat. If defense of the character is at -100 in the game engine, putting on a +100 defense armor will NOT up defense, it will stay at zero.

You could make the item that lowers your agility only lower it until it hits zero, by having the item call a common event with a conditional branch. There are a couple ways you could do this. The way I would do it is to store the character's agility in a variable, and then just do a single check if it's greater than or equal to 5; if it is, then just take away 5 points. But if not, then just take away the equivalent of the player's current agility to bring them to zero - no more, no less. Something like this:

picture1.png


EDIT: I just realized you're asking for MZ (not MV), but the logic should work the same 😛
You could make the item that lowers your agility only lower it until it hits zero, by having the item call a common event with a conditional branch.😛
I presumed the items were applying states, it didn't even occur to me (despite the clear wording) that he was actually modifying the straight parameter.

This would work perfectly well without any of the plugins I mentioned.
By default the minimum value for all base parameters except Max HP is 0 (minimum MHP is 1). That cap is applied after the "plus" value (e.g. from a Grow effect or the Change Parameters command) and param rates from traits/buffs.

If you want to change this, you'll need a plugin that lets you define custom parameter formulae, e.g. VisuStella Core Engine:
I presumed the items were applying states, it didn't even occur to me (despite the clear wording) that he was actually modifying the straight parameter.

This would work perfectly well without any of the plugins I mentioned.

Yeah, well I mean if they wanted it to act like a state where the points are automatically returned after a certain amount of time or something, it would be a little more complicated than what I suggested 😛 I just went off of the simplest interpretation of their wording, but what they want might not actually be that simple. So we'll see!
You could make the item that lowers your agility only lower it until it hits zero, by having the item call a common event with a conditional branch. There are a couple ways you could do this. The way I would do it is to store the character's agility in a variable, and then just do a single check if it's greater than or equal to 5; if it is, then just take away 5 points. But if not, then just take away the equivalent of the player's current agility to bring them to zero - no more, no less. Something like this:

View attachment 219773

EDIT: I just realized you're asking for MZ (not MV), but the logic should work the same 😛

Yes perfect ! I should have thought about it, it's clear as day. I should also have precised that it's for a reputation system, so the stat modification is definitive, sorry about that @ATT_Turan

I was too much absorbed by one other thing I'm making : multilayered common events to change charset when the hero changes his armors and weapons. It's easy to do but you need to stay focused.

Solved.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/negative-parameters-how-to-avoid-it.145731/