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,832
Reaction score
14,024
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,832
Reaction score
14,024
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 find great satisfaction in smiting spambots. I'm not really sure why.
I finally added my newly updated demo back to the website! It only took like 4 weeks of work...
Where is the "world-weary sigh" comment response when you need it? I need that one more than anything, but the closest we have is "wow" or "angry".
My apologies if it's out-of-place for my goyim-lookin' ass to be the one to say it, but the mythology of "Golems" is that they were created by Rabbis to protect Jewish villages from Anti-semetic attacks.

Forum statistics

Threads
107,775
Messages
1,032,064
Members
139,918
Latest member
Sianar
Top