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
41,302
Reaction score
14,278
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,283
Reaction score
1,692
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
41,302
Reaction score
14,278
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 Profile Posts

-Updated- Lowered fog / found more problems :kaoswt2:
6 more weeks of this nutty semester. Then maybe I'll have time to game make. After I curl up and sleep for a day or two that is.
Wondering how big I can make Dorothy's skill menu before the game just becomes irredeemably bad.
Studio Blue is playing the RPG Maker game Phil Alone live now! Phil may be alone, but you don't have to be, come join us in chat!

Forum statistics

Threads
109,209
Messages
1,043,073
Members
141,725
Latest member
718346584zy
Top