Remove stat minimum and let base DEF be 0?

Hi, I'm making a simple RPG that doesn't differentiate between physical and magical damage, it simply has one kind of attack and one kind of defense. The defense stat is repurposed for providing flat damage reduction in the form of an Armor stat. If you want an example, the first two Paper Mario games are probably the closest comparison I can think of, where almost all damage formulas are simply
Markdown (GitHub flavored):
`f(user_atk, skill_damage) - (enemy_def)`
for some function f.

The problem is that almost all my damage formulas end up off-by-one because characters are locked to having a minimum of 1 base DEF. There is no damage variance in this game. So if I'm using, say, a default Attack, then it should do
Markdown (GitHub flavored):
`a.atk - b.def`
damage, but I have to account for 1 DEF on everyone making it the effective zero.

I could just treat 1 DEF as the baseline but then that runs into problems with things like defense-ignoring skills (such as one I will call Fireball) where I'm now manually reducing each output instance of damage by 1 to account for it, and there's just so many off-by-ones to handle that it feels like a bug waiting to happen.

It would be so much easier to have a base DEF of zero, since I don't plan to do any division by the DEF stat, but the editor doesn't allow this. Is there a way to change this limit somehow?
I believe this is possible with Yanfly's Base Parameters Control plugin. I definitely did something similar with ONE of their plugins, I just forget which one.
1654025637691.png
Of course it would be Yanfly - their scripts do damn near anything. I'll check that one out, thank you!
You really only need to get into something like the Base Parameters Control to do more complicated equations with level gains.

If all of that is pretty straightforward in your game, there's a more straightforward solution.

The game function that defaults all parameters to one:
Code:
Game_BattlerBase.prototype.paramMin = function(paramId) {
    if (paramId === 1) {
        return 0;   // MMP
    } else {
        return 1;
    }
};

Simply change it to:
Code:
Game_BattlerBase.prototype.paramMin = function(paramId) {
return 0;
};

Save that in a .js file in your plugins folder and add it to your project.
ATT_Turan is correct. It is also much cheaper than paying 30 USD for full collection when you probably only need one or two plugins.
I already owned the Yanfly full collection for a different project I made - but I'm glad to know where that's actually present in the core. I was digging through the battler base but I kept looking at the wrong place for some reason. Thank you!
Sure, although that plugin is available in the $10 pack.

But even that isn't necessary if you just need something this simple and you don't want to take advantage of all of the options offered in the plugin.
Is the editor hardcoded to force the stat on the parameter curve back up to 1? Because editing paramMin changes the cap internally, but it doesn't reflect that change in the editor, so I have to manually set their stats through some convoluted means.

Yanfly's script seems to work. But the alternative fix of just updating and setting the min param on its own doesn't do anything - I actually need to change the parameter curve to have it be valued at the min. I'll use Yanfly's tweak for now, but if I can use fewer plugins that would be optimal (smallest codebase possible) so if there's any more advice on that front I would appreciate it!
ATT_Turan is correct. It is also much cheaper than paying 30 USD for full collection when you probably only need one or two plugins.
I keep forgetting it's paywalled lol. I got all the Yanfly stuff back when it was free. Sucks that people have to pay for it now...

Although, I do like the plugin for the script calls it provides. I make heavy use of stuff like battler.addAtk(x) or battler.minusDef(x) for various skill effects because I use a lot of utility scaling in my game and thus "x" would constantly vary.
Are you wanting to see the stats be 0 on your database editor? I do not think you are allowed to change editor code. I don't know why you really need to see it on the graphs in the editor. Even if you wanted to change how it looks in the editor, you would have to un-encrypt those files.

I believe editing or reverse engineering those files are going against terms of use for using the application. Practically illegal. Similar to if a plugin maker states in their terms of use to not edit any code or distribute any code would be going against terms of use.

Edit: If graphs are what you want, then Google spreadsheets is free and easy to use. You can make really nice looking graphs to look at.
Is the editor hardcoded to force the stat on the parameter curve back up to 1?
Yes. But you can simply put an autorun event at the beginning of the game that adjusts it.

