Check if target is a state affected

optiprimeful

Veteran
Veteran
Joined
Aug 27, 2017
Messages
83
Reaction score
6
First Language
English
Primarily Uses
RMMV
How do I check if the target of an attack has a state so that my common event activates?

Something like this $gameActors.actor(x).isStateAffected(x) but for the target of an attack.
Thanks.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,139
Reaction score
14,204
First Language
English
Primarily Uses
RMMV
In the damage formula, a is the attacker, and b is the target. So if the formula above is correct, you would use b.isStateAffected(x)
 

optiprimeful

Veteran
Veteran
Joined
Aug 27, 2017
Messages
83
Reaction score
6
First Language
English
Primarily Uses
RMMV
I meant something like a restriction to the common event. The target of the attack would need to be inflicted with a particular state for the common event to run. The problem with the formula is that the common event will run even if the target is not under the state requirement.
 

Frozen_Phoenix

Veteran
Veteran
Joined
Nov 15, 2014
Messages
133
Reaction score
75
First Language
Portuguese
Primarily Uses
RMMV
You can break the event if the condition is not met:

60lq3PwMTLiVbo4SPROy9Q.png
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
582
Reaction score
286
First Language
German
Primarily Uses
When I didn't know much about scripting I usually made my skills add an invisible state to the target. The common event would then check every battler for that state to determine if it was hit by the skill (before removing that state again).

You could use that strategy to find out if there is one target that is inflicted with both the "target marker" state and the state you originally wanted to check.
If there is none, the common event would end without doing anything (in a way like Frozen_Phoenix already suggested).

Alternatively, you can also extend the skills damage formula to set a switch or variable that your common event can check and reset. For example, if you add this before your actual damage formula:

if (b.isStateAffected( 15 )) $gameSwitches.setValue( 25 , true); (actual damage formula here)

Switch 25 would be "ON" if the target was inflicted with state 15 when you run the common event (The common event would be required to change the switch back to "OFF" of course in order to work the next time).
Keep in mind that if you use the damage formula for anything not related to calculating damage, you probably should not use the default "Auto Battle" trait for any actor that could learn the skill.

Edit: Replaced the damage formula suggestion.
 
Last edited:

optiprimeful

Veteran
Veteran
Joined
Aug 27, 2017
Messages
83
Reaction score
6
First Language
English
Primarily Uses
RMMV
Problem solved! I had no idea I could use a target mark state and totally forgot about the exit event processing. Thank you so much!
 

Latest Threads

Latest Profile Posts


I've started working on rpg maker again, and I can see a lot of improvement from when I was 13. I still have a long way to go, but I'm proud that I've gotten this far.
Animated Title screen is by SharkerrBlue(SB)
I am using the Nightmare Land pack.
I just can't walk to the store for lunch without walking past people smoking. It not only smells bad, it's probably poisoning me. I'm afraid I'll eventually have to be hospitalized. I can't take another path because there's too much traffic and drivers in the plaza are reckless sometimes. I almost got run over once, even after looking both ways.
RyanYe wrote on whtdragon's profile.
Your art works about Wyrvens and Dragons are sooooooooo cooooooooool~! I like them so bad
Can you create more? like Archangels, Devils, Titans, Cyclops!!
My valentine cutscene is now available on itch.io and you can get the "source code" as well, feel free to check it out!

The game page on itch can be found at:
A self-aware gamer, playing my game on video, and being honest about his feelings: :kaojoy:


It gets funny, there's heart, and his laptop is on fire as he plays. :kaoswt2:

Forum statistics

Threads
108,795
Messages
1,039,549
Members
141,245
Latest member
feedtalefour
Top