I am trying to make a move that swaps the agility stat of the user and target
There exists a "a.setMp()" but nothing for setting some of the other parameters...
Looking in the rpg_objects.js i find the code
Game_BattlerBase.prototype.setMp = function(mp) {
this._mp = mp;
this.refresh();
};
but when i add something like this under it it doesn't work...
Game_BattlerBase.prototype.setAgi = function(agi) {
this.param(6) = agi;
this.refresh();
};
How do i make a function for setting agility in the damage formula?
The simple answer is, you don't.
The setMp function is setting a value to a object that is already just a number.
this.param() is a function, not a value, and the function returns a value, specifically the total value of the param called (6). You can't set it equal to something else because it's only job is to report to you (or whatever is asking) what the value of param(6) is. In order to change that value, you'd need to change the function that this.param(paramId) does in the first place, to check for a state, or something, and return a specific value if that state is present, or the original value if it is not.
In order for that to work, you'd need to set the state on the battler when the skill is cast, and use something like YEP_BuffsStatesCore to add a variable to the battler to set what their agi should be, and then alias the this.param(paramId) function to return that value instead of the real value if the state is present.
This is an overly complicated way to do it, as well. The system was not made to set base parameters to flat values. One of yanfly's plugins does allow you to have states that raise and lower params by a flat amount, and you could probably use that to do a math calculation and then modify agi by a specific amount to swap the stats of two battlers, but then you'd need to think about what happens in situations where the state is removed, the battler's stats change, or someone died, as messing this up could result in the target never recovering their original agi values, for example.