Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------------------------------
- // SOUL_MV Rune Factory HUD.js
- // ------------------------------------------------
- /*:
- * @plugindesc Creates a HUD with the same style as Rune Factory.
- * @author Soulpour777 - soulxregalia.wordpress.com
- *
- * @help
- Plugin Commands
- change_actor x
- where x is the number of the actor you want to be
- displayed instead of the default actor.
- Place all images in the img / rf_hud folder.
- * @param Default Actor
- * @desc The default actor that the hud will display its HP and MP. (Changable in Plugin Commands)
- * @default 1
- *
- * @param HUD_Switch
- * @desc The switch for the hud to show.
- * @default 1
- *
- * @param HUD Background
- * @desc The background image that holds both the HP and MP bars.
- * @default HUD_Background
- *
- * @param HUD Background X
- * @desc The x axis of the background image that holds both the HP and MP bars.
- * @default 40
- *
- * @param HUD Background Y
- * @desc The y axis of the background image that holds both the HP and MP bars.
- * @default 20
- *
- * @param HP Image
- * @desc The hp image that holds both the HP metre.
- * @default HP
- *
- * @param HP Image X
- * @desc The x axis of the hp image that holds both the HP metre.
- * @default 88
- *
- * @param HP Image Y
- * @desc The y axis of the hp image that holds both the HP metre.
- * @default 26
- *
- * @param MP Image
- * @desc The mp image that holds both the MP metre.
- * @default MP
- *
- * @param MP Image X
- * @desc The x axis of the mp image that holds both the HP metre.
- * @default 88
- *
- * @param MP Image Y
- * @desc The y axis of the mp image that holds both the HP metre.
- * @default 50
- *
- */
- var SOUL_MV = SOUL_MV || {};
- SOUL_MV.RuneFactory = {};
- SOUL_MV.RuneFactory.pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- SOUL_MV.RuneFactory.pluginCommand.call(this);
- if (command === "change_actor") {
- $gameSystem._defaultActor = args[0];
- }
- };
- ImageManager.loadRune = function(filename, hue) {
- return this.loadBitmap('img/rf_hud/', filename, hue, true);
- };
- SOUL_MV.RuneFactory.xinitialize = Game_System.prototype.initialize;
- Game_System.prototype.initialize = function() {
- SOUL_MV.RuneFactory.xinitialize.call(this);
- this._defaultActor = SOUL_MV.RuneFactory.DefaultActor;
- }
- SOUL_MV.RuneFactory.DefaultActor = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['Default Actor'] || 1);
- SOUL_MV.RuneFactory.HudSwitch = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['HUD_Switch'] || 1);
- SOUL_MV.RuneFactory.BackgroundSprite = PluginManager.parameters('SOUL_MV Rune Factory HUD')['HUD Background'] || "HUD_Background";
- SOUL_MV.RuneFactory.BackgroundX = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['HUD Background X'] || 40);
- SOUL_MV.RuneFactory.BackgroundY = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['HUD Background Y'] || 20);
- SOUL_MV.RuneFactory.HPSprite = PluginManager.parameters('SOUL_MV Rune Factory HUD')['HP Image'] || "HP";
- SOUL_MV.RuneFactory.MPSprite = PluginManager.parameters('SOUL_MV Rune Factory HUD')['MP Image'] || "MP";
- SOUL_MV.RuneFactory.HPImageX = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['HP Image X'] || 88);
- SOUL_MV.RuneFactory.HPImageY = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['HP Image Y'] || 26);
- SOUL_MV.RuneFactory.MPImageX = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['MP Image X'] || 88);
- SOUL_MV.RuneFactory.MPImageY = Number(PluginManager.parameters('SOUL_MV Rune Factory HUD')['MP Image Y'] || 50);
- ////log_add( "start switch:"+SOUL_MV.RuneFactory.HudSwitch );
- ////log_add( "hp image:"+SOUL_MV.RuneFactory.HPSprite );
- function Sprite_BarHud() {
- this.initialize.apply(this, arguments);
- }
- Sprite_BarHud.prototype = Object.create(Sprite.prototype);
- Sprite_BarHud.prototype.constructor = Sprite_BarHud;
- Sprite_BarHud.prototype.initialize = function (bitmap) {
- Sprite.prototype.initialize.apply(this, arguments);
- this._backgroundSprite = new Sprite(ImageManager.loadRune(SOUL_MV.RuneFactory.BackgroundSprite));
- this._barSprite = new Sprite(ImageManager.loadRune(SOUL_MV.RuneFactory.HPSprite));
- this.addChild(this._backgroundSprite);
- this.addChild(this._barSprite);
- }
- Sprite_BarHud.prototype.update = function () {
- Sprite.prototype.update.apply(this, arguments);
- this.updateBackground();
- this.updateBar();
- }
- Sprite_BarHud.prototype.updateBackground = function () {
- this._backgroundSprite.x = SOUL_MV.RuneFactory.BackgroundX;
- this._backgroundSprite.y = SOUL_MV.RuneFactory.BackgroundY;
- //log_add('back x:'+this._backgroundSprite.x+'|y:'+this._backgroundSprite.y);
- this._backgroundSprite.opacity = this.opacity;
- }
- Sprite_BarHud.prototype.updateBar= function () {
- this._barSprite.x = this.x + SOUL_MV.RuneFactory.HPImageX;
- this._barSprite.y = this.y + SOUL_MV.RuneFactory.HPImageY;
- //log_add('hp x:'+this._barSprite.x+'|y:'+this._barSprite.y);
- this._barSprite.opacity = this.opacity;
- }
- Sprite_BarHud.prototype.setRate = function (rate) {
- this._barSprite.setFrame(0, 0, this._barSprite.bitmap.width * rate, this._barSprite.bitmap.height);
- }
- function Sprite_ActorHpBar() {
- this.initialize.apply(this, arguments);
- }
- Sprite_ActorHpBar.prototype = Object.create(Sprite_BarHud.prototype)
- Sprite_ActorHpBar.prototype.constructor = Sprite_ActorHpBar;
- Sprite_ActorHpBar.prototype.initialize = function (bitmap) {
- this._actor = null;
- Sprite_BarHud.prototype.initialize.apply(this, arguments);
- }
- Sprite_ActorHpBar.prototype.setActor = function (actor) {
- this._actor = actor;
- }
- Sprite_ActorHpBar.prototype.update = function () {
- Sprite_BarHud.prototype.update .apply(this, arguments);
- if (this._actor) {
- this.setRate(this._actor.hpRate());
- }
- }
- function SOUL_MV_SpriteRFMPBar() {
- this.initialize.apply(this, arguments);
- }
- SOUL_MV_SpriteRFMPBar.prototype = Object.create(Sprite.prototype);
- SOUL_MV_SpriteRFMPBar.prototype.constructor = SOUL_MV_SpriteRFMPBar;
- SOUL_MV_SpriteRFMPBar.prototype.initialize = function (bitmap) {
- Sprite.prototype.initialize.apply(this, arguments);
- this._mpBarSprite = new Sprite(ImageManager.loadRune(SOUL_MV.RuneFactory.MPSprite));
- this.addChild(this._mpBarSprite);
- }
- SOUL_MV_SpriteRFMPBar.prototype.update = function () {
- Sprite.prototype.update.apply(this, arguments);
- this.updateBar();
- }
- SOUL_MV_SpriteRFMPBar.prototype.updateBar= function () {
- this._mpBarSprite.x = this.x + SOUL_MV.RuneFactory.MPImageX;
- this._mpBarSprite.y = this.y + SOUL_MV.RuneFactory.MPImageY;
- this._mpBarSprite.opacity = this.opacity;
- }
- SOUL_MV_SpriteRFMPBar.prototype.setRate = function (rate) {
- this._mpBarSprite.setFrame(0, 0, this._mpBarSprite.bitmap.width * rate, this._mpBarSprite.bitmap.height);
- }
- function Sprite_ActorMpBar() {
- this.initialize.apply(this, arguments);
- }
- Sprite_ActorMpBar.prototype = Object.create(SOUL_MV_SpriteRFMPBar.prototype)
- Sprite_ActorMpBar.prototype.constructor = Sprite_ActorMpBar;
- Sprite_ActorMpBar.prototype.initialize = function (bitmap) {
- this._actor = null;
- SOUL_MV_SpriteRFMPBar.prototype.initialize.apply(this, arguments);
- }
- Sprite_ActorMpBar.prototype.setActor = function (actor) {
- this._actor = actor;
- }
- Sprite_ActorMpBar.prototype.update = function () {
- SOUL_MV_SpriteRFMPBar.prototype.update .apply(this, arguments);
- if (this._actor) {
- this.setRate(this._actor.mpRate());
- }
- }
- Spriteset_Map.prototype.createHud = function() {
- this._sprite = new Sprite_ActorHpBar();
- this._sprite.setActor($gameActors.actor($gameSystem._defaultActor));
- this._mpBarsprite = new Sprite_ActorMpBar();
- this._mpBarsprite.setActor($gameActors.actor($gameSystem._defaultActor));
- this._baseSprite.addChild(this._sprite, 1);
- this._baseSprite.addChild(this._mpBarsprite, 2);
- }
- Spriteset_Map.prototype.update = function() {
- Spriteset_Base.prototype.update.call(this);
- this.updateTileset();
- this.updateParallax();
- this.updateTilemap();
- this.updateShadow();
- this.updateWeather();
- //log_add( "switch:"+SOUL_MV.RuneFactory.HudSwitch );
- if($gameSwitches.value(SOUL_MV.RuneFactory.HudSwitch)) {
- //log_add('show ');
- if (!this._fin) {
- this.createHud();
- this._fin = true;
- }
- else{}
- }
- else{
- //log_add('hide ');
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement