YEP Equip Core HP/MP Issue

mangaka7

Villager
Member
Joined
Jan 10, 2014
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hey guys,

I've been having issues with YEP Equip Core since I installed it way back. I never dealt with the issue because I was busy mapping and doing other things. I was hoping the updates would fix this issue, but it persists. Maybe I'm an idiot and I'm doing something totally wrong. The plugin can be found here:

http://www.yanfly.moe/wiki/Equip_Core_(YEP)

The issue is when I have an actor that does not have full HP/MP and the actor equips an item that changes max HP/MP, the actor will lose some HP/MP every time the equipment is put on and removed. The lost of HP/MP will stop after a certain point. This doesn't happen when Equip Core is disabled. Putting the script in a different order doesn't seem to help. I have a video demonstrating this issue. All the YEP scripts shown are up to date as of the video's upload date.

It would be grateful if anybody can try this script on their own fresh project and confirm this issue. If you also have this issue and found a solution, please let me know.

Thank you,
-mangaka7

 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,036
Reaction score
6,693
First Language
German
Primarily Uses
RMMV
OK, first question whenever yanfly's plugins behave strangely:
are they installed in the correct order?

Yanfly's plugins have to be installed in exactly the correct order as given on his website - if you just add them when and where it tickles you, they can cause strange effects.

If the order is correct, please show us screenshots of your plugin manager and of how you configured the equipment
 

mangaka7

Villager
Member
Joined
Jan 10, 2014
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
OK, first question whenever yanfly's plugins behave strangely:
are they installed in the correct order?

Yanfly's plugins have to be installed in exactly the correct order as given on his website - if you just add them when and where it tickles you, they can cause strange effects.

If the order is correct, please show us screenshots of your plugin manager and of how you configured the equipment
Hello!

The beginning of the video shows the current order of plugins. Most of them are off and Yanfly's video states that it doesn't matter what order the Equip Core is installed.

Regardless, I will check if the other scripts are in order. As for the configuration of the equipment, in this case the ring, I'm basically using the tags. Alternatively, I can just put 50 on the HP and MP and the results will still be the same. Here's an image:

If there's something I'm doing wrong here, please let me know. I will get back to you on the plugin order.

 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,036
Reaction score
6,693
First Language
German
Primarily Uses
RMMV
Yanfly's video states that it doesn't matter what order the Equip Core is installed.
unfortunately that video is old, from a time when yanfly had only a few plugins.
even on top of the list on his website he now has placed a "strong recommendation" to install them in exactly that order, and all our experience with his plugins here on the forum clearly points to a requirement of that order for quite a number of errors and strange behaviour that otherwise would pop up.

second, please do NOT use videos for things that can be shown by screenshots. Videos are a bad choice to get help for a lot of reasons.
for example quite a lot of people on this site go only with their phones or on a limited bandwidth - they will never watch your video simply because they can't. And why should we go to the problem of finding a stable, readable point to stop the video if a screenshot doesn't have those problems?

what is the version of your project's rpg_core.js file? Please go to your project folder and open that file with a text editor to read the number at the end of the title line (no number means 1.0)
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,391
Reaction score
871
First Language
EN
Primarily Uses
RMMV
Just to mention: I suspect this is a rounding error. JavaScript is somewhat notorious in that regard, even among other programming languages (e.g. 0.1 + 0.2 = 0.30000000000000004). Looks like the value is getting rounded down for consistent and non-exploitable behaviour. :kaoslp:
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
It's an issue with applying HP Rate to the increase of current HP.

Part (or all) of the issue comes from this function:
Code:
Yanfly.Equip.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk;
Scene_Equip.prototype.onItemOk = function() {
    var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
    var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
    Yanfly.Equip.Scene_Equip_onItemOk.call(this);
    var max = this.actor().isDead() ? 0 : 1;
    var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
    this.actor().setHp(hpAmount);
    this.actor().setMp(parseInt(this.actor().mmp * mpRate));
    this._itemWindow.hide();
    this._statusWindow.refresh();
};
It's not adding a flat amount here (+50hp), it's calculating the HP amount based on the HP Rate.
To use an example:
  1. Harold has a max HP of 400
  2. The ring increases max HP by 50
  3. Harold gets damaged to 50% of his health (200)
  4. Harold equips the ring. His current HP is increased by +25 which is the ring bonus (+50) multiplied by his HP rate (50%)

I don't know if it's a bug or not, it's certainly unexpected behavior for consumable stats such as HP, MP, or TP. If the ring has +50 to MHP, as a player I would either expect my current HP to also go up +50, or for my current HP to not increase (max HP only). It works as I expect without the YEP plugin, so you might want to find where YEP is overwriting the core code and comment it out.
 

Winek

