MV YEP_EnhancedTP Follow-up

Good morning.

It has been a long road rebuilding my skill system, and I could use JS assistance to get to the next stage of development. This post is a follow-up to these two posts regarding YEP_EnhancedTP and YEP_X_BattleStatistics JS assistance requests, thanks Turan:



Background:
Currently, my actors have access to all TP modes from the game start; their skills are in their inventory but hidden. More to follow. Said skills become visible based on which TP mode the actor is in, among other things, such as kill count. I was okay with things this way until I realized in battle when an actor's TP bar is fully charged, I have it set to lock down the basic "Attack" command until a TP skill is utilized. So if they are in a TP mode where they have not learned the skill yet, this creates a problem as their"Attack" command becomes locked for the remainder of the battle because they have no skill to utilize to unlock it.

Solution?:
If I were to start the user with only one TP mode instead of all four (which would have been preferred anyways), is there a way to add to the following script to have it unlock the next TP mode when the "killCount" is reached?:

JavaScript:
<Custom Show Eval>
visible=user.tpModeId()==2 && user.killCount()>=82;
</Custom Show Eval>

I do not think it is possible, so my other idea was to achieve the ask via Common Events but not sure where to begin...

Assistance is appreciated because I am out of ideas.
\when an actor's TP bar is fully charged, I have it set to lock down the basic "Attack" command until a TP skill is utilized. So if they are in a TP mode where they have not learned the skill yet, this creates a problem as their "Attack" command becomes locked for the remainder of the battle because they have no skill to utilize to unlock it.
How are you doing this? You should probably be able to modify this to only disable Attack if they've also learned a skill.

(as a side note...is this necessary? Does it hurt anything if the player chooses to make suboptimal choices and Attack instead of using a skill?)

is there a way to add to the following script to have it unlock the next TP mode when the "killCount" is reached?:

JavaScript:
<Custom Show Eval>
visible=user.tpModeId()==2 && user.killCount()>=82;
</Custom Show Eval>
I don't really understand the question - the above code has nothing to do with unlocking modes. It determines whether a skill shows as available to use in the skill menu.

I do not think it is possible, so my other idea was to find a way to convert "killCount" into a variable to achieve the ask via Common Events by unlocking the TP modes with a "YEP_EnhancedTP" Plugin call, but not sure where to begin without a variable...
You don't need a variable.

Make a parallel common event. In it put a Script command:
Code:
var eligible=$gameParty.members().filter(actor => actor.killCount()>=82);
eligible.forEach(actor => actor.unlockTpMode(2));
Control Switch -> OFF (the switch that turns on this parallel event)

Hopefully you can read the numbers going on there - that will unlock TP mode 2 for every actor that has at least 82 kills. Modify those numbers as you like. If you want to unlock more modes that way, just copy and paste those two lines and change the numbers, but get rid of the var after the first line.

You'll make a Turn 0 Troop Event that turns on a switch which will activate the parallel event when the battle finishes, and copy it into each troop in your game (or use something like Yanfly's Base Troop Events).
How are you doing this? You should probably be able to modify this to only disable Attack if they've also learned a skill.

(as a side note...is this necessary? Does it hurt anything if the player chooses to make suboptimal choices and Attack instead of using a skill?)


I don't really understand the question - the above code has nothing to do with unlocking modes. It determines whether a skill shows as available to use in the skill menu.


You don't need a variable.

Make a parallel common event. In it put a Script command:
Code:
var eligible=$gameParty.members().filter(actor => actor.killCount()>=82);
eligible.forEach(actor => actor.unlockTpMode(2));
Control Switch -> OFF (the switch that turns on this parallel event)

Hopefully you can read the numbers going on there - that will unlock TP mode 2 for every actor that has at least 82 kills. Modify those numbers as you like. If you want to unlock more modes that way, just copy and paste those two lines and change the numbers, but get rid of the var after the first line.

