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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
470
在线时间
271 小时
注册时间
2011-10-17
帖子
99
跳转到指定楼层
1
发表于 2017-6-23 15:41:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
制作跑商系统必不可少的脚本,但是找了一圈(包括YEP系列和SRD系列)居然没找到,所以请问大家谁知道吗,谢谢了

Lv4.逐梦者

梦石
0
星屑
15512
在线时间
3951 小时
注册时间
2015-9-14
帖子
1333

开拓者

2
发表于 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
(沒測試)
JAVASCRIPT 代码复制
  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.  
  164. (function() {
  165.         //プラグインマネージャーで設定されたパラメータを取得
  166.         var parameters = PluginManager.parameters('PNDK_LuggageCapacity');
  167.  
  168.         //パラメータを変数へ
  169.         var cp = parameters['Carry point'];
  170.         var defW = Number(parameters['Default weight']);
  171.         var wUnit = parameters['Unit'];
  172.         var wText = parameters['Attribute name'];
  173.         var layoutMenu = parameters['Window layout in menu'];
  174.         var opacityMenu = parseInt(parameters['Window opacity in menu'], 10);
  175.         var layoutShop = parameters['Window layout in shop'];
  176.         var opacityShop = parseInt(parameters['Window opacity in shop'], 10);
  177.  
  178.         //最大積載量の取得
  179.         function getCP() {
  180.                 return Number(Window_Base.prototype.convertEscapeCharacters(cp));
  181.         }
  182.  
  183.         //それの重量
  184.         function getWeight(item, amount){
  185.                 if (item) {
  186.                         return item.meta.weight !== undefined ? (item.meta.weight * amount) : defW * amount;
  187.                 }
  188.                 //itemがnullの場合もある(装備していない時や全部解除したときなど)
  189.                 return 0;
  190.         }
  191.  
  192.         //総重量取得
  193.         function getAllItemWeights() {
  194.                 var w = 0;
  195.                 //アイテム・武器・防具
  196.                 $gameParty.allItems().forEach(function(item){
  197.                         var n = $gameParty.numItems(item);
  198.                         w += getWeight(item, n);
  199.                 });
  200.                 //全アクターの装備品
  201.                 $gameParty.allMembers().forEach(function(actor) {
  202.                         actor.equips().forEach(function(item){
  203.                                 w += getWeight(item, 1);
  204.                         });
  205.     });
  206.                 return w;
  207.         }
  208.  
  209.         //持てるかチェック
  210.         function canHaveItem(item, amount) {
  211.                 return getCP() >= (getAllItemWeights() + getWeight(item, amount));
  212.         }
  213.  
  214.         //余剰積載量
  215.         function getSurplusCP() {
  216.                 return getCP() - getAllItemWeights();
  217.         }
  218.  
  219.         //CPウィンドウ=====================================================================
  220.         function Window_CP() {
  221.                 this.initialize.apply(this, arguments);
  222.         }
  223.  
  224.         Window_CP.prototype = Object.create(Window_Base.prototype);
  225.         Window_CP.prototype.constructor = Window_CP;
  226.  
  227.         Window_CP.prototype.initialize = function(x, y, w, h) {
  228.                 Window_Base.prototype.initialize.call(this, x, y, w, h);
  229.                 this.refresh();
  230.         };
  231.  
  232.         Window_CP.prototype.refresh = function() {
  233.                 var x = this.textPadding();
  234.                 var width = this.contents.width - this.textPadding() * 2;
  235.                 this.contents.clear();
  236.                 this.drawCpValue(getAllItemWeights(), x, 0, width);
  237.         };
  238.  
  239.         Window_Base.prototype.drawCpValue = function(value, x, y, width) {
  240.                 var unitWidth = this.textWidth(wUnit) + this.textPadding();
  241.                 var cpWidth = this.textWidth(getCP());
  242.                 var slashWidth = this.textWidth("/");
  243.                 var sCpWidth = width - (slashWidth + cpWidth + unitWidth);
  244.                 //
  245.                 this.resetFontSettings();
  246.                 //this.makeFontSmaller();
  247.                 this.drawText(value, x, y, sCpWidth, 'right');
  248.                 //
  249.                 this.changeTextColor(this.systemColor());
  250.                 this.drawText("/", (x + sCpWidth), y, slashWidth, 'right');
  251.                 //
  252.     this.resetTextColor();
  253.                 this.drawText(getCP(), (x + sCpWidth + slashWidth), y, cpWidth, 'right');
  254.                 //
  255.                 this.changeTextColor(this.systemColor());
  256.                 this.drawText(wUnit, (x + sCpWidth + slashWidth + cpWidth), y, unitWidth, 'right');
  257.         };
  258.  
  259.         //メニュー画面にCPウィンドウを追加---------------------------------------------------------------
  260.         var _Scene_Menu_create = Scene_Menu.prototype.create;
  261.         Scene_Menu.prototype.create = function() {
  262.                 _Scene_Menu_create.call(this);
  263.                 //
  264.                 this.createCpWindow(layoutMenu, opacityMenu);
  265.         };
  266.  
  267.         Scene_MenuBase.prototype.createCpWindow = function(layout, opacity) {
  268.                 var x = this._goldWindow.x;
  269.                 var y = this._goldWindow.y - this._goldWindow.height;
  270.                 var w = this._goldWindow.width;
  271.                 var h = this._goldWindow.height;
  272.                 //
  273.                 if (layout == "TopLeft") {
  274.                         x = 0;
  275.                         y = 0;
  276.                 } else if (layout == "TopRight") {
  277.                         x = Graphics.boxWidth - w;
  278.                         y = 0;
  279.                 } else if (layout == "BottomLeft") {
  280.                         x = 0;
  281.                         y = Graphics.boxHeight - h;
  282.                 } else if (layout == "BottomRight") {
  283.                         x = Graphics.boxWidth - w;
  284.                         y = Graphics.boxHeight - h;
  285.                 }
  286.                 this._cpWindow = new Window_CP(x, y, w, h);
  287.                 this._cpWindow.opacity = opacity;
  288.                 this.addWindow(this._cpWindow);
  289.         };
  290.  
  291.         //小さなヘルプウィンドウを作れるようにする---------------------------------------------------------------
  292.         var _Window_Help_initialize = Window_Help.prototype.initialize;
  293.         Window_Help.prototype.initialize = function(numLines, isShort) {
  294.                 if (isShort) {
  295.                         var width = Graphics.boxWidth - Window_Gold.prototype.windowWidth();
  296.                         var height = this.fittingHeight(numLines || 2);
  297.                         Window_Base.prototype.initialize.call(this, 0, 0, width, height);
  298.                         this._text = '';
  299.                 } else {
  300.                         _Window_Help_initialize.call(this, numLines);
  301.                 }
  302.         };
  303.  
  304.         //shop画面のヘルプウィンドウを小さくする---------------------------------------------------------------
  305.         Scene_Shop.prototype.createHelpWindow = function() {
  306.           this._helpWindow = new Window_Help(2, true);
  307.                 this.addWindow(this._helpWindow);
  308.         };
  309.  
  310.         //shop画面にCPウィンドウを追加---------------------------------------------------------------
  311.         var _Scene_Shop_create = Scene_Shop.prototype.create;
  312.         Scene_Shop.prototype.create = function() {
  313.                 _Scene_Shop_create.call(this);
  314.                 //
  315.                 this.createCpWindow(layoutShop, opacityShop);
  316.         };
  317.  
  318.         //商品購入時の購入可能最大数取得を書き換え---------------------------------------------------------------
  319.         var _Scene_Shop_maxBuy = Scene_Shop.prototype.maxBuy;
  320.         Scene_Shop.prototype.maxBuy = function() {
  321.                 var r = _Scene_Shop_maxBuy.call(this);
  322.                 var w = getWeight(this._item, 1);
  323.                 if (w === 0) {
  324.                         return r;
  325.                 } else {
  326.                         return Math.min(r, Math.floor(getSurplusCP() / w));
  327.                 }
  328.         };
  329.  
  330.         //商品選択時の購入可否判定を書き換え---------------------------------------------------------------
  331.         var _Window_ShopBuy_isEnabled = Window_ShopBuy.prototype.isEnabled;
  332.         Window_ShopBuy.prototype.isEnabled = function(item) {
  333.                 return _Window_ShopBuy_isEnabled.call(this, item) && canHaveItem(item, 1);
  334.         };
  335.  
  336.         //売買時にCPウィンドウを更新するよう書き換え---------------------------------------------------------------
  337.         var _Scene_Shop_onNumberOk = Scene_Shop.prototype.onNumberOk;
  338.         Scene_Shop.prototype.onNumberOk = function() {
  339.                 _Scene_Shop_onNumberOk.call(this);
  340.                 //
  341.                 this._cpWindow.refresh();
  342.         };
  343.  
  344.         //数量選択画面に重さを追加---------------------------------------------------------------
  345.         var _Window_ShopNumber_refresh = Window_ShopNumber.prototype.refresh;
  346.         Window_ShopNumber.prototype.refresh = function() {
  347.                 _Window_ShopNumber_refresh.call(this);
  348.                 //
  349.                 this.drawWeight();
  350.         };
  351.  
  352.         Window_ShopNumber.prototype.drawWeight = function() {
  353.                 var total = getWeight(this._item, this._number);
  354.                 var width = this.contentsWidth() - this.textPadding();
  355.                 //drawCurrencyValue を代用
  356.     this.drawCurrencyValue(total, wUnit, 0, this.weightY(), width);
  357.         };
  358.  
  359.         Window_ShopNumber.prototype.weightY = function() {
  360.                 return Math.round(this.contentsHeight() / 2 - this.lineHeight() * 0.5);
  361.         };
  362.  
  363.         //shopのステータスウィンドウに重さを追加---------------------------------------------------------------
  364.         var _Window_ShopStatus_drawPossession = Window_ShopStatus.prototype.drawPossession;
  365.         Window_ShopStatus.prototype.drawPossession = function(x, y) {
  366.                 _Window_ShopStatus_drawPossession.call(this, x, y);
  367.                 //
  368.                 var width = this.contents.width - (this.textPadding() + x);
  369.                 var wTextWidth = this.textWidth(wText);
  370.                 var wY = this.lineHeight();
  371.                 this.changeTextColor(this.systemColor());
  372.                 this.drawText(wText, x, wY, wTextWidth);
  373.                 this.resetTextColor();
  374.                 this.drawText(getWeight(this._item, 1), (x + wTextWidth), wY, (width - wTextWidth), 'right');
  375.         };
  376.  
  377.         //アイテム増減処理の書き換え---------------------------------------------------------------
  378.         var _Game_Party_gainItem = Game_Party.prototype.gainItem;
  379.         Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
  380.                 if (canHaveItem(item, amount)) {
  381.                         //増減可能
  382.                         _Game_Party_gainItem.call(this, item, amount, includeEquip);
  383.                 }
  384.         };
  385.  
  386.         //プラグインコマンドの追加===================================================================
  387.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  388.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  389.                 _Game_Interpreter_pluginCommand.call(this, command, args);
  390.                 //
  391.                 if (command === 'PNDK_LC') {
  392.                         switch (args[0]) {
  393.                                 case 'getSurplusWeights':
  394.                                         $gameVariables.setValue(parseInt(args[1], 10), getSurplusCP());
  395.                                         break;
  396.                                 case 'getAllItemWeights':
  397.                                         $gameVariables.setValue(parseInt(args[1], 10), getAllItemWeights());
  398.                                         break;
  399.                         }
  400.                 }
  401.         };
  402.  
  403. })();
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 10:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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