RPG Maker Forums

Oh, boy! Here we go again...


Okay, for some reason when it reaches to the point of the low hp (and only that point), the game crashes with error "TypeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': float parameter 1 is non-finite."


Here's the code:


var FirehawkADK = FirehawkADK || {};
FirehawkADK.HPControl = FirehawkADK.HPControl || {};
// Reference the Plugin Manager's parameters.
var paramdeck = PluginManager.parameters('HPColor');
//Load variables set in the Plugin Manager.
FirehawkADK.HPControl.CompatMode = String(paramdeck['Compatibility Mode']).trim().toLowerCase() === 'true';
FirehawkADK.HPControl.LowHPLimit = parseFloat(paramdeck['Low HP']);
FirehawkADK.HPControl.CriticalHPLimit = parseFloat(paramdeck['Critical HP']);
FirehawkADK.HPControl.HPNormalBar1 = Number(paramdeck['Normal HP Color 1']);
FirehawkADK.HPControl.HPNormalBar2 = Number(paramdeck['Normal HP Color 2']);
FirehawkADK.HPControl.HPLowText = Number(paramdeck['Low HP Text']);
FirehawkADK.HPControl.HPBarLow1 = Number(paramdeck['Low HP Bar Color 1']);
FirehawkADK.HPControl.HPBarLow2 = Number (paramdeck['Low HP Bar Color 2']);
FirehawkADK.HPControl.CriticalHPText = Number(paramdeck['Critical HP Text']);
FirehawkADK.HPControl.CriticalHPBar1 = Number(paramdeck['Critical HP Bar Color 1']);
FirehawkADK.HPControl.CriticalHPBar2 = Number(paramdeck['Critical HP Bar Color 2']);

Window_Base.prototype.hpTextColorPicker = function(actor) {
if (actor.hp < actor.mhp * FirehawkADK.HPControl.CriticalHPLimit) return this.textColor(FirehawkADK.HPControl.CriticalHPText);
else if (actor.hp > actor.mhp * FirehawkADK.HPControl.CriticalHPLimit && actor.hp < actor.mhp * FirehawkADK.HPControl.LowHPLimit) return this.textColor(FirehawkADK.HPControl.HPLowText);
else return this.systemColor();
};

Window_Base.prototype.hpbarColorPicker1 = function(actor) {
if (actor.hp < actor.mhp * FirehawkADK.HPControl.CriticalHPLimit) return this.textColor(FirehawkADK.HPControl.CriticalHPBar1);
else if (actor.hp > actor.mhp * FirehawkADK.HPControl.CriticalHPLimit && actor.hp < actor.mhp * FirehawkADK.HPControl.LowHPLimit) return this.textColor(FirehawkADK.HPControl.HPBarLow1);
else if (FirehawkADK.HPControl.CompatMode == true) this.hpGaugeColor1();
else return this.textColor(FirehawkADK.HPControl.HPNormalBar1);
};

Window_Base.prototype.hpbarColorPicker2 = function(actor) {
if (actor.hp < actor.mhp * FirehawkADK.HPControl.CriticalHPLimit) return this.textColor(FirehawkADK.HPControl.CriticalHPBar2);
else if (actor.hp > actor.mhp * FirehawkADK.HPControl.CriticalHPLimit && actor.hp < actor.mhp * FirehawkADK.HPControl.LowHPLimit) return this.textColor(FirehawkADK.HPControl.HPBarLow2);
else if (FirehawkADK.HPControl.CompatMode == true) this.hpGaugeColor2();
else return this.textColor(FirehawkADK.HPControl.HPNormalBar2);
};

this.Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
width = width || 186;
var color1 = this.hpbarColorPicker1(actor);
var color2 = this.hpbarColorPicker2(actor);
this.drawGauge(x, y, width, actor.hpRate(), color1, color2);
this.changeTextColor(this.hpTextColorPicker(actor));
this.drawText(TextManager.hpA, x, y, 44);
this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
this.hpColor(actor), this.normalColor());
};

Window_Base.prototype.hpColor = function(actor) {
if (actor.isDead()) {
return this.deathColor();
} else if (actor.hp < actor.mhp * FirehawkADK.HPControl.CriticalHPLimit)
return this.textColor(FirehawkADK.HPControl.CriticalHPText);
else if (actor.hp > actor.mhp * FirehawkADK.HPControl.CriticalHPLimit && actor.hp < actor.mhp * FirehawkADK.HPControl.LowHPLimit)
return this.textColor(FirehawkADK.HPControl.HPLowText);
else {
return this.normalColor();
}
};


Here's the error log:


TypeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': float parameter 1 is non-finite.
    at TypeError (native)
    at Bitmap.getPixel (<game's folder>/js/rpg_core.js:906:30)
    at Window_MenuStatus.Window_Base.textColor (<game's folder>/js/rpg_windows.js:176:28)
    at Window_MenuStatus.Window_Base.hpColor (<game's folder>/js/plugins/HPColor.js:144:18)
    at Window_MenuStatus.Window_Base.drawActorName (<game's folder>/js/rpg_windows.js:500:31)
    at Window_MenuStatus.drawItem (<game's folder>/js/rpg_windows.js:1736:10)
    at Window_MenuStatus.Window_Selectable.drawAllItems (<game's folder>/js/rpg_windows.js:1250:18)
    at Window_MenuStatus.Window_Selectable.refresh (<game's folder>/js/rpg_windows.js:1277:14)

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,578
Members
137,843
Latest member
Betwixt000
Top