查看: 6745|回复: 8

[搬运汉化] 仿碧轨地图血条mv移植至mz

[复制链接]
梦石
0
星屑
351
在线时间
68 小时
注册时间
2020-7-17
回帖
6
发表于 2020-10-28 15:43:07 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
本帖最后由 wtyliangting 于 2020-10-29 10:22 编辑

原作https://rpg.blue/thread-386077-1-1.html
个人制作游戏过程中要用到大地图血条,所以就拿这个看看应该怎么写,顺便就移植过来的,希望对需要的朋友有帮助。
本来应该是一个很简单的工作,可惜个人js掌握的不是很熟练。
注意,本人并未修改NotShowSwitch,因此此处应该已经失效。
注意,元代码中部分没有调用的函数,可能在移植过程中疏忽而丢失,使用中如果出现问题,可以尝试从元代码中找到相应部分移植过来。
注意,元代码会导致每次update都会触发refresh清空_last_hps[],从而反复渲染。本人已经修改这部分代码, 但如果出现渲染问题,可以尝试继续修改这部分代码以解决问题。

其实应该算是写好一段时间了,不过前段时间在等待某大厂感谢信,所以现在才发出来哈。

[pre lang="JavaScript"]//=============================================================================
// MrLiu_MapStatus.js
//=============================================================================
/*:
        @target MZ
*         @plugindesc 在RMMV游戏的题图界面中显示仿空轨人物血条.
*         @author 移植自 MrLiu-过眼云烟
*         @param NotShowSwitch
*         @desc 开启此开关则不显示地图血条,多用于剧情等特殊场景。
*         @default 50
*
* @help MrLiu-过眼云烟:这是我开发的第四个或者说第五个MV插件,本来程序可以实现自动切图功能
* 但是切图之后,在菜单界面下的人物图片也会被切割,所以只能麻烦您自行提供素材了。
* 请讲您的游戏中想显示在地图上的人物图片放到Faces目录下,请以Actor1_face.png
* 格式命名,其中1代表1号角色,其他的您不需要改变。在插件中您可以自动设置的开关,
* 可以在一些特殊剧情的时候打开这个开关,地图血条将自动关闭。后续版本我会考虑陆续
* 增添功能的。Enjoy it~~支持我就多回帖多送糖吧。
*
* 那只野生loli:已将这个插件从mv移植到了mz。本来应该是一个很简单的工作,可惜个人js掌握的不是很熟练。
*!注意,本人并未修改NotShowSwitch,因此此处可能应该已经失效。
*!注意,元代码中部分没有调用的函数,可能在移植过程中疏忽而丢失,使用中如果出现问题,
*  可以尝试从元代码中找到相应部分移植过来。
*!注意,元代码会导致每次update都会触发refresh清空_last_hps[],从而反复渲染。本人已经修改这部分代码,
*  但如果出现渲染问题,可以尝试继续修改这部分代码以解决问题。
*
*/


Bitmap.prototype.outlineTrap1 = function(x, y, width, height, color1, color2) {
                const context = this.context;
                x = x + 5;
                y = y + 485;
                const grad = context.createLinearGradient(x, y, x + width, y);
                var startCoords = [];
                grad.addColorStop(0, color1);
                grad.addColorStop(1, color2);
                context.save();
                context.beginPath();
                startCoords = [x, y + height];
                context.moveTo(x, y + height);
                context.lineTo(x + height, y);
                context.lineTo(x + width, y);
                context.lineTo(x + width - height, y + height);
                context.lineTo(startCoords[0], startCoords[1]);
                context.strokeStyle = grad;
                context.stroke();
                context.restore();
                this._baseTexture.update();
        };
       
