TP Energy System

TP Energy System v1.4
by Phalk

Introduction

A js script to change the way the TP system works to make it work similar to World of Warcraft's energy system.

Features
* You always start battles with a fixed amount of TP, defined in the params.
* You earn a predetermined amount of TP once per turn, defined in the configuration.
* You can enable or disable TP gain from damage.
* You can also set the maximum amount of TP all actors can have.


How to Use
Just put the js file inside your plugins folder and set the desired values at the plugin parameters configuration.

Script
Code:
//=============================================================================
// Phalk_TpEnergy
//=============================================================================
var Imported = Imported || {};
Imported.Phalk_TpEnergy = true;
//=============================================================================
/*:
 * @plugindesc v1.4 You can now enable or disable the TP gain on damage taken.
 * @version 1.4
 * @author Phalk  | Version 1.4
 *
 * @param TP Gain
 * @desc Amount of TP gained each turn.
 * Default: 10.
 * @default 10
 *
 * @param Starting TP
 * @desc Amount of TP to start battles with.
 * Default: 100.
 * @default 100
 *
 * @param Max TP
 * @desc Define the maximum amount of TP.
 * Default: 100.
 * @default 100
 *
 * @param TP on Damage
 * @desc Gain TP on received damage. Set 0 to disable or 1 to enable.
 * Default: 0.
 * @default 0
 *
 * @help
 * <Phalk_TpEnergy>
 * =======================================
 * This plugin changes the way TP works.
 * =======================================
 * 
 * HOW IT WORKS
 * =======================================
 * 
 * * You always start battles with a fixed amount of TP, defined in the params.
 * * You earn a predetermined amount of TP once per turn, defined in the configuration.
 * * You can enable or disable TP gain from damage.
 * * You can also set the maximum amount of TP all actors can have.
 *
 *
 * @tags battle, tp
 */
//=============================================================================
(function () {
    
var parameters = PluginManager.parameters('Phalk_TpEnergy');
var TpGain = Number(parameters['TP Gain'] || 0);
var TpStart = Number(parameters['Starting TP'] || 0);
var MaximumTp = Number(parameters['Max TP'] || 100);
var TpDamage = Number(parameters['TP on Damage'] || 0);

if (TpDamage == 0) { Game_Battler.prototype.onDamage = function(value) { this.removeStatesByDamage(); }; }

Game_Battler.prototype.initTp = function() { this.setTp(TpStart); };

Game_BattlerBase.prototype.maxTp = function() { return MaximumTp; };

Game_Battler.prototype.onAllActionsEnd = function() { 
    this.clearResult();
    this.removeStatesAuto(1);
    this.removeBuffsAuto();
    this.setTp(Math.floor(this.tp + TpGain));
};

Game_Battler.prototype.onBattleEnd = function() {
    this.clearResult();
    this.removeBattleStates();
    this.removeAllBuffs();
    this.clearActions();
    this.setTp(MaximumTp);
    this.appear();
};

Game_BattlerBase.prototype.recoverAll = function() {
    this.clearStates();
    this._hp = this.mhp;
    this._mp = this.mmp;
    this.setTp(MaximumTp);
};

})();

FAQ
Q: If I start a new game the TP starts at 0. How do I fix this?
A: Just create a "RecoverAll" event before the start and it'll max the TP for everyone. After that TP should always be maxed outside of battles.

Credit and Thanks
- Me

Terms
You are free to use this plugin in commercial games as long as you mention me in the credits.

Author's Notes
This is probably buggy and not compatible with a lot of things.
At least I can confirm it works with most free Yanfly battle plugins, since I use them.
Nice, is there a way to set the parameters differently for each actor/class? Or increase them via skill/items? Or does TP Charge Rate / TP regeneration effect them normally?
Nice, is there a way to set the parameters differently for each actor/class? Or increase them via skill/items? Or does TP Charge Rate / TP regeneration effect them normally?

For now it's just a global setting that affects the whole battle system. I might add the option to set up values per class in the future tho.

TP Charge does not work, but TP regeneration items should work just fine.
Couldn't these things already be done w/ YEP_EnhancedTP? Not dissing your plugin or anything and I'm an avid WoW addict as well, so I like having TP work like Energy too.

TP regen could also simply be applied in Traits, no?
Couldn't these things already be done w/ YEP_EnhancedTP? Not dissing your plugin or anything and I'm an avid WoW addict as well, so I like having TP work like Energy too.

TP regen could also simply be applied in Traits, no?

YEP_EnhancedTP is behind a paywall, so I can't say as I have no access to it. I needed this for my game so I made it. I'm sharing because I thought it might be useful for someone.
Ah, I see. I forgot about that. Lucky me, I grabbed all 200 plugins + the sample project before the paywall lol. It will definitely be useful for those w/o don't have YEP_EnhancedTP.

Original thread: https://forums.rpgmakerweb.com/threads/tp-energy-system.123023/