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,603
Reaction score
1,940
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,603
Reaction score
1,940
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

Yes it took me this long to make a basic cape. :p Here is a shady necromancer elf to model it.



I dub him Nyxiel.
Thinking to make a portrait for almost every NPC in the game, and I'm already dreading the fun journey ahead.
A hilarious video at the beginning


What kind of drinks does a bar populated entirely by monsters serve?

Forum statistics

Threads
103,344
Messages
998,915
Members
134,856
Latest member
AlterSS
Top