MV Need help with active defenses

I'm working on a game with active dodging and countering during enemy turns. I have came up with this code to start with, using SRD Sequence Inputs, but it's not working right.

Code:
$game_switches[25] == true
$gameVariables.value(11) == 1

START SEQUENCE INPUT: ok, 6
attack animation: target
wait for animation
END SEQUENCE INPUT

if (Input.isPressed('shift')
 SE: Blow1
 wait: 5
 $gameVariables.value(11) == 0.5
 action effect
 wait: 5
 $game_switches[25] == false
elif $gameVariables.value(6) < 5
 action effect
 wait: 5
 $game_switches[25] == false
else
 SE: Sword2
 motion guard: target
 wait: 5
end

if $gameSwitches(25) == true
 SE: Attack1
 wait: 5
 motion attack: target
 wait 5
 animation 2: target
 attack effect: user
end

The idea is that you can hold down a button to guard and take reduced damage, or you can risk being vulnerable to parry. Variable 6 in the sequence input is the parry command, and Variable 11 is a damage modifier that is applied and changes if the player is holding the guard button. Switch 25 changes if the player takes damage of any kind, and by the end of the attack, the player counters if it is still on.

Any help to improve this code would be appreciated. Thanks.
Well for one "elif" isn't a thing in yanfly's action sequencing. In fact, nested conditional branches aren't a thing either. Even if you have the somewhat elusive nested if plugin from serge of bibek, it needs to be written out as "else if", so I doubt any of that part actually works.

However, you never said what actually doesn't work. We probably need to know in order to help you outside of straight up code errors.

Another thing is that your block check only runs for a single frame since it's not a sequence input. (you only start one for the parry it looks like)

That's about as much as I can see after waking up just now.
$game_switches[25] == true
$gameVariables.value(11) == 1
Yanflys' action sequence plugin doesnt evaluate code without a command. without using the eval command, neither of those would do anything. Even then, one appears to be ruby syntax for ACE and would result in an error for trying to read a property on an undefined object. The other has a valid call for getting the value of a variable, but == is not how you set values in js and if it were, it wouldnt work here. setValue() should be used instead, but also yanfly already has a command to do that for action sequences.

if (Input.isPressed('shift')
the missing closing parenthesis should cause an error. also i believe yanfly's IF's dont require a set of parenthesis for their conditions. so removing the first opening one would also work.

elif $gameVariables.value(6) < 5
elif isnt a command provided in yanfly's action sequences nor a keyword in js. as far as i know, only python uses it, which would be totally irrelevant here
Yanflys' action sequence plugin doesnt evaluate code without a command. without using the eval command, neither of those would do anything. Even then, one appears to be ruby syntax for ACE and would result in an error for trying to read a property on an undefined object. The other has a valid call for getting the value of a variable, but == is not how you set values in js and if it were, it wouldnt work here. setValue() should be used instead, but also yanfly already has a command to do that for action sequences.


the missing closing parenthesis should cause an error. also i believe yanfly's IF's dont require a set of parenthesis for their conditions. so removing the first opening one would also work.


elif isnt a command provided in yanfly's action sequences nor a keyword in js. as far as i know, only python uses it, which would be totally irrelevant here

I've set the variables properly and added that one parenthesis. The only issue now would be that last point.

Here's what it looks like now:
Code:
CHANGE SWITCH 25: on
CHANGE VARIABLE 11: 1

START SEQUENCE INPUT: ok, 6
attack animation: target
wait for animation
END SEQUENCE INPUT

if (Input.isPressed('shift'))
 SE: Blow1
 motion guard: target
 wait: 10
 CHANGE VARIABLE 11: 2
 action effect
 wait: 5
 CHANGE SWITCH 25: off
elseif $gameVariables.value(6) < 5
 action effect
 wait: 5
 CHANGE SWITCH 25: off
else
 SE: Sword2
 motion guard: target
 wait: 5
end

I just have the input code for convenience.
else if
1754710171251.png


I just have the input code for convenience.
you can have js inside of yanfly's if command, but im not familiar with SRD's plugin at all and couldnt tell you if how youre using is correct. @SGHarlekin has already said that the block should only run for the single frame as it is.
else if
View attachment 346997


you can have js inside of yanfly's if command, but im not familiar with SRD's plugin at all and couldnt tell you if how youre using is correct. @SGHarlekin has already said that the block should only run for the single frame as it is.

I have it working excellently now!

Code:
CHANGE SWITCH 25: on
CHANGE VARIABLE 11 = 1

START SEQUENCE INPUT: ok, 6
action animation: target
wait for animation
END SEQUENCE INPUT

if (Input.isPressed('shift'))
 SE: Blow1
 motion guard: target
 wait: 10
 CHANGE VARIABLE 11 = 2
 action effect
 CHANGE VARIABLE 11 = 1
 wait: 5
 CHANGE SWITCH 25: off
else if $gameVariables.value(6) < 5
 action effect
 wait: 5
 CHANGE SWITCH 25: off
else
 SE: Sword2
 motion guard: target
 wait: 5
end
death break

if $gameSwitches.value(25) == true
 SE: Attack1
 wait: 5
 motion attack: target
 wait 5
 animation 2: user
 wait for animation
 action effect: user
end

Thank you!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-active-defenses.179456/