Or use the Yanfly plugin if it's easier for you at that point. I'm not sure about enemies, if you want them to have 0 DEF I think you'll need to put a state on them with a negative 1 and use the function I provided to let the game allow it.
Are you wanting to see the stats be 0 on your database editor?
It's not about seeing the stats in the editor. I don't even have level up curves at all, my character's damage stats only change with plot events. It's about actually implementing default values that are valued at the new minimum. That functionality is impossible as-is if the minimum is less than 1. You can set the minimum of the stat to be 0 using Yanfly's Base Parameter Control etc. but you can't set the character's stat to be 0 in the editor. It still forces you to start at 1, even if it can handle the stat being 0 if it's set to 0 by some other means. That's the problem. It seems necessary to use scripting to get around it.

One hacky way of doing it that I found was by using YBPC to change the parameter's base formula. This doesn't really require it per se but I do like using that plugin for the script calls etc and I already own the library so why not. I changed
Markdown (GitHub flavored):
(**base** + plus) * paramRate * buffRate + flat
to
Markdown (GitHub flavored):
(**base - 1** + plus) * paramRate * buffRate + flat
so that the actual value that's computed and used for the stat uses 1 less than the base. This is possible without Yanfly's script, since this is basically the formula used internally in MV's code, the only difference being that +flat is not there.

I'll do some testing to make sure that this works.
It's not about seeing the stats in the editor. I don't even have level up curves at all, my character's damage stats only change with plot events. It's about actually implementing default values that are valued at the new minimum. That functionality is impossible as-is if the minimum is less than 1. You can set the minimum of the stat to be 0 using Yanfly's Base Parameter Control etc. but you can't set the character's stat to be 0 in the editor. It still forces you to start at 1, even if it can handle the stat being 0 if it's set to 0 by some other means. That's the problem. It seems necessary to use scripting to get around it.

One hacky way of doing it that I found was by using YBPC to change the parameter's base formula. This doesn't really require it per se but I do like using that plugin for the script calls etc and I already own the library so why not. I changed
Markdown (GitHub flavored):
(**base** + plus) * paramRate * buffRate + flat
to
Markdown (GitHub flavored):
(**base - 1** + plus) * paramRate * buffRate + flat
so that the actual value that's computed and used for the stat uses 1 less than the base. This is possible without Yanfly's script, since this is basically the formula used internally in MV's code, the only difference being that +flat is not there.

I'll do some testing to make sure that this works.
From my understanding you might be entry level to javascript. That is okay. I am not expert. I have been studying for over a year. I have chosen to learn javascript because I want to understand the logic of the engine to better my own game creation.

From my studies I am able to open up .js file with a text editor and look through the core files in js folder. Anyone can do this. The developers are good at coding. They name their functions clearly and easily for those whom want to understand what is going on with each of the functions in each script.

There is nothing hacky going on with plugins. The developers are fully aware that the editor is limiting. That is why plugins.js and the plugin manager exist. With some basic knowledge of javascipt which may take a week to a month, you will have understanding to read through the files provided that are not encrypted. In fact a lot of them have comments in them which is cool.

I understand you may or may not want to learn any coding. That is okay. I personally think that anyone that wants to do video game design should at least know the basics or more. I know this is a silly comparison, but can you imagine if there is a director that wants to make a move, but does not understand to read or write a script for the actors, or any of the knowledge of what an actor should do? For me if I were a director for a movie, I would have experience as an actor.

I genuinely want your project to reach the conclusion that you envision. I hope you are able to achieve what you want with your game.

Spoiler: rpg_objects.js
If Yanfly or any other plugin writer didn't exist for the public to access, then the places in rpg_object.js you would be looking for to do what you want is Game_BattlerBase.prototype.paramMin and Game_Actor.prototype.paramBase. You will have to overwrite those functions. Starting with Game_BattlerBase.prototype.paramMin, you will return 0. Next with Game_Actor.prototype.paramBase, you will find out that the base params are an array. The solution I can think of is to create a loop, however I think a switch statement will work better since you plan to use events to reward stat increases.

Spoiler: A free plugin for anyone to use :)
Game_BattlerBase.prototype.paramMin = function(paramId) {
return 0;
};

Game_Actor.prototype.paramBase = function(paramId) {
switch(paramId) {
case 0:
return 1;
break;
case 1:
return 1;
break;
default:
return 0;
}
};

Terms of use: You can modify the code and distribute. It is free to use in non-commercial and commercial projects. No credit to me required. Have a nice day 🙂