Villager
Member
Joined
Apr 12, 2017
Messages
26
Reaction score
3
First Language
English
Primarily Uses
RMMV
I haven't actually seen the script in details, but from what @Aloe Guvner has stated with the matter, you could easily fix the issue by going in Equip Core's plugin, finding the Scene_Equip.prototype.onItemOk function and replacing the hpRate and mpRate by this:
Code:
var hpRate = 1;
var mpRate = 1;
Do try it- I won't guarantee anything, but it's better than nothing, and it may just work- especially if @Aloe Guvner is right about the cause.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
The RPGs I've played deal with this by not modifying *current* HP when *max* HP is modified (that's how the core MV code works too). It would be better to comment out the lines that do setHp and setMp.

Changing the hpRate variable to 1 as suggested would cause the player to heal to full health each time they equipped something (I think). Because the line that sets hp would become basically "setHp(mhp * 1)"
 

Winek

Villager
Member
Joined
Apr 12, 2017
Messages
26
Reaction score
3
First Language
English
Primarily Uses
RMMV
Ah, yes, I just noticed. That's my bad. You're right. I misread it, thinking it was the item's hp increase times the rate, so figured doing 1 all the time would simply always increase it to the item's HP/MP increase.

From the looks of it, it should then be changed to this:
Code:
this.actor().setMp(parseInt(this.actor().mmp * itemMp));
But I haven't seen the script, so I have no idea where to get the item's HP/MP increase. In any case, the rates will definitively need to be removed.
 

mangaka7

Villager
Member
Joined
Jan 10, 2014
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
@Andar

The video was recorded on June 24, 2019. The plugins that you see are recent as of the date of the video. There's only a few scripts because I don't need all of them. The Equip Core doesn't rely on anything other than the Core Engine and it can be placed anywhere. In this case, the very bottom. With that said, I did check for updates to the Core Engine and the Equip Core and there aren't any updates.

However, the rpg_core.js has no number so it's outdated. So what I did today was to create a new project with the updated rpg_core (1.6.2) and I brought in only 2 of Yanfly plugins (CoreEngine and EquipCore). The problem is still there.

I have tried what the others below have suggested and it does have a direct effect. I will have to look into this more.

Noted about the video, it will not happen again. Thanks!

@Aloe Guvner

I would like the current HP/MP to stay the same. Only the maximum should be changed. With this plugin disabled, this is exactly how it works. I'm not sure what to do since I don't know much Javascript. I have done @Winek 's suggestion of changing the var hpRate to 1, but that does exactly what you stated above. So now we know partially what's causing the issue. I will look into this more, but if you find anything else, please let me know. Thanks for the help!

@Winek

I did what you suggested and changed that line. I get a "ReferenceError: itemMP is not defined" as soon as I equip the ring. Not sure what I can do at this point. I'll try to mess with the code and see if anything changes. Thanks!

 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
@mangaka7 Try this suggestion next:
It would be better to comment out the lines that do setHp and setMp.
To "comment out" in Javascript, write a // at the beginning of the line. That turns the line into a "comment", which is not part of the code anymore. So to try commenting those lines, it would looks like this:
Code:
Yanfly.Equip.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk;
Scene_Equip.prototype.onItemOk = function() {
    var hpRate = this.actor().hp / Math.max(1, this.actor().mhp);
    var mpRate = this.actor().mp / Math.max(1, this.actor().mmp);
    Yanfly.Equip.Scene_Equip_onItemOk.call(this);
    var max = this.actor().isDead() ? 0 : 1;
    var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate));
   //this.actor().setHp(hpAmount); 
   //this.actor().setMp(parseInt(this.actor().mmp * mpRate));
    this._itemWindow.hide();
    this._statusWindow.refresh();
};
(I'm on mobile so I hope the formatting doesn't look horrible. But it's just putting // in front of those two lines)
 

mangaka7

Villager
Member
Joined
Jan 10, 2014
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
@Aloe Guvner

Oh my god! I think that fixed the problem! I'm not seeing the current HP/MP being changed when I'm swapping the ring and other equipment. I also tried healing the character a little bit and the current HP/MP still stays the same.

It's strange the code is set up this way. Maybe Yanfly can update this in the future?

You are a life saver! Thank you very much!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

When you go to the beach watch out for coconuts. Coconuts are more dangerous than sharks. Fact.
Try to get into pixelart again, so far its a sucess.
Also finally found a useful pixeltutorial which helps a lot.
♫ Anyone knows an ant can't move a rubber tree plant, but he's got high hopes, he's got high hopes, he's got high apple pie in the sky hopes ♫
The three if us sat to watch "The day India Burned" to take notes. 10 minutes in, one went to sleep. I wanted to finish it but I couldn't stop tearing up (yawning makes me cry) so after 40 minutes I gave up. But now I'm not sleepy anymore :0
OH... OKAY... Well, VX Ace certainly never did THAT before. :mad:

Forum statistics

Threads
93,611
Messages
913,921
Members
123,167
Latest member
DanielSan
Top