Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Steampunk Hud
- // By Kvothe
- // steampunk_hud.js
- // Version: 0.1
- // Free for commercial and non commercial use.
- //=============================================================================
- var Imported = Imported || {};
- var SteampunkHud = SteampunkHud || {};
- 'use strict';
- //=============================================================================
- // Game_System:initialize
- //=============================================================================
- var __oldGameSystem_initialize = Game_System.prototype.initialize;
- Game_System.prototype.initialize = function() {
- __oldGameSystem_initialize.call(this);
- this._steamHud = true;
- }
- //=============================================================================
- // Game_System::steamHud
- //=============================================================================
- Object.defineProperty(Game_System.prototype, 'steamHud', {
- get: function() {
- return this._steamHud || false;
- }, set : function(value) {
- if ( typeof value == 'boolean' ) {
- this._steamHud = value;
- }
- }
- })
- //=============================================================================
- // [Extended]Number:to_p
- //=============================================================================
- Number.prototype.to_p = function(actual, max) {
- return (this * actual / max);
- }
- //=============================================================================
- // function:OpacityEffect
- //=============================================================================
- function numberEffectUpDown(num, low, max) {
- var _num = num
- _low = low
- _max = max
- _chg = true;
- if ( _chg == true ) {
- _num = _num > _max ? _num + 1 : _max;
- if ( _num > _max ) { _chg = false };
- } else {
- _num = _num < _low ? _num - 1 : _low;
- if ( _num < _low ) { _chg = true };
- }
- return _now
- }
- //=============================================================================
- // Sprite:SteampunkHud
- //=============================================================================
- function SpriteSteampunkHud() { this.initialize.apply(this, arguments) }
- SpriteSteampunkHud.prototype.constructor = SpriteSteampunkHud;
- //=============================================================================
- // steampunk_hud:
- //=============================================================================
- (function($){
- //---------------------------------------------------------------------------
- // Carregar parameters.
- //---------------------------------------------------------------------------
- $.Parameters = PluginManager.parameters['SteampunkHud'];
- $.Param = $.Param || {};
- //---------------------------------------------------------------------------
- // Configuração.
- //---------------------------------------------------------------------------
- $.Param.layout0 = "Layout 0 - Back HUD"; // Primeiro layout da HUD.
- $.Param.layout1 = "Layout 1 - Icon HUD"; // Segundo layout da HUD.
- $.Param.layoutEffect = "Efeito HUD"; // Layout de efeito da HUD.
- $.Param.hp_meter = "Hp Meter HUD"; // Barra de HP da HUD.
- $.Param.mp_meter = "Mp Meter HUD"; // Barra de MP da HUD.
- $.Param.speed = 4; // Velocidade para esconder/ativar
- $.Param.actor_id = 1; // A HUD é destinada a qual actor?
- $.Param.addonX = 0; // Modificar a posição X.
- $.Param.addonY = 0; // Modificar a posição Y.
- $.Param.switchID = 1; // ID para ativar/desativar a HUD.
- //---------------------------------------------------------------------------
- // Inicialização.
- //---------------------------------------------------------------------------
- SpriteSteampunkHud.prototype.initialize = function() {
- var actor = $gameActor.actor($.Param.actor_id);
- var layout0 = new Sprite(null);
- layout0.bitmap = ImageManager.loadSystem($.Param.layout0);
- layout0.move(30 + $.Param.addonX.toNumber, 16 + $.Param.addonY.toNumber);
- var layout1 = new Sprite(null);
- layout1.bitmap = ImageManager.loadSystem($.Param.layout1);
- layout1.move(19 + $.Param.addonX.toNumber, 10 + $.Param.addonY.toNumber);
- var hpBitmap = ImageManager.loadSystem($.Param.hp_meter);
- var mpBitmap = ImageManager.loadSystem($.Param.mp_meter);
- var sHp = new Sprite(null);
- sHp.bitmap = new Bitmap(hpBitmap.width, mpBitmap.width);
- sHp.move(42 + $.Param.addonX.toNumber, 22 + $.Param.addonY.toNumber);
- var sMp = new Sprite(null);
- sMp.bitmap = new Bitmap(mpBitmap.width, mpBitmap.height);
- sMp.move(44 + $.Param.addonX.toNumber, 43 + $.Param.addonY.toNumber);
- sHp.bitmap.blt(hpBitmap, 0, 0, hpBitmap.width.to_p(actor.hp, actor.mhp), hpBitmap.height, 0, 0, sHp.width, sHp.height);
- sMp.bitmap.blt(mpBitmap, 0, 0, mpBitmap.width.to_p(actor.mp, actor.mmp), mpBitmap.height, 0, 0, sHp.width, sHp.height);
- var effect = new Sprite(null);
- effect.bitmap = ImageManager.loadSystem($.Param.layoutEffect);
- effect.opacity.set(128);
- var effectOpacity = 128;
- var opacityGeral = 0;
- }
- //---------------------------------------------------------------------------
- // Renovar
- //---------------------------------------------------------------------------
- SpriteSteampunkHud.prototype.dispose = function() {
- layout0.clear;
- layout1.clear;
- sHp.clear;
- sMp.clear;
- effect.clear;
- }
- //---------------------------------------------------------------------------
- // Atualizar
- //---------------------------------------------------------------------------
- SpriteSteampunkHud.prototype.update = function() {
- sHp._refresh;
- sMp._refresh;
- sHp.bitmap.blt(hpBitmap, 0, 0, hpBitmap.width.to_p(actor.hp, actor.mhp), hpBitmap.height, 0, 0, sHp.width, sHp.height);
- sMp.bitmap.blt(mpBitmap, 0, 0, mpBitmap.width.to_p(actor.mp, actor.mmp), mpBitmap.height, 0, 0, sHp.width, sHp.height);
- if ( $.Param.switchID !== undefined && $.Param.switchID > 0 ) {
- $gameSystem.steamHud.set($gameSwitches.value($.Param.switchID))
- }
- if ( $gameSystem.steamHud.get == true ) {
- effectOpacity = numberEffectUpDown.call(effectOpacity, 62, 122);
- effect.opacity.set(effectOpacity);
- if ( layout0.opacity.get !== 255 || layout1.opacity.get !== 255 || sHp.opacity.get !== 255 || sHp.opacity !== 255 ) {
- opacityGeral = Math.clamp(opacityGeral + 1, 0, 255)
- layout0.opacity.set(opacityGeral);
- layout1.opacity.set(opacityGeral);
- sHp.opacity.set(opacityGeral);
- sMp.opacity.set(opacityGeral);
- }
- } else {
- if ( effect.opacity.get !== 0 || layout0.opacity.get !== 0 || layout1.opacity.get !== 0 || sHp.opacity.get !== 0 || sHp.opacity !== 0 ) {
- opacityGeral = Math.clamp(opacityGeral - 1, 0, 255)
- effect.opacity.set(opacityGeral);
- layout0.opacity.set(opacityGeral);
- layout1.opacity.set(opacityGeral);
- sHp.opacity.set(opacityGeral);
- sMp.opacity.set(opacityGeral);
- }
- }
- }
- //---------------------------------------------------------------------------
- // Scene_Map:start
- //---------------------------------------------------------------------------
- var oldSceneMapSteampunkHud_start = Scene_Map.prototype.start;
- Scene_Map.prototype.start = function() {
- oldSceneMapSteampunkHud_start.call(this);
- this.createSteampunkHud();
- }
- //---------------------------------------------------------------------------
- // Scene_Map:createSteampunkHud
- //---------------------------------------------------------------------------
- Scene_Map.prototype.createSteampunkHud = function () {
- this._steampunkHud = new SpriteSteampunkHud();
- this.addChild(this._steampunkHud);
- };
- //---------------------------------------------------------------------------
- // Scene_Map:terminate
- //---------------------------------------------------------------------------
- var oldSceneMapSteampunkHud_terminate = Scene_Map.prototype.terminate;
- Scene_Map.prototype.terminate = function () {
- oldSceneMapSteampunkHud_terminate.call(this);
- this._steampunkHud.dispose();
- };
- //---------------------------------------------------------------------------
- // Scene_Map:update
- //---------------------------------------------------------------------------
- var oldSceneMapSteampunkHud_update = Scene_Map.prototype.update;
- Scene_Map.prototype.update = function () {
- oldSceneMapSteampunkHud_update.call(this);
- this._steampunkHud.update();
- };
- })(SteampunkHud)
- //=============================================================================
- // PluginManager:register
- //=============================================================================
- PluginManager.register("SteampunkHud", "0.1.0.0", "HUD estilo steampunk.", {
- email: "dax-soft@live.com",
- name: "Kvothe",
- website: "http://www.dax-soft.weebly.com"
- }, "2015-10-17");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement