Make TP gain a variable?

I was wondering if, instead of each skill granting a fixed amount of TP, it could give a range of points? Like instead of just 5, it would be 3-8, so sometimes you lose out, sometimes you get lucky.

Though off that, maybe having the Luck stat play a roll in making sure you get higher numbers more often would be neat.

How would one do this? A common event that goes off every time you attack?
no, this would need a plugin if you want it done correctly.
the common event would have some timing problem and a few others.

For MV there was a plugin from yanfly for extra parameter formula and/or TP modes, but I don't know if there is a visustella equivalent for MZ.
In case it helps, I posted a plugin in another thread for TP Gain variance:
Spoiler: plugin code
JavaScript:
// ============= //
// VarianceTP.js //
// ============= //

/*:
 * @target MV MZ
 * @plugindesc v2 - Apply variance for user TP Gain.
 * @url https://forums.rpgmakerweb.com/index.php?threads/152698/
 * @help Set the default TP Gain variance in the plugin parameters.
 * 
 * You can also use this tag in the Note box of an Item or Skill:
 *        <TP Gain Variance: X>
 *   e.g. <TP Gain Variance: 40>
 * This example sets the TP Gain variance to 40% for the tagged Item/Skill.
 * 
 * Free to use and/or modify for any project, no credit required.
 * 
 * @param Variance
 * @type number
 * @decimals 2
 * @min 0
 * @max 100
 * @desc Variance to apply to all items/skills.
 * Default: 20, i.e. ±20%.
 * @default 20
 */

void (function(alias) {
'use strict';
    var PLUGIN_NAME = 'VarianceTP';
    var TAG_NAME    = 'TP Gain Variance';

    var PARAMS   = PluginManager.parameters(PLUGIN_NAME);
    var VARIANCE = Number(PARAMS.Variance || 0);

    Game_Action.prototype.applyItemUserEffect = function() {
        var item = this.item();
        var orig = item.tpGain;
        var tag  = item.meta[TAG_NAME];
        var v    = isNaN(tag) ? VARIANCE : Number(tag);
        // adjust value
        item.tpGain = this.applyVariance(orig, v);
        // console.info('    tp =', this.subject().tp, '\n   old =', orig, '\n   new =', item.tpGain);
        // apply existing TP Gain method
        alias.apply(this, arguments);
        // reset value
        item.tpGain = orig;
        // console.info('now tp =', this.subject().tp);
    };

})(Game_Action.prototype.applyItemUserEffect);
The thread was for MV, but I wrote MZ in the plugin header, so it should work in MZ as well.
Cool beans, I'll have to check that out; thanks @caethyril !
You're welcome! It uses the damage formula variance method, so if you find a plugin for luck bias in that, then it should also affect the TP Gain variance. 👋

Original thread: https://forums.rpgmakerweb.com/threads/make-tp-gain-a-variable.155052/