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,600
Reaction score
1,931
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,600
Reaction score
1,931
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 Profile Posts

Hello I buyed RPG Maker VX Ace a long ago and I want to use it again but in the meantime I changed my pc but I lost the paper with my product key on so I can't use RPG maker again... someone can help me please ? or there is no hopes ?:'( ( I have a bad english I'm sorry )
I was away this days here in the forum but it was for a good cause!
The trailer of the demo of Luke Inn is on youtube and I am so happy!
I need to see the bugs of the game but I am happy that I have new content to show!

The last part of the modern interior will be ready soon. This will be a B-tile. With interior items for the kitchen, bathroom, toilet and storage room.
This frantic shooting ARPG plugin for MZ looks really great. Here is the link to a post from the official Japanese RPG Maker forum.

Forum statistics

Threads
102,941
Messages
996,125
Members
134,397
Latest member
Harwin
Top