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,932
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,932
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

I've had some hard times. A co-worker accused me (not going into detail here), and I am trying finish training next week. Still not paid yet, I think next week.
I don't like hard boiled eggs...
it's weird to eat something that crunchy outside soft inside. And after chewing it for a while it started to spill red sauces that taste like iron.
Latest member to OcRam -plugin suite: OcRam_Layers! Optimized parallax layers (for parallax mapping?) + dynamic layers which can be used in title-, battle and map scenes!
People convinced me to use my old graphics for this new project, i guess i can't run away from blender just yet. https://gyazo.com/2a105847c042bb78c6d4919ec1308660

Forum statistics

Threads
102,963
Messages
996,322
Members
134,427
Latest member
bellin_blue
Top