Use and set TP outside of battle

● ARCHIVED · READ-ONLY
Started by Doombringer 12 posts View original ↗
  1. Hello, o/

    In RPG Maker MV, I'm using an action battle system, but I'd like to have 2 types of skill "pools"/bars. What I mean by that is, for example, I'd like to use Mana for magic skills and another for physical skills, since I won't be using the battle system the maker itself provides, I figured I'd use the TP.

    The thing is, since I'm new, I just found out that TP is usually for the normal battle system, so I googled around for some sort of script or plugin that allows me to set TP outside of battle, because it's always "0", and found these 2 threads:

    https://forums.rpgmakerweb.com/index.php?threads/can-anyone-help-me-change-default-tp.46974/

    [embedded media]

    In the first one, there are these 2 lines:
    Code:
    Game_Battler.prototype.initTp = function() { this.setTp(Math.randomInt(25));};So just change that to:
    
    Game_Battler.prototype.initTp = function() { this.setTp(0);};Or add a new plugin with just that...
    Now, I don't know Javascript, but I'm assuming ("Game_Battler") that'll only work during normal battle.

    In the second one, there was a comment saying to put this:
    Code:
    <Custom Execution>
    user.setTp(0);
    </Custom Execution>
    Into a note tag and use the YEP Skill Core, but nothing happens. Also, I'm assuming the "note tag" is the one from picture "1"?

    I tried going to the third tab and putting the code in to a script (picture "2") but when I start the game, I get an error that keeps stacking on indefinitely(picture "3").

    I don't know what else to do since I don't know Javascript. :(
  2. Close, but not quite. The comment for <Custom Execution>is for skills in the database and will make the code inside run when that skill is used.

    Just because the class is called Game_Battler doesn't in any way mean it's only relevant in battles. It just contains all the properties and functions of an entity that participates in battle. You can still execute Javascript on the map, in another scene, anywhere else in the game you like that accesses/manipulates the stats of a battler, including their TP value.
  3. Wow, thank you for such a "Speedy" response. :3

    So, let's see if I get this.
    In order to use the "<Custom Execution>" in the note tag, I need to assign a skill to an event and then use it?
    As for the other case, I can use it as it is?
    Code:
    Game_Battler.prototype.initTp = function() { this.setTp(100);};
    If so, just create a plugin and put this ^ ?

    Edit: I tried using the Plugin Command inserting the code above and also creating an actual ".js" file with it in it, but absolutely nothing happened.
    Edit 2: I tried putting only "user.setTp(100);" in a script, but then I get an error that says "user not defined".
    I tried putting the actual name of the character/actor instead of "user" and also "userName" but it keeps saying the same error.
    I tried putting the actual ID of the actor instead of "user" but then I get another error saying that the thing is invalid.
    Edit 3: I FOUND A SOLUTION!!!
    I don't know how I didn't stumble upon this earlier.

    https://forums.rpgmakerweb.com/inde...tle-tp-tp-cost-gain-tp-damage-and-more.50692/

    Using SumRndmDde's plugin from the link above and then creating a parallel event with a plugin command (SetActorTP[actorID][value] - picture "4"):
    Code:
    SetActorTP 1 100

    Result -> picture "5". I hope other people find this helpful as well. (づ。◕‿‿◕。)づ
  4. try
    Code:
    $gameActors.actor(ACTOR ID HERE).setTp(100)
    in a script call.

    Obviously replace "ACTOR ID HERE" with the actor's id number that you want to affect. But as Trihan just said, this is for out of combat changes. to modify your skill with the <custom execution> put it in that skill's notebox in the database.
  5. Sorry, I guess I didn't explain the Yanfly notetag well enough. This will not do what you're looking for: it's intended to be added to the notetag of a skill in the Skills tab of the database, and the code inside it will then run when that skill is used in battle. It's completely separate from events.
  6. Looks like I was editing my post as you guys were typing and beat me to posting.
    Either way, thank you both. <3

    @Fugama's solution makes things a lot easier and I don't have to use plugins, though. <3
  7. Yeah, I think the plugin you mentioned basically just does that. :p
  8. True, but when you open the plugin, the option to show TP is not implemented. You're obligated to use a plugin command and without the plugin itself, the command doesn't work.

    By the way, if I wanted the TP to "regenerate" every few seconds, e.g. 10 TP per 5 seconds, how would I do that?
  9. If you wanted it to be that exact, you could write a plugin that aliases the update function of Game_Map to add 1 to a variable on each update, then check for it being 300 (as it's 60 frames per second), increase TP by 10, and set the variable to 0.

    Or just have a parallel process event on each map that waits 300 frames and then adds 10 TP, but that's the boring way. :)
  10. Was just about to update my previous post; you beat me to i again. xD

    To be honest I don't really understand this part "a plugin that aliases the update function of Game_Map to add 1 to a variable on each update".

    About the parallel thing, I think if it were to check if the TP was at, in this case, 100 every 5 seconds, it could impact the performance in the long run. Especially if there are a lot of events.

    What I was about to update was that I was going through the Script Call List and managed to write this up:
    Code:
    while ($gameActors.actor(actorID).tp < 100){
    $gameActors.actor(actorID).gainTp(10);
    this.wait(300);
    }

    What I'm not sure about is the "waiting" part. In the list it says "$gameInterpreter.wait(frames);", but there's a comment saying "There is no $gameInterpreter. The base Game_Interpreter is newed up in $gameMap._interpreter, $gameTroop._interpreter, etc." and since I don't really understand it and how I could change it up, I googled a bit and found this topic:

    https://rpgmakermv.co/threads/waiting-in-js.3239/

    There the OP was using a script in which it was written "this.wait(300);", so I suppose I could also do that?
    OP's code:
    Code:
    E1= $gameMap.event(1);
    E2 = $gameMap.event(2);
    E1.moveStraight(4);
    E1.requestBalloon(10);
    this.wait(30);
    E2.requestBalloon(1);

    I know there's an actual "wait" function in the second tab of the event commands, but I don't know how to put it in a "while" loop since it won't let me move the lines of code up and down once they're written.

    Edit: I tried the following things:

    Code:
    $gameActors.actor(1).setTp(50)
    while ($gameActors.actor(actorID).tp < 100){
    $gameActors.actor(actorID).gainTp(10);
    this.wait(300);
    }
    Since you mentioned "Game_Map", I figured I'd try something like this:
    Code:
    $gameActors.actor(1).setTp(50)
    while ($gameActors.actor(1).tp < 100){
    $gameActors.actor(1).gainTp(10);
    $gameMap._interpreter.wait(300);
    }

    The TP immediately jumps to 100 in both cases.
    I also tried putting the waiting options before the "gainTp", same result, though.
    Code:
    $gameActors.actor(1).setTp(50)
    while ($gameActors.actor(1).tp < 100){
    $gameActors.actor(1).gainTp(10);
    $gameInterpreter.wait(300);
    }

    In this last one I get a "Game interpreter not defined" error.
  11. What I meant was something like this:

    Code:
    var _Scene_Map_initialize = Scene_Map.prototype.initialize;
    Scene_Map.prototype.initialize = function() {
      _Scene_Map_initialize.call(this);
      this._tpCounter = 0;
    };
    
    var _Scene_Map_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function() {
      _Scene_Map_update.call(this);
      this._tpCounter++;
      if (this._tpCounter === 300) {
        $gameActors.forEach(function(actor) {
          if (actor.tp < 100) {
            actor.gainTp(10);
          }
        });
        this._tpCounter = 0;
      }
    };
  12. O.O

    I understand some parts of it (I code in Java), but I'm definitely not capable of writing that.
    Is this what goes into a .js file?

    Edit: So, I literally copy/pasted what you wrote and put it in a .js file but when I start the game and after those 5s, I get a "Type error: undefined is not a function" error (picture "6").

    I'm assuming I did it wrong?

    Edit 2: I found a workaround solution!!! (づ。◕‿‿◕。)づ
    So, I set my TP to 50 and then created a "Loop" using the in game event command. Then, inside I put a script to check if the TP is 100 and if not, to add 10. Then outside the script, I used the built in "wait" command for the 5s and now it seems to do what need it to do (picture "7"). Yay! :3

    Edit 3: Now there's another problem. I can't seem to find a way to assign TP to a variable. :(
    I tried Creating a Variable and then put in the script option:
    Code:
    $gameActors.actor(1).tp
    Unfortunately the value of the variable remains "0" when I try to show it on screen.

    Edit 4: After countless of searching there was absolutely not one place where someone had explained how to assign TP to a variable. I don't know if people really have no clue or they simply ignored other people's request, but I figured it out. It's not one script on how to do it, though. It's a combination of the event commands and scripts.

    So, this is how to assign TP to a variable:
    Create a control variable -> select your variable and insert the following script in the script....thing-y (picture "9"):

    Code:
    $gameActors.actor(1).tp;

    Yes, it's that simple. I can't believe I spent hours looking around on how to do it and even though I tried this, I now realize that I had forgotten to put the ";" at the end. feelsedman :(

    Also, if you want to check the TP using a Conditional Branch first and then assign it to a variable, one way to do it is like this:

    You select the Conditional Branch -> go to the script part at the end -> place this code there:
    Code:
    $gameActors.actor(1).tp <= 100
    Then you put the variable IN the conditional branch (picture "10").
    One thing I'm not sure is if the semicolon is relevant for the condition or not since it's not a full "If" script.

    I hope someone else finds this useful as well.
    Have fun making your RPGs! w00t w00t (づ。◕‿‿◕。)づ

    Edit 5: For some reason, once it reaches 100, the FPS drops significantly. I wonder why...
    Edit 6: I added a "Break Loop" at the end of the "If" and it seems to fix the issue (picture "11"). I don't know if it will "recharge" again if I lose TP, though and at the moment I can't test it.
    Edit 7: I just tested it and it keeps working. So the "Break Loop" does the trick, but my FPS seems kind of low. Not as much as before, but still.
    Edit 8: I used the "FPS Box" by pressing "F2" and it shows 60FPS. Everything is fine. I was just imagining it. xD