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

Project1

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

[有事请教] 用限制物品插件,物品栏显示正常,战...

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1433
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
跳转到指定楼层
1
发表于 2019-2-27 14:51:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 黑舞嗜 于 2019-2-28 16:08 编辑

找到一个YEP的Item Requirements插件,想用来限制蓝量不足的时候无法使用道具
然后使用下面这个备注蓝量不够时物品栏显示正常(灰色无法使用),但战斗中物品栏直接就看不见了
<Custom Enable Requirement>
condition = battler.mp >= 100;
</Custom Enable Requirement>
,求大神指导
当然有其他的插件也可以

说明和插件:https://www.jianshu.com/p/6a396b895654
JAVASCRIPT 代码复制
  1. YEP.136Item Requirements – RPG Maker MV
  2. Introduction
  3. This plugin requires YEP_ItemCore. Make sure this plugin is located under YEP_ItemCore in the plugin list.
  4. 这个插件需要 YEP_ItemCore.确保这个插件在 YEP_ItemCore列表下面
  5. In RPG Maker MV, items only have a few restrictions on them by default, whether or not they can be used in or out of battle or never. There aren’t any other conditions that you can set that would otherwise determine if an item can or cannot be used. This plugin gives more ways to restrict item usage based on switches, variables, the actors using them, classes, state requirements, and more.
  6. 在RMMV里面,物品通常只有简单的限制来决定它们是否可以在战斗中使用,并没有其他可以自定义的情况来决定它们。因此,这个插件会提供给你物品使用的更多限制,例如开关、变量、职业等等
  7. Notetags
  8. Use the following notetags to enforce requirements for items before they can be used.
  9. 使用下面的备注栏来设置物品能否使用
  10. Item Notetags:
  11. <Enable Requirements>
  12. condition
  13. condition
  14. </Enable Requirements>
  15.  
  16. – Replace ‘condition’ with the desired condition setup. You can insert any number of conditions inside the notetags. All of the conditions must be met before the item can be used. Look below for a list of the possible conditions that can be used.
  17. 你只需要设置condition为你需要的限制条件即可,下面是限制条件可使用的命令列表
  18. Conditions:
  19. Eval: code
  20. – Replace ‘code’ with JavaScript code that you’d like to run a check against to enable the item. If the check returns false, the item will be disabled regardless of other conditions.
  21. 设置某变量是否和指定数值或文本相同
  22. Examples:
  23. Eval: $gameActors.actor(1).name() === ‘Harold’
  24. Eval: $gameActors.leader().name() !== ‘Ralph’
  25.  
  26. Actor: x
  27. Actor: x, x, x
  28. – Requires actor(s) ID ‘x’ to use the item. If the actor isn’t the one using the said item, then the item is disabled and cannot be used regardless of other conditions.
  29. 设置可以使用的角色
  30. Not Actor: x
  31. Not Actor: x, x, x
  32. – Requires the actor using the item to NOT be actor ID ‘x’. If the actor’s ID matches one of the listed ‘x’, then the item is disabled and cannot be used regardless of other conditions.
  33. 设置不可以使用的角色
  34. Examples:
  35. Actor: 1
  36. Actor: 2, 3, 4, 5, 6
  37. Not Actor: 7
  38. Not Actor: 8, 9, 10
  39.  
  40. Armor: x
  41. Armor: x, x, x
  42. – Requires the actor to specifically have armor ID ‘x’ equipped to use the item. If multiple ‘x’ are used, the actor can have any of them equipped. If the actor does not have armor ‘x’ equipped, then the item is disabled and cannot be used regardless of other conditions.
  43. 装备指定护甲时可以使用
  44. Not Armor: x
  45. Not Armor: x, x, x
  46. – Requires the actor to not have armor ID ‘x’ equipped to use the item. If multiple ‘x’ are used, the actor cannot have any of them equipped. If the actor does have armor ‘x’ equipped, then the item is disabled and cannot be used regardless of other conditions.
  47. 装备指定护甲时不可以使用
  48. Examples:
  49. Armor: 1
  50. Armor: 2, 3, 4, 5, 6
  51. Not Armor: 7
  52. Not Armor: 8, 9, 10
  53.  
  54. Class: x
  55. Class: x, x, x
  56. – Requires class(es) ID ‘x’ to use the item. If the actor’s class doesn’t match the item requirement, then the item is disabled and cannot be used regardless of other conditions.
  57. 指定职业可以使用
  58. Not Class: x
  59. Not Class: x, x, x
  60. – Requires the actor using the item to NOT be class ID ‘x’. If the actor’s class ID matches one of the listed ‘x’, then the item is disabled and cannot be used regardless of other conditions.
  61. 指定职业不可以使用
  62. Examples:
  63. Class: 1
  64. Class: 2, 3, 4, 5, 6
  65. Not Class: 7
  66. Not Class: 8, 9, 10
  67.  
  68. Subclass: x
  69. Subclass: x, x, x
  70. – Requires YEP_X_Subclass.js
  71. – Requires subclass(es) ID ‘x’ to use the item. If the actor’s class doesn’t match the item requirement, then the item is disabled and cannot be used regardless of other conditions.
  72. 需要YEP_X_Subclass插件支持
  73. 指定副职业可以使用
  74. Not Subclass: x
  75. Not Subclass: x, x, x
  76. – Requires YEP_X_Subclass.js
  77. – Requires the actor using the item to NOT be subclass ID ‘x’. If the actor’s subclass ID matches one of the listed ‘x’, then the item is disabled and cannot be used regardless of other conditions.
  78. 需要YEP_X_Subclass插件支持
  79. 指定副职业不可以使用
  80. Examples:
  81. Subclass: 1
  82. Subclass: 2, 3, 4, 5, 6
  83. Not Subclass: 7
  84. Not Subclass: 8, 9, 10
  85.  
  86. Either Class: x
  87. Either Class: x, x, x
  88. – Requires YEP_X_Subclass.js
  89. – The actor’s primary class or subclass ID has to match ‘x’. If at least one of them match, then the condition passes. Otherwise, the condition fails and the item is disabled and cannot be used regardless of other conditions.
  90. 需要YEP_X_Subclass插件支持
  91. 主职业或副职业满足一个即可使用
  92. Neither Class: x
  93. Neither Class: x, x, x
  94. – Requires YEP_X_Subclass.js
  95. – Requires YEP_X_Subclass.js
  96. – The actor’s primary class or subclass ID has to NOT match ‘x’. If at least one of them match, then the condition fails and the item is disabled and cannot be used regardless of other conditions.
  97. 需要YEP_X_Subclass插件支持
  98. 主职业或副职业都不满足才可使用
  99. Examples:
  100. Either Class: 1
  101. Either Class: 2, 3, 4, 5, 6
  102. Neither Class: 7
  103. Neither Class: 8, 9, 10
  104.  
  105. State: x
  106. State: x, x, x
  107. – Requires the actor using the item to be affected by state ‘x’. If multiple ‘x’ are used, the actor can be affected by any of them. If the actor is not affected by state ‘x’, then the condition fails and the item is disabled and cannot be used regardless of other conditions.
  108. 存在指定状态时可以使用
  109. Not State: x
  110. Not State: x, x, x
  111. – Requires the actor using the item to be not affected by state ‘x’. If multiple ‘x’ are used, the actor cannot be affected by any of them. If the actor is not affected by state ‘x’, then the condition fails and the item is disabled and cannot be used regardless of other conditions.
  112. 存在指定状态时不可以使用
  113. Examples:
  114. State: 10
  115. State: 11, 12, 13, 14, 15
  116. Not State: 16
  117. Not Stage: 17, 18, 19, 20
  118.  
  119. Switch Off: x
  120. Switch Off: x, x, x
  121. – Requires switch(es) x to be OFF before the item can be used. If the switch is ON, then the item is disabled and cannot be used regardless of other conditions.
  122. 指定开关关闭时才可以使用
  123. Examples:
  124. Switch Off: 1
  125. Switch Off: 2, 3, 4, 5, 6
  126.  
  127. Switch On: x
  128. Switch On: x, x, x
  129. – Requires switch(es) x to be ON before the item can be used. If the switch is OFF, then the item is disabled and cannot be used regardless of other conditions.
  130. 指定开关关闭时才可以使用
  131. Examples:
  132. Switch On: 1
  133. Switch On: 2, 3, 4, 5, 6
  134.  
  135. Variable x eval
  136. – Makes a check against variable x. Replace ‘x’ with an integer value and ‘evalwith the code check you wish to run it against.
  137. 指定变量满足条件是可以使用
  138. Examples:
  139. Variable 1 >= 5
  140. Variable 2 < 6
  141. Variable 3 === 7
  142. Variable 4 !== 8
  143.  
  144. Weapon: x
  145. Weapon: x, x, x
  146. – Requires the actor to specifically have weapon ID ‘x’ equipped to use the item. If multiple ‘x’ are used, the actor can have any of them equipped. If the actor does not have weapon ‘x’ equipped, then the item is disabled and cannot be used regardless of other conditions.
  147. 装备指定武器时可以使用
  148. Not Weapon: x
  149. Not Weapon: x, x, x
  150. – Requires the actor to not have weapon ID ‘x’ equipped to use the item. If multiple ‘x’ are used, the actor cannot have any of them equipped. If the actor does have weapon ‘x’ equipped, then the item is disabled and cannot be used regardless of other conditions.
  151. 装备指定武器时不可以使用
  152. Examples:
  153. Weapon: 1
  154. Weapon: 2, 3, 4, 5, 6
  155. Not Weapon: 7
  156. Not Weapon: 8, 9, 10
  157.  
  158. Weapon Type: x
  159. Weapon Type: x, x, x
  160. – Requires the actor to have weapon type ‘x’ equipped. If multiple ‘x’ are used, the actor can have any of the ‘x’ weapon types equipped. If the actor does not have the matching weapon types, then the item is disabled and cannot be used regardless of other conditions.
  161. 装备指定武器类型时可以使用
  162. Not Weapon Type: x
  163. Not Weapon Type: x, x, x
  164. – Requires the actor to not have weapon type ‘x’ equipped. If multiple ‘x’ are used, the actor cannot have any of the ‘x’ weapon types equipped. If the actor does have the matching weapon types, then the item is disabled and cannot be used regardless of other conditions.
  165. 装备指定武器类型时不可以使用
  166. Examples:
  167. Weapon Type: 1
  168. Weapon Type: 2, 3, 4, 5, 6
  169. Not Weapon Type: 7
  170. Not Weapon Type: 8, 9, 10
  171.  
  172. Lunatic Mode – Custom Enable Requirements
  173. For those with JavaScript experience, you can create your own custom requirements for whether or not items can be used using the following notetag setup:
  174. 对于熟练使用JS语言的人,你可以编程实现自己的需求
  175. Item Notetags:
  176. <Custom Enable Requirement>
  177. condition = battler.level >= item.price;
  178. </Custom Enable Requirement>
  179.  
  180. – The ‘condition’ variable will determine whether or not the item will be enabled/disabled. If the ‘condition’ variable returns true, then the item is enabled provided all other conditions (if any) are also met. Otherwise, the item is disabled and cannot be used. The ‘battler’ variable will refer to the battler using the item. Theitem’ variable will refer to the item being checked.
  181.  
  182. 作者:沧笙
  183. 链接:[url]https://www.jianshu.com/p/6a396b895654[/url]
  184. 来源:简书
  185. 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。


JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // Yanfly Engine Plugins - Item Core Extension - Item Requirements
  3. // YEP_X_ItemRequirements.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.YEP_X_ItemRequirements = true;
  8.  
  9. var Yanfly = Yanfly || {};
  10. Yanfly.ItemReq = Yanfly.ItemReq || {};
  11. Yanfly.ItemReq.version = 1.01;
  12.  
  13. //=============================================================================
  14. /*:
  15.  * @plugindesc v1.01 (Requires YEP_ItemCore.js) Place requirements on
  16.  * items before they can be used.
  17.  * @author Yanfly Engine Plugins
  18.  *
  19.  * @help
  20.  * ============================================================================
  21.  * Introduction
  22.  * ============================================================================
  23.  *
  24.  * This plugin requires YEP_ItemCore. Make sure this plugin is located under
  25.  * YEP_ItemCore in the plugin list.
  26.  *
  27.  * In RPG Maker MV, items only have a few restrictions on them by default,
  28.  * whether or not they can be used in or out of battle or never. There aren't
  29.  * any other conditions that you can set that would otherwise determine if an
  30.  * item can or cannot be used. This plugin gives more ways to restrict item
  31.  * usage based on switches, variables, the actors using them, classes, state
  32.  * requirements, and more.
  33.  *
  34.  * ============================================================================
  35.  * Notetags
  36.  * ============================================================================
  37.  *
  38.  * Use the following notetags to enforce requirements for items before they can
  39.  * be used.
  40.  *
  41.  * Item Notetags:
  42.  *
  43.  *   <Enable Requirements>
  44.  *    condition
  45.  *    condition
  46.  *   </Enable Requirements>
  47.  *   - Replace 'condition' with the desired condition setup. You can insert any
  48.  *   number of conditions inside the notetags. All of the conditions must be
  49.  *   met before the item can be used. Look below for a list of the possible
  50.  *   conditions that can be used.
  51.  *
  52.  * ---
  53.  *
  54.  * Conditions:
  55.  *
  56.  * ---
  57.  *
  58.  * Eval: code
  59.  * - Replace 'code' with JavaScript code that you'd like to run a check against
  60.  * to enable the item. If the check returns false, the item will be disabled
  61.  * regardless of other conditions.
  62.  *
  63.  * Examples:
  64.  *   Eval: $gameActors.actor(1).name() === 'Harold'
  65.  *   Eval: $gameActors.leader().name() !== 'Ralph'
  66.  *
  67.  * ---
  68.  *
  69.  * Actor: x
  70.  * Actor: x, x, x
  71.  * - Requires actor(s) ID 'x' to use the item. If the actor isn't the one using
  72.  * the said item, then the item is disabled and cannot be used regardless of
  73.  * other conditions.
  74.  *
  75.  * Not Actor: x
  76.  * Not Actor: x, x, x
  77.  * - Requires the actor using the item to NOT be actor ID 'x'. If the actor's
  78.  * ID matches one of the listed 'x', then the item is disabled and cannot be
  79.  * used regardless of other conditions.
  80.  *
  81.  * Examples:
  82.  *   Actor: 1
  83.  *   Actor: 2, 3, 4, 5, 6
  84.  *   Not Actor: 7
  85.  *   Not Actor: 8, 9, 10
  86.  *
  87.  * ---
  88.  *
  89.  * Armor: x
  90.  * Armor: x, x, x
  91.  * - Requires the actor to specifically have armor ID 'x' equipped to use the
  92.  * item. If multiple 'x' are used, the actor can have any of them equipped. If
  93.  * the actor does not have armor 'x' equipped, then the item is disabled and
  94.  * cannot be used regardless of other conditions.
  95.  *
  96.  * Not Armor: x
  97.  * Not Armor: x, x, x
  98.  * - Requires the actor to not have armor ID 'x' equipped to use the item.
  99.  * If multiple 'x' are used, the actor cannot have any of them equipped. If
  100.  * the actor does have armor 'x' equipped, then the item is disabled and
  101.  * cannot be used regardless of other conditions.
  102.  *
  103.  * Examples:
  104.  *   Armor: 1
  105.  *   Armor: 2, 3, 4, 5, 6
  106.  *   Not Armor: 7
  107.  *   Not Armor: 8, 9, 10
  108.  *
  109.  * ---
  110.  *
  111.  * Class: x
  112.  * Class: x, x, x
  113.  * - Requires class(es) ID 'x' to use the item. If the actor's class doesn't
  114.  * match the item requirement, then the item is disabled and cannot be used
  115.  * regardless of other conditions.
  116.  *
  117.  * Not Class: x
  118.  * Not Class: x, x, x
  119.  * - Requires the actor using the item to NOT be class ID 'x'. If the actor's
  120.  * class ID matches one of the listed 'x', then the item is disabled and cannot
  121.  * be used regardless of other conditions.
  122.  *
  123.  * Examples:
  124.  *   Class: 1
  125.  *   Class: 2, 3, 4, 5, 6
  126.  *   Not Class: 7
  127.  *   Not Class: 8, 9, 10
  128.  *
  129.  * ---
  130.  *
  131.  * Subclass: x
  132.  * Subclass: x, x, x
  133.  * - Requires YEP_X_Subclass.js
  134.  * - Requires subclass(es) ID 'x' to use the item. If the actor's class doesn't
  135.  * match the item requirement, then the item is disabled and cannot be used
  136.  * regardless of other conditions.
  137.  *
  138.  * Not Subclass: x
  139.  * Not Subclass: x, x, x
  140.  * - Requires YEP_X_Subclass.js
  141.  * - Requires the actor using the item to NOT be subclass ID 'x'. If the
  142.  * actor's subclass ID matches one of the listed 'x', then the item is disabled
  143.  * and cannot be used regardless of other conditions.
  144.  *
  145.  * Examples:
  146.  *   Subclass: 1
  147.  *   Subclass: 2, 3, 4, 5, 6
  148.  *   Not Subclass: 7
  149.  *   Not Subclass: 8, 9, 10
  150.  *
  151.  * ---
  152.  *
  153.  * Either Class: x
  154.  * Either Class: x, x, x
  155.  * - Requires YEP_X_Subclass.js
  156.  * - The actor's primary class or subclass ID has to match 'x'. If at least one
  157.  * of them match, then the condition passes. Otherwise, the condition fails and
  158.  * the item is disabled and cannot be used regardless of other conditions.
  159.  *
  160.  * Neither Class: x
  161.  * Neither Class: x, x, x
  162.  * - Requires YEP_X_Subclass.js
  163.  * - Requires YEP_X_Subclass.js
  164.  * - The actor's primary class or subclass ID has to NOT match 'x'. If at least
  165.  * one of them match, then the condition fails and the item is disabled and
  166.  * cannot be used regardless of other conditions.
  167.  *
  168.  * Examples:
  169.  *   Either Class: 1
  170.  *   Either Class: 2, 3, 4, 5, 6
  171.  *   Neither Class: 7
  172.  *   Neither Class: 8, 9, 10
  173.  *
  174.  * ---
  175.  *
  176.  * State: x
  177.  * State: x, x, x
  178.  * - Requires the actor using the item to be affected by state 'x'. If multiple
  179.  * 'x' are used, the actor can be affected by any of them. If the actor is not
  180.  * affected by state 'x', then the condition fails and the item is disabled
  181.  * and cannot be used regardless of other conditions.
  182.  *
  183.  * Not State: x
  184.  * Not State: x, x, x
  185.  * - Requires the actor using the item to be not affected by state 'x'. If
  186.  * multiple 'x' are used, the actor cannot be affected by any of them. If the
  187.  * actor is not affected by state 'x', then the condition fails and the item is
  188.  * disabled and cannot be used regardless of other conditions.
  189.  *
  190.  * Examples:
  191.  *   State: 10
  192.  *   State: 11, 12, 13, 14, 15
  193.  *   Not State: 16
  194.  *   Not Stage: 17, 18, 19, 20
  195.  *
  196.  * ---
  197.  *
  198.  * Switch Off: x
  199.  * Switch Off: x, x, x
  200.  * - Requires switch(es) x to be OFF before the item can be used. If the switch
  201.  * is ON, then the item is disabled and cannot be used regardless of other
  202.  * conditions.
  203.  *
  204.  * Examples:
  205.  *   Switch Off: 1
  206.  *   Switch Off: 2, 3, 4, 5, 6
  207.  *
  208.  * ---
  209.  *
  210.  * Switch On: x
  211.  * Switch On: x, x, x
  212.  * - Requires switch(es) x to be ON before the item can be used. If the switch
  213.  * is OFF, then the item is disabled and cannot be used regardless of other
  214.  * conditions.
  215.  *
  216.  * Examples:
  217.  *   Switch On: 1
  218.  *   Switch On: 2, 3, 4, 5, 6
  219.  *
  220.  * ---
  221.  *
  222.  * Variable x eval
  223.  * - Makes a check against variable x. Replace 'x' with an integer value and
  224.  * 'eval' with the code check you wish to run it against.
  225.  *
  226.  * Examples:
  227.  *   Variable 1 >= 5
  228.  *   Variable 2 < 6
  229.  *   Variable 3 === 7
  230.  *   Variable 4 !== 8
  231.  *
  232.  * ---
  233.  *
  234.  * Weapon: x
  235.  * Weapon: x, x, x
  236.  * - Requires the actor to specifically have weapon ID 'x' equipped to use the
  237.  * item. If multiple 'x' are used, the actor can have any of them equipped. If
  238.  * the actor does not have weapon 'x' equipped, then the item is disabled and
  239.  * cannot be used regardless of other conditions.
  240.  *
  241.  * Not Weapon: x
  242.  * Not Weapon: x, x, x
  243.  * - Requires the actor to not have weapon ID 'x' equipped to use the item.
  244.  * If multiple 'x' are used, the actor cannot have any of them equipped. If
  245.  * the actor does have weapon 'x' equipped, then the item is disabled and
  246.  * cannot be used regardless of other conditions.
  247.  *
  248.  * Examples:
  249.  *   Weapon: 1
  250.  *   Weapon: 2, 3, 4, 5, 6
  251.  *   Not Weapon: 7
  252.  *   Not Weapon: 8, 9, 10
  253.  *
  254.  * ---
  255.  *
  256.  * Weapon Type: x
  257.  * Weapon Type: x, x, x
  258.  * - Requires the actor to have weapon type 'x' equipped. If multiple 'x' are
  259.  * used, the actor can have any of the 'x' weapon types equipped. If the actor
  260.  * does not have the matching weapon types, then the item is disabled and
  261.  * cannot be used regardless of other conditions.
  262.  *
  263.  * Not Weapon Type: x
  264.  * Not Weapon Type: x, x, x
  265.  * - Requires the actor to not have weapon type 'x' equipped. If multiple 'x'
  266.  * are used, the actor cannot have any of the 'x' weapon types equipped. If the
  267.  * actor does have the matching weapon types, then the item is disabled and
  268.  * cannot be used regardless of other conditions.
  269.  *
  270.  * Examples:
  271.  *   Weapon Type: 1
  272.  *   Weapon Type: 2, 3, 4, 5, 6
  273.  *   Not Weapon Type: 7
  274.  *   Not Weapon Type: 8, 9, 10
  275.  *
  276.  * ============================================================================
  277.  * Lunatic Mode - Custom Enable Requirements
  278.  * ============================================================================
  279.  *
  280.  * For those with JavaScript experience, you can create your own custom
  281.  * requirements for whether or not items can be used using the following
  282.  * notetag setup:
  283.  *
  284.  * Item Notetags:
  285.  *
  286.  *   <Custom Enable Requirement>
  287.  *    condition = battler.level >= item.price;
  288.  *   </Custom Enable Requirement>
  289.  *   - The 'condition' variable will determine whether or not the item will be
  290.  *   enabled/disabled. If the 'condition' variable returns true, then the item
  291.  *   is enabled provided all other conditions (if any) are also met. Otherwise,
  292.  *   the item is disabled and cannot be used. The 'battler' variable will refer
  293.  *   to the battler using the item. The 'item' variable will refer to the item
  294.  *   being checked.
  295.  *
  296.  * ============================================================================
  297.  * Changelog
  298.  * ============================================================================
  299.  *
  300.  * Version 1.01:
  301.  * - Updated for RPG Maker MV version 1.5.0.
  302.  *
  303.  * Version 1.00:
  304.  * - Finished Plugin!
  305.  */
  306. //=============================================================================
  307.  
  308. if (Imported.YEP_ItemCore) {
  309.  
  310. //=============================================================================
  311. // DataManager
  312. //=============================================================================
  313.  
  314. Yanfly.ItemReq.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  315. DataManager.isDatabaseLoaded = function() {
  316.   if (!Yanfly.ItemReq.DataManager_isDatabaseLoaded.call(this)) return false;
  317.  
  318.   if (!Yanfly._loaded_YEP_X_ItemRequirements) {
  319.     this.processItemRequirementsNotetags1($dataItems);
  320.     Yanfly._loaded_YEP_X_ItemRequirements = true;
  321.   }
  322.  
  323.   return true;
  324. };
  325.  
  326. DataManager.processItemRequirementsNotetags1 = function(group) {
  327.   for (var n = 1; n < group.length; n++) {
  328.     var obj = group[n];
  329.     var notedata = obj.note.split(/[\r\n]+/);
  330.  
  331.     obj.itemRequirements = [];
  332.     var evalMode = 'none';
  333.     obj.customItemRequirements = '';
  334.  
  335.     for (var i = 0; i < notedata.length; i++) {
  336.       var line = notedata[i];
  337.       if (line.match(/<ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  338.         evalMode = 'enable requirements';
  339.       } else if (line.match(/<\/ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  340.         evalMode = 'none';
  341.       } else if (evalMode === 'enable requirements') {
  342.         obj.itemRequirements.push(line);
  343.       } else if (line.match(/<CUSTOM ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  344.         evalMode = 'custom enable requirements';
  345.       } else if (line.match(/<\/CUSTOM ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  346.         evalMode = 'none';
  347.       } else if (evalMode === 'custom enable requirements') {
  348.         obj.customItemRequirements += line + '\n';
  349.       }
  350.     }
  351.   }
  352. };
  353.  
  354. //=============================================================================
  355. // Game_BattlerBase
  356. //=============================================================================
  357.  
  358. Yanfly.ItemReq.Game_BattlerBase_mIC =
  359.   Game_BattlerBase.prototype.meetsItemConditions;
  360. Game_BattlerBase.prototype.meetsItemConditions = function(item) {
  361.   if (!Yanfly.ItemReq.Game_BattlerBase_mIC.call(this, item)) {
  362.     return false;
  363.   }
  364.   return ItemManager.meetsUsableItemRequirements(item, this);
  365. };
  366.  
  367. //=============================================================================
  368. // Game_Actor
  369. //=============================================================================
  370.  
  371. Game_Actor.prototype.isAtypeEquipped = function(atypeId) {
  372.   return this.armors().some(function(armor) {
  373.     return armor.atypeId === atypeId;
  374.   });
  375. };
  376.  
  377. //=============================================================================
  378. // ItemManager
  379. //=============================================================================
  380.  
  381. ItemManager.meetsUsableItemRequirements = function(item, battler) {
  382.   if (!item) return false;
  383.   if (!item.itemRequirements) {
  384.     var baseItem = DataManager.getBaseItem(item);
  385.     item.itemRequirements = JsonEx.makeDeepCopy(baseItem.itemRequirements);
  386.   }
  387.   var length = item.itemRequirements.length;
  388.   if ($gameParty.inBattle()) var battler = this.battleSubject() || battler;
  389.   for (var i = 0; i < length; ++i) {
  390.     var line = item.itemRequirements[i];
  391.     if (!line) continue;
  392.     if (!this.checkUsableItemRequirement(line, item, battler)) return false;
  393.   }
  394.   if (item.customItemRequirements && item.customItemRequirements.length >= 1) {
  395.     if (!this.checkCustomUsableItemRequirement(item, battler)) return false;
  396.   }
  397.   return true;
  398. };
  399.  
  400. ItemManager.battleSubject = function() {
  401.   return BattleManager.actor() || BattleManager._subject;
  402. };
  403.  
  404. ItemManager.checkUsableItemRequirement = function(line, item, battler) {
  405.   // EVAL
  406.   if (line.match(/EVAL:(.*)/i)) {
  407.     var code = String(RegExp.$1);
  408.     return this.usableItemRequirementEval(code);
  409.   }
  410.   // NOT ACTOR
  411.   if (line.match(/NOT ACTOR:(.*)/i)) {
  412.     var data = String(RegExp.$1);
  413.     return this.usableItemRequirementActor(data, battler, false);
  414.   }
  415.   // ACTOR
  416.   if (line.match(/ACTOR:(.*)/i)) {
  417.     var data = String(RegExp.$1);
  418.     return this.usableItemRequirementActor(data, battler, true);
  419.   }
  420.   // NOT ARMOR TYPE
  421.   if (line.match(/NOT ARMOR TYPE:(.*)/i)) {
  422.     var data = String(RegExp.$1);
  423.     return this.usableItemRequirementAtype(data, battler, false);
  424.   }
  425.   // ARMOR TYPE
  426.   if (line.match(/ARMOR TYPE:(.*)/i)) {
  427.     var data = String(RegExp.$1);
  428.     return this.usableItemRequirementAtype(data, battler, true);
  429.   }
  430.   // NOT ARMOR
  431.   if (line.match(/NOT ARMOR:(.*)/i)) {
  432.     var data = String(RegExp.$1);
  433.     return this.usableItemRequirementArmor(data, battler, false);
  434.   }
  435.   // ARMOR
  436.   if (line.match(/ARMOR:(.*)/i)) {
  437.     var data = String(RegExp.$1);
  438.     return this.usableItemRequirementArmor(data, battler, true);
  439.   }
  440.   if (Imported.YEP_X_Subclass) {
  441.     // NOT SUBCLASS
  442.     if (line.match(/NOT SUBCLASS:(.*)/i)) {
  443.       var data = String(RegExp.$1);
  444.       return this.usableItemRequirementSubclass(data, battler, false);
  445.     }
  446.     // SUBCLASS
  447.     if (line.match(/SUBCLASS:(.*)/i)) {
  448.       var data = String(RegExp.$1);
  449.       return this.usableItemRequirementSubclass(data, battler, true);
  450.     }
  451.     // EITHER CLASS
  452.     if (line.match(/EITHER CLASS:(.*)/i)) {
  453.       var data = String(RegExp.$1);
  454.       return this.usableItemRequirementDuoClass(data, battler, true);
  455.     }
  456.     // NEITHER CLASS
  457.     if (line.match(/NEITHER CLASS:(.*)/i)) {
  458.       var data = String(RegExp.$1);
  459.       return this.usableItemRequirementDuoClass(data, battler, false);
  460.     }
  461.   }
  462.   // NOT CLASS
  463.   if (line.match(/NOT CLASS:(.*)/i)) {
  464.     var data = String(RegExp.$1);
  465.     return this.usableItemRequirementClass(data, battler, false);
  466.   }
  467.   // CLASS
  468.   if (line.match(/CLASS:(.*)/i)) {
  469.     var data = String(RegExp.$1);
  470.     return this.usableItemRequirementClass(data, battler, true);
  471.   }
  472.   // NOT STATE
  473.   if (line.match(/NOT STATE:(.*)/i)) {
  474.     var data = String(RegExp.$1);
  475.     return this.usableItemRequirementState(data, battler, false);
  476.   }
  477.   // STATE
  478.   if (line.match(/STATE:(.*)/i)) {
  479.     var data = String(RegExp.$1);
  480.     return this.usableItemRequirementState(data, battler, true);
  481.   }
  482.   // NOT WEAPON TYPE
  483.   if (line.match(/NOT WEAPON TYPE:(.*)/i)) {
  484.     var data = String(RegExp.$1);
  485.     return this.usableItemRequirementWtype(data, battler, false);
  486.   }
  487.   // WEAPON TYPE
  488.   if (line.match(/WEAPON TYPE:(.*)/i)) {
  489.     var data = String(RegExp.$1);
  490.     return this.usableItemRequirementWtype(data, battler, true);
  491.   }
  492.   // NOT WEAPON
  493.   if (line.match(/NOT WEAPON:(.*)/i)) {
  494.     var data = String(RegExp.$1);
  495.     return this.usableItemRequirementWeapon(data, battler, false);
  496.   }
  497.   // WEAPON
  498.   if (line.match(/WEAPON:(.*)/i)) {
  499.     var data = String(RegExp.$1);
  500.     return this.usableItemRequirementWeapon(data, battler, true);
  501.   }
  502.   // SWITCH OFF
  503.   if (line.match(/SWITCH OFF:(.*)/i)) {
  504.     var data = String(RegExp.$1);
  505.     return this.usableItemRequirementSwitch(data, false);
  506.   }
  507.   // SWITCH ON
  508.   if (line.match(/SWITCH ON:(.*)/i)) {
  509.     var data = String(RegExp.$1);
  510.     return this.usableItemRequirementSwitch(data, true);
  511.   }
  512.   // VARIABLE
  513.   if (line.match(/VARIABLE[ ](\d+)[ ](.*)/i)) {
  514.     var variableId = parseInt(RegExp.$1);
  515.     var code = String(RegExp.$2);
  516.     return this.usableItemRequirementVariable(variableId, code);
  517.   }
  518.   return true;
  519. };
  520.  
  521. ItemManager.usableItemRequirementEval = function(code) {
  522.   var value = false;
  523.   try {
  524.     eval(code);
  525.   } catch (e) {
  526.     Yanfly.Util.displayError(e, code, 'CUSTOM ITEM USE EVAL CODE ERROR');
  527.   }
  528.   return value;
  529. };
  530.  
  531. ItemManager.usableItemRequirementActor = function(data, battler, condition) {
  532.   var array = data.split(',');
  533.   var length = array.length;
  534.   for (var i = 0; i < length; ++i) {
  535.     var actorId = parseInt(array[i].trim());
  536.     if (battler.actorId() === actorId) return condition;
  537.   }
  538.   return !condition;
  539. };
  540.  
  541. ItemManager.usableItemRequirementClass = function(data, battler, condition) {
  542.   var array = data.split(',');
  543.   var length = array.length;
  544.   for (var i = 0; i < length; ++i) {
  545.     var classId = parseInt(array[i].trim());
  546.     if (battler._classId === classId) return condition;
  547.   }
  548.   return !condition;
  549. };
  550.  
  551. ItemManager.usableItemRequirementDuoClass = function(data, battler, condition) {
  552.   var array = data.split(',');
  553.   var length = array.length;
  554.   for (var i = 0; i < length; ++i) {
  555.     var classId = parseInt(array[i].trim());
  556.     var subclassId = parseInt(array[i].trim());
  557.     if (battler._classId === classId || battler._subclassId === subclassId) {
  558.       return condition;
  559.     }
  560.   }
  561.   return !condition;
  562. };
  563.  
  564. ItemManager.usableItemRequirementSubclass = function(data, battler, condition) {
  565.   var array = data.split(',');
  566.   var length = array.length;
  567.   for (var i = 0; i < length; ++i) {
  568.     var subclassId = parseInt(array[i].trim());
  569.     if (battler._subclassId === subclassId) return condition;
  570.   }
  571.   return !condition;
  572. };
  573.  
  574. ItemManager.usableItemRequirementState = function(data, battler, condition) {
  575.   var array = data.split(',');
  576.   var length = array.length;
  577.   for (var i = 0; i < length; ++i) {
  578.     var stateId = parseInt(array[i].trim());
  579.     var state = $dataStates[stateId];
  580.     if (battler.states().contains(state)) return condition;
  581.   }
  582.   return !condition;
  583. };
  584.  
  585. ItemManager.usableItemRequirementWtype = function(data, battler, condition) {
  586.   var array = data.split(',');
  587.   var length = array.length;
  588.   for (var i = 0; i < length; ++i) {
  589.     var id = parseInt(array[i].trim());
  590.     if (battler.isWtypeEquipped(id)) return condition;
  591.   }
  592.   return !condition;
  593. };
  594.  
  595. ItemManager.usableItemRequirementWeapon = function(data, battler, condition) {
  596.   var array = data.split(',');
  597.   var length = array.length;
  598.   for (var i = 0; i < length; ++i) {
  599.     var id = parseInt(array[i].trim());
  600.     var equip = $dataWeapons[id];
  601.     if (battler.hasWeapon(equip)) return condition;
  602.   }
  603.   return !condition;
  604. };
  605.  
  606. ItemManager.usableItemRequirementAtype = function(data, battler, condition) {
  607.   var array = data.split(',');
  608.   var length = array.length;
  609.   for (var i = 0; i < length; ++i) {
  610.     var id = parseInt(array[i].trim());
  611.     if (battler.isAtypeEquipped(id)) return condition;
  612.   }
  613.   return !condition;
  614. };
  615.  
  616. ItemManager.usableItemRequirementArmor = function(data, battler, condition) {
  617.   var array = data.split(',');
  618.   var length = array.length;
  619.   for (var i = 0; i < length; ++i) {
  620.     var id = parseInt(array[i].trim());
  621.     var equip = $dataArmors[id];
  622.     if (battler.hasArmor(equip)) return condition;
  623.   }
  624.   return !condition;
  625. };
  626.  
  627. ItemManager.usableItemRequirementSwitch = function(data, condition) {
  628.   var array = data.split(',');
  629.   var length = array.length;
  630.   for (var i = 0; i < length; ++i) {
  631.     var switchId = parseInt(array[i].trim());
  632.     if ($gameSwitches.value(switchId) !== condition) return false;
  633.   }
  634.   return true;
  635. };
  636.  
  637. ItemManager.usableItemRequirementVariable = function(variableId, code) {
  638.   return eval('$gameVariables.value(variableId) ' + code);
  639. };
  640.  
  641. ItemManager.checkCustomUsableItemRequirement = function(item, battler) {
  642.   var condition = false;
  643.   var user = battler;
  644.   var a = battler;
  645.   var b = battler;
  646.   var target = battler;
  647.   var subject = battler;
  648.   var s = $gameSwitches._data;
  649.   var v = $gameVariables._data;
  650.   var code = item.customItemRequirements;
  651.   try {
  652.     eval(code);
  653.   } catch (e) {
  654.     Yanfly.Util.displayError(e, code, 'CUSTOM ITEM USE REQUIREMENT CODE ERROR');
  655.   }
  656.   return condition;
  657. };
  658.  
  659. //=============================================================================
  660. // Utilities
  661. //=============================================================================
  662.  
  663. Yanfly.Util = Yanfly.Util || {};
  664.  
  665. Yanfly.Util.displayError = function(e, code, message) {
  666.   console.log(message);
  667.   console.log(code || 'NON-EXISTENT');
  668.   console.error(e);
  669.   if (Utils.isNwjs() && Utils.isOptionValid('test')) {
  670.     if (!require('nw.gui').Window.get().isDevToolsOpen()) {
  671.       require('nw.gui').Window.get().showDevTools();
  672.     }
  673.   }
  674. };
  675.  
  676. //=============================================================================
  677. // End of File
  678. //=============================================================================
  679. } else {
  680.  
  681. var text = '================================================================\n';
  682. text += 'YEP_X_ItemRequirements requires YEP_ItemCore to be at the ';
  683. text += 'latest version to run properly.\n\nPlease go to [url]www.yanfly.moe[/url] and ';
  684. text += 'update to the latest version for the YEP_ItemCore plugin.\n';
  685. text += '================================================================\n';
  686. console.log(text);
  687. require('nw.gui').Window.get().showDevTools();
  688.  
  689. } // // Imported.YEP_ItemCore
roguelike求生RPG研发中....

Lv3.寻梦者

梦石
0
星屑
1433
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
2
 楼主| 发表于 2019-2-27 14:54:10 | 只看该作者
https://rpg.blue/thread-406067-1-1.html
用这个帖子2楼的备注方法,蓝量不够直接看不到物品了...
roguelike求生RPG研发中....
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1433
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
3
 楼主| 发表于 2019-2-28 14:40:22 | 只看该作者
本帖最后由 黑舞嗜 于 2019-2-28 15:39 编辑

日了,外面物品栏显示正常(灰色),战斗物品栏直接不显示
roguelike求生RPG研发中....
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7427
在线时间
948 小时
注册时间
2017-9-27
帖子
583
4
发表于 2019-2-28 18:18:32 | 只看该作者
战斗中不可使用的物品本来就不会在战斗场景里显示。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1433
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
5
 楼主| 发表于 2019-2-28 18:26:00 | 只看该作者
梦想家大魔王 发表于 2019-2-28 18:18
战斗中不可使用的物品本来就不会在战斗场景里显示。

但是我调的任何时候都能使用也无法,就是说这个插件不适用战斗中咯?
roguelike求生RPG研发中....
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-26 14:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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