Turning elemental rates into elemental resistances?

Hi!
I am looking for a way to change elemental rates,
at the moment they are multiplying with each other and 110% means the actor/enemy will take MORE damage.
What I want is, that I can give an item 110% (for example) Fire Rate, it will add 10% Resistance against the element fire.
If an item has an elemental rate of 70% it will decrease by 30%.
Also, I would like to be able to set a max resistance. (for example 75% - would also be neat if the max resistances for each element could be defined by myself with maker variables)
Last but not least, it would be great if this system would work with
http://yanfly.moe/2015/12/04/yep-37-status-menu-core/
&
http://sumrndm.site/equip-comparison-upgrade/
Technically it doesn't have to work with the comparison upgrade plugin because I will show all stats an item gives in its description anyways.

TLDR;

Basically I am trying to emulate resistance system of games like Diablo 2 or Path of Exile into the RPG Maker, and I haven't found a compact way to do it.


~ Benji
You don't need a plug-in, you just have to redo your math. Since it is * the rate, if you want 10% resistance, you just need to do * 90 element rate. Or do decrease by 30%, put 130% on the item instead.

As for maximums, I think I've seen that on some of the elemental resistance plug-ins, maybe check there?
But I am pretty sure it is multiplicative, that means if 2 items have 90% it will be 1 * 0.9 * 0.9 = 0.81 - and not 0.8
I know you can change the "formular" in vx ace, but I dont know how to do that in MV :/
So yeah, thats why I am seeking help.
But yeah you are right, - a little bit of a brainfart for me, obviously I only need to turn my math around 😀
As for the maximum resistcap, I googled a bit - but plugins like Elemental Core overpower all my searches although they don't do what I want :<
Actually, I thought Elemental Core allowed you to change it to additive? For some reason I thought it was an option on there.
It allows you to change the calculation method if a weapon or skill has multiple elements - thats how I understood it. Its actually doing nothing for the base calculation of element rates in general.
The reason the system is multiplicative in the first place is to avoid a negative percentage value, which the program itself doesn't know how to handle. I don't know what errors the program spits out at you if you do have a negative percentage value, but I think I'd work hard to avoid that.

In any case, an easy to way to manage a "cap" on an element rate is just to manage your skills and equipment. Requires a little bit of math to pull off, however. How many equipment slots do you have? The more you have that can have an elemental resist on them, the less high your resistances on each individual piece of equipment you have. If you have 5 pieces of equipment that give a 5% reduction in element rate against you, then you'll have (roughly, but not quite exact) a 75% resistance (it's like 77%, but going any higher on the numbers goes above the 25% in your example).

This means you won't be able to go above 5% resistance if you've got 5 pieces of equipment that can be equipped, provided you're shooting for only a 25% cap on any elemental resistance.

