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.
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.