Project1

标题: 单个物品最大数限制+物品种类限制/格子数 [打印本页]

作者: zhanghao    时间: 2017-1-10 20:01
标题: 单个物品最大数限制+物品种类限制/格子数
本帖最后由 zhanghao 于 2017-1-10 20:18 编辑

【原创】作者: 范夏jk
实现以下功能: 单个物品最大数限制+物品种类限制/格子数
可在插件菜单调整你想要的参数。
*文件名请保存为Koo_ItemsLimited.js

使用、转载请署名


JAVASCRIPT 代码复制下载
  1. //=============================================================================
  2. // Koo_ItemsLimited.js
  3. //=============================================================================
  4. /*:
  5.  * @plugindesc (v1.1) 物品种类限制。可能会与其他物品插件冲突,请注意。
  6.  * @author 范夏jk
  7.  *
  8.  * @param maxItemsType
  9.  * @desc 最大种类数/格子数
  10.  * @default 30
  11.  *
  12.  * @param maxItems
  13.  * @desc 单个物品最大数
  14.  * @default 99
  15.  *
  16.  * 作者:范夏jk
  17.  * 转载、使用请署名
  18.  * 更新日志
  19.  * 1.1版 修正原来考虑不周到的部分,增加了限制单个物品最大数目的功能
  20.  *
  21.  */
  22.  
  23.  
  24. Game_Party.prototype.maxItems = function(item) {
  25.     return Number(PluginManager.parameters('Koo_ItemsLimited')['maxItems'] || 99);//修改单个物品的最大数
  26. };
  27.  
  28. Game_Party.prototype.numItemsType = function() {
  29.     var container = Object.keys($gameParty._items);
  30.     return container.length;
  31. };
  32.  
  33. Game_Party.prototype.maxItemsType = function() {
  34.     return Number(PluginManager.parameters('Koo_ItemsLimited')['maxItemsType'] || 30);//修改物品种类的最大数
  35. };
  36.  
  37. Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
  38.     var container = this.itemContainer(item);
  39.     if (container) {
  40.         var lastNumber = this.numItems(item);
  41.         var newNumber = lastNumber + amount;
  42.         if (this.numItemsType() >= this.maxItemsType()&& !container.hasOwnProperty(item.id)) {
  43.             console.log("你的格子已满");
  44.         }else{
  45.             container[item.id] = newNumber.clamp(0, this.maxItems(item));
  46.             if (container[item.id] === 0) {
  47.                 delete container[item.id];
  48.             }
  49.             if (includeEquip && newNumber < 0) {
  50.                 this.discardMembersEquip(item, -newNumber);
  51.             }
  52.         }
  53.         $gameMap.requestRefresh();
  54.     }
  55. };

作者: walf_man    时间: 2017-1-11 11:03
非常实用非常好的插件,感谢大神共享
作者: a6633069    时间: 2020-8-4 04:29
不错不错啊
作者: dongtian    时间: 2020-8-26 18:23
感谢分享




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1