Use skill upon reaching Max TP

Hello, I was wondering if someone could make a plugin that enables you to use a skill automatically once you reach maximum TP.

Some things I was thinking of having inside the plugin:
  • TP Maximum should be defined by whatever plugin (usually Yanfly's Enhanced TP) is defining it.
    • TP doesn't need to be maxed out in order for the skill to be used (can define percentages either by decimals or a whole number)
  • This can be used by enemies and actors alike
  • The skill is used automatically at the end of the turn of the specified user without needing input and subsequently using up the turn
Those are just some ideas, but the Bolded/Italicized are more of a priority than anything else.

Thank you for taking a shot at this, i greatly appreciate your time. 🙂
Why not just put an event in the troop page that checks for TP of a certain value, on a certain participant and when its full, a force action is used? Or you could find a plugin that adds a state to the actor/enemy when TP is full and when it is, force an action in the troops event page? I don't think this needs a plugin specificly for this. I'm going to sleep now, but i'll fiddle around with troop events when i wake up to see if i can screenshot some examples on how to do this with events, but i certainly think it's possible to do this entirley with events
Why not just put an event in the troop page that checks for TP of a certain value, on a certain participant and when its full, a force action is used? Or you could find a plugin that adds a state to the actor/enemy when TP is full and when it is, force an action in the troops event page? I don't think this needs a plugin specificly for this. I'm going to sleep now, but i'll fiddle around with troop events when i wake up to see if i can screenshot some examples on how to do this with events, but i certainly think it's possible to do this entirley with events

Alright thanks. I looked, but it seems...complicated. I am not even sure how to check for TP with Conditional Branches...
https://forums.rpgmakerweb.com/index.php?threads/setting-a-variable-equal-to-tp.113642/#post-1004082
https://forums.rpgmakerweb.com/index.php?threads/how-do-you-refrence-a-specific-actors-tp.113038/

This should give you some ideas on how to do so
Yes, you'll need a script call to get the TP of an actor/enemy, e.g. one of these in Control Variables > Script~
Code:
$gameActors.actor(id).tp
$gameParty.members()[index].tp
$gameTroop.members()[index].tp
Replace id with the actor's database ID, or index with the battler's position in their unit (leader is position 0, followed by 1, 2, etc). That said, using events strikes me as kinda clunky in this case (unless it's going to be an ability confined to only a few actors/enemies) since you'll need to check each actor and troop position individually. 😅

I imagine there's a neater solution available with existing plugins, e.g. using a <Custom Turn End Effect> notetag from Yanfly's Buffs & States Core plugin...I found this Tips & Tricks article featuring a force action (requires Battle Engine Core due to the way it's written): Jump (MV Tips & Tricks). So you could maybe try a (passive?) state with something like this in its notebox:
Spoiler: Suggested state notetag (example, needs adjustment)
Code:
<Custom Turn End Effect>
if (user.tp >= 0.8 * user.maxTp()) {	// at or above 80% max TP
  var skill = 200;  // ID of skill to force
  var target = -2;  // target (-2 = previous target, -1 = random)
  BattleManager.queueForceAction(user, skill, target);
}
</Custom Turn End Effect>

Some clarifications that may help you get responses:
  1. How is the TP threshold determined: does each trigger skill have its own value and/or is it impacted by other factor(s)?
  2. How is the trigger skill determined?
    • Is it randomly selected from a pool of skills, and if so, how is the skill pool determined?
    • Do you want the player to be able to select the trigger skill themselves, and if so, when/how?
Yes, you'll need a script call to get the TP of an actor/enemy, e.g. one of these in Control Variables > Script~
Code:
$gameActors.actor(id).tp
$gameParty.members()[index].tp
$gameTroop.members()[index].tp
Replace id with the actor's database ID, or index with the battler's position in their unit (leader is position 0, followed by 1, 2, etc). That said, using events strikes me as kinda clunky in this case (unless it's going to be an ability confined to only a few actors/enemies) since you'll need to check each actor and troop position individually. 😅

I imagine there's a neater solution available with existing plugins, e.g. using a <Custom Turn End Effect> notetag from Yanfly's Buffs & States Core plugin...I found this Tips & Tricks article featuring a force action (requires Battle Engine Core due to the way it's written): Jump (MV Tips & Tricks). So you could maybe try a (passive?) state with something like this in its notebox:
Spoiler: Suggested state notetag (example, needs adjustment)
Code:
<Custom Turn End Effect>
if (user.tp >= 0.8 * user.maxTp()) {    // at or above 80% max TP
  var skill = 200;  // ID of skill to force
  var target = -2;  // target (-2 = previous target, -1 = random)
  BattleManager.queueForceAction(user, skill, target);
}
</Custom Turn End Effect>

Some clarifications that may help you get responses:
  1. How is the TP threshold determined: does each trigger skill have its own value and/or is it impacted by other factor(s)?
  2. How is the trigger skill determined?
    • Is it randomly selected from a pool of skills, and if so, how is the skill pool determined?
    • Do you want the player to be able to select the trigger skill themselves, and if so, when/how?

caethyril. It's always you. Why? LMAO you're the best.

To answer your questions first:

1. Skills are executed once the TP is at 100 (maximum). They use up all the TP.
2.1. It would be selected from a predefined skill. No pools are used.
2.2 No, I don't. I want them to use them automatically, without intervention.

Also, some questions of my own:

1. If i were to use that <Custom Turn End Effect>, would I need all three Action Sequence Packs referenced in that Jump article?

2.
Code:
var target = -2
is there a way to select all targets? The skills I wanted to implement this to were already targeting all enemies.

In regards to the script call, would that need to be in a common event that i can have a troop reference when needed?

How would that work if i wanted the specific enemy to use a specific skill upon reaching max tp?

Side note: I am assuming that i will be going with the Custom Turn End Effects, but I want to explore all possible areas. Also, I will report this post due to it not needing a plugin so a moderator can move it to the correct location. 🙂


Thank you for the information. Although this was not what I was looking for, thank you for taking the time to look for it for me. 🙂
The OP has asked for this to be moved as they now will not be using a plugin but would still like some help.

Moderator note: Moving this.
Iv'e got it. Set up a number of variables equal to the number of party members you have. In the troop event page set it up so each turn it sets the variables equal to the respective actors TP. Then, in conditinal branches, check if the variable is equal to whatever your max TP is. If it is, force action. Set the contition to turn 1+1. You'll have to also turn on a switch in the event page

Edit: $gameActors.actor(x).tp is the command you want in the set variable
Iv'e got it. Set up a number of variables equal to the number of party members you have. In the troop event page set it up so each turn it sets the variables equal to the respective actors TP. Then, in conditinal branches, check if the variable is equal to whatever your max TP is. If it is, force action. Set the contition to turn 1+1. You'll have to also turn on a switch in the event page

Cool. I'll look into this when I get back on my computer. Sounds a bit complicated, but I should be able to do it. Thanks.

Still gonna wait on Caethryil to see what she says. Thank you though!
It's simpler than you think

MAXTP.png

Edit: I didn't set the variables correctly >.<
on the bottom one i should have put (2) instead of (1), but you get the idea
1. If i were to use that <Custom Turn End Effect>, would I need all three Action Sequence Packs referenced in that Jump article?

2.
Code:
var target = -2
is there a way to select all targets? The skills I wanted to implement this to were already targeting all enemies.
  1. You shouldn't need any of the sequence pack add-ons for this little force-action thing.
  2. A skill with "All Allies" or "All Enemies" scope should target all members of that unit, force-action doesn't override the skill's scope. 🙂
In regards to the script call, would that need to be in a common event that i can have a troop reference when needed?

How would that work if i wanted the specific enemy to use a specific skill upon reaching max tp?
I've been looking into that~
  • One option would be to have a separate state for each trigger skill: probably the easiest route if you only have a few different skills.

  • Alternatively, I tested out a state with this in its notebox:
    Spoiler: Chunky state notetag
    Code:
    <turnEndSkill: 8,9,10>
    
    <Custom Turn End Effect>
    if (user.tp >= user.maxTp()) {
      var skills = user.traitObjects().reduce(function(a, c) {
        var m = c.meta.turnEndSkill;
        m = m ? m.split(',').map(function(n) { return parseInt(n, 10); }) : null;
        return m ? a.concat(m) : a;
      }, []);
      var len = skills.length;
      var skill = len > 0 ? skills[Math.randomInt(len)] : 0;
      if (skill > 0) {
        var target = -1;   // random
        BattleManager.queueForceAction(user, skill, target);
      }
    }
    </Custom Turn End Effect>
    I gave Harold the state and full TP, then at the end of each turn he'd cast skill 8 (heal, one ally), 9 (fire, one enemy), or 10 (spark, all enemies) on an appropriate target. I lowered his TP and the force-actions stopped. 😂

    It needs Yanfly's Battle Engine Core + Buffs & States Core plugins. Basically, you can add a <turnEndSkill: x> notetag to any "trait object": actor, class, enemy, weapon, armor, or (as you can see) state. The big <Custom Turn End Effect> tag checks for these <turnEndSkill> tags, grabs a random number from the ones it finds, and uses that as the skill ID. If there's only one number, it'll use that; if there's none, no skill will be forced.
It's simpler than you think

View attachment 124474

Edit: I didn't set the variables correctly >.<
on the bottom one i should have put (2) instead of (1), but you get the idea

This didn't work for me. :/ Sorry. Thank you for trying though. I really appreciate you helping me. 🙂

  1. You shouldn't need any of the sequence pack add-ons for this little force-action thing.
  2. A skill with "All Allies" or "All Enemies" scope should target all members of that unit, force-action doesn't override the skill's scope. 🙂
I've been looking into that~
  • One option would be to have a separate state for each trigger skill: probably the easiest route if you only have a few different skills.

  • Alternatively, I tested out a state with this in its notebox:
    Spoiler: Chunky state notetag
    Code:
    <turnEndSkill: 8,9,10>
    
    <Custom Turn End Effect>
    if (user.tp >= user.maxTp()) {
      var skills = user.traitObjects().reduce(function(a, c) {
        var m = c.meta.turnEndSkill;
        m = m ? m.split(',').map(function(n) { return parseInt(n, 10); }) : null;
        return m ? a.concat(m) : a;
      }, []);
      var len = skills.length;
      var skill = len > 0 ? skills[Math.randomInt(len)] : 0;
      if (skill > 0) {
        var target = -1;   // random
        BattleManager.queueForceAction(user, skill, target);
      }
    }
    </Custom Turn End Effect>
    I gave Harold the state and full TP, then at the end of each turn he'd cast skill 8 (heal, one ally), 9 (fire, one enemy), or 10 (spark, all enemies) on an appropriate target. I lowered his TP and the force-actions stopped. 😂

    It needs Yanfly's Battle Engine Core + Buffs & States Core plugins. Basically, you can add a <turnEndSkill: x> notetag to any "trait object": actor, class, enemy, weapon, armor, or (as you can see) state. The big <Custom Turn End Effect> tag checks for these <turnEndSkill> tags, grabs a random number from the ones it finds, and uses that as the skill ID. If there's only one number, it'll use that; if there's none, no skill will be forced.

Can confirm this works. A little too well.

It uses the Force Action system and causes the enemy to have TWO effective turns, rather then being forced to use the skill on that very turn instead of whatever it would have used OR using it on the next turn instead of whatever it would have used.

But it does work, and it's very cool. Thank you Caethyril.
Can confirm this works. A little too well.

It uses the Force Action system and causes the enemy to have TWO effective turns, rather then being forced to use the skill on that very turn instead of whatever it would have used OR using it on the next turn instead of whatever it would have used.
Oh, I see! I misread your original request. 😴

Maybe try replacing the <Custom Turn End Effect>...</Custom Turn End Effect> with <Custom Turn Start Effect> instead? That'll make the force-action override whatever skill the user may have selected during that turn's input phase. 👋 Not sure how best to avoid them being able to input on that turn...maybe someone else has an idea there? 😅
Oh, I see! I misread your original request. 😴

Maybe try replacing the <Custom Turn End Effect>...</Custom Turn End Effect> with <Custom Turn Start Effect> instead? That'll make the force-action override whatever skill the user may have selected during that turn's input phase. 👋 Not sure how best to avoid them being able to input on that turn...maybe someone else has an idea there? 😅

Yea, I tried 'turnStartSkill' instead and it doesn't even register at all. :/

If anyone has any ideas, even if it might not be what I am looking for, shoot a post at me. Ill try it out and see if it works for me.
Yea, I tried 'turnStartSkill' instead and it doesn't even register at all. :/
Sounds like you used a different name for the notetag and didn't edit the code to check for a different name? What I meant was you can simply change the name of the actual Buffs & States Core notetag, so it triggers at a different time. 😅

Here's a version with all the "turn end" stuff replaced with "turn start" stuff:
Spoiler: Turn Start version
Code:
<turnStartSkill: 8,9,10>

<Custom Turn Start Effect>
if (user.tp >= user.maxTp()) {
  var skills = user.traitObjects().reduce(function(a, c) {
    var m = c.meta.turnStartSkill;
    m = m ? m.split(',').map(function(n) { return parseInt(n, 10); }) : null;
    return m ? a.concat(m) : a;
  }, []);
  var len = skills.length;
  var skill = len > 0 ? skills[Math.randomInt(len)] : 0;
  if (skill > 0) {
    var target = -1;   // random
    BattleManager.queueForceAction(user, skill, target);
  }
}
</Custom Turn Start Effect>
Sounds like you used a different name for the notetag and didn't edit the code to check for a different name? What I meant was you can simply change the name of the actual Buffs & States Core notetag, so it triggers at a different time. 😅

Here's a version with all the "turn end" stuff replaced with "turn start" stuff:
Spoiler: Turn Start version
Code:
<turnStartSkill: 8,9,10>

<Custom Turn Start Effect>
if (user.tp >= user.maxTp()) {
  var skills = user.traitObjects().reduce(function(a, c) {
    var m = c.meta.turnStartSkill;
    m = m ? m.split(',').map(function(n) { return parseInt(n, 10); }) : null;
    return m ? a.concat(m) : a;
  }, []);
  var len = skills.length;
  var skill = len > 0 ? skills[Math.randomInt(len)] : 0;
  if (skill > 0) {
    var target = -1;   // random
    BattleManager.queueForceAction(user, skill, target);
  }
}
</Custom Turn Start Effect>

OHHHHH. I see.
Code:
var m = c.meta.turnStartSkill;
That it what defines turnStartSkill/turnEndSkill. My bad. LMAO I didnt need all that after all. Pfft. Thank you again Caethyril

Edit: I think I found a better way to do this: http://www.yanfly.moe/wiki/Battle_A.I._Core_(YEP)

Edit 2: So maybe not. LMAO. I get a error about elements or something not being defined. Thank god I didn't delete anything.

Edit 3: So it actually works using:
Code:
<AI Priority>
EVAL user.tp === 100: [insert skill here without brackets], User
</AI Priority>
but in order to fix this issue, I had to install Yanfly Element Core plugin. But NOW, SRD Pokemon Type System does not register. At all. Am I going to have to use the Element plugin alone or is there a way for these two to work together?

Edit 4: I seem to have fixed it by having Yanfly Element Core OFF but still listed inside the plugin list. Hopefully nothing else breaks. LMAO

Original thread: https://forums.rpgmakerweb.com/threads/use-skill-upon-reaching-max-tp.113629/