DESCRIZIONE
HUD totalmente personalizzabile compreso di barre hp e mp, livello, nome e immagine del main character
AUTORE
Francesco "Frash" Ascenzi
ISTRUZIONI
Creare un nuovo file nella cartella plugin del proprio progetto denominandolo Hud.js.
L'HUD può essere personalizzato direttamente nel plugin editor di RPG maker.
Per modificare i colori si utilizzano i codice HEX; per la lunghezza, e l'altezza, i punti.
BUG E CONFLITTI
Non noti
SCRIPT
/*: * @plugindesc Show a custom HUD on screen. * @author Francesco Ascenzi | Frash * * @help Made by Francesco Ascenzi | Frash * _______________ * * Username on RPG2S. * Fash on RPG Maker forum. * * @param X position of HUD * @desc X position of HUD * Default: 25 * @default 25 * * @param Y position of HUD * @desc Y position of HUD * Default: 25 * @default 25 * * @param X position of actor name * @desc X position of actor name text * Default: 0 * @default 0 * * @param Y position of actor name * @desc Y position of actor name text * Default: 0 * @default 0 * * @param X position of HP * @desc X position of HP bar * Default: 15 * @default 15 * * @param Y position of HP * @desc Y position of HP bar * Default: 15 * @default 15 * * @param X position of MP * @desc Y position of MP bar * Default: 15 * @default 15 * * @param Y position of MP * @desc Y position of MP bar * Default: 30 * @default 30 * * @param X position of level * @desc X position of level bar * Default: 0 * @default 0 * * @param Y position of level * @desc Y position of level bar * Default: 0 * @default 0 * * @param HP width * @desc Width of HP bar * Default: 200 * @default 200 * * @param MP width * @desc Width of MP bar * Default: 80 * @default 80 * * @param HP height * @desc Height of HP bar * Default: 15 * @default 15 * * @param MP height * @desc Height of MP bar * Default: 10 * @default 10 * * @param Max HP bar width * @desc Max width of HP bar * Default: 200 * @default 200 * * @param Max MP bar width * @desc Max width of MP bar * Default: 80 * @default 80 * * @param HP back color * @desc HEX HP base bar color * Default: #000000 * @default #000000 * @require 1 * * @param HP color * @desc HEX HP bar color * Default: #0FBA48 * @default #0FBA48 * @require 1 * * @param HP gradient color * @desc HEX HP gradient bar color * Default: #0FBA48 * @default #0FBA48 * * @param MP back color * @desc HEX MP base bar color * Default: #000000 * @default #000000 * @require 1 * * @param MP color * @desc HEX MP bar color * Default: #1D7CDB * @default #1D7CDB * @require 1 * * @param MP gradient color * @desc HEX MP gradient bar color * Default: #1D7CDB * @default #1D7CDB * * @param Party member * @desc Number of party member that you want to show (0 => Leader) * Default: 0 * @default 0 * */ (function showHud() { // INPUT PARAMETERS var inputParams = PluginManager.parameters('Hud'); // HUD | Position var hudX = Number(inputParams["X position of HUD"]) || 0; var hudY = Number(inputParams["Y position of HUD"]) || 0; // Name position var nameX = Number(inputParams["X position of actor name"]) || 84; var nameY = Number(inputParams["Y position of actor name"]) || 0; // HP properties var hpX = Number(inputParams["X position of HP"]) || 84; var hpY = Number(inputParams["Y position of HP"]) || 10; var hpW = Number(inputParams["HP width"]) || 320; var hpH = Number(inputParams["HP height"]) || 15; // MP properties var mpX = Number(inputParams["X position of MP"]) || 84; var mpY = Number(inputParams["Y position of MP"]) || 30; var mpW = Number(inputParams["MP width"]) || 150; var mpH = Number(inputParams["MP height"]) || 5; // Level properties var lvlY = Number(inputParams["Y position of level"]) || 2; // COLORS | Properties var hpColor = inputParams["HP color"] || "#0FBA48"; var gradHpC = inputParams["HP gradient color"] || "#0FBA48"; var mpColor = inputParams["MP color"] || "#1D7CDB"; var gradMpC = inputParams["MP gradient color"] || "#1D7CDB"; // PARTY | Properties var partyMember = Number(inputParams["Party member"]) || 0; // ASSIGN Hud.prototype = Object.create(Window_Base.prototype); Hud.prototype.constructor = Hud; // START | Create the Hud object from method function Hud() { this.initialize.apply(this, arguments); } // INITIALIZE METHOD Hud.prototype.initialize = function() { // Use HP or MP bars width depends on which is wider var hudW = hpW; if (hpW < mpW) { var hudW = mpW; }; Window_Base.prototype.initialize.call(this, hudX, hudY, hudW, 220); this.opacity = 0; } // DRAW | Hp, Mp, set font size, actor name, level Hud.prototype.drawActorFace = function(actor) { this.drawFace(actor.faceName(), actor.faceIndex(), 0, 0, 64, 64); } Hud.prototype.drawActorName = function(actor) { this.contents.fontSize = 19; var actorName = actor.name(); if (actorName.length > 12) { actorName = actorName.substr(0, 12) + '...'; } this.drawText(actorName, nameX, nameY, null); } Hud.prototype.drawActorLevel = function(actor) { var levelString = 'lvl.' + actor.level; this.contents.fontSize = 15; var lvlLength = 0; if (levelString.length >= 6) { lvlLength += 9; } var lvlX = (hpW - 74 - lvlLength); this.drawText(levelString, lvlX, lvlY, null); } Hud.prototype.drawBar = function(actor, x, y, width, height, rate, color1, color2, tilted, hp) { var hpMW = actor.mhp / 2; var fillW = Math.floor(width * rate); var gaugeY = y + this.lineHeight() - 8; this.contents.fillRect(x, gaugeY, width, height, this.gaugeBackColor()); this.contents.gradientFillRect(x, gaugeY, fillW, height, color1, color2); }; // UPDATE Hud.prototype.update = function() { this.contents.clear(); var leader = $gameParty.members()[partyMember]; this.drawActorFace(leader); this.drawBar(leader, hpX, hpY, hpW, hpH, leader.hpRate(), hpColor, gradHpC, 1, 1); // Hp bar this.drawBar(leader, mpX, mpY, mpW, mpH, leader.mpRate(), mpColor, gradMpC, 1, 0); // Mp bar this.drawActorName(leader); this.drawActorLevel(leader); } // ADD _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows; Scene_Map.prototype.createAllWindows = function() { if (!DataManager.isBattleTest()) { this._hudWindow=new Hud(); this.addWindow(this._hudWindow); }; }; })();
Modificato da Frash, 27 May 2023 - 09:35 AM.