设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 69|回复: 0

[转载发布] Max Items v1.2

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Introduction
    Allows for more control over the maximum number of items that may be carried, as well as displaying information about them in the inventory.

    Features

    • Control the maximum number of items that may be carried. Can use evals/code, allowing for the maximum to be changed mid-game.
    • Customise how the information is displayed in the inventory/item scene.
    • Change the colours of the numbers dynamically.
    How to use
    Adjust the parameters as you see fit.
    Most of the parameters should be self-explanatory, but there's a few that probably warrant some extra explanation.

    Override_drawItemNumber:
    By default, in RMMV, the quantity of items is displayed as follows:
    (Item Name)          :xx
    where the position of the ':' is fixed, regardless of the number of digits in the quantity.
    This may result in overlapping with the ':' if the quantity owned is 3 or more digits long.
    To avoid this, this plugin provides an option to override the default drawItemNumber function with a customisable one.
    This is required for any customisation of the item number.

    PrefixPositionMode:
    This allows you to choose how the position of the prefix is determined.
    Automatic - Prefix is automatically placed behind the number.
    Manual - Prefix location is manually set.

    Notetags
    The following notetags are available for items, weapons, and armours:
    1. <max:x>
    复制代码
    Specifies the maximum carrying quantity of that item. x must be a value greater than 0.
    1. <maxeval>
    复制代码
    1. //code
    复制代码
    1. </maxeval>
    复制代码
    Evaluates code to determine the maximum carrying quantity of that item.
    Must return a value greater than 0.
    1. <showitemmax>
    复制代码
    1. <hideitemmax>
    复制代码
    Overrides the default setting and shows or hides the max carrying quantity.
    1. <hidenumberprefix>
    复制代码
    Hides the prefix for the item number.
    1. <hidenumber>
    复制代码
    Hides the number. Nothing will be drawn.
    1. <numbercolour>
    复制代码
    1. //code
    复制代码
    1. </numbercolour>
    复制代码
    Overrides the default setting and evaluates code to determine the number colour.

    Script
    Spoiler: CODE
                    JavaScript:       
    1. //==========================================
    2. // APHO_MaxItems.js
    3. //==========================================
    4. /*:
    5. * @title Max Items
    6. * @author Apho
    7. * @plugindesc v1.1 Allows for more control over the maximum number of items that may be carried, as well as displaying information about them in the inventory.
    8. *
    9. * @param DefaultMax
    10. * @text Default Max.
    11. * @type string
    12. * @desc Default maximum carrying quantity. This is an eval.
    13. * @default 99
    14. *
    15. * @param Override_drawItemNumber
    16. * @text Override drawItemNumber?
    17. * @type boolean
    18. * @desc Override the default drawItemNumber function and use a custom one?
    19. * @default true
    20. *
    21. * @param ItemNumberPrefix
    22. * @parent Override_drawItemNumber
    23. * @text Item Number Prefix
    24. * @type string
    25. * @desc Stuff shown before the number of items owned.
    26. * @default :
    27. *
    28. * @param PrefixPositionMode
    29. * @parent ItemNumberPrefix
    30. * @text Prefix Position Mode
    31. * @type select
    32. * @option Automatic
    33. * @value 0
    34. * @option Manual
    35. * @value 1
    36. * @desc Positioning of the prefix.
    37. * @default 0
    38. *
    39. * @param PrefixPosition
    40. * @parent ItemNumberPrefix
    41. * @text Prefix Position
    42. * @desc Prefix is fixed at this location. (Manual mode only)
    43. * @type string
    44. * @default width - this.textWidth('00')
    45. *
    46. * @param DrawItemMax
    47. * @parent Override_drawItemNumber
    48. * @text Draw Item Max?
    49. * @desc Append the max carrying quantity to the owned quantity in the inventory by default?
    50. * @type boolean
    51. * @default false
    52. *
    53. * @param DrawItemMaxPrefix
    54. * @parent DrawItemMax
    55. * @text Draw Item Max Prefix
    56. * @desc Stuff to show before the max carrying quantity.
    57. * @type string
    58. * @default /
    59. *
    60. * @param DrawItemMaxSuffix
    61. * @parent DrawItemMax
    62. * @text Draw Item Max Suffix
    63. * @desc Stuff to show after the max carrying quantity.
    64. * @type string
    65. * @default
    66. *
    67. * @param DrawItemMax_AutoHidePrefix
    68. * @parent DrawItemMax
    69. * @text Auto Hide Number Prefix
    70. * @desc Automatically hide the number prefix whenever max carrying quantity is drawn?
    71. * @type boolean
    72. * @default true
    73. *
    74. * @param ItemNumberColour
    75. * @parent Override_drawItemNumber
    76. * @text Item Number Colour
    77. * @desc Colour of the item number. This is an eval.
    78. * @type string
    79. * @default $gameParty.numItems(item) >= $gameParty.maxItems(item) ? "#FF0000" : "#FFFFFF"
    80. *
    81. * @param HighNumberOverride
    82. * @parent Override_drawItemNumber
    83. * @text High Number Override
    84. * @desc Override the item number with a string upon exceeding specified value?
    85. * @type boolean
    86. * @default false
    87. *
    88. * @param HighNumberOverrideThreshold
    89. * @parent HighNumberOverride
    90. * @text High Number Override Threshold
    91. * @desc The item number will be replaced if it exceeds this value.
    92. * @type number
    93. * @default 99
    94. *
    95. * @param HighNumberOverrideString
    96. * @parent HighNumberOverride
    97. * @text High Number Override
    98. * @desc String that will replace the item number upon exceeding the threshold.
    99. * @type string
    100. * @default 99+
    101. *
    102. * @param HighNumberOverride_AutoHidePrefix
    103. * @parent HighNumberOverride
    104. * @text Auto Hide Number Prefix
    105. * @desc Automatically hide the number prefix for high numbers?
    106. * @type boolean
    107. * @default false
    108. *
    109. * @param NumberWidth
    110. * @text Number Width
    111. * @desc Amount of space that should be reserved for the item number. Leave blank for default.
    112. * @type string
    113. * @default this.textWidth('000')
    114. *
    115. * @help
    116. * Allows for more control over the maximum number of items that may be carried.
    117. * You may also customise how that information will be displayed to the player.
    118. *
    119. * PLUGIN PARAMETERS
    120. * Most of the parameters should be self-explanatory, but there's a few that
    121. * probably warrant some extra explanation.
    122. * Override_drawItemNumber:
    123. * By default, in RMMV, the quantity of items is displayed as follows:
    124. * (Item Name)          :xx
    125. * where the position of the ':' is fixed, regardless of the number of digits
    126. * in the quantity.
    127. * This may result in overlapping with the ':' if the quantity owned is 3 or
    128. * more digits long.
    129. * To avoid this, this plugin provides an option to override the default
    130. * drawItemNumber function with a customisable one.
    131. * This is required for any customisation of the item number.
    132. *
    133. * PrefixPositionMode:
    134. * This allows you to choose how the position of the prefix is determined.
    135. * Automatic - Prefix is automatically placed behind the number.
    136. * Manual - Prefix location is manually set.
    137. *
    138. * NOTETAGS
    139. * The following notetags are available for items, weapons, and armours:
    140. * <max:x>
    141. * Specifies the maximum carrying quantity of that item. x must be a value
    142. * greater than 0.
    143. *
    144. * <maxeval>
    145. * //code
    146. * </maxeval>
    147. * Evaluates code to determine the maximum carrying quantity of that item.
    148. * Must return a value greater than 0.
    149. *
    150. * <showitemmax>
    151. * <hideitemmax>
    152. * Overrides the default setting and shows or hides the max carrying quantity.
    153. *
    154. * <hidenumberprefix>
    155. * Hides the prefix for the item number.
    156. *
    157. * <hidenumber>
    158. * Hides the number. Nothing will be drawn.
    159. *
    160. * <numbercolour>
    161. * //code
    162. * </numbercolour>
    163. * Overrides the default setting and evaluates code to determine the number
    164. * colour.
    165. *
    166. * NOTES
    167. * - When using a formula to determine maximum carrying quantity, if the value is
    168. *   reduced mid-game and the player had more than they can carry, the player
    169. *   does not lose the excess; however they will be unable to obtain more.
    170. * - If a max quantity has not been specified, and the default formula in this
    171. *   plugin evaluates to 0 or undefined, RMMV's original default applies.
    172. *   (99, may be changed by other plugins)  
    173. * - If you are using YEP_CoreEngine, or any plugin that changes the default
    174. *   item limit, place this plugin below them in the plugin manager.
    175. *
    176. * TERMS OF USE
    177. * - Free for commercial and non-commercial use, as long as I get a free copy
    178. *   of the game.
    179. * - Edits allowed for personal use.
    180. * - Do not repost or claim as your own, even if edited.
    181. *
    182. * VERSION HISTORY
    183. * v1.2 - 2023/10/18 - Bugfix for crashing during battle test when using the <max> notetag.
    184. * v1.1 - 2023/09/25 - Bugfix for crashing when checking an item that does not exist.
    185. * v1.0 - 2023/09/08 - Initial release.
    186. */
    187. (function(){
    188.     var parameters = PluginManager.parameters('APHO_MaxItems');
    189.     CheckMaxEval = function(notetag, item)
    190.     {
    191.         const MaxEvalOpen = '<maxeval>';
    192.         const MaxEvalClose = '</maxeval>';
    193.         let ReadMaxEval = false;
    194.         let MaxEvalInfo = "";
    195.         for (var n = 0; n < notetag.length; n++)
    196.         {
    197.             let NoteData = notetag.split(/[\r\n]+/);
    198.             let line = NoteData[n];
    199.             if (line && line.match(MaxEvalOpen))
    200.             {
    201.                 ReadMaxEval = true;
    202.             }
    203.             else if (line && line.match(MaxEvalClose))
    204.             {
    205.                 ReadMaxEval = false;
    206.             }
    207.             else if (ReadMaxEval == true)
    208.             {
    209.                 MaxEvalInfo += line + '\n';
    210.             }
    211.         }
    212.         return eval(MaxEvalInfo)
    213.     };
    214.     const Game_Party_maxItems = Game_Party.prototype.maxItems;
    215.     Game_Party.prototype.maxItems = function(item) {
    216.         if(item)
    217.         {
    218.             if(CheckMaxEval(item.note, item) && CheckMaxEval(item.note, item) > 0)
    219.             {
    220.                 return CheckMaxEval(item.note, item);
    221.             }
    222.             else if(item.meta.max)
    223.             {
    224.                 return parseInt(item.meta.max);
    225.             }
    226.         }
    227.         return Function("return " + parameters['DefaultMax'])() || Game_Party_maxItems.call(this, item);
    228.     }
    229.     const Game_Party_gainItem = Game_Party.prototype.gainItem;
    230.     Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
    231.         if($gameParty.numItems(item) <= this.maxItems(item))
    232.         {
    233.             Game_Party_gainItem.call(this, item, amount, includeEquip);
    234.         }
    235.         else
    236.         {
    237.             var container = this.itemContainer(item);
    238.             if (container) {
    239.                 var lastNumber = this.numItems(item);
    240.                 var newNumber = lastNumber + amount;
    241.                 container[item.id] = newNumber.clamp(0, $gameParty.numItems(item));
    242.                 if (container[item.id] === 0) {
    243.                     delete container[item.id];
    244.                 }
    245.                 if (includeEquip && newNumber < 0) {
    246.                     this.discardMembersEquip(item, -newNumber);
    247.                 }
    248.                 $gameMap.requestRefresh();
    249.             }
    250.         }
    251.     };
    252.     var Override_drawItemNumber = JSON.parse(parameters['Override_drawItemNumber']);
    253.     if(Override_drawItemNumber)
    254.     {
    255.         CheckColourEval = function(notetag, item)
    256.         {
    257.             const ColourEvalOpen = '<numbercolour>';
    258.             const ColourEvalClose = '</numbercolour>';
    259.             let ReadColourEval = false;
    260.             let ColourEvalInfo = "";
    261.             for (var n = 0; n < notetag.length; n++)
    262.             {
    263.                 let NoteData = notetag.split(/[\r\n]+/);
    264.                 let line = NoteData[n];
    265.                 if (line && line.match(ColourEvalOpen))
    266.                 {
    267.                     ReadColourEval = true;
    268.                 }
    269.                 else if (line && line.match(ColourEvalClose))
    270.                 {
    271.                     ReadColourEval = false;
    272.                 }
    273.                 else if (ReadColourEval == true)
    274.                 {
    275.                     ColourEvalInfo += line + '\n';
    276.                 }
    277.             }
    278.             return eval(ColourEvalInfo)
    279.         };
    280.         var ItemNumberPrefix = String(parameters['ItemNumberPrefix']);
    281.         var PrefixPositionMode = parseInt(parameters['PrefixPositionMode']);
    282.         var DrawItemMax = JSON.parse(parameters['DrawItemMax']);
    283.         var DrawItemMaxPrefix = String(parameters['DrawItemMaxPrefix']);
    284.         var DrawItemMaxSuffix = String(parameters['DrawItemMaxSuffix']);
    285.         var DrawItemMax_AutoHidePrefix = JSON.parse(parameters['DrawItemMax_AutoHidePrefix']);
    286.         var HighNumberOverride = JSON.parse(parameters['HighNumberOverride']);
    287.         var HighNumberOverrideThreshold = parseInt(parameters['HighNumberOverrideThreshold']);
    288.         var HighNumberOverrideString = String(parameters['HighNumberOverrideString']);
    289.         var HighNumberOverride_AutoHidePrefix = JSON.parse(parameters['HighNumberOverride_AutoHidePrefix']);
    290.         Window_ItemList.prototype.drawItemNumber = function(item, x, y, width) {
    291.             if(item.meta.numbercolour)
    292.             {
    293.                 this.changeTextColor(CheckColourEval(item.note, item));
    294.             }
    295.             else
    296.             {
    297.                 this.changeTextColor(eval(parameters['ItemNumberColour']));
    298.             }
    299.             if (this.needsNumber() && !item.meta.hidenumber) {
    300.                 let TextToDraw = $gameParty.numItems(item);
    301.                 let NeedsDrawItemMax = (DrawItemMax || item.meta.showitemmax) && !item.meta.hideitemmax;
    302.                 let NeedsNumPrefix = !item.meta.hidenumberprefix
    303.                 if(HighNumberOverride && $gameParty.numItems(item) > HighNumberOverrideThreshold)
    304.                 {
    305.                     TextToDraw = HighNumberOverrideString;
    306.                     if(NeedsNumPrefix && HighNumberOverride_AutoHidePrefix)
    307.                     {
    308.                         NeedsNumPrefix = false;
    309.                     }
    310.                 }
    311.                 if(NeedsNumPrefix && DrawItemMax_AutoHidePrefix && NeedsDrawItemMax)
    312.                 {
    313.                     NeedsNumPrefix = false;
    314.                 }
    315.                 if(NeedsNumPrefix)
    316.                 {
    317.                     switch(PrefixPositionMode)
    318.                     {
    319.                         case 0:
    320.                             TextToDraw = ItemNumberPrefix + TextToDraw;
    321.                         break;
    322.                         case 1:
    323.                             this.drawText(ItemNumberPrefix, x, y, eval(parameters['PrefixPosition']), 'right');
    324.                         break;
    325.                     }
    326.                 }
    327.                 if(NeedsDrawItemMax)
    328.                 {
    329.                     TextToDraw = TextToDraw + DrawItemMaxPrefix + $gameParty.maxItems(item) + DrawItemMaxSuffix;
    330.                 }
    331.                 this.drawText(TextToDraw, x, y, width, 'right');
    332.             }
    333.         };
    334.     }
    335.     const Window_ItemList_numberWidth = Window_ItemList.prototype.numberWidth;
    336.     var NumberWidth = parameters['NumberWidth'];
    337.     Window_ItemList.prototype.numberWidth = function() {
    338.         if(NumberWidth)
    339.         {
    340.             return eval(NumberWidth)
    341.         }
    342.         else
    343.         {
    344.             return Window_ItemList_numberWidth.call(this);
    345.         }
    346.     };
    347. })();
    复制代码


    Notes

    • When using a formula to determine maximum carrying quantity, if the value is reduced mid-game and the player had more than they can carry, the player does not lose the excess; however they will be unable to obtain more.
    • If a max quantity has not been specified, and the default formula in this plugin evaluates to 0 or undefined, RMMV's original default applies. (99, may be changed by other plugins)
    • If you are using YEP_CoreEngine, or any plugin that changes the default item limit, place this plugin below them in the plugin manager.
    Terms of use

    • Free for commercial and non-commercial use, as long as I get a free copy of the game.
    • Edits allowed for personal use.
    • Do not repost or claim as your own, even if edited.
    • Do not use for training AI models. This includes, but is not limited to, inputting the plugin contents or part thereof into AI models that train on user input.
    Version history
    v1.2 - 2023/10/18 - Bugfix for crashing during battle test when using the <max> notetag.
    v1.1 - 2023/09/25 - Bugfix for crashing when checking an item that does not exist.
    v1.0 - 2023/09/08 - Initial release.

    Download link
    GitHub

    Spoiler: SCREENSHOT




    本贴来自国际rpgmaker官方论坛作者:AphoticAmaranth处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/max-items-v1-2.161017/

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 03:40 , Processed in 0.139931 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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