In my last post , I detailed how I adapted a tutorial for RPG Maker VX ACE by Pixii to display a Zelda-type HUD for Faraway Foibles (the game I am writing).
The HUD employed Common Events and the MapTransferCommonEvent plug-in to work.
Instead, I found a plug-in written by Pivoo called Pv_Scriptlets that allows me to run the code without having to use a common event on every map.
Now, the implementation is much simpler.
After copying Pv_Scriptlets.js into my project's JS / PLUGINS folder, I added it to my project and placed it second on my plug-ins list.
I then edited the JavaScript Scripts Parameters under the plug-in's General Settings, adding an entry called zHUD_HP.
I set the Type to "Parallel" and under the Script parameter I put the following value:
Number.prototype.roundTo = function (num) {
var xBuff = this% num;
if (xBuff <= (num / 2)) {
return this-xBuff;
} else {
return this + num-x Buff;
}
}
var calcHP = ($ gameActors.actor (1) .hp * 112) / $ gameActors.actor (1) .mhp;
var pSuffix = calcHP.roundTo (4);
var pName = "zhud_hp_" + pSuffix;
var xTopRight = (Graphics.boxWidth * 0.75);
$ gameScreen.showPicture (1, pName, 0, xTopRight, 3, 100, 100, 255, 0);
I explain this code in detail in my previous Zelda HUD post.
I have toyed with a variation of the script that causes the hearts to blink when a character has critically low HP:
Number.prototype.roundTo = function (num) {
var xBuff = this% num;
if (xBuff <= (num / 2)) {
return this-xBuff;
} else {
return this + num-x Buff;
}
}
var calcHP = ($ gameActors.actor (1) .hp * 112) / $ gameActors.actor (1) .mhp;
var pSuffix = calcHP.roundTo (4);
an if (PSuffix <4) {
an if ($ GameSwitches.Value (14) == true) {
var pName = "Zhud_hp_8";
$ GameSwitches.SetValue (14, false);
} the else {
var pName = "Zhud_hp_0";
$ GameSwitches .setValue (14, true);
}
} else {
var pName = "zhud_hp_" + pSuffix;
$ gameSwitches.setValue (14, false);
}var xTopRight = (Graphics.boxWidth * 0.75);
$ gameScreen.showPicture (1, pName, 0, xTopRight, 3, 100, 100, 255, 0);
But I reverted to the original code because I felt that the constant additional calculation was causing performance lag.
So, there you have it.
I am not feeling one-hundred percent about the zHUD yet- I would like to find a way to have the hearts blink when HP is critically low that does not affect performance, and the HUD seems to disappear sometimes when I am screen capturing games play (see video below).
There are some errors when pops up sometime when the character is killed to appear the script trying to load a "zhud_hp_" file with a non-integer suffix, so clearly there are improvements that need to be made. But, it kind works for now so I will continue with other aspects of the game and address these problems at a later date.