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,727
Reaction score
13,997
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,222
Reaction score
1,630
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,727
Reaction score
13,997
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!!!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Who would think putting a power button on a side of a laptop is a good thing? You want to move the laptop and you suddenly press the button.
The second draft of my script is almost done, and I don't think I'm going to write a third draft. I'll make changes to dialogue here and there, but I'm happy with the series of events the way they are.
How you feel about font and dialogue box changing for every main character while the minor cast and regular npc get their own styles? Too much?
Just found an obviously custom effect (i.e. edited by me) in my resources>sounds folder called "rip jaw off". Dear Lord what is wrong with me as a person that at some point I needed a sound *specifically* for THAT??
(...rhetorical question.)

Forum statistics

Threads
107,526
Messages
1,030,277
Members
139,652
Latest member
jasasewamobilbali
Top