Yanflys core engine, not playing nice

Consider the following code, executed in battle, DIRECTLY after a player commits an action:

        this._actorWhobrokeLaw.gainHp(-lawObject.amount);        if (this._actorWhobrokeLaw._hp <= 0) {          this._actorWhobrokeLaw.die();          this._actorWhobrokeLaw.preformCollapse();        }Couple things to note: this._actorWhobrokeLaw is a game actor instance. Obviously.  lets assume amount is 1000.

So what happens when a player executes the attack command and this code is triggered?

Screen Shot 2015-11-12 at 1.18.57 PM.png

The first thing in the stack is the

Screen Shot 2015-11-12 at 1.20.10 PM.png

The particular line we care about is the else  in the inf statement.  the cursor blinks on context, I believe context is not defined in this instance.

How does this have anything to do with yanfly?

This code:

Screen Shot 2015-11-12 at 1.23.20 PM.png

particularly the: this.contents at the bottom of the page.

So my question is, how do you update the actors health directly after they execute an action? I have it so that I say, in the Game Action, apply function, that:

On hit, if target is a game enemy and the item is attack, take 1000 hp from the player.

Any ideas about these errors? Is there a simple solution here?
Try changing this line:

fillW = Math.floor(dw * rate);
for this:

fillW = Math.max(0, Math.floor(dw * rate));
and see if it works.

My guess is that your script is changing _hp to a negative value.

Game_BattlerBase.prototype.refresh should clamp the _hp to 0, but the gauge may be updating first.
hmm, instead of doing that I might actually do:

var health = this._actorWhobrokeLaw._hpvar health -= lawObject.amount;check if health is below 0, if so kill the player, if not set the value of the players hp. thus it can never be below 0 😀
hmm, instead of doing that I might actually do:

var health = this._actorWhobrokeLaw._hpvar health -= lawObject.amount;check if health is below 0, if so kill the player, if not set the value of the players hp. thus it can never be below 0 😀
Sure, but it would be good to test if Yanfly's script is really crashing with negative hps and report the issue to him.
The issue I do not think is with yanfly, so I updated the code to:

        var health = this._actorWhobrokeLaw._hp;        health -= lawObject.amount        if (health <= 0) {          this._actorWhobrokeLaw.die();          this._actorWhobrokeLaw.preformCollapse();        } else {          this._actorWhobrokeLaw._hp = health;        }Same issue ... I'll try your solution now

So just an update same issue even with your suggested fix hudel.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.


at OP's request

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-core-engine-not-playing-nice.50327/