Hello again!
I have this notetag in a state that "sets a number of turn for a state". But it does not work, or I think it doesn't.
Maybe I misunderstood it's function. Anyway, I can setup the number of turns before the state fades away using the State Removal Conditions, but since I want to learn about scripting, I want to know if I just misunderstood the function of it or I made a mistake on using it.
Below is the notetag:
The way it's supposed to work is that every attack or skill, would add a stack of the state until the 5th stack in which it would trigger another state that actually stuns the enemy.
At it's current code, it works, the stacking works, but the state would not remove itself after 3 turns if I stopped attacking the enemy. I have to put the Removal Conditions manually instead of in this code.
So this is the code that confuses me, because I thought the function of this is to literally setup how many turns a state would last.
I have this notetag in a state that "sets a number of turn for a state". But it does not work, or I think it doesn't.
Maybe I misunderstood it's function. Anyway, I can setup the number of turns before the state fades away using the State Removal Conditions, but since I want to learn about scripting, I want to know if I just misunderstood the function of it or I made a mistake on using it.
Below is the notetag:
Code:
<Custom Confirm Effect>
// The State ID used for stage 1.
var stage1 = 14;
// The State ID used for stage 2.
var stage2 = 15;
// The State ID used for stage 3.
var stage3 = 16;
// The State ID used for stage 4.
var stage4 = 17;
// The State ID used for stage 5.
var stage5 = 18;
// The State ID used for stun.
var stun = 19;
// Check to see if the action is an attack.
if (this.isAttack()) {
// Check if the target is affected by stage 1.
if (target.isStateAffected(stage1)) {
// Set the number of turns for stage 1 to 3.
target.setStateTurns(stage1, 3);
// Check if the target is affected by stage 2.
} else if (target.isStateAffected(stage2)) {
// Set the number of turns for stage 2 to 3.
target.setStateTurns(stage2, 3);
// Check if the target is affected by stage 3.
} else if (target.isStateAffected(stage3)) {
// Set the number of turns for stage 3 to 3.
target.setStateTurns(stage3, 3);
// Check if the target is affected by stage 4.
} else if (target.isStateAffected(stage4)) {
// Set the number of turns for stage 4 to 3.
target.setStateTurns(stage4, 3);
// Check if the target is affected by stage 5.
} else if (target.isStateAffected(stage5)) {
// Set the number of turns for stage 5 to 3.
target.setStateTurns(stage5, 3);
}
// Check if the action is a skill and if the target and user are on opposite teams.
} else if (this.isSkill() && target.isActor() !== user.isActor()) {
// Check if the target is NOT affected by stages up to 5
if (!target.isStateAffected(stage1) && !target.isStateAffected(stage2) && !target.isStateAffected(stage3) && !target.isStateAffected(stage4) && !target.isStateAffected(stage5)) {
// Add stage 1 to the target.
target.addState(stage1);
// Check if the target is affected by stage 1.
} else if (target.isStateAffected(stage1)) {
// Remove stage 1.
target.removeState(stage1);
// Apply stage 2.
target.addState(stage2);
// Check if the target is affected by stage 2.
} else if (target.isStateAffected(stage2)) {
// Remove stage 2.
target.removeState(stage2);
// Apply stage 3.
target.addState(stage3);
// Check if the target is affected by stage 3.
} else if (target.isStateAffected(stage3)) {
// Remove stage 3.
target.removeState(stage3);
// Apply stage 4.
target.addState(stage4);
// Check if the target is affected by stage 4.
} else if (target.isStateAffected(stage4)) {
// Remove stage 4.
target.removeState(stage4);
// Apply stage 5.
target.addState(stage5);
// Check if the target is affected by stage 5.
} else if (target.isStateAffected(stage5)) {
// Remove stage 5.
target.removeState(stage5);
// Apply stun.
target.addState(stun);
}
}
</Custom Confirm Effect>
<Custom Conclude Effect>
// The State ID used for stun.
var stun = 19;
// Check if the target is affected by stun.
if (target.isStateAffected(stun)) {
// Play animation 0002 on target.
target.startAnimation(2);
}
</Custom Conclude Effect>
The way it's supposed to work is that every attack or skill, would add a stack of the state until the 5th stack in which it would trigger another state that actually stuns the enemy.
At it's current code, it works, the stacking works, but the state would not remove itself after 3 turns if I stopped attacking the enemy. I have to put the Removal Conditions manually instead of in this code.
Code:
// Set the number of turns for stage 1 to 3.
target.setStateTurns(stage1, 3);
So this is the code that confuses me, because I thought the function of this is to literally setup how many turns a state would last.