Bitmap.prototype.fillTrap = function(x, y, width, widthpart, height, color1, color2) {
                const context = this.context;
                x = x + 5;
                y = y + 485;
            const x1 = x + width;
                const y1 = y;
                const grad = context.createLinearGradient(x, y, x1, y1);
                grad.addColorStop(0, color1);
                grad.addColorStop(1, color2);
                context.save();
               
                context.beginPath();
                context.moveTo(x, y + height)
                context.lineTo(x + height, y)
                context.lineTo(x + width, y)
                context.lineTo(x + width - height, y + height)
                context.clip();
               
                context.fillStyle = grad;
                context.fillRect(x, y, widthpart, height);               
                context.restore();
                this._baseTexture.update();
        }
       
       
function Window_MapStatus() {
    this.initialize.apply(this, arguments);
}
var parameters = PluginManager.parameters('MrLiu_MapStatus');
var notShowSwitch = Number(parameters['NotShowSwitch']);

Window_MapStatus.prototype = Object.create(Window_Selectable.prototype);
Window_MapStatus.prototype.constructor = Window_MapStatus;

Window_MapStatus.prototype.initialize = function(x, y) {
    var width = this.windowWidth();
    var height = this.windowHeight();
       
        var _tem_var_this = new Rectangle(x, y, width, height);
       
    Window_Selectable.prototype.initialize.call(this,_tem_var_this);
    this._formationMode = false;
    this._pendingIndex = -1;
    this.loadImages();
    this._last_hps =  new Array();
    this._last_mps =  new Array();
    this._last_tps =  new Array();
        this._hps =  new Array();
        this._mps =  new Array();
        this._tps =  new Array();
        this._firstOpen = true;
    this.refresh();
};

Window_MapStatus.prototype.drawGauge= function(x, y, width, rate, color1, color2) {
                var fillW = Math.floor(width * rate);
                var gaugeY = y + this.lineHeight() - 12;
                this.contents.fillTrap(x, gaugeY, width, width, 5, ColorManager.textColor(19), ColorManager.textColor(19));
                this.contents.fillTrap(x, gaugeY, width, fillW, 5, color1, color2);
                this.contents.outlineTrap1(x, gaugeY, width, 5, "#92F825", "#F85925");       
};

Window_MapStatus.prototype.maxItems = function() {
    return $gameParty.size();
};

Window_MapStatus.prototype.loadImages = function() {
    $gameParty.members().forEach(function(actor) {
        ImageManager.loadFace(actor.faceName());
    }, this);
};

ImageManager.loadFace1 = function(filename, hue) {
    return this.loadBitmap('img/faces/', 'Actor'+filename+'_face', hue, true);
};

Window_MapStatus.prototype.drawFace1 = function(faceName,  x, y, width, height) {
    width = width || Window_Base._faceWidth;
    height = height || Window_Base._faceHeight;
    var bitmap1 = ImageManager.loadFace1(faceName);
        var dx = Math.floor(x + Math.max(width - 144, 0) / 2);
    var dy = Math.floor(y + Math.max(height - 144, 0) / 2);
    this.contents.blt(bitmap1, 0, 0, 72, 72, dx, dy,72,72);//gradientFillRect ( x , y , width , height , color1 , color2 , vertical )
};

Window_MapStatus.prototype.drawActorFace1 = function(actor, x, y, width, height) {
    this.drawFace1(actor._actorId,  x, y, width, height);
   };

Window_Base.prototype.changePaintOpacity = function(enabled) {
    this.contents.paintOpacity = enabled ? 255 : this.translucentOpacity();
};

Window_MapStatus.prototype.drawItemBackground = function(index) {
    if (index === this._pendingIndex) {
        var rect = this.itemRect(index);
        var color = this.pendingColor();
        this.changePaintOpacity(false);
        this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
        this.changePaintOpacity(true);
    }
};

Window_MapStatus.prototype.drawItemImage = function(index) {
        var actor = $gameParty.members()[index];
        var rect = this.itemRectForText(index);
        var w = Math.min(rect.width, 144);
        var h = Math.min(rect.height, 144);
        var lineHeight = this.lineHeight();
        this.changePaintOpacity(actor.isBattleMember());
        this.drawActorFace1(actor, rect.x, 380, w, h);//(actor, rect.x, rect.y + lineHeight * 2.5, w, h);
        this.changePaintOpacity(true);
    };

