查看: 4095|回复: 1

[已经过期] 请问MV有没有队伍负重(背包负重)脚本

[复制链接]
梦石
0
星屑
470
在线时间
271 小时
注册时间
2011-10-17
回帖
70
发表于 2017-6-23 15:41:10 | 显示全部楼层 |阅读模式

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

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

×
制作跑商系统必不可少的脚本,但是找了一圈(包括YEP系列和SRD系列)居然没找到,所以请问大家谁知道吗,谢谢了
梦石
0
星屑
16296
在线时间
4017 小时
注册时间
2015-9-14
回帖
1322

开拓者

发表于 2017-6-23 16:29:21 | 显示全部楼层
本帖最后由 wabcmcc 于 2017-6-23 16:39 编辑

日本論壇:http://tm.lucky-duet.com/viewtopic.php?f=5&t=2459
重量限制插件:PNDK_LuggageCapacity.js
(沒測試)
  1. // --------------------------------------------------------------------------
  2. //
  3. // PNDK_LuggageCapacity
  4. // Copyright (c) 2016 PANDAKO
  5. // This software is released under the MIT License.
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //
  8. // --------------------------------------------------------------------------
  9. /*:
  10. * @plugindesc This plugin sets weights for items.
  11. * @author PANDAKO
  12. *
  13. * @help
  14. * Meta tag:
  15. *   <weight:10>
  16. *
  17. * Plugin Command:
  18. *   PNDK_LC getSurplusWeights [variable ID]
  19. *   PNDK_LC getAllItemWeights [variable ID]
  20. *
  21. * Disclaimer:
  22. *   I will not be responsible for any accident or injures.
  23. *
  24. * @param Carry point
  25. * @desc Max weights.
  26. * @default 1000
  27. *
  28. * @param Default weight
  29. * @desc Default weight.
  30. * @default 10
  31. *
  32. * @param Unit
  33. * @desc Unit for weight.
  34. * @default W
  35. *
  36. * @param Attribute name
  37. * @desc Name for attribute.
  38. * @default Weights
  39. *
  40. * @param Window layout in menu
  41. * @desc Layout of the weights window in menu.
  42. * TopOfGold, TopLeft, TopRight, BottomLeft, BottomRight
  43. * @default TopOfGold
  44. *
  45. * @param Window opacity in menu
  46. * @desc Opacity of the weights window in menu.
  47. * 0~255
  48. * @default 255
  49. *
  50. * @param Window layout in shop
  51. * @desc Layout of the weights window in shop.
  52. * TopOfGold, TopLeft, TopRight, BottomLeft, BottomRight
  53. * @default TopOfGold
  54. *
  55. * @param Window opacity in shop
  56. * @desc Opacity of the weights window in shop.
  57. * 0~255
  58. * @default 255
  59. *
  60. */
  61. /*:ja
  62. * @plugindesc アイテムや武器・防具の所持できる数を重量(ポイント)制にします。
  63. * @author パンダコ
  64. *
  65. * @help
  66. * このプラグインを有効にすると、個々のアイテムや武器・防具(以下アイテム)に
  67. * 重さが設定できるようになり、パーティーは決められた総重量までしかアイテムを
  68. * 所持できなくなります。
  69. *
  70. * ■重さの設定方法
  71. * アイテムのメモ欄に以下のようなメタタグを記入してください。
  72. * <weight:10>
  73. * 上記の場合、重さが10に設定されます。
  74. * 重さが設定されていないものは、パラメータで設定された Default weight の
  75. * 重さになります。
  76. *
  77. * ■プラグインコマンド
  78. * ・所持できる残りの重量を変数0001へ代入します。
  79. *   PNDK_LC getSurplusWeights 1
  80. *
  81. * ・所持しているアイテムの総重量を変数0007へ代入します。
  82. *   PNDK_LC getAllItemWeights 7
  83. *
  84. * ■仕様
  85. * ・メニュー画面とショップ画面に重量ウィンドウが追加されます。
  86. * ・ショップ画面の商品選択時に対象の重さが表示されます。
  87. * ・ショップ画面の数量選択時に重さの小計が表示されます。
  88. * ・ショプ画面では商品の説明欄が小さくなるので文字数に注意してください。
  89. * ・装備しているものも総重量に含まれます。
  90. * ・控えメンバーの装備も総重量に含まれます。
  91. * ・「大事なもの」の重さも総重量に含まれます。
  92. * ・重さなし <weight:0> も可能です。
  93. * ・システムで定められた上限(通常は99個)以上には所持できません。
  94. * ・イベントや戦闘でアイテムを入手した際、持ちきれないものは破棄されます。
  95. *
  96. * ■総重量ウィンドウの位置について
  97. * パラメータ Window layout in menu と Window layout in shop を
  98. * 以下の値にすることで、総重量ウィンドウの位置を変更できます。
  99. *
  100. * TopOfGold      #所持金の上
  101. * TopLeft        #画面の左上
  102. * TopRight       #画面の右上
  103. * BottomLeft     #画面の左下
  104. * BottomRight    #画面の右下
  105. *
  106. * ■更新履歴
  107. * Version:1.1.0[2016/11/11]
  108. * 総重量ウィンドウの位置と不透明度を選択できる機能を追加。
  109. *
  110. * Version:1.0.0[2016/11/10]
  111. * 初版
  112. *
  113. * ■ライセンス
  114. * Copyright (c) 2016 PANDAKO
  115. * This software is released under the MIT License.
  116. * [url]http://opensource.org/licenses/mit-license.php[/url]
  117. *
  118. * [Blog : [url]http://memo.pandako.com/[/url]]
  119. *
  120. * ■免責事項
  121. * このプラグインの利用により利用者または第三者に生じたいかなる損害や
  122. * 不利益も、このプラグインの開発者はその責任を負いません。
  123. *
  124. *
  125. * @param Carry point
  126. * @desc 所持できる総重量の上限。
  127. * 制御文字が利用できます。
  128. * @default 1000
  129. *
  130. * @param Default weight
  131. * @desc 重さの初期値。weight を設定していないアイテムや武器・防具はこの重さになります。
  132. * @default 10
  133. *
  134. * @param Unit
  135. * @desc 重さの単位。
  136. * @default W
  137. *
  138. * @param Attribute name
  139. * @desc 重さの用語。
  140. * @default 重さ
  141. *
  142. * @param Window layout in menu
  143. * @desc メニュー画面での総重量ウィンドウの位置
  144. * TopOfGold, TopLeft, TopRight, BottomLeft, BottomRight
  145. * @default TopOfGold
  146. *
  147. * @param Window opacity in menu
  148. * @desc メニュー画面での総重量ウィンドウの不透明度
  149. * 0~255(0 透明 ⇔ 255 不透明)
  150. * @default 255
  151. *
  152. * @param Window layout in shop
  153. * @desc ショップ画面での総重量ウィンドウの位置
  154. * TopOfGold, TopLeft, TopRight, BottomLeft, BottomRight
  155. * @default TopOfGold
  156. *
  157. * @param Window opacity in shop
  158. * @desc ショップ画面での総重量ウィンドウの不透明度
  159. * 0~255(0 透明 ⇔ 255 不透明)
  160. * @default 255
  161. *
  162. */

  163. (function() {
  164.         //プラグインマネージャーで設定されたパラメータを取得
  165.         var parameters = PluginManager.parameters('PNDK_LuggageCapacity');
  166.        
  167.         //パラメータを変数へ
  168.         var cp = parameters['Carry point'];
  169.         var defW = Number(parameters['Default weight']);
  170.         var wUnit = parameters['Unit'];
  171.         var wText = parameters['Attribute name'];
  172.         var layoutMenu = parameters['Window layout in menu'];
  173.         var opacityMenu = parseInt(parameters['Window opacity in menu'], 10);
  174.         var layoutShop = parameters['Window layout in shop'];
  175.         var opacityShop = parseInt(parameters['Window opacity in shop'], 10);
  176.        
  177.         //最大積載量の取得
  178.         function getCP() {
  179.                 return Number(Window_Base.prototype.convertEscapeCharacters(cp));
  180.         }
  181.        
  182.         //それの重量
  183.         function getWeight(item, amount){
  184.                 if (item) {
  185.                         return item.meta.weight !== undefined ? (item.meta.weight * amount) : defW * amount;
  186.                 }
  187.                 //itemがnullの場合もある(装備していない時や全部解除したときなど)
  188.                 return 0;
  189.         }
  190.        
  191.         //総重量取得
  192.         function getAllItemWeights() {
  193.                 var w = 0;
  194.                 //アイテム・武器・防具
  195.                 $gameParty.allItems().forEach(function(item){
  196.                         var n = $gameParty.numItems(item);
  197.                         w += getWeight(item, n);
  198.                 });
  199.                 //全アクターの装備品
  200.                 $gameParty.allMembers().forEach(function(actor) {
  201.                         actor.equips().forEach(function(item){
  202.                                 w += getWeight(item, 1);
  203.                         });
  204.     });
  205.                 return w;
  206.         }
  207.        
  208.         //持てるかチェック
  209.         function canHaveItem(item, amount) {
  210.                 return getCP() >= (getAllItemWeights() + getWeight(item, amount));
  211.         }
  212.        
  213.         //余剰積載量
  214.         function getSurplusCP() {
  215.                 return getCP() - getAllItemWeights();
  216.         }
  217.        
  218.         //CPウィンドウ=====================================================================
  219.         function Window_CP() {
  220.                 this.initialize.apply(this, arguments);
  221.         }
  222.        
  223.         Window_CP.prototype = Object.create(Window_Base.prototype);
  224.         Window_CP.prototype.constructor = Window_CP;
  225.        
  226.         Window_CP.prototype.initialize = function(x, y, w, h) {
  227.                 Window_Base.prototype.initialize.call(this, x, y, w, h);
  228.                 this.refresh();
  229.         };

  230.         Window_CP.prototype.refresh = function() {
  231.                 var x = this.textPadding();
  232.                 var width = this.contents.width - this.textPadding() * 2;
  233.                 this.contents.clear();
  234.                 this.drawCpValue(getAllItemWeights(), x, 0, width);
  235.         };
  236.        
  237.         Window_Base.prototype.drawCpValue = function(value, x, y, width) {
  238.                 var unitWidth = this.textWidth(wUnit) + this.textPadding();
  239.                 var cpWidth = this.textWidth(getCP());
  240.                 var slashWidth = this.textWidth("/");
  241.                 var sCpWidth = width - (slashWidth + cpWidth + unitWidth);
  242.                 //
  243.                 this.resetFontSettings();
  244.                 //this.makeFontSmaller();
  245.                 this.drawText(value, x, y, sCpWidth, 'right');
  246.                 //
  247.                 this.changeTextColor(this.systemColor());
  248.                 this.drawText("/", (x + sCpWidth), y, slashWidth, 'right');
  249.                 //
  250.     this.resetTextColor();
  251.                 this.drawText(getCP(), (x + sCpWidth + slashWidth), y, cpWidth, 'right');
  252.                 //
  253.                 this.changeTextColor(this.systemColor());
  254.                 this.drawText(wUnit, (x + sCpWidth + slashWidth + cpWidth), y, unitWidth, 'right');
  255.         };
  256.        
  257.         //メニュー画面にCPウィンドウを追加---------------------------------------------------------------
  258.         var _Scene_Menu_create = Scene_Menu.prototype.create;
  259.         Scene_Menu.prototype.create = function() {
  260.                 _Scene_Menu_create.call(this);
  261.                 //
  262.                 this.createCpWindow(layoutMenu, opacityMenu);
  263.         };
  264.        
  265.         Scene_MenuBase.prototype.createCpWindow = function(layout, opacity) {
  266.                 var x = this._goldWindow.x;
  267.                 var y = this._goldWindow.y - this._goldWindow.height;
  268.                 var w = this._goldWindow.width;
  269.                 var h = this._goldWindow.height;
  270.                 //
  271.                 if (layout == "TopLeft") {
  272.                         x = 0;
  273.                         y = 0;
  274.                 } else if (layout == "TopRight") {
  275.                         x = Graphics.boxWidth - w;
  276.                         y = 0;
  277.                 } else if (layout == "BottomLeft") {
  278.                         x = 0;
  279.                         y = Graphics.boxHeight - h;
  280.                 } else if (layout == "BottomRight") {
  281.                         x = Graphics.boxWidth - w;
  282.                         y = Graphics.boxHeight - h;
  283.                 }
  284.                 this._cpWindow = new Window_CP(x, y, w, h);
  285.                 this._cpWindow.opacity = opacity;
  286.                 this.addWindow(this._cpWindow);
  287.         };
  288.        
  289.         //小さなヘルプウィンドウを作れるようにする---------------------------------------------------------------
  290.         var _Window_Help_initialize = Window_Help.prototype.initialize;
  291.         Window_Help.prototype.initialize = function(numLines, isShort) {
  292.                 if (isShort) {
  293.                         var width = Graphics.boxWidth - Window_Gold.prototype.windowWidth();
  294.                         var height = this.fittingHeight(numLines || 2);
  295.                         Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  296.                         this._text = '';
  297.                 } else {
  298.                         _Window_Help_initialize.call(this, numLines);
  299.                 }
  300.         };
  301.        
  302.         //shop画面のヘルプウィンドウを小さくする---------------------------------------------------------------
  303.         Scene_Shop.prototype.createHelpWindow = function() {
  304.           this._helpWindow = new Window_Help(2, true);
  305.                 this.addWindow(this._helpWindow);
  306.         };

  307.         //shop画面にCPウィンドウを追加---------------------------------------------------------------
  308.         var _Scene_Shop_create = Scene_Shop.prototype.create;
  309.         Scene_Shop.prototype.create = function() {
  310.                 _Scene_Shop_create.call(this);
  311.                 //
  312.                 this.createCpWindow(layoutShop, opacityShop);
  313.         };
  314.        
  315.         //商品購入時の購入可能最大数取得を書き換え---------------------------------------------------------------
  316.         var _Scene_Shop_maxBuy = Scene_Shop.prototype.maxBuy;
  317.         Scene_Shop.prototype.maxBuy = function() {
  318.                 var r = _Scene_Shop_maxBuy.call(this);
  319.                 var w = getWeight(this._item, 1);
  320.                 if (w === 0) {
  321.                         return r;
  322.                 } else {
  323.                         return Math.min(r, Math.floor(getSurplusCP() / w));
  324.                 }
  325.         };
  326.        
  327.         //商品選択時の購入可否判定を書き換え---------------------------------------------------------------
  328.         var _Window_ShopBuy_isEnabled = Window_ShopBuy.prototype.isEnabled;
  329.         Window_ShopBuy.prototype.isEnabled = function(item) {
  330.                 return _Window_ShopBuy_isEnabled.call(this, item) && canHaveItem(item, 1);
  331.         };
  332.        
  333.         //売買時にCPウィンドウを更新するよう書き換え---------------------------------------------------------------
  334.         var _Scene_Shop_onNumberOk = Scene_Shop.prototype.onNumberOk;
  335.         Scene_Shop.prototype.onNumberOk = function() {
  336.                 _Scene_Shop_onNumberOk.call(this);
  337.                 //
  338.                 this._cpWindow.refresh();
  339.         };
  340.        
  341.         //数量選択画面に重さを追加---------------------------------------------------------------
  342.         var _Window_ShopNumber_refresh = Window_ShopNumber.prototype.refresh;
  343.         Window_ShopNumber.prototype.refresh = function() {
  344.                 _Window_ShopNumber_refresh.call(this);
  345.                 //
  346.                 this.drawWeight();
  347.         };
  348.        
  349.         Window_ShopNumber.prototype.drawWeight = function() {
  350.                 var total = getWeight(this._item, this._number);
  351.                 var width = this.contentsWidth() - this.textPadding();
  352.                 //drawCurrencyValue を代用
  353.     this.drawCurrencyValue(total, wUnit, 0, this.weightY(), width);
  354.         };
  355.        
  356.         Window_ShopNumber.prototype.weightY = function() {
  357.                 return Math.round(this.contentsHeight() / 2 - this.lineHeight() * 0.5);
  358.         };
  359.        
  360.         //shopのステータスウィンドウに重さを追加---------------------------------------------------------------
  361.         var _Window_ShopStatus_drawPossession = Window_ShopStatus.prototype.drawPossession;
  362.         Window_ShopStatus.prototype.drawPossession = function(x, y) {
  363.                 _Window_ShopStatus_drawPossession.call(this, x, y);
  364.                 //
  365.                 var width = this.contents.width - (this.textPadding() + x);
  366.                 var wTextWidth = this.textWidth(wText);
  367.                 var wY = this.lineHeight();
  368.                 this.changeTextColor(this.systemColor());
  369.                 this.drawText(wText, x, wY, wTextWidth);
  370.                 this.resetTextColor();
  371.                 this.drawText(getWeight(this._item, 1), (x + wTextWidth), wY, (width - wTextWidth), 'right');
  372.         };
  373.        
  374.         //アイテム増減処理の書き換え---------------------------------------------------------------
  375.         var _Game_Party_gainItem = Game_Party.prototype.gainItem;
  376.         Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
  377.                 if (canHaveItem(item, amount)) {
  378.                         //増減可能
  379.                         _Game_Party_gainItem.call(this, item, amount, includeEquip);
  380.                 }
  381.         };
  382.        
  383.         //プラグインコマンドの追加===================================================================
  384.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  385.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  386.                 _Game_Interpreter_pluginCommand.call(this, command, args);
  387.                 //
  388.                 if (command === 'PNDK_LC') {
  389.                         switch (args[0]) {
  390.                                 case 'getSurplusWeights':
  391.                                         $gameVariables.setValue(parseInt(args[1], 10), getSurplusCP());
  392.                                         break;
  393.                                 case 'getAllItemWeights':
  394.                                         $gameVariables.setValue(parseInt(args[1], 10), getAllItemWeights());
  395.                                         break;
  396.                         }
  397.                 }
  398.         };
  399.        
  400. })();
复制代码
https://rpg.blue/data/attachment/album/202003/28/021323lltgrsvfytfwuya5.gif
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部