Showing Enemy Intent before Turn

Hello!

I've been trying to show the next enemy action before their turn so that the player can prepare accordingly beforehand.
I've found 2 forum threads that discusses what I wanted to do, this and this.

I've tried to recreate them using the required notetags, but it never worked for me.
The enemy won't even attack or do anything and just skip their turn, they also do not show their next move.

Can someone enlighten me on what I'm doing wrong?

Skill Notetag:
Code:
<After Eval>
var old = 11
// Change # to the skill's required state
var newstate = $dataEnemies[user._enemyId].meta.states.split(',').map(function(n){return parseInt(n)});
// Reads the allowed state values from the enemy notetag
var index = Math.randomInt(newstate.length);
var choice = newstate[index]
if (user.isStateAffected(choice)) {
} else {
BattleManager._subject.removeState(old);
BattleManager._subject.addState(choice);
}
</After Eval>

<Custom Requirement>
var x = 11
// Change # to the skill's required state
if (user.isStateAffected(11)) {
value = true;
} else {
value = false;
}
</Custom Requirement>

Enemy Notetag:
Code:
<states:11,12>
This is how it looks in combat, 1st turn.
The "var x" in the Custom Requirement is pointless if you never use x and you directly type in isStateAffected(11) (which makes more sense to do anyway).

When do you actually give the enemy a state? The code in the states will do stuff once a skill is used, but you need to use a Turn 0 troop event or something to put it on in the first place and start the process.
The "var x" in the Custom Requirement is pointless if you never use x and you directly type in isStateAffected(11) (which makes more sense to do anyway).

When do you actually give the enemy a state? The code in the states will do stuff once a skill is used, but you need to use a Turn 0 troop event or something to put it on in the first place and start the process.

Thank you for replying.

I changed the skill notetag to this one:

Code:
<After Eval>
var old = 11
// Change # to the skill's required state
var newstate = $dataEnemies[user._enemyId].meta.states.split(',').map(function(n){return parseInt(n)});
// Reads the allowed state values from the enemy notetag
var index = Math.randomInt(newstate.length);
var choice = newstate[index]
if (user.isStateAffected(choice)) {
} else {
BattleManager._subject.removeState(old);
BattleManager._subject.addState(choice);
}
</After Eval>

<Custom Requirement>
// Change # to the skill's required state
if (user.isStateAffected(11)) {
value = true;
} else {
value = false;
}
</Custom Requirement>

Also, I made the Turn0 Troop as you said, applying the attack state.
I tried it in combat and they did attack, I also notice one of the enemy readied the next action, but after my 2nd turn, they just proceeded to skip their turn again.
Okay, well, show the code for that state/skill, then.
Attached are the states.

The codes for Attack Skill:

Code:
<After Eval>
var old = 11
// Change # to the skill's required state
var newstate = $dataEnemies[user._enemyId].meta.states.split(',').map(function(n){return parseInt(n)});
// Reads the allowed state values from the enemy notetag
var index = Math.randomInt(newstate.length);
var choice = newstate[index]
if (user.isStateAffected(choice)) {
} else {
BattleManager._subject.removeState(old);
BattleManager._subject.addState(choice);
}
</After Eval>

<Custom Requirement>
// Change # to the skill's required state
if (user.isStateAffected(11)) {
value = true;
} else {
value = false;
}
</Custom Requirement>

The codes for the Guard Skill:

Code:
<After Eval>
var old = 12
// Change # to the skill's required state
var newstate = $dataEnemies[user._enemyId].meta.states.split(',').map(function(n){return parseInt(n)});
// Reads the allowed state values from the enemy notetag
var index = Math.randomInt(newstate.length);
var choice = newstate[index]
if (user.isStateAffected(choice)) {
} else {
BattleManager._subject.removeState(old);
BattleManager._subject.addState(choice);
}
</After Eval>

<Custom Requirement>
// Change # to the skill's required state
if (user.isStateAffected(12)) {
value = true;
} else {
value = false;
}
</Custom Requirement>
I don't see the shot of the Guard skill in your database.
Attached are the skills page.

The notetags are the ones I posted above

Edit: I also tried removing the "add state: guard 100%" and the same thing happens after their first turn, the next turns they just skip any actions.
Do they actually still have the required state?

Your states have removal at the end of 1 turn, so I would expect:
- Enemy has Attack from the turn 0 event
- Enemy does Attack for their first action which gives them the Guard Next Turn state
- End of turn 1 happens, Guard Next Turn expires and is removed
- Turn 2 starts, enemy has no state, can't use any skill

Can you see they actually have the states going into the second turn?
Do they actually still have the required state?

Your states have removal at the end of 1 turn, so I would expect:
- Enemy has Attack from the turn 0 event
- Enemy does Attack for their first action which gives them the Guard Next Turn state
- End of turn 1 happens, Guard Next Turn expires and is removed
- Turn 2 starts, enemy has no state, can't use any skill

Can you see they actually have the states going into the second turn?

I removed them both on both states and now they are working properly!
Each enemy in the troop first starts with attacking state, they do the attack, and from there they randomly select their next turn between the 2 states and proceed on doing it, next turn it randomize again.

What if let's say I want a specific arrangement on their actions?
Let's say for example: Attack, Attack, Guard, Attack, Attack, Guard
You can use $gameTroop.turnCount() to reference your current turn and affect what you do inside the codes for the states.
You can use $gameTroop.turnCount() to reference your current turn and affect what you do inside the codes for the states.
Sorry but I don't know how to use that or where to place it.
I'm quite new. Sorry for the trouble.

Original thread: https://forums.rpgmakerweb.com/threads/showing-enemy-intent-before-turn.156082/