Window_MapStatus.prototype.drawActorHp = function(actor, x, y, width) {
    width = width || 186;
    var color1 = ColorManager.hpGaugeColor1();
    var color2 = ColorManager.hpGaugeColor2();
    this.drawGauge(x+49, y, width-54, actor.hpRate(), color1, color2);
};

Window_MapStatus.prototype.drawActorMp = function(actor, x, y, width) {
    width = width || 186;
    var color1 = ColorManager.mpGaugeColor1();
    var color2 = ColorManager.mpGaugeColor2();
    this.drawGauge(x+42, y, width-54, actor.mpRate(), color1, color2);
};

Window_MapStatus.prototype.drawActorTp = function(actor, x, y, width) {
    width = width || 96;
    var color1 = ColorManager.tpGaugeColor1();
    var color2 = ColorManager.tpGaugeColor2();
    this.drawGauge(x+35, y, width-54, actor.tpRate(), color1, color2);
};

Window_MapStatus.prototype.drawItemStatus = function(index) {
        var actor = $gameParty.members()[index];
        var rect = this.itemRectForText(index);
        var x = rect.x;
        var y = rect.y;
        var width = rect.width;
        var bottom = y + rect.height-40;
        var lineHeight = this.lineHeight();       
        this.drawActorHp(actor, x, bottom - lineHeight * 3, width);
        this.drawActorMp(actor, x, bottom - lineHeight * 2, width);
                this.drawActorTp(actor, x, bottom - lineHeight * 1, width);
    };

Window_MapStatus.prototype.drawItem = function(index) {
    this.drawItemBackground(index);
    this.drawItemImage(index);
    this.drawItemStatus(index);
};

Window_MapStatus.prototype.processOk = function() {
    Window_Selectable.prototype.processOk.call(this);
    $gameParty.setMenuActor($gameParty.members()[this.index()]);
};

Window_MapStatus.prototype.isCurrentItemEnabled = function() {
    if (this._formationMode) {
        var actor = $gameParty.members()[this.index()];
        return actor && actor.isFormationChangeOk();
    } else {
        return true;
    }
};

Window_MapStatus.prototype.windowWidth = function() {
        return Graphics.boxWidth * 0.7;
    };

    Window_MapStatus.prototype.windowHeight = function() {
        var h1 = this.fittingHeight(1);
        var h2 = this.fittingHeight(2);
        return Graphics.boxHeight - h1 - h2;
};

    Window_MapStatus.prototype.maxCols = function() {
        return 4;
    };


Window_Base.prototype.textPadding = function() {
    return 6;
};

Window_Selectable.prototype.itemRectForText = function(index) {
    var rect = this.itemRect(index);
    rect.x += this.textPadding();
    rect.width -= this.textPadding() * 2;
    return rect;
};


       
Window_MapStatus.prototype.lineHeight = function() {
       return 6;
    };
       
       
       
//关于refresh与update的交互:元代码会导致每次update都会触发refresh清空_last_hps[],因此在修改可用后需要重写这部分代码!

Window_MapStatus.prototype.update = function() {

  Window_Base.prototype.update.call(this);
  this._hps.length = 0;
  this._mps.length = 0;
  this._tps.length = 0;
  for(var el=0;el<$gameParty.size();el++){
    this._hps.push($gameParty.members()[el].hpRate());
        this._mps.push($gameParty.members()[el].mpRate());
        this._tps.push($gameParty.members()[el].tpRate());
  }
  
   for(var i=0;i<this._hps.length;i++){
    if (this._hps != this._last_hps){
                this.refresh();
                break;
        }
        if (this._mps != this._last_mps){
                this.refresh();
                break;
        }
        if (this._tps != this._last_tps){
                this.refresh();
                break;
        }
        if (this._firstOpen === true ){
                this._firstOpen = false;
                this.refresh();
                break;
        }
               
  }
  
};

