查看: 6699|回复: 8

[已经解决] MV怎样设置某一物品的持有数量

[复制链接]
梦石
0
星屑
2773
在线时间
675 小时
注册时间
2012-1-29
回帖
61
发表于 2017-5-10 01:58:59 | 显示全部楼层 |阅读模式

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

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

×
MV怎样设置某一物品的持有数量上限
我先用的是YEP插件
谢谢大神们了

点评

改物品上限的判断数值,依照对应的物品ID来分别判断  发表于 2017-5-10 08:54
梦石
0
星屑
2773
在线时间
675 小时
注册时间
2012-1-29
回帖
61
 楼主| 发表于 2017-5-10 20:17:56 | 显示全部楼层
......能不能再详细点?吸血拉
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2017-5-10 20:33:46 | 显示全部楼层
本帖最后由 tseyik 于 2017-5-10 23:35 编辑

http://space6718.lolipop.jp/script/setItemMax.js

setItemMax.js[pre lang="javascript"]/*:ja
* @plugindesc アイテムの最大所持個数をアイテムIdごとに指定できます。
* @author 村人A
*
* @help
*
*  アイテムのメモ欄に「itemMaxNum:個数」と入力することによりそのアイテムのデフォルトの最大所持数を設定することが出来ます。
*  コマンド例
*  itemMaxNum:1010  #入力したアイテムの最大所持数を1010個に設定
*
*  アイテムの所持上限数をゲーム中に変更したい場合は「アイテム上限設定変更」とプラグインコマンドを入力後、指定したいアイテムidと最大所持数を入力
*  別のアイテムも変更したい場合続けて入力してください
*  デフォルトの最大所持数(99個)を変更したい場合はidを0と入力し、その後に個数を指定してください。
*
* プラグインコマンド例:
*   アイテム上限設定変更 3 35
*   #アイテムidが3のアイテムの最大所持数を35個に設定
*   アイテム上限設定変更 1 20 4 8 7 15 9 100 0 200
*   #idが1のアイテムの最大個数を20個に、idが4のアイテムの最大個数を8個に以下、7を15、9を100、デフォルトの最大個数を200個に変更
*
*  変更したときにアイテムの所持数が指定した最大所持数より多かった場合、自動的に最大所数に直されます。
*
*  値の優先度としては
*  プラグインコマンドによる変更 > データベースでの指定 > 変更したデフォルトの最大個数 > デフォルトの最大個数(99個)
*  となります。
*/

