设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 119|回复: 0

[转载发布] zHUD - A Zelda-esque HP HUD Plug-In

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9072

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58885
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68851

    灌水之王

    发表于 2026-7-27 09:05:06 | 显示全部楼层 |阅读模式
    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:       
    1. 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:       
    1. /*:
    2. * zHUD.js
    3. *
    4. * @plugindesc (v0.8)
    5. * A Zelda-esque Head-Up Display.
    6. *
    7. * @author dismal_science__, caethyril
    8. *
    9. * @help
    10. *
    11. * zHUD is a very rudimentary HP HUD, reminiscent to the style used in the
    12. * Zelda series.
    13. *
    14. * zHUD is designed for use with single-actor games.
    15. *
    16. * zHUD uses a set of image files to indicate HP status.
    17. *
    18. *
    19. * =[ U S A G E ]===========================================================
    20. *
    21. * zHUD's filename must remain "zHUD.js" in order to work properly.
    22. *
    23. * The example includes 33 image files, all named similarly with the
    24. * prefix "zhud_x_hp_" and bearing the same width of "237" pixels.
    25. *
    26. * The first image file- "zhud_x_hp_0.png"- represents the image shown when
    27. * HP is at its lowest.
    28. *
    29. * The second image file- "zhud_x_hp_128.png"- represents the image shown
    30. * when HP is full.
    31. *
    32. * The 31 images in-between represent the various possible HP states, in this
    33. * case, increasing/reducing in increments of 4.
    34. *
    35. * The example uses 33 images, but the plug-in can use any number of files.
    36. * The plug-in adjusts depending on the ImgMax and LastImgSuffix parameters.
    37. *
    38. * For the included example, the parameter ImgMax should be set to "33" and
    39. * LastImgSuffix should be set to "128".
    40. *
    41. * For this example, the ImgWidth parameter should be set to "237".
    42. * This may be adjusted depending on the size of the image used.
    43. *
    44. * Place image files in your project's IMG/PICTURES folder.
    45. *
    46. * During gameplay, when HP reaches a critical low, zHUD activates an
    47. * audible warning- specified in the LowHealthSE parameter.
    48. *
    49. * For the example- LowHealthSE is set to "LowHPBeep", which represents the
    50. * audio files "LowHPBeep.ogg" and "LowHPBeep.m4a".
    51. *
    52. * Place audio files in the project's AUDIO/SE folder.
    53. *
    54. * SE_Interval represents the amount of time in milliseconds between beeping.
    55. * It is set to "700" by default but may need to be adjusted depending on the
    56. * length of the audio file that is used.
    57. *
    58. * Finally, the zActorID parameter is the number of the Actor whose HP will be
    59. * displayed.
    60. *
    61. * zHUD usually updates its display automatically, but in cases where this
    62. * doesn't happen, you may need to use a script call to do it manually.
    63. *
    64. * Script call: dismal_sci.zHUD.refreshHUD();
    65. *
    66. *
    67. * =[ E T C . ]===========================================================
    68. *
    69. * zHUD is written by dismal_science__ and caethyril.
    70. *
    71. * zHUD is free for use in both commercial and non-commercial projects,
    72. * as long as both authors are credited accordingly.
    73. *
    74. * For updates and copies of the example files mentioned in this help file,
    75. * please check out-
    76. *
    77. * https://ameblo.jp/dismal-science/entry-12454556656.html
    78. *
    79. *
    80. * For more of Caethyril's plug-ins, please check out-
    81. *
    82. * http://bit.ly/2UYQnpS
    83. *
    84. *
    85. * @param Prefix
    86. * @type text
    87. * @desc Filename prefix, ex. "zhud_x_hp_"
    88. * @default zhud_x_hp_
    89. *
    90. * @param ImgWidth
    91. * @type number
    92. * @desc Width of image (in pixels).
    93. * @default 237
    94. *
    95. * @param ImgMax
    96. * @type number
    97. * @desc Total number of images.
    98. * @default 33
    99. *
    100. * @param LastImgSuffix
    101. * @type number
    102. * @desc Suffix of last image in group.
    103. * @default 128
    104. *
    105. * @param LowHealthSE
    106. * @type file
    107. * @dir audio/se
    108. * @require 1
    109. * @desc Low HP Sound Effect, place in AUDIO/SE folder.
    110. * @default LowHPBeep
    111. *
    112. * @param SE_Interval
    113. * @type number
    114. * @desc Interval between Low HP Sound Effect beeps (in milliseconds).
    115. * @default 700
    116. *
    117. * @param zActorID
    118. * @type number
    119. * @desc ID of Actor whose HP will be displayed.
    120. * @default 1
    121. *
    122. */
    123. var dismal_sci = dismal_sci || {};        // Author namespace
    124. dismal_sci.zHUD = dismal_sci.zHUD || {};    // Plugin namespace
    125. (function($) {
    126.     // Get parameters
    127.     $.params = PluginManager.parameters('zHUD');
    128.     if ($.params === undefined) throw new Error('zHUD parameters not found! Check the plugin is named correctly and try again.');
    129.     // Define parameter variables on plugin namespace
    130.     $.Prefix = $.params['Prefix'];
    131.     $.ImgWidth = Number($.params['ImgWidth']);
    132.     $.ImgMax = Number($.params['ImgMax']) - 1;
    133.     $.LastImgSuffix = Number($.params['LastImgSuffix']);
    134.     $.LowHealthSE = $.params['LowHealthSE'];
    135.     $.SE_Interval = Number($.params['SE_Interval']);
    136.     $.zActorID = Number($.params['zActorID']);
    137.     // Other plugin variables
    138.     $.lastHP = 0;
    139. //    $.xRight = Graphics.boxWidth - ($.ImgWidth + 24);    // boxWidth is not set yet!
    140.     $.xOffset = $.ImgWidth + 24;                // Alternative approach
    141.     $.xRound = $.LastImgSuffix / $.ImgMax;
    142.     // Round to nearest multiple of integer num
    143.     Number.prototype.roundTo = function(num) {
    144.         return Math.ceil(this/num) * num;
    145.     };
    146.     $.lowHP = Math.pow($.xRound,2);
    147.     $.lowHP_SND = {name: $.LowHealthSE, volume: 90, pitch: 100, pan: 0};
    148.     $.lowHP_beep = function() {
    149.         if ($.beepInterval === undefined) {
    150.             $.beepInterval = setInterval(function(){
    151.                 AudioManager.playSe($.lowHP_SND);
    152.             }, $.SE_Interval);
    153.         }
    154.     };
    155.     $.lowHP_beep_kill = function() {
    156.         if ($.beepInterval != undefined) {
    157.             clearInterval(this.beepInterval);
    158.             delete this.beepInterval;
    159.         }
    160.     };
    161.     // Display appropriate picture for HUD, via showPicture
    162.     $.refreshHUD = function() {
    163.             // console.log('Refreshing HUD!');
    164.             var actor = $gameActors.actor($.zActorID);
    165.             var calcHP = ($.LastImgSuffix * actor.hp / actor.mhp).roundTo($.xRound);
    166.             if ($.lastHP === calcHP) return;    // Only continue if changed
    167.             $.lastHP = calcHP;            // Remember HP
    168.             // console.log('calculated:', calcHP, '\nlow:', $.lowHP);
    169.             if (calcHP <= $.lowHP && calcHP > 0) {  // at or below low HP, and not dead
    170.                 $.lowHP_beep();
    171.             } else {   // end beep in all other cases
    172.                 $.lowHP_beep_kill();
    173.         };
    174.             var id = 1;
    175.             var name = $.Prefix + String(calcHP);
    176.             var origin = 0, x = Graphics.boxWidth - $.xOffset, y = 3;
    177.             var scaleX = 100, scaleY = 100, opacity = 255, blend = 0;
    178.             $gameScreen.showPicture(id, name, origin, x, y, scaleX, scaleY, opacity, blend);
    179.         };
    180.     // Refresh HUD when Scene_Map loads
    181.     var _Scene_Map_start = Scene_Map.prototype.start;
    182.     Scene_Map.prototype.start = function() {
    183.         _Scene_Map_start.call(this);
    184.         // console.log('Scene_Map has started!');
    185.         $.refreshHUD();
    186.     };
    187.     // Refresh HUD when actor gains/loses HP
    188.     var _Game_Actor_setHp = Game_Actor.prototype.setHp;
    189.     Game_Actor.prototype.setHp = function(value) {
    190.         _Game_Actor_setHp.call(this, value);
    191.         // console.log('Actor HP changed!');
    192.         $.refreshHUD();
    193.     };
    194. })(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/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-22 07:52 , Processed in 0.137939 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表