Hello everyone!
I’m Melphilium, and this is my first post on this forum, so I apologize in advance if I make any mistakes.
I’d like to share a small RPG Maker MV plugin I created while working on my own project.
It’s inspired by the Disease status effect from Final Fantasy XII and recreates a similar mechanic in RPG Maker MV.
While the state is active, a battler’s Max HP is locked to its current HP.
I thought this mechanic might be useful for other developers, so I decided to share it.
The plugin is free for both commercial and non-commercial use. Feel free to modify it however you’d like—no permission is required.
If you decide to use it, I’d really appreciate it if you could credit “Melphilium” in your project.
I hope you find it useful. Thank you!
UwU
/*:
* @plugindesc [MV] State Lock MaxHP To CurrentHP v1.0
* @author Melphilium
*
* @help
* ============================================================================
* Overview
* ============================================================================
*
* Add the following notetag to a State:
*
* <LockCurrentHp>
*
* While a battler is affected by this state:
*
* - Max HP is locked to the battler's current HP.
* - HP recovery and healing will have no effect.
* - Damage can still reduce HP normally.
* - When the state is removed, Max HP returns to its original value.
*
* ============================================================================
* Example
* ============================================================================
*
* Original HP:
* HP: 500 / 1000
*
* After applying the state:
* HP: 500 / 500
*
* Attempt to heal:
* HP: 500 / 500
*
* Receive 100 damage:
* HP: 400 / 400
*
* After the state is removed:
* HP: 400 / 1000
*
* ============================================================================
* Compatibility
* ============================================================================
*
* RPG Maker MV
*
* ============================================================================
* Terms of Use
* ============================================================================
*
* Free for commercial and non-commercial use.
*
* You may modify this plugin to suit your project.
*
* No permission is required.
*
* Credit: Melphilium
*
*/
(function() {
// =========================================================================
// Utility
// =========================================================================
Game_BattlerBase.prototype.hasLockCurrentHpState = function() {
return this.states().some(function(state) {
return state && state.meta.LockCurrentHp;
});
};
// =========================================================================
// Param Max HP
// =========================================================================
const _Game_BattlerBase_param = Game_BattlerBase.prototype.param;
Game_BattlerBase.prototype.param = function(paramId) {
// Param ID 0 = Max HP
if (paramId === 0 && this.hasLockCurrentHpState()) {
return Math.max(this._hp, 1);
}
return _Game_BattlerBase_param.call(this, paramId);
};
// =========================================================================
// HP Clamp
// =========================================================================
const _Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh;
Game_BattlerBase.prototype.refresh = function() {
_Game_BattlerBase_refresh.call(this);
if (this.hasLockCurrentHpState()) {
this._hp = Math.min(this._hp, this.mhp);
}
};
})();