(function() {
        villaA_itemIdMaxArray = [];
        villaA_itemSeachNum = 1;
        villaA_itemMaxNum = 2;
       
        var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
                _Game_Interpreter_pluginCommand.call(this, command, args);
                if (command === 'アイテム上限設定変更') {
                        for(var i = 0; i < args.length; i += 2){
                                villaA_itemIdMaxArray.push([args, args[i+1]]);
                                if(String(args[i+1]).length > villaA_itemMaxNum){
                                        villaA_itemMaxNum = String(args[i+1]).length;
                                }
                        }
               
                        for(var i = 1; i < $dataItems.length; i++){
                                if(villaA_itemSeachNum < String($gameParty.maxItems($dataItems)).length){
                                        villaA_itemSeachNum = String($gameParty.maxItems($dataItems)).length;
                                }
                        }
                        villaA_itemMaxNum = villaA_itemSeachNum;
                        villaA_itemSeachNum = 1;
                       
                        for(var i = 1; i < $dataItems.length; i++){
                                if($gameParty.numItems($dataItems) > $gameParty.maxItems($dataItems)){
                                        $gameParty.loseItem($dataItems, $gameParty.numItems($dataItems))
                                        $gameParty.gainItem($dataItems, parseInt($gameParty.maxItems($dataItems)))
                                }
                               
                                if(villaA_itemIdMaxArray[villaA_itemIdMaxArray.length-1][0] == 0){
                                        if($gameParty.numItems($dataItems) > villaA_itemIdMaxArray[villaA_itemIdMaxArray.length-1][1]){
                                                $gameParty.loseItem($dataItems, $gameParty.numItems($dataItems))
                                                $gameParty.gainItem($dataItems, parseInt($gameParty.maxItems($dataItems)))
                                        }
                                }
                        }
                }
        }
       
        var _Game_Party_gainItem = Game_Party.prototype.gainItem;
        Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
                _Game_Party_gainItem.call(this, item, amount, includeEquip);
                for(var i = 1; i < $dataItems.length; i++){
                        if(villaA_itemSeachNum < String(this.maxItems($dataItems)).length){
                                villaA_itemSeachNum = String(this.maxItems($dataItems)).length;
                        }
                }
                villaA_itemMaxNum = villaA_itemSeachNum;
                villaA_itemSeachNum = 1;
        };

        Game_Party.prototype.maxItems = function(item) {
                for(var i = 0; i < villaA_itemIdMaxArray.length; i++){
                        if(villaA_itemIdMaxArray[0] == item.id){
                                return villaA_itemIdMaxArray[1]
                        }
                }
               
                if(item.note != ""){
                        var itemNoteArray = []
                        itemNoteArray = item.note.split(/\r\n|\r|\n/);
                       
                        for(var i = 0 ; i < itemNoteArray.length; i++){
                                if(itemNoteArray.indexOf('itemMaxNum') != -1){
                                        var MaxNum = itemNoteArray.split(":");
                                        return parseInt(MaxNum[1]);
                                }
                        }
                }
               
                for(var i = 0; i < villaA_itemIdMaxArray.length; i++){
                        if(villaA_itemIdMaxArray[0] == 0){
                                return villaA_itemIdMaxArray[1]
                        }
                }
               
                return 99;
        };
       
        Window_ItemList.prototype.drawItem = function(index) {
                var item = this._data[index];
                if (item) {
                        var textWid1 = "0";
                        var textWid2 = "";
                        for(var i = 1; i <= villaA_itemMaxNum; i++){
                                textWid1 += 0;
                                textWid2 += 0;
                        }
               
                        var numberWidth = this.numberWidth(textWid1);
                        var rect = this.itemRect(index);
                        rect.width -= this.textPadding();
                        this.changePaintOpacity(this.isEnabled(item));
                        this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
                        this.drawItemNumber(item, rect.x, rect.y, rect.width, textWid2);
                        this.changePaintOpacity(1);
                }
        };

        Window_ItemList.prototype.numberWidth = function(textWid) {
                return this.textWidth(textWid);
        };

        Window_ItemList.prototype.drawItemNumber = function(item, x, y, width, textWid) {
                if (this.needsNumber()) {
                        this.drawText(':', x, y, width - this.textWidth(textWid), 'right');
                        this.drawText($gameParty.numItems(item), x, y, width, 'right');
                }
        };
})();[/pre]




* @plugindesc アイテムの最大所持個数をアイテムIdごとに指定できます。
* @author 村人A
*
* @help
*
*  アイテムのメモ欄に「itemMaxNum:個数」と入力することによりそのアイテムのデフォルトの最大所持数を設定することが出来ます。
*  コマンド例
*  itemMaxNum:1010  #入力したアイテムの最大所持数を1010個に設定
*
*  アイテムの所持上限数をゲーム中に変更したい場合は「アイテム上限設定変更」とプラグインコマンドを入力後、指定したいアイテムidと最大所持数を入力
*  別のアイテムも変更したい場合続けて入力してください
*  デフォルトの最大所持数(99個)を変更したい場合はidを0と入力し、その後に個数を指定してください。
*
* プラグインコマンド例:
*   アイテム上限設定変更 3 35
*   #アイテムidが3のアイテムの最大所持数を35個に設定
*   アイテム上限設定変更 1 20 4 8 7 15 9 100 0 200
*   #idが1のアイテムの最大個数を20個に、idが4のアイテムの最大個数を8個に以下、7を15、9を100、デフォルトの最大個数を200個に変更
*
*  変更したときにアイテムの所持数が指定した最大所持数より多かった場合、自動的に最大所数に直されます。
*
*  値の優先度としては
*  プラグインコマンドによる変更 > データベースでの指定 > 変更したデフォルトの最大個数 > デフォルトの最大個数(99個)
*  となります。

点评

可指定個別道具所持上限,亦可在遊戯中改変上限  发表于 2017-5-10 22:47
这只是变更最大数的功能吗?怎么这么长!  发表于 2017-5-10 21:00

