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,215
Reaction score
14,248
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,269
Reaction score
1,675
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,215
Reaction score
14,248
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

Hi everyone! I've relased a demo about my new game in "Games in Development". Someone interested? :3
Going live at 2pm EST
Today is the day! I will be productive in game dev work! I will - *gets distracted by cat playing with her toy mouse* Awww <3
Whelp. I tried to be productive.
Decided to work on Fandom Scouts today. I've decided that instead of using the generic "scrolling text" event that MV has (I'm using MV for FS, not MZ) I'll use the movie option. I'm still trying to find a way to get Premiere Pro to output the compatible format though. If anyone can give me some help, it would be greatly appreciated!
Barthdry wrote on tln143's profile.
Hello tln143 Welcome to the RPG Maker Forum. We wish you enjoy and make good rpg games

Forum statistics

Threads
109,040
Messages
1,041,557
Members
141,528
Latest member
Munchacha
Top