I think this would be pretty awkward without a plugin, unless you want to risk bugs by adding the state in the damage formula.
😅
By default the relative luck of the user/target affects state/debuff apply chance (when not Certain Hit). So if this "TP% apply chance" thing is meant to apply to everything, it may be simplest to look for a plugin that customises that "luck effect rate". E.g. (untested):
Spoiler: plugin code
JavaScript:
/*:
* @target MV MZ
* @plugindesc Sets luck effect rate equal to the subject's TP%.
* @author Caethyril
* @url https://forums.rpgmakerweb.com/threads/175516/
* @help Free to use and/or modify for any project, no credit required.
*/
Game_Action.prototype.lukEffectRate = function(target) {
return this.subject().tpRate(); // user's current TP%
};
Alternatively you could find a plugin that lets you run a script call just after the skill hits, e.g.
Eval Tags 2.0 ATT_Turan Introduction I have found I often recommend plugins to people solely for the ability to use notetags to execute code at times when events are not accessible. However, there are situations where those plugins include many other features that the user may not want in their...
forums.rpgmakerweb.com
With ATT_Turan's Eval Tags plugin, you could try something like this (untested):
<Action Post-Apply Eval>
if (Math.randomInt(100) < user.tp) {
target.addState(123);
}
value;
</Action Post-Apply Eval>
I.e. "if (random integer from 0~99) is less than the user's current TP, add state ID 123 to the target". I've added
value at the end, since the plugin seems to take the final value of this tag as the damage value for its follow-up action tags.
(Alternatively you could use
if (Math.random() < user.tpRate()).
tpRate returns the current/max TP, and
Math.random() goes from 0 to 0.999-ish, so the logic is the same unless you've changed the max TP.)
VisuStella Battle Core offers similar tags; the syntax might be slightly different, I haven't checked. There are probably other options available~