评分

参与人数 1星屑 +10 收起 理由
小小小蚩尤 + 10 精品文章

查看全部评分

回复

使用道具 举报

梦石
0
星屑
34460
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2017-5-10 22:03:58 | 显示全部楼层
本帖最后由 芯☆淡茹水 于 2017-5-10 22:13 编辑

这个是现写的,已经测试。

相同的物品可以随时改变最大持有数。比如游戏前期改变道具1的最大持有数为10,游戏后期可以改变为100.
物品最大持有数改变后,物品的当前持有数不会改变。比如有 50把1号武器,把1号武器最大持有数改为20时,1号武器仍然拥有50把。
但在数量少于20时,再得到的话,不会超过20.

  1. //===============================================================================
  2. //===============================================================================
  3. /*:
  4. * @plugindesc  更改物品最大持有数量。
  5. *
  6. * @author 芯☆淡茹水
  7. *
  8. * @help ____________________________________________________________________
  9. * 初始物品最大数没有变化,都是 99,需要在游戏中用插件命令添加最大数。
  10. *
  11. * 插件命令格式: Add_MaxNum 类型 ID 最大数量
  12. * 其中     类型:道具写 item    武器写 weapon     防具写 armor
  13. *             ID    : 限制最大数所对应的道具/武器/防具的ID
  14. *  最大数量:该物品能持有的最大数量。
  15. *
  16. *举例:改变2号道具最大持有数为 10   :   Add_MaxNum item 2 10
  17. *          改变5号武器最大持有数为 555  :   Add_MaxNum weapon 5 555
  18. *          改变12号防具最大持有数为 110 :   Add_MaxNum armor 12 110
  19. */
  20. //==============================================================
  21. var XdrsCMIGinPluginCommand = Game_Interpreter.prototype.pluginCommand;
  22. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  23.     XdrsCMIGinPluginCommand.call(this, command, args);
  24.     if (command === 'Add_MaxNum') {
  25.        var type = args[0], id = parseInt(args[1]), num = parseInt(args[2]);
  26.        $gameParty.addNumData([type,id,num]);
  27.     }
  28. };
  29. //===============================================================
  30. var xdrsCMIGamePartyInitialize = Game_Party.prototype.initialize;
  31. Game_Party.prototype.initialize = function() {
  32.     xdrsCMIGamePartyInitialize.call(this);
  33.     this._maxNumData = {'item':{}, 'weapon':{},'armor':{}};
  34. };
  35. Game_Party.prototype.addNumData = function(data) {
  36.     data[2] = Math.max(data[2], 1);
  37.     this._maxNumData[data[0]][data[1]] = data[2];
  38. };
  39. Game_Party.prototype.maxNumData = function(item) {
  40.     switch (true) {
  41.     case DataManager.isItem(item)  :return this._maxNumData['item'];
  42.     case DataManager.isWeapon(item):return this._maxNumData['weapon'];
  43.     case DataManager.isArmor(item) :return this._maxNumData['armor'];
  44.     }
  45. };
  46. Game_Party.prototype.maxItems = function(item) {
  47.     return item.id in this.maxNumData(item) ? this.maxNumData(item)[item.id] : 99;
  48. };
  49. //===============================================================
复制代码


评分

参与人数 2星屑 +20 收起 理由
白嫩白嫩的 + 10 认可答案
小小小蚩尤 + 10 精品文章

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 3 0

使用道具 举报

梦石
0
星屑
2773
在线时间
675 小时
注册时间
2012-1-29
回帖
61
 楼主| 发表于 2017-5-10 22:50:15 | 显示全部楼层
芯☆淡茹水 发表于 2017-5-10 22:03
这个是现写的,已经测试。

相同的物品可以随时改变最大持有数。比如游戏前期改变道具1的最大持有数为10, ...

谢谢了
回复

使用道具 举报

梦石
0
星屑
2773
在线时间
675 小时
注册时间
2012-1-29
回帖
61
 楼主| 发表于 2017-5-10 22:50:35 | 显示全部楼层
tseyik 发表于 2017-5-10 20:33
http://space6718.lolipop.jp/script/setItemMax.js

[fold=setItemMax.js]/*:ja

谢谢了啊啊
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部