ICF-Soft Stat affecting Variance

This is a bit hard to explain, and this isn't overly critical, but bear with me, okay?

I'm using a plugin by ICF-Soft allowing me to implement custom parameters. The two stats- Skill and Intellect- have effects on other things, but I want to add one more, subtle effect to both of them. I want them to slowly move the bottom threshold of the variance up- Skill for Physical attacks, Intellect for Magical attacks.

Here's what I mean.

At level 10, let's say the main physical attacker, after calculating the damage formula, has a damage range between 172 and 259. However, he has a Skill stat of 11. As it is now, Skill is only used to increase Accuracy (read: Hit Rate) as well as the power of most physical skills that cost TP.

What I want to do is raise the lower threshold of variance by a percentage equal to the Skill stat. So, if this were implemented, the lowest the attack could be would be raised 11% from 172 to 181.

That doesn't seem like much, but in the endgame, with damage reaching the 4000s and Skill also being much higher, this would make damage a lot more consistent. I want Intellect (which currently determined Item potency and the extra damage you do with elemental weaknesses) to do basically the same thing, but for magic. That's kind of what I want Skill and Intellect to be- negligible in the early stages of the game, incredibly important in the endgame.
I used more time on this than I thought I would. You might be able to find a more elegant solution than this. I do not really know exactly how ICE-Soft Param Core works but I did my best.

I hardcoded that the "Skill" or "Intellect" affects the variance by a 1 to 1 ration. I assumed these were NParams, if not tell me or this will not work.

You need to set the parameters of this plugin to correspond with the index of "Skill" and "Intellect" respectively.

Code:
//=============================================================================
// Decrease Variance Damage
// MRP_DecreaseVarianceDamage.js
// By Magnus0808 || Magnus Rubin Peterson
//=============================================================================

/*:
 * @plugindesc Extension to ICFSoft_ParamsCore
 * @author Magnus0808
 *
 * @help This plugin needs ICFSoft_ParamsCore to work.
 * Set the parameters to indicate the index of the NParam that is used to
 * affect the variance.
 * If the value of the NParam is 1 then it will remove 1% of the variance from
 * the minimum damage. So if it is 100 then you will always deal max damage.
 *
 * @param Physical NParam Index
 * @type Number
 * @desc The index of the NParam with the parameter that affect the variance
 * of physcial dmg.
 *
 * @param Magical NParam Index
 * @type Number
 * @desc The index of the NParam with the parameter that affect the variance
 * of magical dmg.
 *
 */

(function(){
    
    DecreaseVarianceDamage = {};
    DecreaseVarianceDamage.Parameters = PluginManager.parameters('MRP_DecreaseVarianceDamage');
    DecreaseVarianceDamage.physicalIndex = Number(DecreaseVarianceDamage.Parameters['Physical NParam Index']);
    DecreaseVarianceDamage.magicIndex = Number(DecreaseVarianceDamage.Parameters['Magical NParam Index']);
    
    Game_Action.prototype.applyVariance = function(damage, variance) {
        var amp = Math.max(Math.abs(damage) * variance / 100, 0);
        var gVariance = 0;

        if(this.isPhysical() && this.isMagical){
            gVariance =  (this.subject().NParam(DecreaseVarianceDamage.physicalIndex)/100 + this.subject().NParam(DecreaseVarianceDamage.magicIndex)/100)/2;
        } else if(this.isPhysical()){
            gVariance =  this.subject().NParam(DecreaseVarianceDamage.physicalIndex)/100;
        } else if (this.isMagical){
            gVariance = this.subject().NParam(DecreaseVarianceDamage.magicIndex)/100;
        }
        if(gVariance > 1) gVariance = 1;
        
        var gAmp = amp * gVariance;           
        amp = Math.floor(amp - gAmp);
        gAmp = Math.floor(gAmp);
        
        var v = Math.randomInt(amp + 1) + Math.randomInt(amp + 1) - amp;
        return damage >= 0 ? damage + v + gAmp : damage - v - gAmp;
    };
    
})();
I used more time on this than I thought I would. You might be able to find a more elegant solution than this. I do not really know exactly how ICE-Soft Param Core works but I did my best.

I hardcoded that the "Skill" or "Intellect" affects the variance by a 1 to 1 ration. I assumed these were NParams, if not tell me or this will not work.

You need to set the parameters of this plugin to correspond with the index of "Skill" and "Intellect" respectively.

Code:
//=============================================================================
// Decrease Variance Damage
// MRP_DecreaseVarianceDamage.js
// By Magnus0808 || Magnus Rubin Peterson
//=============================================================================

/*:
 * @plugindesc Extension to ICFSoft_ParamsCore
 * @author Magnus0808
 *
 * @help This plugin needs ICFSoft_ParamsCore to work.
 * Set the parameters to indicate the index of the NParam that is used to
 * affect the variance.
 * If the value of the NParam is 1 then it will remove 1% of the variance from
 * the minimum damage. So if it is 100 then you will always deal max damage.
 *
 * @param Physical NParam Index
 * @type Number
 * @desc The index of the NParam with the parameter that affect the variance
 * of physcial dmg.
 *
 * @param Magical NParam Index
 * @type Number
 * @desc The index of the NParam with the parameter that affect the variance
 * of magical dmg.
 *
 */

(function(){
   
    DecreaseVarianceDamage = {};
    DecreaseVarianceDamage.Parameters = PluginManager.parameters('MRP_DecreaseVarianceDamage');
    DecreaseVarianceDamage.physicalIndex = Number(DecreaseVarianceDamage.Parameters['Physical NParam Index']);
    DecreaseVarianceDamage.magicIndex = Number(DecreaseVarianceDamage.Parameters['Magical NParam Index']);
   
    Game_Action.prototype.applyVariance = function(damage, variance) {
        var amp = Math.max(Math.abs(damage) * variance / 100, 0);
        var gVariance = 0;

        if(this.isPhysical() && this.isMagical){
            gVariance =  (this.subject().NParam(DecreaseVarianceDamage.physicalIndex)/100 + this.subject().NParam(DecreaseVarianceDamage.magicIndex)/100)/2;
        } else if(this.isPhysical()){
            gVariance =  this.subject().NParam(DecreaseVarianceDamage.physicalIndex)/100;
        } else if (this.isMagical){
            gVariance = this.subject().NParam(DecreaseVarianceDamage.magicIndex)/100;
        }
        if(gVariance > 1) gVariance = 1;
       
        var gAmp = amp * gVariance;          
        amp = Math.floor(amp - gAmp);
        gAmp = Math.floor(gAmp);
       
        var v = Math.randomInt(amp + 1) + Math.randomInt(amp + 1) - amp;
        return damage >= 0 ? damage + v + gAmp : damage - v - gAmp;
    };
   
})();
Sorry I didn't get back to you for a while, but thank you so much for the help!

Original thread: https://forums.rpgmakerweb.com/threads/icf-soft-stat-affecting-variance.105687/