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 Profile Posts

Just for the record I have greatly enjoyed the past couple months of using RPG Maker MV - enough that I went ahead and bought MZ although it's going to be a bit before I seriously start a project with that.
I have a pretty reasonable alpha of one game that's got roughly 4 hours of content and some bits and pieces of others after only about 300 hours total time and about 2 1/2 months of owning RPG Maker.....
I completely forgot which forum had the personal blogs for members. :LZSlol: It was probably a forum for the Ace program. I was going to see about posting a blog post, but I'm too tired, and if its associated with Ace, then its a moot point. :LZSlol:
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.

Forum statistics

Threads
102,969
Messages
996,368
Members
134,431
Latest member
OrigamiChan
Top