Boost Everyone's AGI By a Percentage of User's

Hi guys,

I'm trying to create a passive state that increases everyone's AGI by a percentage of the user's. This applies throughout the battle, so that if the user's AGI increases, so does everyone else's.

...At least, it's supposed to, but nothing's actually happening to anyone's AGI. Here's my code:

Code:
<Custom Regenerate Effect>
var group = user.friendsUnit().battleMembers();
var agiBoost = Math.floor(user.agi * 0.3);
for (var i = 0; i < group.length; i++){
 var ally = group[i];
 ally.agi += agiBoost;
 console.log(ally.agi);
}
</Custom Regenerate Effect>
you cant modify battler stats directly like that.

without customizing how they work or adding another plugin, you can try using ally.addParam(6, agiBoost) to increase agi.
But if you do that, youll have to both log how much the effect gives throughout its entire duration so that you can revert it afterwards with the same function, and then also be sure that however you revert it, it catches every scenario so that it cant be exploited to increase agi infinitely
There may be easier ways to achieve this, but since you are using javascript for most of the logic anyways you could try to make a custom plugin for this effect.

As Robro33 mentioned, the "addParam" function would permanently increase the allies agility, so you would have to subtract the bonus again when you want to update the amount, including after the user lost the state.
Internally, the parameters are handled with a parameter ID (from 0 = MHP to 7 = LUK).

Parameter values in MV are calculated on demand whenever battler.agi is used, so by writing a plugin you could just modify the function that calculates the AGI for your ally to include their party members share states, for example (the comments probably make this look bigger than it is):
Spoiler
JavaScript:
/*:
 * @plugindesc
 * Implement a state that shares the users agi with their party
 * @help
 * This text goes into the help window.
 */

// Copy ("alias") the previous version of the "param" function under a new name:
// This way the old code is not lost when this plugin later replaces the function.
Game_BattlerBase.prototype.paramBeforeAllyShares =
    Game_BattlerBase.prototype.param;

// Replace the "param" function to include your custom bonuses.
// The original version can be found in "rpg_objects.js" line 2450ff.
// All the shortcuts (a.atk, a.def, ... ) go through this function:
Game_BattlerBase.prototype.param = function(paramId) {
 
    // Get the previous parameter value (through the created alias):
    let value = this.paramBeforeAllyShares(paramId);
 
    // < ---- Here goes the code to modify the result: ---- >
    // (from the perspective of the receiver, so the bonus is inverted):
 
    if (paramId == 6) {  // paramId = 6 means agility
 
        var group = this.friendsUnit().battleMembers();
        for (var i = 0; i < group.length; i++) {
            var ally = group[i];
            if (ally !== this && ally.isStateAffected(17)) {  // Replace 17 with the agi boost state ID
                value += 0.3 * ally.paramBeforeAllyShares(paramId);
                console.log(value);
            }
        }

        // Make sure the new modifications do not exceed the parameters bounds:
        // Also make sure the final result is still an integer:
        value = Math.round(value.clamp(this.paramMin(paramId), this.paramMax(paramId)));
    }
 
    // < -------------------------------------------------- >
 
    // In all cases, return the (modified) value as the new result:
    return value;
};
Notes:
- Replace "ally.isStateAffected(17)" with the state that should share the agility.
- Instead of "ally.paramBeforeAllyShares(paramId)" you could of course use "ally.agi". You have to be careful here though, since if two allies would share their agility, they would end up boosting each other in an infinite loop.
- Save the script as a plugin, place the plugin close to the bottom of your list to make sure it is the last plugin to modify the function.

- Right now bonuses from allies are applied after everything else is calculated, so they do not benefit further from "Parameter Rate" traits.

Original thread: https://forums.rpgmakerweb.com/threads/boost-everyones-agi-by-a-percentage-of-users.168041/