I know that probably doesn't help you find the plugin you're requesting, but it's an alternative if you can't find a plugin to do what you want (or it doesn't exist yet). Feel free to ignore this entire post if you've managed to find a plugin for the cap. Otherwise, feel free to keep it in mind if you discover there is no plugin for what you want.
@Tai_MT : Actually, the program handles a negative element rate by treating it as Absorption. That's exactly how Yanfly coded their elemental absorption script in ACE, it just flipped the rate to negative, and as far as I can tell it is the same in MV. So the program can handle negative element rates just fine.
@Tai_MT yeah I guess thats how I can do it, a hard cap plugin would still be great though 😀

Tsukihime actually posted a really short script sniped for vx ace back in the days to change the calculation of elemental rates, I was hoping something like this could be done for MV too :<
https://forums.rpgmakerweb.com/index.php?threads/element-rate-and-equipment.25476/
The element rate calculation can be found in the rpg_objects.js file. It's on line 2464:

Code:
Game_BattlerBase.prototype.elementRate = function(elementId) {
    return this.traitsPi(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
};

To change it from multiplicative to additive, change traitsPi to traitsSum. So, it'll look like this:

Code:
Game_BattlerBase.prototype.elementRate = function(elementId) {
    return this.traitsSum(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
};

In order to set a maximum resistance, change the function to this:

Code:
Game_BattlerBase.prototype.elementRate = function(elementId) {
    var rate = this.traitsSum(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
    rate = Math.max(x, rate);
    return rate;
};

Replace x with the resistance cap you want your game to have (x is calculated as a percentage). So, if you want the resistance to not go below 75%, the function would be:

Code:
Game_BattlerBase.prototype.elementRate = function(elementId) {
    var rate = this.traitsSum(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
    rate = Math.max(0.75, rate);
    return rate;
};

Note that this will disable certain features of your game, such as having immunity to an element because the rate will not go down to zero. Also, since now the rate you specify will be additive, any value you put in is going to increase the element rate. To decrease the element rate (ie increase resistance to that element), you would have to use negative values, which the editor does not allow. So, you're going to need a plugin that allows you to specify element rates by notetag.

Also note that I did not test this myself, and the rate is multiplicative by default for good reasons (otherwise, you wouldn't be able to set element immunity for example), and changing it could result in unwanted effects, although I can't think of any way it could as of this moment.
Hm- I can't find a plugin that lets me set elemental rates with plugin - but this looks already very promising.
Also, you are right that I won't be able to set imunities any longer, but I can deal with that- I don't like imunities anyways 😀
So, just to be clear I understand this now.
When setting it to be additive, and my equip piece has 70% elemental rate.
The calculation will be
1 + (0.7 -1)
or
1 + 0.7
?

I guess the second option.
Would I maybe able to set the
Code:
 var rate = this.traitsSum(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
to subtract instead of add?

Because then, an elemental rate trait of 70% would do
1 - 0.7 = 0.3
So 30% damage is taken.
In that case I wouldn't need to set a maximum, but a minimum!
So...
Code:
Game_BattlerBase.prototype.elementRate = function(elementId) {
    var rate = this.traitsDif(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
    rate = Math.min(0.25, rate);
    return rate;
};
(this.traitsDif) & (Math.min(0.25)
?

I guess I can just test it out and see if an error comes up 😳

Edit: Dif and not Sub I guess... ?

Edit 2: My magic didnt work :<

Edit 3: I found this! http://himeworks.com/2015/12/elemental-negation/
Maybe I can get it to work 😀

Edit 4: I couldn't get it to work. Seems that plugin is doing something really weird, when I gave my actor 2 items, 1 with -10% and one with -20% , the element rate went to 2%... and I can't explain that.
To answer the first question, since all battlers have an element rate of 1 by default, if you have an equipment that gives 70% element rate, it would be 1+0.7 which is 1.7, meaning 70% increased damage. If you had two equipment pieces, one giving 30% and one giving 50%, the total rate would be 1 + 0.3 + 0.5 which is 1.8, 80% increased damage.

Moving on, traitsSum is not some magic word I made up. It's a function that is defined within the code. So you simply can't change it to traitsDif or something else and hope it'll work (props for trying though 😉). Subtraction of traits isn't defined within the code, so you can't really do that (unless you define the function yourself).

And I am defining the minimum value using the Math.max operator (a bit unintuitive for new people not familiar with it I know) . The Math.max operator compares the two values you input into it and chooses the larger value as the output. So when I did Math.max(0.75, rate), what it did was compare the values of rate and 0.75. If rate is greater than 0.75, take the value of rate. If 0.75 is greater than rate (ie rate is less than 0.75) take 0.75. This effectively makes 0.75 the minimum value it can be.
So, all I really need is a plugin now that allows me to put in negative elemental rates that actually subtract of each other.
Have been looking now but can't find one :<
RIP dreams ?
Can I maybe change the
Code:
var rate = this.traitsSum(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
So that it calculates -1 for every elemental rate, so that it would calculate
1 + (0.7 -1) + (0.3 - 1) + (0.5 -1) and so on?
Here's something I made in 5 minutes. It will calculate the element rate how you described above.

So if you have equipment pieces giving 70%, 90% and 150% element rates, the calculated rate will be:

1 + (0.7-1) + (0.9-1) + (1.5-1) = 1.1, so 110% damage.

The minimum element rate can be set in the plugin parameter. If this is set to 0.25, for example, the element rate will not go below 0.25, so the player can have a maximum resistance of 75% (25% damage taken).

Remember to place this plugin ABOVE Yanfly's Element Core plugin. Also, I only tested it with Yanfly's Element Core, so if you have other plugins that change how elements work, I don't know what could happen 😅

You can forget the changes I told you to make to the rpg_objects.js file earlier since I've incorporated that into this.
Omg! It works perfectly!
Thanks so much for your help 🙂
I don't have any other plugins which change elements in any way so yeah- great!

Original thread: https://forums.rpgmakerweb.com/threads/turning-elemental-rates-into-elemental-resistances.80080/