设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 5148|回复: 7
打印 上一主题 下一主题

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
351
在线时间
68 小时
注册时间
2020-7-17
帖子
8
跳转到指定楼层
1
发表于 2020-10-28 15:43:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

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

JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // MrLiu_MapStatus.js
  3. //=============================================================================
  4. /*:
  5.         @target MZ
  6. *         @plugindesc 在RMMV游戏的题图界面中显示仿空轨人物血条.
  7. *         @author 移植自 MrLiu-过眼云烟
  8. *         @param NotShowSwitch
  9. *         @desc 开启此开关则不显示地图血条,多用于剧情等特殊场景。
  10. *         @default 50
  11. *
  12. * @help MrLiu-过眼云烟:这是我开发的第四个或者说第五个MV插件,本来程序可以实现自动切图功能
  13. * 但是切图之后,在菜单界面下的人物图片也会被切割,所以只能麻烦您自行提供素材了。
  14. * 请讲您的游戏中想显示在地图上的人物图片放到Faces目录下,请以Actor1_face.png
  15. * 格式命名,其中1代表1号角色,其他的您不需要改变。在插件中您可以自动设置的开关,
  16. * 可以在一些特殊剧情的时候打开这个开关,地图血条将自动关闭。后续版本我会考虑陆续
  17. * 增添功能的。Enjoy it~~支持我就多回帖多送糖吧。
  18. *
  19. * 那只野生loli:已将这个插件从mv移植到了mz。本来应该是一个很简单的工作,可惜个人js掌握的不是很熟练。
  20. *!注意,本人并未修改NotShowSwitch,因此此处可能应该已经失效。
  21. *!注意,元代码中部分没有调用的函数,可能在移植过程中疏忽而丢失,使用中如果出现问题,
  22. *  可以尝试从元代码中找到相应部分移植过来。
  23. *!注意,元代码会导致每次update都会触发refresh清空_last_hps[],从而反复渲染。本人已经修改这部分代码,
  24. *  但如果出现渲染问题,可以尝试继续修改这部分代码以解决问题。
  25. *
  26. */
  27.  
  28.  
  29. Bitmap.prototype.outlineTrap1 = function(x, y, width, height, color1, color2) {
  30.                 const context = this.context;
  31.                 x = x + 5;
  32.                 y = y + 485;
  33.                 const grad = context.createLinearGradient(x, y, x + width, y);
  34.                 var startCoords = [];
  35.                 grad.addColorStop(0, color1);
  36.                 grad.addColorStop(1, color2);
  37.                 context.save();
  38.                 context.beginPath();
  39.                 startCoords = [x, y + height];
  40.                 context.moveTo(x, y + height);
  41.                 context.lineTo(x + height, y);
  42.                 context.lineTo(x + width, y);
  43.                 context.lineTo(x + width - height, y + height);
  44.                 context.lineTo(startCoords[0], startCoords[1]);
  45.                 context.strokeStyle = grad;
  46.                 context.stroke();
  47.                 context.restore();
  48.                 this._baseTexture.update();
  49.         };
  50.  
  51. Bitmap.prototype.fillTrap = function(x, y, width, widthpart, height, color1, color2) {
  52.                 const context = this.context;
  53.                 x = x + 5;
  54.                 y = y + 485;
  55.             const x1 = x + width;
  56.                 const y1 = y;
  57.                 const grad = context.createLinearGradient(x, y, x1, y1);
  58.                 grad.addColorStop(0, color1);
  59.                 grad.addColorStop(1, color2);
  60.                 context.save();
  61.  
  62.                 context.beginPath();
  63.                 context.moveTo(x, y + height)
  64.                 context.lineTo(x + height, y)
  65.                 context.lineTo(x + width, y)
  66.                 context.lineTo(x + width - height, y + height)
  67.                 context.clip();
  68.  
  69.                 context.fillStyle = grad;
  70.                 context.fillRect(x, y, widthpart, height);               
  71.                 context.restore();
  72.                 this._baseTexture.update();
  73.         }
  74.  
  75.  
  76. function Window_MapStatus() {
  77.     this.initialize.apply(this, arguments);
  78. }
  79. var parameters = PluginManager.parameters('MrLiu_MapStatus');
  80. var notShowSwitch = Number(parameters['NotShowSwitch']);
  81.  
  82. Window_MapStatus.prototype = Object.create(Window_Selectable.prototype);
  83. Window_MapStatus.prototype.constructor = Window_MapStatus;
  84.  
  85. Window_MapStatus.prototype.initialize = function(x, y) {
  86.     var width = this.windowWidth();
  87.     var height = this.windowHeight();
  88.  
  89.         var _tem_var_this = new Rectangle(x, y, width, height);
  90.  
  91.     Window_Selectable.prototype.initialize.call(this,_tem_var_this);
  92.     this._formationMode = false;
  93.     this._pendingIndex = -1;
  94.     this.loadImages();
  95.     this._last_hps =  new Array();
  96.     this._last_mps =  new Array();
  97.     this._last_tps =  new Array();
  98.         this._hps =  new Array();
  99.         this._mps =  new Array();
  100.         this._tps =  new Array();
  101.         this._firstOpen = true;
  102.     this.refresh();
  103. };
  104.  
  105. Window_MapStatus.prototype.drawGauge= function(x, y, width, rate, color1, color2) {
  106.                 var fillW = Math.floor(width * rate);
  107.                 var gaugeY = y + this.lineHeight() - 12;
  108.                 this.contents.fillTrap(x, gaugeY, width, width, 5, ColorManager.textColor(19), ColorManager.textColor(19));
  109.                 this.contents.fillTrap(x, gaugeY, width, fillW, 5, color1, color2);
  110.                 this.contents.outlineTrap1(x, gaugeY, width, 5, "#92F825", "#F85925");       
  111. };
  112.  
  113. Window_MapStatus.prototype.maxItems = function() {
  114.     return $gameParty.size();
  115. };
  116.  
  117. Window_MapStatus.prototype.loadImages = function() {
  118.     $gameParty.members().forEach(function(actor) {
  119.         ImageManager.loadFace(actor.faceName());
  120.     }, this);
  121. };
  122.  
  123. ImageManager.loadFace1 = function(filename, hue) {
  124.     return this.loadBitmap('img/faces/', 'Actor'+filename+'_face', hue, true);
  125. };
  126.  
  127. Window_MapStatus.prototype.drawFace1 = function(faceName,  x, y, width, height) {
  128.     width = width || Window_Base._faceWidth;
  129.     height = height || Window_Base._faceHeight;
  130.     var bitmap1 = ImageManager.loadFace1(faceName);
  131.         var dx = Math.floor(x + Math.max(width - 144, 0) / 2);
  132.     var dy = Math.floor(y + Math.max(height - 144, 0) / 2);
  133.     this.contents.blt(bitmap1, 0, 0, 72, 72, dx, dy,72,72);//gradientFillRect ( x , y , width , height , color1 , color2 , vertical )
  134. };
  135.  
  136. Window_MapStatus.prototype.drawActorFace1 = function(actor, x, y, width, height) {
  137.     this.drawFace1(actor._actorId,  x, y, width, height);
  138.    };
  139.  
  140. Window_Base.prototype.changePaintOpacity = function(enabled) {
  141.     this.contents.paintOpacity = enabled ? 255 : this.translucentOpacity();
  142. };
  143.  
  144. Window_MapStatus.prototype.drawItemBackground = function(index) {
  145.     if (index === this._pendingIndex) {
  146.         var rect = this.itemRect(index);
  147.         var color = this.pendingColor();
  148.         this.changePaintOpacity(false);
  149.         this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  150.         this.changePaintOpacity(true);
  151.     }
  152. };
  153.  
  154. Window_MapStatus.prototype.drawItemImage = function(index) {
  155.         var actor = $gameParty.members()[index];
  156.         var rect = this.itemRectForText(index);
  157.         var w = Math.min(rect.width, 144);
  158.         var h = Math.min(rect.height, 144);
  159.         var lineHeight = this.lineHeight();
  160.         this.changePaintOpacity(actor.isBattleMember());
  161.         this.drawActorFace1(actor, rect.x, 380, w, h);//(actor, rect.x, rect.y + lineHeight * 2.5, w, h);
  162.         this.changePaintOpacity(true);
  163.     };
  164.  
  165. Window_MapStatus.prototype.drawActorHp = function(actor, x, y, width) {
  166.     width = width || 186;
  167.     var color1 = ColorManager.hpGaugeColor1();
  168.     var color2 = ColorManager.hpGaugeColor2();
  169.     this.drawGauge(x+49, y, width-54, actor.hpRate(), color1, color2);
  170. };
  171.  
  172. Window_MapStatus.prototype.drawActorMp = function(actor, x, y, width) {
  173.     width = width || 186;
  174.     var color1 = ColorManager.mpGaugeColor1();
  175.     var color2 = ColorManager.mpGaugeColor2();
  176.     this.drawGauge(x+42, y, width-54, actor.mpRate(), color1, color2);
  177. };
  178.  
  179. Window_MapStatus.prototype.drawActorTp = function(actor, x, y, width) {
  180.     width = width || 96;
  181.     var color1 = ColorManager.tpGaugeColor1();
  182.     var color2 = ColorManager.tpGaugeColor2();
  183.     this.drawGauge(x+35, y, width-54, actor.tpRate(), color1, color2);
  184. };
  185.  
  186. Window_MapStatus.prototype.drawItemStatus = function(index) {
  187.         var actor = $gameParty.members()[index];
  188.         var rect = this.itemRectForText(index);
  189.         var x = rect.x;
  190.         var y = rect.y;
  191.         var width = rect.width;
  192.         var bottom = y + rect.height-40;
  193.         var lineHeight = this.lineHeight();       
  194.         this.drawActorHp(actor, x, bottom - lineHeight * 3, width);
  195.         this.drawActorMp(actor, x, bottom - lineHeight * 2, width);
  196.                 this.drawActorTp(actor, x, bottom - lineHeight * 1, width);
  197.     };
  198.  
  199. Window_MapStatus.prototype.drawItem = function(index) {
  200.     this.drawItemBackground(index);
  201.     this.drawItemImage(index);
  202.     this.drawItemStatus(index);
  203. };
  204.  
  205. Window_MapStatus.prototype.processOk = function() {
  206.     Window_Selectable.prototype.processOk.call(this);
  207.     $gameParty.setMenuActor($gameParty.members()[this.index()]);
  208. };
  209.  
  210. Window_MapStatus.prototype.isCurrentItemEnabled = function() {
  211.     if (this._formationMode) {
  212.         var actor = $gameParty.members()[this.index()];
  213.         return actor && actor.isFormationChangeOk();
  214.     } else {
  215.         return true;
  216.     }
  217. };
  218.  
  219. Window_MapStatus.prototype.windowWidth = function() {
  220.         return Graphics.boxWidth * 0.7;
  221.     };
  222.  
  223.     Window_MapStatus.prototype.windowHeight = function() {
  224.         var h1 = this.fittingHeight(1);
  225.         var h2 = this.fittingHeight(2);
  226.         return Graphics.boxHeight - h1 - h2;
  227. };
  228.  
  229.     Window_MapStatus.prototype.maxCols = function() {
  230.         return 4;
  231.     };
  232.  
  233.  
  234. Window_Base.prototype.textPadding = function() {
  235.     return 6;
  236. };
  237.  
  238. Window_Selectable.prototype.itemRectForText = function(index) {
  239.     var rect = this.itemRect(index);
  240.     rect.x += this.textPadding();
  241.     rect.width -= this.textPadding() * 2;
  242.     return rect;
  243. };
  244.  
  245.  
  246.  
  247. Window_MapStatus.prototype.lineHeight = function() {
  248.        return 6;
  249.     };
  250.  
  251.  
  252.  
  253. //关于refresh与update的交互:元代码会导致每次update都会触发refresh清空_last_hps[],因此在修改可用后需要重写这部分代码!
  254.  
  255. Window_MapStatus.prototype.update = function() {
  256.  
  257.   Window_Base.prototype.update.call(this);
  258.   this._hps.length = 0;
  259.   this._mps.length = 0;
  260.   this._tps.length = 0;
  261.   for(var el=0;el<$gameParty.size();el++){
  262.     this._hps.push($gameParty.members()[el].hpRate());
  263.         this._mps.push($gameParty.members()[el].mpRate());
  264.         this._tps.push($gameParty.members()[el].tpRate());
  265.   }
  266.  
  267.    for(var i=0;i<this._hps.length;i++){
  268.     if (this._hps[i] != this._last_hps[i]){
  269.                 this.refresh();
  270.                 break;
  271.         }
  272.         if (this._mps[i] != this._last_mps[i]){
  273.                 this.refresh();
  274.                 break;
  275.         }
  276.         if (this._tps[i] != this._last_tps[i]){
  277.                 this.refresh();
  278.                 break;
  279.         }
  280.         if (this._firstOpen === true ){
  281.                 this._firstOpen = false;
  282.                 this.refresh();
  283.                 break;
  284.         }
  285.  
  286.   }
  287.  
  288. };
  289.  
  290. Window_MapStatus.prototype.refresh = function() {
  291.     this.contents.clear();
  292.         this.drawAllItems();
  293.         this._last_hps.length = 0;
  294.     this._last_mps.length = 0;
  295.     this._last_tps.length = 0;
  296.     for(var el=0;el<$gameParty.size();el++){
  297.                 this._last_hps.push($gameParty.members()[el].hpRate());
  298.                 this._last_mps.push($gameParty.members()[el].mpRate());
  299.                 this._last_tps.push($gameParty.members()[el].tpRate());
  300.         }
  301.  
  302. };
  303. Window_MapStatus.prototype.drawAllItems = function() {
  304.     var topIndex = this.topIndex();
  305.     for (var i = 0; i < this.maxPageItems(); i++) {
  306.         var index = topIndex + i;
  307.         if (index < this.maxItems()) {
  308.             this.drawItem(index);
  309.         }
  310.     }
  311.  
  312.   for(var el=0;el<$gameParty.size();el++){
  313.     this._last_hps.push($gameParty.members()[el].hpRate());
  314.         this._last_mps.push($gameParty.members()[el].mpRate());
  315.         this._last_tps.push($gameParty.members()[el].tpRate());
  316.   }
  317. };
  318.  
  319.  
  320.  
  321. var _Scene_Map_createMapStatusWindow = Scene_Map.prototype.createDisplayObjects;
  322. Scene_Map.prototype.createDisplayObjects = function() {
  323.         _Scene_Map_createMapStatusWindow.call(this);
  324.         this._mapStatusWindow = new Window_MapStatus();
  325.         this._mapStatusWindow.opacity = 1;
  326.         this._mapStatusWindow.x = 0;
  327.         this._mapStatusWindow.y = 100;
  328.         this.addWindow(this._mapStatusWindow);
  329.  
  330. };
  331.  
  332. var _Scene_Map_updateMapStatusWindow1 = Scene_Map.prototype.update;
  333. Scene_Map.prototype.update = function() {
  334.         _Scene_Map_updateMapStatusWindow1.call(this);////gameSwitches.value(dataId)
  335.         if(($gameMap._interpreter.isRunning()) || ($gameSwitches.value(notShowSwitch) == true)){
  336.  
  337.            this._mapStatusWindow.close();
  338.      }
  339.         else{
  340.            this._mapStatusWindow.open();  
  341.      }
  342. };


