MV BattleActionExp + MP recovery troubles

I'm using Tsukihime's BattleActionExp plugin with the following formula:
Code:
Math.abs(b.result().hpDamage + b.result().mpDamage)
This allows the characters in the party to gain EXP not just by damaging enemies, but also healing each other, including healing MP.

I have it set up so that whenever a character targets themselves with an MP heal spell, they gain the same amount of MP that they lose. Thus, negating the effects of the MP heal.

This causes a problem though where the character who targets themselves with the spell won't recover MP, but they will gain EXP. Basically, since they lose MP and then gain it again, the Battle Action Exp plugin thinks that they have gained the MP.

I have tried making it so that they cannot select themselves with the spell using Yanfly's Target Core and Selection Control, but unfortunately this only works inside battles and not in the menu. If there is a way for it to work in the menu that would eliminate all of my issues I've had with the MP spells in general, but I can't seem to find anyone who has made that work.

I realize this is a pretty niche issue but if someone could help me figure out a solution it would be fantastic.
a little workaround-y, but does this sound like work for you? stick a condition in the formula that if the user and the target are the same person and the party isnt in battle, the mp portion is ignored entirely
Code:
Math.abs(b.result().hpDamage + !$gameParty.inBattle() && a==b ? 0 : b.result().mpDamage)
a little workaround-y, but does this sound like work for you? stick a condition in the formula that if the user and the target are the same person and the party isnt in battle, the mp portion is ignored entirely
Code:
Math.abs(b.result().hpDamage + !$gameParty.inBattle() && a==b ? 0 : b.result().mpDamage)
Ah, I should have thought of that xD I figured it was something easy enough and I just wasn't approaching it from the right angle. I'll test it out and get back to you 🙂\

EDIT: Okay, this is weird.
The caster no longer gains EXP if they use it on themselves. However, if they use it on someone else and THEN use it on themselves, they gain EXP again.
EDIT: Okay, this is weird.
The caster no longer gains EXP if they use it on themselves. However, if they use it on someone else and THEN use it on themselves, they gain EXP again.
weird indeed...

before going any further - can you confirm if this happens both before and after the formula change to that skill and other skills as well? if you were to use some other skill outside of battle on some number of other actors and then on the caster, does it give the correct amount of exp per use?

my guess from the description is that results arent being cleared between uses on the map and the exp calculation is sweeping through every actor's results to give out exp. I was going to suggest another formula that looks at the current scene's item, but if that guess is true then it wouldnt matter in the end
weird indeed...

before going any further - can you confirm if this happens both before and after the formula change to that skill and other skills as well? if you were to use some other skill outside of battle on some number of other actors and then on the caster, does it give the correct amount of exp per use?

my guess from the description is that results arent being cleared between uses on the map and the exp calculation is sweeping through every actor's results to give out exp. I was going to suggest another formula that looks at the current scene's item, but if that guess is true then it wouldnt matter in the end
With the original formula, it does indeed seem like the base value is being added to the amount of EXP earned each time.
The skill I'm testing it with adds 52 MP. So, with the formula, the caster should gain 52 EXP. However, on subsequent casts, it looks like it adds 52 EXP each time. You're right on the money!
With the original formula, it does indeed seem like the base value is being added to the amount of EXP earned each time.
The skill I'm testing it with adds 52 MP. So, with the formula, the caster should gain 52 EXP. However, on subsequent casts, it looks like it adds 52 EXP each time. You're right on the money!
that narrows things down considerably. I am in no position to peek into it now, but later today ill take a look at the plugin and try to fix it if nobody else has by then. chances are its some Game_Party method that just needs to call the clear function on each member's result.
that narrows things down considerably. I am in no position to peek into it now, but later today ill take a look at the plugin and try to fix it if nobody else has by then. chances are its some Game_Party method that just needs to call the clear function on each member's result.
Thank you very much 😀 the help is much appreciated.
I was so focused on testing if balance was good, NPCs and quests worked, etc. that I did not notice that EXP wasn't cleared like that, so you've even helped solve an issue I didn't know I had xD
save this as a .js file and load it directly after the HIME one
Code:
Game_Actor.prototype.applyActionExp = function() {
  Game_Battler.prototype.applyActionExp.call(this); 
  this.gainExp(this._gainedActionExp);
  this.clearActionExp();
};
it appears that the only time the exp to be gained by an actor from their actions is cleared is at the at the end of an action taken *in battle*. so out of battle, each each use of anything that would generate exp would just keep building it. above should make it so that whenever the actor is fully awarded that exp, it clears it right then and there.
save this as a .js file and load it directly after the HIME one
Code:
Game_Actor.prototype.applyActionExp = function() {
  Game_Battler.prototype.applyActionExp.call(this);
  this.gainExp(this._gainedActionExp);
  this.clearActionExp();
};
it appears that the only time the exp to be gained by an actor from their actions is cleared is at the at the end of an action taken *in battle*. so out of battle, each each use of anything that would generate exp would just keep building it. above should make it so that whenever the actor is fully awarded that exp, it clears it right then and there.
That did the trick 😀 Thank you so much!!

EDIT: For anyone reading this in the future, the proposed formula below resulted in no EXP being earned during battles:
Math.abs(b.result().hpDamage + !$gameParty.inBattle() && a==b ? 0 : b.result().mpDamage)
I switched to using this one that takes the enemy's EXP and Max HP into account. This one does gain EXP during battles:
Code:
Math.abs(b.isEnemy() ? (b.result().hpDamage / b.mhp) * b.exp() : b.result().hpDamage + !$gameParty.inBattle() && a==b ? 0 : b.result().mpDamage)
I don't actually know why, because the code seems to be exactly the same other than the addition of the clarifying enemy stats. I have also confirmed that the original one I used did gain EXP. Not sure what's going on there but figured I'd let people know just in case.

Original thread: https://forums.rpgmakerweb.com/threads/battleactionexp-mp-recovery-troubles.168667/