Yanfly Stat Allocation Plugin Abuse/Bug

Hello,

I am using the above mentioned plugin.

I noticed people can cheat the game by applying a paint to Max HP or Max MP and taking it off and reapplying.

This will cause them to get a little bit if their health back.... so if they keep doing this, they can get all of their HP and MP back... They can leave just 1 point to always be able to do this anywhere they are.

Is this the best way to report these kind of bugs? I did not see a way to report this to yanfly directly.
Yanfly has made the bug reports a patreon-only feature due to the amount of reported bugs that weren't actually bugs.
Yee, looks like Yanfly explicitly set it to increase HP when allocating MHP, but forgot (?) to reverse the process on refund. 😅

If you save the code below as a plugin and load it after Yanfly's Stat Allocation, does it solve the issue?
Code:
// YEP_StatAllocation: alias for stat point refund method
_Window_AllocationList_cursorLeft = Window_AllocationList.prototype.cursorLeft;
Window_AllocationList.prototype.cursorLeft = function(wrap) {
	var maxHp = this._actor.mhp;				// Remember max HP & MP before refund
	var maxMp = this._actor.mmp;
	_Window_AllocationList_cursorLeft.call(this, wrap);	// Do the usual stuff
	var hpGain = this._actor.mhp - maxHp;			// Calculate change in max HP & MP
	var mpGain = this._actor.mmp - maxMp;
	this._actor._hp += hpGain;				// Adjust current HP & MP accordingly
	this._actor._mp += mpGain;
	SceneManager._scene.refreshWindows();			// Update display
};
[Edit: changed - to + in last two lines, oops.]
[Edit2: added scene refresh to show correct HP after adjustment.]
Hello Caethyril,

I appreciate you trying.

However this does not work. The cheat is still present however, this actually somehow gives players a higher current value than the max Value...

So when you play around with the points you get something like 814/800
👋 That's what I get for not testing it first! hpGain will be negative if current max HP is less than previous value (ditto mpGain); should add the difference in those last two lines, not subtract it. 😴 I edited my previous post, does that work better? 😅

Edit: actually, hang on, there's some odd behaviour where the first revert point is being ignored, still testing.

Edit2: @KillerGin ah, it's OK, just needed to refresh the windows at the end, edited my previous post again.

Still not perfect, though; I think I see why Yanfly avoided the issue. E.g. if an actor has 100 HP and refunds 100 (or more) max HP, this add-on will leave them with zero (or less) current HP. If you cap the HP at 1 or 0, the exploit can kick back in. It'll need something more comprehensive, though I'm not sure precisely what. Hopefully Yanfly will come up with an idea at some point. 😅
Hello,

How about making it so that it doesnt ever update the current Hp or MP?

Or just save the current.... and will give them only that until the dang menu is closed?

So if they took points away it will only give up to max.... or adjusted up and down will only give what ever the current amount was when the menu was open in the first place?
Cancelling out the HP change is one approach! I went back and fiddled around a bit...this seems to work:
Spoiler
Code:
_Scene_StatAllocation_processAllocateParam = Scene_StatAllocation.prototype.processAllocateParam;
Scene_StatAllocation.prototype.processAllocateParam = function() {
	var maxHp = this._actor.mhp;
	var maxMp = this._actor.mmp;
	_Scene_StatAllocation_processAllocateParam.call(this);
	var hpGain = this._actor.mhp - maxHp;
	var mpGain = this._actor.mmp - maxMp;
	this._actor._hp -= hpGain;			// Cancel out addition
	this._actor._mp -= mpGain;
	this._allocationWindow.activate();		// Re-refresh
	this.refreshWindows();
};
That will damage the actor if they refund enough max HP to bring it below their current HP, but it does make more sense than my original suggestion! Could try a ratiometric approach instead, where it attempts to preserve the current/max ratios:
Spoiler
Code:
_Scene_StatAllocation_processAllocateParam = Scene_StatAllocation.prototype.processAllocateParam;
Scene_StatAllocation.prototype.processAllocateParam = function() {
	var hpr = this._actor.hpRate();				// Get point/max ratios
	var mpr = this._actor.mpRate();
	_Scene_StatAllocation_processAllocateParam.call(this);	// Callback
	this._actor._hp = Math.floor(hpr * this._actor.mhp);	// Retain original rates, rounded down
	this._actor._mp = Math.floor(mpr * this._actor.mmp);
	this._allocationWindow.activate();			// Re-refresh
	this.refreshWindows();
};

_Window_AllocationList_cursorLeft = Window_AllocationList.prototype.cursorLeft;
Window_AllocationList.prototype.cursorLeft = function(wrap) {
	var hpr = this._actor.hpRate();				// Get point/max ratios
	var mpr = this._actor.mpRate();
	_Window_AllocationList_cursorLeft.call(this, wrap);	// Callback
	this._actor._hp = Math.floor(hpr * this._actor.mhp);	// Retain original rates, rounded down
	this._actor._mp = Math.floor(mpr * this._actor.mmp);
	SceneManager._scene.refreshWindows();			// Update display
};
May experience rounding errors with this one, but it seems fairly stable. Both of these work for me as plugins, just like my original suggestion. 🙂

Edit: hello future people! Yanfly has since released v1.02 of Stat Allocation to fix this exploit~
Ah so you say this one works pretty well? Ill definitely have to check later today. Awesome. Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-stat-allocation-plugin-abuse-bug.105256/