# Looking for help or tutorials in breaking down the formulas and methods behind TBPS

#### GHNeko

##### Sega Stockholm Syndrome.
Good afternoon/evening/morning.
I'm trying to find information in regards to trying to understand the code behind TBPS.

JavaScript:
``````Game_Battler.prototype.tpbAcceleration = function() {
const speed = this.tpbRelativeSpeed();
const referenceTime = \$gameParty.tpbReferenceTime();
return speed / referenceTime;
};

Game_Battler.prototype.tpbRelativeSpeed = function() {
return this.tpbSpeed() / \$gameParty.tpbBaseSpeed();
};

Game_Battler.prototype.tpbSpeed = function() {
return Math.sqrt(this.agi) + 1;
};

Game_Battler.prototype.tpbBaseSpeed = function() {
const baseAgility = this.paramBasePlus(6);
return Math.sqrt(baseAgility) + 1;
};

Game_Battler.prototype.tpbRequiredCastTime = function() {
const actions = this._actions.filter(action => action.isValid());
const items = actions.map(action => action.item());
const delay = items.reduce((r, item) => r + Math.max(0, -item.speed), 0);
return Math.sqrt(delay) / this.tpbSpeed();``````

My end goal is to completely nix the relativity between the battlers, and instead have a single variable/value that is static that the battler's speeds becomes relative to e.g. this value is set to X and rate of which the TBPS gauges fill up are checked against X rather than each other. As an extension of this, I was also trying to figure out how to specifically have state's turn count decay also relative to this universal value of which gauges are relative to (rather than states decaying based on the battler; also for design purposes.)

I thought this might go in the JS boards but it seems the JS boards are primarily made for plugins and I'm not trying to make a plugin but rather edit rmmz_objects.js to get the results I'm looking for (though I'm not sure if the states decaying based on something not related to battlers is something that can be directly editted or if it requires a plugin)

Despite that if this belongs somewhere else that's fine. I'm mostly just looking to learn the logic because i cant seem to connect the dots between the code block up there in regards to what each method does exactly and how they not only influence each other, but how they work together, and how they contribute to TBPS's gauge.

#### DoubleX

##### Just a nameless weakling
First, Game_Battler.prototype.tpbRequiredCastTime is unrelated to your goal, because that method is about the time needed to fully charge an already inputted skill/item.
Second, Game_Battler.prototype.tpbBaseSpeed determines which parts of the battler dictates its own speed, so it's also unlikely what you want to change.

Instead, you'll want to have a look on this method:
JavaScript:
``````Game_Unit.prototype.tpbBaseSpeed = function() {
const members = this.members();
return Math.max(...members.map(member => member.tpbBaseSpeed()));
};``````
It means that \$gameParty.tpbBaseSpeed() returns the base speed of the fastest battler, so you'll want to change this method to return the single fixed value or game variable you want, like:
JavaScript:
``````Game_Unit.prototype.tpbBaseSpeed = function() {
return \$gameVariables.value(x); // Returns the value of game variable with id x
};``````
Or
JavaScript:
``````Game_Unit.prototype.tpbBaseSpeed = function() {
return y; // Returns the fixed value y
};``````

Similarly, you'll want to check this method:
JavaScript:
``````Game_Unit.prototype.tpbReferenceTime = function() {
return BattleManager.isActiveTpb() ? 240 : 60;
};``````
Because MZ has hardcoded the assumption of the game loop to be always 60 fps, it means that the TPBS bars are supposed to be fully filled for the fastest battler within 1 second for wait TPBS, and 4 seconds for active TPBS.
Therefore, you'll want to keep these constants in mind when you edit Game_Unit.prototype.tpbBaseSpeed.

As for the state turn count delay, you may want to try this plugin

### Latest Profile Posts

I'm a master in procrastination and have finally decided to educate people in this art in a seminar in Calais. Please don't come. I won't be there.
Testing some of my custom battlers (they're all trash, sorry).

a friend of mines said I need an elevator pitch for my game. he then went and gave me his for his comic... then I realized I have no idea how to explain my game the way he did his comic lol.
How much armor is too much armor I wonder....
Some people wished to be governed. Some people wished to be ruled.