MV (Yanfly's) Action Sequence - Check if user is an enemy

Hello there.
I'm new here, sorry if I'm posting on the wrong Forum.
So, I'm trying to make a basic sequence I saw on youtube (Driftwood Gaming), but I want it not to work if the actor is an enemy. Tried checking that spreadsheet with all script calls but I don't think it's the right way.

Here's the sequence:
<setup action>

display action
immortal: targets, true

</setup action>


<target action>

if user.attackMotion() !== 'missle'
move user: targets, front, 20

//Here's what I was trying to do
else if user.isEnemy()
move user: targets, front, 20

else
perform start
end
wait for movement
motion attack: user
wait: 10
attack animation: target
wait for animation
action effect

</target action>
That's correct.

Are you saying that you see the movement happen when an actor uses the skill?
It's kinda confusing what you're asking, but if i don't remember wrong, isEnemy is actually valid. Or, you can do this (the inverse):

Code:
else if user.isActor()
    perform start
    end
    wait for movement
    motion attack: user
    wait: 10
    attack animation: target
    wait for animation
    action effect
else
    move user: targets, front, 20
That's correct.

Are you saying that you see the movement happen when an actor uses the skill?
Yes, it's the basic "attack animation". The Actor advances towards the enemy, strikes, then go back.
But I want it to perform only if the user is an Actor (I mean, the player characters). If it's an enemy, they should move a little, attack and then go back (or not move at all, just perform the attack).

It's kinda confusing what you're asking, but if i don't remember wrong, isEnemy is actually valid. Or, you can do this (the inverse):

Code:
else if user.isActor()
    perform start
    end
    wait for movement
    motion attack: user
    wait: 10
    attack animation: target
    wait for animation
    action effect
else
    move user: targets, front, 20
That didn't work either. Both Actors and Enemies are doing this animation.
I see your problem now. Remove the end from the code. Or change it to
Code:
else if user.isActor()
    perform start
    wait for movement
    motion attack: user
    wait: 10
    attack animation: target
    wait for animation
    action effect
else
    move user: targets, front, 20
end

"end" is used in ifs to dictate where if and its next conditions( if else) end. Putting it there just straight ends the code after "perform start"
I see your problem now. Remove the end from the code. Or change it to
I'm not sure what you're getting at with end - that's in the correct location. If you just remove it from the code, none of the conditionals will function.

Edit: I think I see what you're getting at, with the placement of end vs. the motion attack and such. Removing it is still not an option, though 😉

Your other point is correct, the OP's logic is backward.

The original post said the movement is desired if the battler is an enemy, but then post #4 says the enemy should not move.

So you want to be checking for the battler to be an actor to do the movement, not an enemy.

For what it's worth, this looks like you edited Yanfly's default attack action sequence. If you had just left it alone, that does exactly what you say you want 😛

Actors with melee weapons will run up to the target, enemies stay in place and flash.
That's why i said it's confusing. Although i have to say i haven't been keeping up with action sequences since i've made the switch to LMBS.
I did it! Now I see that I was dumb for not reading what I was doing at beginning (and why was it confusing for you guys lol sorry)

I see your problem now. Remove the end from the code. Or change it to
Code:
else if user.isActor()
    perform start
    wait for movement
    motion attack: user
    wait: 10
    attack animation: target
    wait for animation
    action effect
else
    move user: targets, front, 20
end

"end" is used in ifs to dictate where if and its next conditions( if else) end. Putting it there just straight ends the code after "perform start"
I didn't know about this. I'm new to this type of coding, never noticed it.

Your other point is correct, the OP's logic is backward.

The original post said the movement is desired if the battler is an enemy, but then post #4 says the enemy should not move.
Yeah, now I see that the line "move user: targets, front, 20" is actually the one making the sprite go towards the enemy, and not the one that makes nothing. I really need to review my coding courses.


Here's the code
Code:
<setup action>
display action
immortal: targets, true
</setup action>


<target action>
face user: targets
if user.attackMotion() !== 'missle'
perform start
else if user.isActor()
move user: targets, front, 20
end
if user.isEnemy()
perform start
end
wait for movement
motion attack: user
wait: 10
attack animation: target
wait for animation
action effect
</target action>

<finish action>
immortal: targets, false
clear battle log
perform finish
</finish action>
I did it! Now I see that I was dumb for not reading what I was doing at beginning (and why was it confusing for you guys lol sorry)


I didn't know about this. I'm new to this type of coding, never noticed it.


Yeah, now I see that the line "move user: targets, front, 20" is actually the one making the sprite go towards the enemy, and not the one that makes nothing. I really need to review my coding courses.


Here's the code
Code:
<setup action>
display action
immortal: targets, true
</setup action>


<target action>
face user: targets
if user.attackMotion() !== 'missle'
perform start
else if user.isActor()
move user: targets, front, 20
end
if user.isEnemy()
perform start
end
wait for movement
motion attack: user
wait: 10
attack animation: target
wait for animation
action effect
</target action>

<finish action>
immortal: targets, false
clear battle log
perform finish
</finish action>
Action sequences aren't that much of programming unless you want specific effects to happen in a single sequence, like what you asked. Glad to know you managed to work it out!
Here's the code
That's not going to work correctly because there's no such motion as "missle". Also, why have two conditions - the missile motion and the isEnemy() - that result in the same single command?

You can get rid of a chunk of code in there if you use either the AND or OR operators.

Code:
if user.isActor() && user.attackMotion() != 'missile'
    move user: target, front, 20
else
    perform start
end

(correct spelling thrown in as a bonus 😉 )
Action sequences aren't that much of programming unless you want specific effects to happen in a single sequence, like what you asked. Glad to know you managed to work it out!
It still uses the same logic. I'm kinda rusty so I didn't notice those basic details, but yeah, I figured it out.

That's not going to work correctly because there's no such motion as "missle".
It was actually just the copy/paste I did with the video. I thought it was referring to bow/gun attacks, which the plugin was able to detect (maybe using the weapon.png files? Or some other logic that the engine uses for autotiles). But yeah, I think I can remove this line as it has no pratical use.

Also, why have two conditions - the missile motion and the isEnemy() - that result in the same single command?
Just a preference. I used it a lot for "debugging" back in the day to make sure the conditions weren't using a null value or being ignored, for example. I can see why it may be strange to use in this scenario, but I like it that way.
It was actually just the copy/paste I did with the video. I thought it was referring to bow/gun attacks, which the plugin was able to detect (maybe using the weapon.png files? Or some other logic that the engine uses for autotiles). But yeah, I think I can remove this line as it has no pratical use.
It has a practical use, it's stopping "ranged" attackers from running up to the enemy. But you misspelled it - thus it wouldn't do anything in your original action sequence.

Notice it is still used in the code I provided you, and I made mention of correcting the spelling.
But you misspelled it - thus it wouldn't do anything in your original action sequence.
Oh, I see it now.

Notice it is still used in the code I provided you, and I made mention of correcting the spelling.
Yeah, now it works as I wanted to. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-action-sequence-check-if-user-is-an-enemy.160776/