Eval based on element rate

CombatJazz

Villager
Member
Joined
Dec 29, 2015
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Hi, everyone. I think this one is pretty simple.

I have a passive state on everyone that does a thing. If you hit a weakness or crit, it does another thing. Otherwise, it does not. I'd like if there were a way to have a "custom action end effect" (yanfly Buff/States Core) that checks if the action that just happened hit a weakness or crit, and if so, it does stuff, but I don't know how to dynamically check for element rates. This is the code I have so far.

Code:
<Custom Action End Effect>
if (target.elementRate(1) > 1) || target.result().critical) {

} else {
  user.addState(257);
}
</Custom Action End Effect>
Specifically, the (target.elementRate(1)) to get changed into something that actually checks the particular element of the attack that just got used against them. Any help would be appreciated. Thank you!
 
Last edited:

CombatJazz

Villager
Member
Joined
Dec 29, 2015
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Solved it by ganking some code from elsewhere:

Code:
<Custom Confirm Effect>

if (this.isHpEffect() && value > 0) {

    var elements = this.getItemElements();

    k = elements.length;

    for (var i = 0; i < k; ++i) {

        var elementId = elements[i];

        if (target.elementRate(elementId) >= 1.01 && !user.isStateAffected(258)) {

            user.addState(258);

        } else {

            user.addState(257);

        }

    }

}

</Custom Confirm Effect>



<Custom Turn End Effect>

  if (target.result().critical && !user.isStateAffected(258)) {

    user.addState(258);

  } else {

    user.addState(257);

  }

</Custom Turn End Effect>
Mods can lock this thread! Just wanted to provide an update in case anyone finds it in the future and needs it
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Code:
<Custom Establish Effect>
if (this.calcElementRate(target) > 1 || target.result().critical) {
  // do stuff
} else {
  user.addState(257);
}
</Custom Establish Effect>
 

CombatJazz

Villager
Member
Joined
Dec 29, 2015
Messages
27
Reaction score
4
First Language
English
Primarily Uses
RMMV
Code:
<Custom Establish Effect>
if (this.calcElementRate(target) > 1 || target.result().critical) {
  // do stuff
} else {
  user.addState(257);
}
</Custom Establish Effect>
Oh that is much cleaner than my code, haha. Thank you!


EDIT: It turns out there's a slight problem - if the attack misses, the state never gets added, and thus you can attack again. Any way to account for this, @Trihan ?
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Yeah, I'll sort that for you when I get a sec. :)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

TMW the air quality is so bad, your hair changes color every time you wash it. :LZYyuck:
Finished two animations today. :kaojoy:
Sigony wrote on Ksi's profile.
Just wanna say that I love your videos.
When are you fighting Floyd Mayweather?
A game is a lot like pasta.
Pasta is technically edible after a few minutes of boiling, if a bit chewy, not very nice.
If you cook it with patience, perhaps with some oil, at a rolling boil in salted water, drain it and add a nice sauce with some roasted vegetables, and present it on a beautiful plate, with beautiful cutlery on a beautiful table in a beautiful restaurant with beautiful sounds and scents; VERY NICE.

Forum statistics

Threads
102,998
Messages
996,610
Members
134,474
Latest member
Spartanbuddy
Top