Hello!
Can someone please help me understand why, when I run this plugin, the window doesn't appear during battle? The idea is that this is a plugin with a note tag of <HPInput> that goes into a skill should then, in theory, cause a window to pop up when the skill is used, that lets the user input an amount of their HP they'd like to use to determine their skill's damage. But when I run it, the skill does some damage, but the window is never popping up 🙁
Thank you!
Can someone please help me understand why, when I run this plugin, the window doesn't appear during battle? The idea is that this is a plugin with a note tag of <HPInput> that goes into a skill should then, in theory, cause a window to pop up when the skill is used, that lets the user input an amount of their HP they'd like to use to determine their skill's damage. But when I run it, the skill does some damage, but the window is never popping up 🙁
JavaScript:
(() => {
let hpInputValue = 0;
const _Scene_Battle_onSkillOk = Scene_Battle.prototype.onSkillOk;
Scene_Battle.prototype.onSkillOk = function() {
const skill = BattleManager.inputtingAction().item();
if (skill && skill.meta.HPInput) {
this.openHPInputWindow();
} else {
_Scene_Battle_onSkillOk.call(this);
}
};
// Create input window
Scene_Battle.prototype.openHPInputWindow = function() {
this._hpInputWindow = new Window_NumberInput(new Rectangle(0, 0, 240, 120));
this._hpInputWindow.x = Graphics.boxWidth / 2 - 120;
this._hpInputWindow.y = Graphics.boxHeight / 2 - 60;
this._hpInputWindow.start();
this._hpInputWindow.setHandler("ok", () => {
hpInputValue = $gameVariables.value(1);
const actor = BattleManager.actor();
const maxSpend = actor.hp - 1;
if (hpInputValue > maxSpend) {
hpInputValue = maxSpend;
}
actor.gainHp(-hpInputValue);
this.removeChild(this._hpInputWindow);
_Scene_Battle_onSkillOk.call(this);
});
this._hpInputWindow.setHandler("cancel", () => {
this.removeChild(this._hpInputWindow);
});
this.addChild(this._hpInputWindow);
};
// Use in damage formula of skill
window.getHPSpent = function() {
return hpInputValue;
};
})();
Thank you!