Starting TP to match actor's level

Hello, everyone!

I'm dabbling with MZ (since the good ol' days of 2k3) and ran into this issue:

How would I set the initial TP in battle to be the name as the character's Level. Similar to how Wild Arms series (e.g. Wild Arms 2) does it to its force system.

I'm fairly new to the forum (used to lurk) so let me know if this type of question has a dedicated place. I don't know if this requires a plug-in, or a script call would suffice, or what.

Thanks for your time!
Technically, you don't need a plugin to change it. It's in one of the .js base files. I believe it's rpgobjects.

The code is something like:

Code:
Game_Battler.prototype.initTp = function() { this.setTp(Math.randomInt(25));};

Change the math.randomint to actor.level()

Otherwise, there are a few free/paid plugins that can also do this.
Just to add to what @Silenity said:
Technically, you don't need a plugin to change it. It's in one of the .js base files.
You should never edit the js files. You should always copy your changes into a new file and include it as a plugin.

There are numerous things that can go wrong by editing the core scripts and zero downsides to doing it the intended way.

Change the math.randomint to actor.level()
That won't work as is - there is no actor variable there.

And also actors don't have a level() method, so that would throw an error if there were an actor variable 😉

Copy the below, paste into a text editor, save as a *.js file, and include as a plugin.
Code:
Game_Battler.prototype.initTp = function()
{
    this.setTp(this.isActor() ? this.level : Math.randomInt(25));
};

That will set initial TP to the actor's level if it's an actor, or the random 0-24 if it's an enemy. If you want the enemies to have a different starting value, you can change that portion.
actor.level()

Thanks, but I tried that before but I get an "Reference Error: actor is not defined" message.

EDIT: @ATT_Turan solution worked! Thank you so much! Yeah, I usually add the stuff I test as a .js plugin. Good to know I'm on the right track on this.
Thanks, but I tried that before but I get an "Reference Error: actor is not defined" message.

Mr. @ATT_Turan (much smarter than I) has the correct info!

Original thread: https://forums.rpgmakerweb.com/threads/starting-tp-to-match-actors-level.167583/