set MP to zero when changing equipment

Detulovnoc

Warper
Member
Joined
Feb 27, 2020
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
I've been trying to figure out all day how to set an actor's MP to 0 when changing equipment. I have tried calling user.setMp(0) and user.gainMp(-1000) when my item is equipped, but neither of these has any effect. I've tried doing this through Yanfly plugins and WAY_CustomOnEquipEval from Waynee95. Any assistance that can be provided for how to do this is much appreciated.
 

edho08

Villager
Member
Joined
Sep 11, 2020
Messages
5
Reaction score
5
First Language
Indonesian
Primarily Uses
RMMV
If you want your actor to set their MP to 0 whenever they change equipment, i think a simple plugin can do that. Something like this probably.

JavaScript:
//=============================================================================
// resetMPEquip.js v1.0
//=============================================================================

/*:
 * @plugindesc set mp to 0 when do equipping.
 * @author edho08
 */
 
var resetMPE = {} || resetMPE;
 
resetMPE.ori_changeEquip = Game_Actor.prototype.changeEquip;
resetMPE.ori_forceChangeEquip = Game_Actor.prototype.forceChangeEquip;

Game_Actor.prototype.changeEquip = function(slotId, item){
    resetMPE.ori_changeEquip.call(this, slotId, item);
    this._mp = 0;
}

Game_Actor.prototype.forceChangeEquip = function(slotId, item){
    resetMPE.ori_forceChangeEquip.call(this, slotId, item);
    this._mp = 0;
}
*Note: i use a supposed private var _mp from actor, you can change it with another func that change MP.
 

Detulovnoc

Warper
Member
Joined
Feb 27, 2020
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
Thanks for your help! I dug a little deeper and discovered where the MP was being set in Yanfly's plugin, but I really only want to set it to 0 when I change weapons. I'm pretty sure I can rework what you posted so it checks for that via slotId. Thanks again!
 

DragonKingDX2

Kamen Rider
Member
Joined
Feb 12, 2019
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
If you got it to work would you mind sharing it? I was also interested in something like this.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Anyone else find it amusing that people watch videos of tragedy and then try to take the "moral high ground" by having sympathy for the victims? Dude, you watched the tragedy for the same reason everyone else. People being injured is an instinctive human curiosity.
Say, does anyone know any other indie game development forums? Progress on my uni survey has been a little slow, so I wanna look into posting it around a bit more.

Forum statistics

Threads
104,304
Messages
1,005,415
Members
135,829
Latest member
LordPenguin666
Top