zHUD (v0.8)
by dismal_science__ and Caethyril
https://www.youtube.com/embed/t2XAsJHW7G0
Spoiler: Screenshots
Introduction
zHUD is a very rudimentary HP Head-Up Display, reminiscent to the style used in the Zelda series.
zHUD is designed for use with single-actor games.
zHUD uses a set of image files to indicate HP status.
Parameters
Prefix
This is the prefix of the set of image files being used.
ImgWidth
This is the width of the image files being used (in pixels).
ImgMax
This is the total number of image files.
LastImgSuffix
This is the last number in the set of image files.
LowHealthSE
This is a sound effect to be used when HP is at a critically low level.
SE_Interval
This is the interval at which to play the sound effect (in milliseconds).
zActorID
This is the ID of the actor whose HP will be displayed.
How To Use
zHUD's filename must remain "zHUD.js" in order to work properly.
Place "zHUD.js" in your project's
JS/PLUGINS folder.
The
example includes 33 image files, all named similarly with the
Prefix "zhud_x_hp_" and the bearing the same width of "237" pixels.
The first image file-
"zhud_x_hp_0.png"- represents the image shown when HP is at its lowest.
The last image file-
"zhud_x_hp_128.png"- represents the image shown when HP is full.
The 31 images in-between represent the various possible HP states, in this case, increasing/reducing in increments of 4.
"zhud_x_hp_4.png"
"zhud_x_hp_64.png"
"zhud_x_hp_76.png"
(A few of the images from the example, "zHUD.zip")
The plug-in controls depend on the
ImgMax and the
LastImgSuffix parameters. The example uses 33 images, but the plug-in can use any number of files.
For the included example, the parameter
ImgMax should be set to "33" and
LastImgSuffix should be set to "128".
For this example, the
ImgWidth parameter should be set to "237". This may be adjusted depending on the size of the image used.
Place image files in your project's
IMG/PICTURES folder.
During gameplay, when HP reaches a critical low, zHUD activates an audible warning- specified in the
LowHealthSE parameter.
For the example-
LowHealthSE is set to "LowHPBeep", which represents the audio files "
LowHPBeep.ogg" and "
LowHPBeep.m4a".
Place audio files in the project's
AUDIO/SE folder.
SE_Interval represents the amount of time in milliseconds between beeping. It is set to "700" by default but may need to be adjusted depending on the length of the audio file that is used.
Finally, the
zActorID parameter is the number of the Actor who will be displayed.
zHUD usually updates its display automatically, but in cases where this doesn't happen, you may need to use a script call to do it manually.
Script call:
Code:
- dismal_sci.zHUD.refreshHUD ();
复制代码
Plug-In
zHUD.zip
(Google Drive. Compressed archive. Includes 1 JS, 33 PNGs, 1 OGG, 1 M4A files. 76 kb)
Script:
Code:
- /*:
- * zHUD.js
- *
- * @plugindesc (v0.8)
- * A Zelda-esque Head-Up Display.
- *
- * @author dismal_science__, caethyril
- *
- * @help
- *
- * zHUD is a very rudimentary HP HUD, reminiscent to the style used in the
- * Zelda series.
- *
- * zHUD is designed for use with single-actor games.
- *
- * zHUD uses a set of image files to indicate HP status.
- *
- *
- * =[ U S A G E ]===========================================================
- *
- * zHUD's filename must remain "zHUD.js" in order to work properly.
- *
- * The example includes 33 image files, all named similarly with the
- * prefix "zhud_x_hp_" and bearing the same width of "237" pixels.
- *
- * The first image file- "zhud_x_hp_0.png"- represents the image shown when
- * HP is at its lowest.
- *
- * The second image file- "zhud_x_hp_128.png"- represents the image shown
- * when HP is full.
- *
- * The 31 images in-between represent the various possible HP states, in this
- * case, increasing/reducing in increments of 4.
- *
- * The example uses 33 images, but the plug-in can use any number of files.
- * The plug-in adjusts depending on the ImgMax and LastImgSuffix parameters.
- *
- * For the included example, the parameter ImgMax should be set to "33" and
- * LastImgSuffix should be set to "128".
- *
- * For this example, the ImgWidth parameter should be set to "237".
- * This may be adjusted depending on the size of the image used.
- *
- * Place image files in your project's IMG/PICTURES folder.
- *
- * During gameplay, when HP reaches a critical low, zHUD activates an
- * audible warning- specified in the LowHealthSE parameter.
- *
- * For the example- LowHealthSE is set to "LowHPBeep", which represents the
- * audio files "LowHPBeep.ogg" and "LowHPBeep.m4a".
- *
- * Place audio files in the project's AUDIO/SE folder.
- *
- * SE_Interval represents the amount of time in milliseconds between beeping.
- * It is set to "700" by default but may need to be adjusted depending on the
- * length of the audio file that is used.
- *
- * Finally, the zActorID parameter is the number of the Actor whose HP will be
- * displayed.
- *
- * zHUD usually updates its display automatically, but in cases where this
- * doesn't happen, you may need to use a script call to do it manually.
- *
- * Script call: dismal_sci.zHUD.refreshHUD();
- *
- *
- * =[ E T C . ]===========================================================
- *
- * zHUD is written by dismal_science__ and caethyril.
- *
- * zHUD is free for use in both commercial and non-commercial projects,
- * as long as both authors are credited accordingly.
- *
- * For updates and copies of the example files mentioned in this help file,
- * please check out-
- *
- * https://ameblo.jp/dismal-science/entry-12454556656.html
- *
- *
- * For more of Caethyril's plug-ins, please check out-
- *
- * http://bit.ly/2UYQnpS
- *
- *
- * @param Prefix
- * @type text
- * @desc Filename prefix, ex. "zhud_x_hp_"
- * @default zhud_x_hp_
- *
- * @param ImgWidth
- * @type number
- * @desc Width of image (in pixels).
- * @default 237
- *
- * @param ImgMax
- * @type number
- * @desc Total number of images.
- * @default 33
- *
- * @param LastImgSuffix
- * @type number
- * @desc Suffix of last image in group.
- * @default 128
- *
- * @param LowHealthSE
- * @type file
- * @dir audio/se
- * @require 1
- * @desc Low HP Sound Effect, place in AUDIO/SE folder.
- * @default LowHPBeep
- *
- * @param SE_Interval
- * @type number
- * @desc Interval between Low HP Sound Effect beeps (in milliseconds).
- * @default 700
- *
- * @param zActorID
- * @type number
- * @desc ID of Actor whose HP will be displayed.
- * @default 1
- *
- */
- var dismal_sci = dismal_sci || {}; // Author namespace
- dismal_sci.zHUD = dismal_sci.zHUD || {}; // Plugin namespace
- (function($) {
- // Get parameters
- $.params = PluginManager.parameters('zHUD');
- if ($.params === undefined) throw new Error('zHUD parameters not found! Check the plugin is named correctly and try again.');
- // Define parameter variables on plugin namespace
- $.Prefix = $.params['Prefix'];
- $.ImgWidth = Number($.params['ImgWidth']);
- $.ImgMax = Number($.params['ImgMax']) - 1;
- $.LastImgSuffix = Number($.params['LastImgSuffix']);
- $.LowHealthSE = $.params['LowHealthSE'];
- $.SE_Interval = Number($.params['SE_Interval']);
- $.zActorID = Number($.params['zActorID']);
- // Other plugin variables
- $.lastHP = 0;
- // $.xRight = Graphics.boxWidth - ($.ImgWidth + 24); // boxWidth is not set yet!
- $.xOffset = $.ImgWidth + 24; // Alternative approach
- $.xRound = $.LastImgSuffix / $.ImgMax;
- // Round to nearest multiple of integer num
- Number.prototype.roundTo = function(num) {
- return Math.ceil(this/num) * num;
- };
-
- $.lowHP = Math.pow($.xRound,2);
- $.lowHP_SND = {name: $.LowHealthSE, volume: 90, pitch: 100, pan: 0};
-
- $.lowHP_beep = function() {
- if ($.beepInterval === undefined) {
- $.beepInterval = setInterval(function(){
- AudioManager.playSe($.lowHP_SND);
- }, $.SE_Interval);
- }
- };
-
- $.lowHP_beep_kill = function() {
- if ($.beepInterval != undefined) {
- clearInterval(this.beepInterval);
- delete this.beepInterval;
- }
- };
-
- // Display appropriate picture for HUD, via showPicture
- $.refreshHUD = function() {
- // console.log('Refreshing HUD!');
- var actor = $gameActors.actor($.zActorID);
- var calcHP = ($.LastImgSuffix * actor.hp / actor.mhp).roundTo($.xRound);
- if ($.lastHP === calcHP) return; // Only continue if changed
- $.lastHP = calcHP; // Remember HP
- // console.log('calculated:', calcHP, '\nlow:', $.lowHP);
- if (calcHP <= $.lowHP && calcHP > 0) { // at or below low HP, and not dead
- $.lowHP_beep();
- } else { // end beep in all other cases
- $.lowHP_beep_kill();
- };
- var id = 1;
- var name = $.Prefix + String(calcHP);
- var origin = 0, x = Graphics.boxWidth - $.xOffset, y = 3;
- var scaleX = 100, scaleY = 100, opacity = 255, blend = 0;
- $gameScreen.showPicture(id, name, origin, x, y, scaleX, scaleY, opacity, blend);
- };
-
- // Refresh HUD when Scene_Map loads
- var _Scene_Map_start = Scene_Map.prototype.start;
- Scene_Map.prototype.start = function() {
- _Scene_Map_start.call(this);
- // console.log('Scene_Map has started!');
- $.refreshHUD();
- };
-
- // Refresh HUD when actor gains/loses HP
- var _Game_Actor_setHp = Game_Actor.prototype.setHp;
- Game_Actor.prototype.setHp = function(value) {
- _Game_Actor_setHp.call(this, value);
- // console.log('Actor HP changed!');
- $.refreshHUD();
- };
-
- })(dismal_sci.zHUD);
复制代码
Dependencies
None.
License
zHUD is free for use in both commercial and non-commercial projects, as long as both dismal_science__ and Caethyril are credited accordingly:
zHUD by dismal_science__ and Caethyril
You are free to edit this plugin as you see fit for your project.
If the edits can benefit the community as a whole, I request that they are also posted here so the edits can be incorporated into an official release.
Please do not re-post, just link to
this forum post or the
dismal_science__ devblog.
Etc.
For updates and copies of the example files mentioned in this help file, please check out-
https://ameblo.jp/dismal-science/entry-12454556656.html
For more of Caethyril's plug-ins, please check out-
http://bit.ly/2UYQnpS
This plug-in was born in an RPG Maker Forum discussion. Check out the original post
here.
本贴来自国际rpgmaker官方论坛作者:p0_boy处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/zhud-a-zelda-esque-hp-hud-plug-in.107992/