Checking if the user of a skill is affected by a state

asanogaijin

creating Valiant Souls
Member
Joined
Mar 4, 2018
Messages
11
Reaction score
13
First Language
EN, JP, GER
Primarily Uses
RMMV
Hi everyone! I would like to create a conditional branch in the common event used for the standard Attack command, checking if the user is affected by a certain state.

I'm using the conditional branch option with "script" selected and the following content

user.isStateAffected(31)

but it doesn't work. I've also tried

a.isStateAffected(31)

instead but it also didn't do anything.

Does anyone know how I can use the conditional branch to check if the user (not a specific character, since everyone uses/shares the Attack skill) of the skill is affected by a specific state or not? Thank you!

1606377496466.png
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,822
Reaction score
14,021
First Language
English
Primarily Uses
RMMV
user is never a valid term in event commands, unless you have a plugin that's looking for it.
a as the user and b as the target is only valid if you're putting something in the damage formula.

What are you going to do with it, if the user IS affected by that state? Is it something you can just put in the damage formula, before calculating the damage amount?
 

asanogaijin

creating Valiant Souls
Member
Joined
Mar 4, 2018
Messages
11
Reaction score
13
First Language
EN, JP, GER
Primarily Uses
RMMV
@Shaz thanks, that is already very helpful.

We have a bunch of really great Japanese voice actors voicing our characters, and I want to play a sound effect (a voice) when the character is attacking beside the SE that is part of the animation. Each character has 3 different versions of the "standard attacking voice" sound effect, so I've included a variable that randomly chooses one out of the three sound effects each time so it's not always the same, but I need to determine which character is attacking, hence the conditional branch.

I've done this in a very similar way (with a permanent state for each character) in MV, but in MZ I just can't get it to work properly ><
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,227
Reaction score
1,634
First Language
EN
Primarily Uses
RMMZ
I think this will check whether the last actor to act is affected by state 31, Conditional Branch > Script:
JavaScript:
$gameActors.actor($gameTemp.lastActionData(2)).isStateAffected(31)
($gameTemp.lastActionData(2) is equivalent to Control Variables > Game Data > Last Actor ID to Act.)

Note that there's a plugin called BattleVoiceMZ that you can find in your RMMZ install folder, under dlc\BasicResources\plugins\launch. It sounds like a good fit for your situation, so I thought I'd mention it~
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,822
Reaction score
14,021
First Language
English
Primarily Uses
RMMV
Yes, you'll want to do this as part of the damage formula. (Or better yet via a plugin as mentioned above)

The problem with doing it in a common event is that a common event attached to a skill is called AFTER the skill is used. You want it to happen while the skill is being used.
 

asanogaijin

creating Valiant Souls
Member
Joined
Mar 4, 2018
Messages
11
Reaction score
13
First Language
EN, JP, GER
Primarily Uses
RMMV
I think this will check whether the last actor to act is affected by state 31, Conditional Branch > Script:
JavaScript:
$gameActors.actor($gameTemp.lastActionData(2)).isStateAffected(31)
($gameTemp.lastActionData(2) is equivalent to Control Variables > Game Data > Last Actor ID to Act.)

Note that there's a plugin called BattleVoiceMZ that you can find in your RMMZ install folder, under dlc\BasicResources\plugins\launch. It sounds like a good fit for your situation, so I thought I'd mention it~
This is perfect, thank you so much!!!
 

Latest Threads

Latest Posts

Latest Profile Posts

I saw my new eye doctor today, he reminds me of Satoru Iwata for some reason
I've been using a modified version of a script called Multiple Messages. It makes my text boxes look like a Mario & Luigi game! There is something about it that bothers me a little bit, but I shouldn't worry about that now.

Side note, Mist's walking animation is almost perfectly in sync with Loose Yourself by Eminem.
Starting work on some stuff for the community. Hopefully it will be fun, and useful to somebody.
Searching what to play in my dead times, the nostalgia hit me hard and ended downloading the Patapon trilogy, hope I can avenge my child self and beating all the games hahaha
Finished the frontier and...I apologize to anyone who saw the trailer I posted and actually tried it. Technical marvel, crazy disjointed fetish story hidden inside a cheap milsim skin that has no idea what it's trying to be except sanctimonious and failing at even that. As much as I hate fallout 4's story, even it was better. I guess there just won't be another non-parody fallout after all.

Forum statistics

Threads
107,767
Messages
1,032,004
Members
139,913
Latest member
EpicLast
Top