How To: Encore Skill (Pokemon)

For those of you who've never played Pokemon before, Encore is a skill that locks the target into repeating the last skill they used, and prevents them from taking other actions.

To create this effect, we'll be using a few Yanfly Scripts
Buffs & States Core
Skill Core
Auto Passive States

Step 1 'Last Skill' Tracking state
Create a state and place the following into it's notetag
Spoiler
Code:
//Stores The User's Last used skill. Bypasses items for use with Encore

<Custom Passive Condition>

if($gameParty.inBattle()){

condition = true;

} else {

condition = false;

}

</Custom Passive Condition>

<Custom Turn Start Effect>

user._LastActionId = user._LastActionId || 0;

</Custom Turn Start Effect>



<Custom Remove Effect>

user._LastActionId = 0;

</Custom Remove Effect>



<Custom Initiate Effect>

var action = user.currentAction();

if (action && action.isSkill()) {

actionId = action.item().id || 0;

if(actionId != x) {//Set X equal to your "Keep Playing Skill" that I'll discuss later.
//You can also add "|| actionId != x" within the parentheses if there are other skills you don't want to be Encored.
user._LastActionId = action.item().id;

}

}

</Custom Initiate Effect>

I also tick 'Remove at Battle End', just incase.

Add this state as a passive to all of your actors and enemies.

This state
  • Passively Adds itself at the start of battle
  • At the start of every action, if the action was a skill that is not exempt, sets that to the subject's Last Skill Used
  • Removes itself outside of battle
  • Sets itself up with a default "Last Skill Used" of 0, meaning combatants who have not taken action yet in battle won't be encored.

Step 2: Setting Up your "Encore" State
Create another state. I call mine "Keep Playing"
Create a new skill type called "Encore" and have this state add that skill type.
Create a skill called "Keep Playing".
With this state afflicted, Seal all of the user's skill types except for the Encore type. Additionally, add the "Keep Playing" Skill while the subject has this state.
Have this state also seal the "Attack, Guard, Wait, & Escape Skills"
Tick "Remove at Battle End" and
I recommend you tick auto-removal, so that actors eventually escape encore naturally

Step 3: Setting up your "Encore & "Keep Playing" skills
Add an "Encore" skill

For "Encore"
Set the target as you like. I recommend "1 enemy" for accuracy to pokemon.
Set the hit type to "Certain Hit" unless you'd prefer it to be able to miss, then use either other option.

In encore's notetag add
Spoiler
Code:
<After Eval>

if(target._LastActionId > 0)

{

target.addState(X);//Replace "X" with the ID of your "Encore" State

}
</After Eval>

This skill will make sure the target's _LastActionID is greater than 0, meaning they've made some action that can be Encored during battle.

Then in your "Keep Playing Skill"
Set the scope to "The User" and the Skill type to Encore
Add this in it's notebox
Spoiler
Code:
<After Eval>

if(user.canPaySkillCost(user._LastActionId))

{

user.forceAction(user._LastActionId, -1);

}

else

{

user.forceAction(WAIT SKILL ID, -1);

}

BattleManager.forceAction(user);

</After Eval>

<Cast Animation: 0>

This will force the user to use the Skill with the ID matching their last skill used.

Because all other actions are sealed aside from the "Keep Playing" Skill, the user will be forced to use this skill until the state is removed.

You can optionally use Hime - Actor Battle Commands to disable item use as well.
It doesn't seem to be working for some reason. None of the Force Action commands seem to be working for me in fact. The enemies just wait and do nothing. I did remember to seal the "Wait" skill, so I don't think that's it either.
The enemies just wait and do nothing
theres your problem. enemies only use skills you tell them they can use, or you force them to use. sealing all of their skills and giving them access to keep playing wouldnt make them use it, and their action is only forced if they actually use keep playing.

The way i see it, you could either give all your enemies the keep playing skill and have its use condition set to having the encore state, or change the encore state to substitute the user's action to the last skill at the start of their turn

Original thread: https://forums.rpgmakerweb.com/threads/how-to-encore-skill-pokemon.95533/