States not being properly applied to enemies? (Buff/States, Auto Passive States)

Status
Not open for further replies.

NikkiKaji

Veteran
Veteran
Joined
Jun 30, 2016
Messages
30
Reaction score
6
First Language
English
Primarily Uses
Hello. As the title implies, I'm trying to create a weapon that has a chance to apply a negative state onto an enemy whenever a physical attack is used, but it's not working quite right.
So, first, I creative a passive state called "freeze chance" using yanfly's auto passive state, and set that passive state to the weapon in question. Then, I used this code so that the freeze state can be applied to enemies that are hit with physical attacks:
<Custom Establish Effect>
\\ I set the chance rate to 99 for the sake of testing
ChanceRate = 0.99;
if (this.isPhysical() && result.isHit() && Math.random() < ChanceRate) {
\\ State 12 is the frozen state
target.addState(12);
}
</Custom Establish Effect>
Then, I tested it in battle a few different ways. Hitting enemies with the default attack didn't work at all. Then, I tested it using a physical skill that targets all enemies, and the state was applied to all enemies except for the first one (Enemy A).
I know that I could just add an attack state to the weapon, but I want all physical attacks to have a chance to inflict freeze, not just the attack command.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,770
Reaction score
2,121
First Language
EN
Primarily Uses
RMMZ
Try this instead~
Code:
<Custom Establish Effect>
var ChanceRate = 1;  // 100% chance
if (this.isPhysical() && target.result().isHit() && Math.random() < ChanceRate) {
  target.addState(12);  // add frozen state
}
</Custom Establish Effect>
 

NikkiKaji

Veteran
Veteran
Joined
Jun 30, 2016
Messages
30
Reaction score
6
First Language
English
Primarily Uses
Try this instead~
Code:
<Custom Establish Effect>
var ChanceRate = 1;  // 100% chance
if (this.isPhysical() && target.result().isHit() && Math.random() < ChanceRate) {
  target.addState(12);  // add frozen state
}
</Custom Establish Effect>
That worked! Thank you so much! ^_^
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,941
Reaction score
5,855
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

RivalRamen_Games wrote on jacobv1014's profile.
I really like your profile picture! Who is that in it? is she an OC?
Making his first game
This scene was suppose to be a test... but now, it's going in the game as official side/optional content. :kaosalute:


functionality(This is function demo not game demo)
1 The door of ABS map can open upon clearing all the monsters
2 Secret room/road arrow/lighting/whatever others can be shown upon clearing too
3 Boss HP bar and loot effect, loot jump and item name color as well as the pick-up animation effect
4 Back to town and "victory aftermath" screen for ABS maps/rooms

Forum statistics

Threads
115,330
Messages
1,089,039
Members
149,994
Latest member
Huzzahhh
Top