You'll make a Turn 0 Troop Event that turns on a switch which will activate the parallel event when the battle finishes, and copy it into each troop in your game (or use something like Yanfly's Base Troop Events).
Answers to your questions:
1. This is how I locked down Attack (Skill #1):

JavaScript:
<Custom Show Eval>
  if (user.tp < 100) {
    visible = true;
  } else {
    visible = false;
  }
</Custom Show Eval>

1.a. Side note answer: Yes, it is necessary, without going into a long explanation of my game mechanics.

2. I suck at explaining things at times. Yes, I understand the code. Sorry, I was trying to show where I was at in looking for a solution to unlocking TP modes. Suppose that could be done by expounding the code; great; if not, no worries. I have no formal JS training, and the little I have learned has been from RPG making 🙂

Comments:
I understand the script you wrote enough to replicate it for other TP modes. Thank you.

Also, I have access to all Yanfly plugins, so the second part (base troop events) should not be an issue.
Answers to your questions:
1. This is how I locked down Attack (Skill #1):

JavaScript:
<Custom Show Eval>
  if (user.tp < 100) {
    visible = true;
  } else {
    visible = false;
  }
</Custom Show Eval>
You can add a check to the appropriate skills here, but it could get lengthy. If the code I gave you for unlocking modes will address your problem, that's easier.

Sorry, I was trying to show where I was at in looking for a solution to unlocking TP modes. Suppose that could be done by expounding the code; great; if not, no worries.
Well...you can put any JavaScript you want into that tag. But it seems not the appropriate place to check for and unlock TP modes every time they open their skill screen in battle - that's what I meant before. If that is what you want, though, to update it mid-battle, you can do it pretty easily.

Code:
<Custom Show Eval>
visible=false;
if (user.killCount>=82)
{
    user.unlockTpMode(2);
    if (user.tpModeId()==2)
        visible=true;
}
</Custom Show Eval>

It could result in some oddities, though, like the user would have to open the skill menu, see that skill is not available, then change to TP mode 2 (can you even do that during battle?) and see it enabled.
You'll make a Turn 0 Troop Event that turns on a switch which will activate the parallel event when the battle finishes, and copy it into each troop in your game (or use something like Yanfly's Base Troop Events).
Okay, I have set up the proposed common event triggered by switch 4895. The attached screenshot shows the "YEP_BaseTroopEvent" that turns on switch 4895 for the common event.

How do I turn off the switch after the battle? I am sure I missed something you explained, or I am probably overthinking it.

Thanks!
You can add a check to the appropriate skills here, but it could get lengthy. If the code I gave you for unlocking modes will address your problem, that's easier.


Well...you can put any JavaScript you want into that tag. But it seems not the appropriate place to check for and unlock TP modes every time they open their skill screen in battle - that's what I meant before. If that is what you want, though, to update it mid-battle, you can do it pretty easily.

Code:
<Custom Show Eval>
visible=false;
if (user.killCount>=82)
{
    user.unlockTpMode(2);
    if (user.tpModeId()==2)
        visible=true;
}
</Custom Show Eval>

It could result in some oddities, though, like the user would have to open the skill menu, see that skill is not available, then change to TP mode 2 (can you even do that during battle?) and see it enabled.
The first solution you presented would be the easiest way to achieve the desired result.

You cannot change TP modes in the battle, to my knowledge.
Facepalm! See attached. I answered my question. Talk about a brain fart...

Before closing this post, I need to devise a way of notifying the player when their new TP mode is unlocked.

Edited to add a question:
@ATT_Turan , is there a way to add a text box pop-up to the script you provided (below) that lets the player know when they have unlocked a new TP mode?

Code:
var eligible=$gameParty.members().filter(actor => actor.killCount()>=82);
eligible.forEach(actor => actor.unlockTpMode(2));
eligible=$gameParty.members().filter(actor => actor.killCount()>=177);
eligible.forEach(actor => actor.unlockTpMode(3));
Before closing this post, I need to devise a way of notifying the player when their new TP mode is unlocked.
Trying to notify which actor and which mode gets more complicated, between formatting it nicely and producing the text window from script. Notifying the player that something was unlocked is pretty simple.

Code:
var eligible=$gameParty.members().filter(actor => actor.killCount()>=82 && !actor._unlockedTpModes.includes(2));
if (eligible.length>0) {eligible.forEach(actor => actor.unlockTpMode(2)); $gameSwitches.setValue(1, true);}
eligible=$gameParty.members().filter(actor => actor.killCount()>=177 && !actor._unlockedTpModes.includes(3));
if (eligible.length>0) {eligible.forEach(actor => actor.unlockTpMode(3)); $gameSwitches.setValue(1, true);}
then, with Event Commands:
Conditional Branch -> Switch 1 ON
- Show Text "New TP mode unlocked!"
- Control Switches -> 1 OFF

where you replace the number 1 in both places in the script and the event command with whatever unused switch you want.
Trying to notify which actor and which mode gets more complicated, between formatting it nicely and producing the text window from script. Notifying the player that something was unlocked is pretty simple.

Code:
var eligible=$gameParty.members().filter(actor => actor.killCount()>=82 && !actor._unlockedTpModes.includes(2));
if (eligible.length>0) {eligible.forEach(actor => actor.unlockTpMode(2)); $gameSwitches.setValue(1, true);}
eligible=$gameParty.members().filter(actor => actor.killCount()>=177 && !actor._unlockedTpModes.includes(3));
if (eligible.length>0) {eligible.forEach(actor => actor.unlockTpMode(3)); $gameSwitches.setValue(1, true);}
then, with Event Commands:
Conditional Branch -> Switch 1 ON
- Show Text "New TP mode unlocked!"
- Control Switches -> 1 OFF

where you replace the number 1 in both places in the script and the event command with whatever unused switch you want.
That is perfect. Once I test it out, I will close this out. Thanks!
Answers to your questions:
1. This is how I locked down Attack (Skill #1):

JavaScript:
<Custom Show Eval>
if (user.tp < 100) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
@ATT_Turan , using the script above, how do I change the text color of Skill Type (#8) only when ATTACK is not visible?
No clue. I've never seen anyone make battle commands different colors.

I suppose you could use Eli's text codes anywhere plugin with some inline JavaScript conditionals.
Please disregard. I will tag this for closing when I have a chance to verify actions above.
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/yep_enhancedtp-follow-up.153439/