Window_MapStatus.prototype.refresh = function() {
    this.contents.clear();
        this.drawAllItems();
        this._last_hps.length = 0;
    this._last_mps.length = 0;
    this._last_tps.length = 0;
    for(var el=0;el<$gameParty.size();el++){
                this._last_hps.push($gameParty.members()[el].hpRate());
                this._last_mps.push($gameParty.members()[el].mpRate());
                this._last_tps.push($gameParty.members()[el].tpRate());
        }

};
Window_MapStatus.prototype.drawAllItems = function() {
    var topIndex = this.topIndex();
    for (var i = 0; i < this.maxPageItems(); i++) {
        var index = topIndex + i;
        if (index < this.maxItems()) {
            this.drawItem(index);
        }
    }
       
  for(var el=0;el<$gameParty.size();el++){
    this._last_hps.push($gameParty.members()[el].hpRate());
        this._last_mps.push($gameParty.members()[el].mpRate());
        this._last_tps.push($gameParty.members()[el].tpRate());
  }
};



var _Scene_Map_createMapStatusWindow = Scene_Map.prototype.createDisplayObjects;
Scene_Map.prototype.createDisplayObjects = function() {
        _Scene_Map_createMapStatusWindow.call(this);
        this._mapStatusWindow = new Window_MapStatus();
        this._mapStatusWindow.opacity = 1;
        this._mapStatusWindow.x = 0;
        this._mapStatusWindow.y = 100;
        this.addWindow(this._mapStatusWindow);
       
};

var _Scene_Map_updateMapStatusWindow1 = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
        _Scene_Map_updateMapStatusWindow1.call(this);////gameSwitches.value(dataId)
        if(($gameMap._interpreter.isRunning()) || ($gameSwitches.value(notShowSwitch) == true)){
               
           this._mapStatusWindow.close();
     }
        else{
           this._mapStatusWindow.open();  
     }
};[/pre]

大地图血条.rar

79.31 KB, 下载次数: 287

梦石
0
星屑
1527
在线时间
85 小时
注册时间
2014-6-13
回帖
96
发表于 2021-1-23 10:52:27 | 显示全部楼层
没懂什么是大地图血条
回复

使用道具 举报

梦石
0
星屑
36
在线时间
8 小时
注册时间
2018-4-14
回帖
5
发表于 2021-9-16 09:12:46 | 显示全部楼层
MZ要是有轨迹风格的战斗插件就好了
回复

使用道具 举报

梦石
0
星屑
121
在线时间
10 小时
注册时间
2021-11-29
回帖
19
发表于 2021-12-5 09:23:28 | 显示全部楼层
大地图血条?很想知道大佬有没有战斗敌人血条之类的。
回复

使用道具 举报

梦石
0
星屑
20
在线时间
1 小时
注册时间
2022-3-4
回帖
4
发表于 2022-3-12 08:53:29 | 显示全部楼层
谢谢大佬的插件,我已经运行发现了点问题:我对话文本是在下方的,用了这个对话文本被影响了。
回复

使用道具 举报

梦石
0
星屑
443
在线时间
42 小时
注册时间
2022-4-14
回帖
34
发表于 2022-5-2 12:03:23 | 显示全部楼层
看上去效果不错~
回复

使用道具 举报

梦石
0
星屑
52
在线时间
8 小时
注册时间
2023-6-16
回帖
11
发表于 2023-6-18 08:58:51 | 显示全部楼层
感谢分享
回复

使用道具 举报

梦石
0
星屑
234
在线时间
40 小时
注册时间
2022-12-12
回帖
42
发表于 2025-9-9 18:05:13 | 显示全部楼层
66666666666666666666
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部