大地图血条.rar

79.31 KB, 下载次数: 261

Lv3.寻梦者

梦石
0
星屑
1393
在线时间
77 小时
注册时间
2014-6-13
帖子
95
2
发表于 2021-1-23 10:52:27 | 只看该作者
没懂什么是大地图血条
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
36
在线时间
8 小时
注册时间
2018-4-14
帖子
5
3
发表于 2021-9-16 09:12:46 | 只看该作者
MZ要是有轨迹风格的战斗插件就好了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
121
在线时间
10 小时
注册时间
2021-11-29
帖子
22
4
发表于 2021-12-5 09:23:28 | 只看该作者
大地图血条?很想知道大佬有没有战斗敌人血条之类的。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
20
在线时间
1 小时
注册时间
2022-3-4
帖子
4
5
发表于 2022-3-12 08:53:29 | 只看该作者
谢谢大佬的插件,我已经运行发现了点问题:我对话文本是在下方的,用了这个对话文本被影响了。
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
418
在线时间
40 小时
注册时间
2022-4-14
帖子
34
6
发表于 2022-5-2 12:03:23 | 只看该作者
看上去效果不错~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
52
在线时间
8 小时
注册时间
2023-6-16
帖子
11
7
发表于 2023-6-18 08:58:51 | 只看该作者
感谢分享
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-23 18:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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