How do I turn this complicated formula into a state?

DeltaLime24

Villager
Member
Joined
Feb 15, 2018
Messages
7
Reaction score
5
First Language
English
Primarily Uses
RMMV
Okay, bottom line here, I have a bit of a mess on my hands. I want to use a formula to create a skill that applies an "Inverted" state to "Invert" the statistics of my characters for 3 turns (e.g. 70 atk at lv 50 would become 255-70 = 185 and 140 atk at lv 100 would become 510-140 = 370 etc)
As you can tell, such an idea is a pain to implement in RPG Maker MV, as is most complex mechanics. Below is a formula I made by butchering the damage formula of a skill:

a._paramPlus[2] = 2.55 * a.level * 2 - (a.atk*2);a._paramPlus[3] = 2.55 * a.level * 2 - (a.def*2);a._paramPlus[4] = 2.55 * a.level * 2 - (a.mat*2);a._paramPlus[5] = 2.55 * a.level * 2 - (a.mdf*2);a._paramPlus[6] = 2.55 * a.level * 2 - (a.agi*2);a._paramPlus[7] = 2.55 * a.level * 2 - (a.luk*2);0

It works fine, but changes the stats permanently. A second inversion seems to not give the character their original stats.

Thank you for reading through my post.
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
If you're using Yanfly's Buffs and States Core, you can create the invert state and use these notetags in that state's notebox:

Code:
<Custom Apply Effect>
user._paramBonuses = user._paramBonuses || [0,0];
var max = Math.round(5.1 * user.level); // Formula for defining max value
for (var i=2; i<8; i++) {
  var param = user.param(i);
  var diff = max - param; // Difference in stat value
  user._paramBonuses[i] = diff;
  user._paramPlus[i] += diff;
}
</Custom Apply Effect>

<Custom Remove Effect>
for (var i=2; i<8; i++) {
  user._paramPlus[i] -= user._paramBonuses[i];
}
user._paramBonuses = undefined;
</Custom Remove Effect>
The bonus stats should revert back once the state is removed. Note that when calculating the original stat, this considers all effects that could affect the stat, which are the base stats, equipments, param rates and buffs/debuffs.
 
Last edited:

DeltaLime24

Villager
Member
Joined
Feb 15, 2018
Messages
7
Reaction score
5
First Language
English
Primarily Uses
RMMV
Thanks for the notetags, I did have Yanfly's Buffs and States Core convieniently enough. One issue though, how do I stop it from affecting HP and MP? I'm keeping those at a constant rate for specific reasons.
Another thing about MP specifically, it returns a non-existant number, so I haven't been able to test it. Checking the menu out of battle causes a fatal error with this installed.
Yet another error that occured was that I cannot access the regular attack or guard as well as any attack that required MP.

Edit: on closer inspection of the fatal error when opening the menu, it seems the notetag you suggested is actually an infinite number.

Does this line affect the stats it selects?
for (var i=2; i<8; i++)
 
Last edited:

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
Oops I made a mistake in the original one where I forgot to reference the index of the array. Fixed it and it should work now (edited the original post).
 

DeltaLime24

Villager
Member
Joined
Feb 15, 2018
Messages
7
Reaction score
5
First Language
English
Primarily Uses
RMMV
Okay, now at LV 50 all stats are 255 and at LV 5 are 26. It appears to just change every stat to the maximum. I think I found what makes that happen, but I'm shaky on my javascript.
For whatever reason, these lines aren't working:

var param = user.param(i);

var diff = max - param; // Difference in stat value
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
Ah I see, I was adding up the difference between the stat and the max, which caused the stat to be max. What I should have done was set it to the difference and not add the difference, then store the difference in paramPlus to restore it later.
This was a bit more complicated than I thought, but it's still possible.

Try this:

Code:
<Custom Apply Effect>
user._paramBonuses = user._paramBonuses || [0,0];
var max = Math.round(5.1 * user.level); // Formula for defining max value
for (var i=2; i<8; i++) {
  var param = user.param(i);
  var diff = max - param; // Difference in stat value
  var temp = param - user._paramPlus[i];
  temp = diff - temp;
  user._paramBonuses[i] = temp - user._paramPlus[i];
  user._paramPlus[i] += user._paramBonuses[i];
}
</Custom Apply Effect>

<Custom Remove Effect>
for (var i=2; i<8; i++) {
  user._paramPlus[i] -= user._paramBonuses[i];
}
user._paramBonuses = undefined;
</Custom Remove Effect>
 

DeltaLime24

Villager
Member
Joined
Feb 15, 2018
Messages
7
Reaction score
5
First Language
English
Primarily Uses
RMMV
Works perfectly now. Thank you for helping. I'll toy around with some of the stuff you put in this.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,015
Members
137,563
Latest member
MinyakaAeon
Top