You can save the file as BaseParametersZero.js or whatever you like, just remember to save the file as .js and not .txt
Er, I actually have a master's degree in computer science. The fact that it's coding isn't the problem - but you're right, I've just never worked with JS or MV's codebase before, I'm a Haskell dev and RPG Maker wise I have only ever made games with RGSS3 stuff in VX Ace years and years ago and played with MV for like a day when I bought it. JS is really different from Ruby/RGSS3, and the MV codebase has a lot of small differences to the VXA one, and I'm still working my way around them.

The hackiness of the solution comes from the fact that, using that formula, their base parameter is set to be n + 1 in order to make it n. This results in the desired stat of 0 and is preferable to having to manually tweak my skills' damage by 1, but I still have to do a bunch of off-by-one adjustments (this time in the parameter curves and enemy database stats). I don't think there's any getting around this, unfortunately - the closest thing I could find was notetagging stats that go outside of the RPG maker limits, but my note boxes are already really cramped with other notetags so I'd rather not add battler stats to those and I think I'll stick with putting one more than the desired DEF in the database.

If Yanfly or any other plugin writer didn't exist for the public to access, then the places in rpg_object.js you would be looking for to do what you want is Game_BattlerBase.prototype.paramMin and Game_Actor.prototype.paramBase.

This is really helpful! Thanks. I wasn't sure where to look to find the basic stats implementation.
That is really cool kecleon2. I am sorry to judge your knowledge of coding as entry level. I am very sure you could study javascript in a month or less and know more than me lol. I do not have a degree of any kind. I am just some random guy on the internet.

When I want to learn more about javascript. I just use my mastery of the search engine lol. I hear that mastery of the search engine is what some software engineers do. I think I recall seeing a comedy video on youtube titled "if programming was an anime" by Joma Tech.

The code I wrote took 3 minutes and 1 minute of testing it in the engine. That is my first time using switch statement. I think normally some would use loops, because they look cool. I know earlier me would have created a loop to solve it. I do not know personally what is faster and easier for javascript to read and write. I know someone could have written a shorter script using less lines and bytes haha.
It's all good! So I played around with it more today and I can more accurately verbalize the problem - changing the minimum on its own doesn't do anything unless you change the parameter curves to match. The best workaround I could find was to just use base - 1 instead of base in the formula used to compute the value of the stat. This makes it show up and function correctly in-game, which is the most important thing.

This works fine for me since all my damage formulae are difference-based, but it will break if you have any formulas that divide by DEF and fail to check if it's nonzero first, so you need to ensure that functionality is present.
I understand divide by 0 getting in the way. I am too lazy to implement a check in Game_Action.prototype.makeDamageValue. In Game_Action.prototype.makeDamageValue there is a line: var baseValue = this.evalDamageFormula(target); That line gets the damage formula from items and skills. There is a lot of cool things you can do with just a damage formula. You can create Sunny Day, advanced critical effects within the damage formula and so on. All you need is an understanding of the objects and functions used by RPG Maker MV.

One of the problems that I don't have time to deal with because I wanted it to be a simple script is divide by 0 checks. Overwriting or aliasing Game_Action.prototype.makeDamageValue can result in compatibility issues of others plugins that use Game_Action.prototype.makeDamageValue.

I personally don't really want to do customer service with each plugin I make for RPG Maker MV and MZ. Maybe I should have included that in terms of use, but whatever. I might clean it up with a nice description and add some comments to each line as I see fit to help out those whom look through it and want an understanding of what each function does.

Lastly I would add a warning above and below the description to tell developers that if they use the plugin, then they need to be aware of divide by 0 and other maths issues that can arise with having 0 as a value for stats. After all that is done I will officially release it on the proper forum with a github link or whatever. I would make my plugins work for default engine with no other plugins and with my own plugins, and if it happens to be compatible with others, then that's cool.

I know you are new here, but in the past there was a lot of demanding users that wanted plugin makers to cater to their every request. I really do not want that. It is already bad enough that I deal with stress and anxiety daily. I try my best to manage that. I have been slowly messaging on the forums to gain confidence, because previously I will admit that I have been a lurker on these forums for years.

Thank you my friend for chatting with me. Feel free to dm if you like. I am going to stop adding more posts to this thread lol. Let me know if you need any more help. I am experienced with RPG Maker MV and MZ. MZ right now got a cool update and I am going to have some fun tonight with it.

Original thread: https://forums.rpgmakerweb.com/threads/remove-stat-minimum-and-let-base-def-be-0.148105/