查看: 3181|回复: 4

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

[复制链接]
梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
回帖
651
发表于 2019-2-27 14:51:21 | 显示全部楼层 |阅读模式

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

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

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

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

说明和插件:https://www.jianshu.com/p/6a396b895654
  1. YEP.136 – Item 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. – 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.
  16. 你只需要设置condition为你需要的限制条件即可,下面是限制条件可使用的命令列表
  17. Conditions:
  18. Eval: code
  19. – 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.
  20. 设置某变量是否和指定数值或文本相同
  21. Examples:
  22. Eval: $gameActors.actor(1).name() === ‘Harold’
  23. Eval: $gameActors.leader().name() !== ‘Ralph’

  24. Actor: x
  25. Actor: x, x, x
  26. – 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.
  27. 设置可以使用的角色
  28. Not Actor: x
  29. Not Actor: x, x, x
  30. – 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.
  31. 设置不可以使用的角色
  32. Examples:
  33. Actor: 1
  34. Actor: 2, 3, 4, 5, 6
  35. Not Actor: 7
  36. Not Actor: 8, 9, 10

  37. Armor: x
  38. Armor: x, x, x
  39. – 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.
  40. 装备指定护甲时可以使用
  41. Not Armor: x
  42. Not Armor: x, x, x
  43. – 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.
  44. 装备指定护甲时不可以使用
  45. Examples:
  46. Armor: 1
  47. Armor: 2, 3, 4, 5, 6
  48. Not Armor: 7
  49. Not Armor: 8, 9, 10

  50. Class: x
  51. Class: x, x, x
  52. – 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.
  53. 指定职业可以使用
  54. Not Class: x
  55. Not Class: x, x, x
  56. – 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.
  57. 指定职业不可以使用
  58. Examples:
  59. Class: 1
  60. Class: 2, 3, 4, 5, 6
  61. Not Class: 7
  62. Not Class: 8, 9, 10

  63. Subclass: x
  64. Subclass: x, x, x
  65. – Requires YEP_X_Subclass.js
  66. – 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.
  67. 需要YEP_X_Subclass插件支持
  68. 指定副职业可以使用
  69. Not Subclass: x
  70. Not Subclass: x, x, x
  71. – Requires YEP_X_Subclass.js
  72. – 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.
  73. 需要YEP_X_Subclass插件支持
  74. 指定副职业不可以使用
  75. Examples:
  76. Subclass: 1
  77. Subclass: 2, 3, 4, 5, 6
  78. Not Subclass: 7
  79. Not Subclass: 8, 9, 10

  80. Either Class: x
  81. Either Class: x, x, x
  82. – Requires YEP_X_Subclass.js
  83. – 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.
  84. 需要YEP_X_Subclass插件支持
  85. 主职业或副职业满足一个即可使用
  86. Neither Class: x
  87. Neither Class: x, x, x
  88. – Requires YEP_X_Subclass.js
  89. – Requires YEP_X_Subclass.js
  90. – 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.
  91. 需要YEP_X_Subclass插件支持
  92. 主职业或副职业都不满足才可使用
  93. Examples:
  94. Either Class: 1
  95. Either Class: 2, 3, 4, 5, 6
  96. Neither Class: 7
  97. Neither Class: 8, 9, 10

  98. State: x
  99. State: x, x, x
  100. – 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.
  101. 存在指定状态时可以使用
  102. Not State: x
  103. Not State: x, x, x
  104. – 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.
  105. 存在指定状态时不可以使用
  106. Examples:
  107. State: 10
  108. State: 11, 12, 13, 14, 15
  109. Not State: 16
  110. Not Stage: 17, 18, 19, 20

  111. Switch Off: x
  112. Switch Off: x, x, x
  113. – 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.
  114. 指定开关关闭时才可以使用
  115. Examples:
  116. Switch Off: 1
  117. Switch Off: 2, 3, 4, 5, 6

  118. Switch On: x
  119. Switch On: x, x, x
  120. – 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.
  121. 指定开关关闭时才可以使用
  122. Examples:
  123. Switch On: 1
  124. Switch On: 2, 3, 4, 5, 6

  125. Variable x eval
  126. – Makes a check against variable x. Replace ‘x’ with an integer value and ‘eval’ with the code check you wish to run it against.
  127. 指定变量满足条件是可以使用
  128. Examples:
  129. Variable 1 >= 5
  130. Variable 2 < 6
  131. Variable 3 === 7
  132. Variable 4 !== 8

  133. Weapon: x
  134. Weapon: x, x, x
  135. – 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.
  136. 装备指定武器时可以使用
  137. Not Weapon: x
  138. Not Weapon: x, x, x
  139. – 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.
  140. 装备指定武器时不可以使用
  141. Examples:
  142. Weapon: 1
  143. Weapon: 2, 3, 4, 5, 6
  144. Not Weapon: 7
  145. Not Weapon: 8, 9, 10

  146. Weapon Type: x
  147. Weapon Type: x, x, x
  148. – 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.
  149. 装备指定武器类型时可以使用
  150. Not Weapon Type: x
  151. Not Weapon Type: x, x, x
  152. – 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.
  153. 装备指定武器类型时不可以使用
  154. Examples:
  155. Weapon Type: 1
  156. Weapon Type: 2, 3, 4, 5, 6
  157. Not Weapon Type: 7
  158. Not Weapon Type: 8, 9, 10

  159. Lunatic Mode – Custom Enable Requirements
  160. 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:
  161. 对于熟练使用JS语言的人,你可以编程实现自己的需求
  162. Item Notetags:
  163. <Custom Enable Requirement>
  164. condition = battler.level >= item.price;
  165. </Custom Enable Requirement>

  166. – 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. The ‘item’ variable will refer to the item being checked.

  167. 作者:沧笙
  168. 链接:[url]https://www.jianshu.com/p/6a396b895654[/url]
  169. 来源:简书
  170. 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
复制代码

  1. //=============================================================================
  2. // Yanfly Engine Plugins - Item Core Extension - Item Requirements
  3. // YEP_X_ItemRequirements.js
  4. //=============================================================================

  5. var Imported = Imported || {};
  6. Imported.YEP_X_ItemRequirements = true;

  7. var Yanfly = Yanfly || {};
  8. Yanfly.ItemReq = Yanfly.ItemReq || {};
  9. Yanfly.ItemReq.version = 1.01;

  10. //=============================================================================
  11. /*:
  12. * @plugindesc v1.01 (Requires YEP_ItemCore.js) Place requirements on
  13. * items before they can be used.
  14. * @author Yanfly Engine Plugins
  15. *
  16. * @help
  17. * ============================================================================
  18. * Introduction
  19. * ============================================================================
  20. *
  21. * This plugin requires YEP_ItemCore. Make sure this plugin is located under
  22. * YEP_ItemCore in the plugin list.
  23. *
  24. * In RPG Maker MV, items only have a few restrictions on them by default,
  25. * whether or not they can be used in or out of battle or never. There aren't
  26. * any other conditions that you can set that would otherwise determine if an
  27. * item can or cannot be used. This plugin gives more ways to restrict item
  28. * usage based on switches, variables, the actors using them, classes, state
  29. * requirements, and more.
  30. *
  31. * ============================================================================
  32. * Notetags
  33. * ============================================================================
  34. *
  35. * Use the following notetags to enforce requirements for items before they can
  36. * be used.
  37. *
  38. * Item Notetags:
  39. *
  40. *   <Enable Requirements>
  41. *    condition
  42. *    condition
  43. *   </Enable Requirements>
  44. *   - Replace 'condition' with the desired condition setup. You can insert any
  45. *   number of conditions inside the notetags. All of the conditions must be
  46. *   met before the item can be used. Look below for a list of the possible
  47. *   conditions that can be used.
  48. *
  49. * ---
  50. *
  51. * Conditions:
  52. *
  53. * ---
  54. *
  55. * Eval: code
  56. * - Replace 'code' with JavaScript code that you'd like to run a check against
  57. * to enable the item. If the check returns false, the item will be disabled
  58. * regardless of other conditions.
  59. *
  60. * Examples:
  61. *   Eval: $gameActors.actor(1).name() === 'Harold'
  62. *   Eval: $gameActors.leader().name() !== 'Ralph'
  63. *
  64. * ---
  65. *
  66. * Actor: x
  67. * Actor: x, x, x
  68. * - Requires actor(s) ID 'x' to use the item. If the actor isn't the one using
  69. * the said item, then the item is disabled and cannot be used regardless of
  70. * other conditions.
  71. *
  72. * Not Actor: x
  73. * Not Actor: x, x, x
  74. * - Requires the actor using the item to NOT be actor ID 'x'. If the actor's
  75. * ID matches one of the listed 'x', then the item is disabled and cannot be
  76. * used regardless of other conditions.
  77. *
  78. * Examples:
  79. *   Actor: 1
  80. *   Actor: 2, 3, 4, 5, 6
  81. *   Not Actor: 7
  82. *   Not Actor: 8, 9, 10
  83. *
  84. * ---
  85. *
  86. * Armor: x
  87. * Armor: x, x, x
  88. * - Requires the actor to specifically have armor ID 'x' equipped to use the
  89. * item. If multiple 'x' are used, the actor can have any of them equipped. If
  90. * the actor does not have armor 'x' equipped, then the item is disabled and
  91. * cannot be used regardless of other conditions.
  92. *
  93. * Not Armor: x
  94. * Not Armor: x, x, x
  95. * - Requires the actor to not have armor ID 'x' equipped to use the item.
  96. * If multiple 'x' are used, the actor cannot have any of them equipped. If
  97. * the actor does have armor 'x' equipped, then the item is disabled and
  98. * cannot be used regardless of other conditions.
  99. *
  100. * Examples:
  101. *   Armor: 1
  102. *   Armor: 2, 3, 4, 5, 6
  103. *   Not Armor: 7
  104. *   Not Armor: 8, 9, 10
  105. *
  106. * ---
  107. *
  108. * Class: x
  109. * Class: x, x, x
  110. * - Requires class(es) ID 'x' to use the item. If the actor's class doesn't
  111. * match the item requirement, then the item is disabled and cannot be used
  112. * regardless of other conditions.
  113. *
  114. * Not Class: x
  115. * Not Class: x, x, x
  116. * - Requires the actor using the item to NOT be class ID 'x'. If the actor's
  117. * class ID matches one of the listed 'x', then the item is disabled and cannot
  118. * be used regardless of other conditions.
  119. *
  120. * Examples:
  121. *   Class: 1
  122. *   Class: 2, 3, 4, 5, 6
  123. *   Not Class: 7
  124. *   Not Class: 8, 9, 10
  125. *
  126. * ---
  127. *
  128. * Subclass: x
  129. * Subclass: x, x, x
  130. * - Requires YEP_X_Subclass.js
  131. * - Requires subclass(es) ID 'x' to use the item. If the actor's class doesn't
  132. * match the item requirement, then the item is disabled and cannot be used
  133. * regardless of other conditions.
  134. *
  135. * Not Subclass: x
  136. * Not Subclass: x, x, x
  137. * - Requires YEP_X_Subclass.js
  138. * - Requires the actor using the item to NOT be subclass ID 'x'. If the
  139. * actor's subclass ID matches one of the listed 'x', then the item is disabled
  140. * and cannot be used regardless of other conditions.
  141. *
  142. * Examples:
  143. *   Subclass: 1
  144. *   Subclass: 2, 3, 4, 5, 6
  145. *   Not Subclass: 7
  146. *   Not Subclass: 8, 9, 10
  147. *
  148. * ---
  149. *
  150. * Either Class: x
  151. * Either Class: x, x, x
  152. * - Requires YEP_X_Subclass.js
  153. * - The actor's primary class or subclass ID has to match 'x'. If at least one
  154. * of them match, then the condition passes. Otherwise, the condition fails and
  155. * the item is disabled and cannot be used regardless of other conditions.
  156. *
  157. * Neither Class: x
  158. * Neither Class: x, x, x
  159. * - Requires YEP_X_Subclass.js
  160. * - Requires YEP_X_Subclass.js
  161. * - The actor's primary class or subclass ID has to NOT match 'x'. If at least
  162. * one of them match, then the condition fails and the item is disabled and
  163. * cannot be used regardless of other conditions.
  164. *
  165. * Examples:
  166. *   Either Class: 1
  167. *   Either Class: 2, 3, 4, 5, 6
  168. *   Neither Class: 7
  169. *   Neither Class: 8, 9, 10
  170. *
  171. * ---
  172. *
  173. * State: x
  174. * State: x, x, x
  175. * - Requires the actor using the item to be affected by state 'x'. If multiple
  176. * 'x' are used, the actor can be affected by any of them. If the actor is not
  177. * affected by state 'x', then the condition fails and the item is disabled
  178. * and cannot be used regardless of other conditions.
  179. *
  180. * Not State: x
  181. * Not State: x, x, x
  182. * - Requires the actor using the item to be not affected by state 'x'. If
  183. * multiple 'x' are used, the actor cannot be affected by any of them. If the
  184. * actor is not affected by state 'x', then the condition fails and the item is
  185. * disabled and cannot be used regardless of other conditions.
  186. *
  187. * Examples:
  188. *   State: 10
  189. *   State: 11, 12, 13, 14, 15
  190. *   Not State: 16
  191. *   Not Stage: 17, 18, 19, 20
  192. *
  193. * ---
  194. *
  195. * Switch Off: x
  196. * Switch Off: x, x, x
  197. * - Requires switch(es) x to be OFF before the item can be used. If the switch
  198. * is ON, then the item is disabled and cannot be used regardless of other
  199. * conditions.
  200. *
  201. * Examples:
  202. *   Switch Off: 1
  203. *   Switch Off: 2, 3, 4, 5, 6
  204. *
  205. * ---
  206. *
  207. * Switch On: x
  208. * Switch On: x, x, x
  209. * - Requires switch(es) x to be ON before the item can be used. If the switch
  210. * is OFF, then the item is disabled and cannot be used regardless of other
  211. * conditions.
  212. *
  213. * Examples:
  214. *   Switch On: 1
  215. *   Switch On: 2, 3, 4, 5, 6
  216. *
  217. * ---
  218. *
  219. * Variable x eval
  220. * - Makes a check against variable x. Replace 'x' with an integer value and
  221. * 'eval' with the code check you wish to run it against.
  222. *
  223. * Examples:
  224. *   Variable 1 >= 5
  225. *   Variable 2 < 6
  226. *   Variable 3 === 7
  227. *   Variable 4 !== 8
  228. *
  229. * ---
  230. *
  231. * Weapon: x
  232. * Weapon: x, x, x
  233. * - Requires the actor to specifically have weapon ID 'x' equipped to use the
  234. * item. If multiple 'x' are used, the actor can have any of them equipped. If
  235. * the actor does not have weapon 'x' equipped, then the item is disabled and
  236. * cannot be used regardless of other conditions.
  237. *
  238. * Not Weapon: x
  239. * Not Weapon: x, x, x
  240. * - Requires the actor to not have weapon ID 'x' equipped to use the item.
  241. * If multiple 'x' are used, the actor cannot have any of them equipped. If
  242. * the actor does have weapon 'x' equipped, then the item is disabled and
  243. * cannot be used regardless of other conditions.
  244. *
  245. * Examples:
  246. *   Weapon: 1
  247. *   Weapon: 2, 3, 4, 5, 6
  248. *   Not Weapon: 7
  249. *   Not Weapon: 8, 9, 10
  250. *
  251. * ---
  252. *
  253. * Weapon Type: x
  254. * Weapon Type: x, x, x
  255. * - Requires the actor to have weapon type 'x' equipped. If multiple 'x' are
  256. * used, the actor can have any of the 'x' weapon types equipped. If the actor
  257. * does not have the matching weapon types, then the item is disabled and
  258. * cannot be used regardless of other conditions.
  259. *
  260. * Not Weapon Type: x
  261. * Not Weapon Type: x, x, x
  262. * - Requires the actor to not have weapon type 'x' equipped. If multiple 'x'
  263. * are used, the actor cannot have any of the 'x' weapon types equipped. If the
  264. * actor does have the matching weapon types, then the item is disabled and
  265. * cannot be used regardless of other conditions.
  266. *
  267. * Examples:
  268. *   Weapon Type: 1
  269. *   Weapon Type: 2, 3, 4, 5, 6
  270. *   Not Weapon Type: 7
  271. *   Not Weapon Type: 8, 9, 10
  272. *
  273. * ============================================================================
  274. * Lunatic Mode - Custom Enable Requirements
  275. * ============================================================================
  276. *
  277. * For those with JavaScript experience, you can create your own custom
  278. * requirements for whether or not items can be used using the following
  279. * notetag setup:
  280. *
  281. * Item Notetags:
  282. *
  283. *   <Custom Enable Requirement>
  284. *    condition = battler.level >= item.price;
  285. *   </Custom Enable Requirement>
  286. *   - The 'condition' variable will determine whether or not the item will be
  287. *   enabled/disabled. If the 'condition' variable returns true, then the item
  288. *   is enabled provided all other conditions (if any) are also met. Otherwise,
  289. *   the item is disabled and cannot be used. The 'battler' variable will refer
  290. *   to the battler using the item. The 'item' variable will refer to the item
  291. *   being checked.
  292. *
  293. * ============================================================================
  294. * Changelog
  295. * ============================================================================
  296. *
  297. * Version 1.01:
  298. * - Updated for RPG Maker MV version 1.5.0.
  299. *
  300. * Version 1.00:
  301. * - Finished Plugin!
  302. */
  303. //=============================================================================

  304. if (Imported.YEP_ItemCore) {

  305. //=============================================================================
  306. // DataManager
  307. //=============================================================================

  308. Yanfly.ItemReq.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  309. DataManager.isDatabaseLoaded = function() {
  310.   if (!Yanfly.ItemReq.DataManager_isDatabaseLoaded.call(this)) return false;

  311.   if (!Yanfly._loaded_YEP_X_ItemRequirements) {
  312.     this.processItemRequirementsNotetags1($dataItems);
  313.     Yanfly._loaded_YEP_X_ItemRequirements = true;
  314.   }
  315.   
  316.   return true;
  317. };

  318. DataManager.processItemRequirementsNotetags1 = function(group) {
  319.   for (var n = 1; n < group.length; n++) {
  320.     var obj = group[n];
  321.     var notedata = obj.note.split(/[\r\n]+/);

  322.     obj.itemRequirements = [];
  323.     var evalMode = 'none';
  324.     obj.customItemRequirements = '';

  325.     for (var i = 0; i < notedata.length; i++) {
  326.       var line = notedata[i];
  327.       if (line.match(/<ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  328.         evalMode = 'enable requirements';
  329.       } else if (line.match(/<\/ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  330.         evalMode = 'none';
  331.       } else if (evalMode === 'enable requirements') {
  332.         obj.itemRequirements.push(line);
  333.       } else if (line.match(/<CUSTOM ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  334.         evalMode = 'custom enable requirements';
  335.       } else if (line.match(/<\/CUSTOM ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
  336.         evalMode = 'none';
  337.       } else if (evalMode === 'custom enable requirements') {
  338.         obj.customItemRequirements += line + '\n';
  339.       }
  340.     }
  341.   }
  342. };

  343. //=============================================================================
  344. // Game_BattlerBase
  345. //=============================================================================

  346. Yanfly.ItemReq.Game_BattlerBase_mIC =
  347.   Game_BattlerBase.prototype.meetsItemConditions;
  348. Game_BattlerBase.prototype.meetsItemConditions = function(item) {
  349.   if (!Yanfly.ItemReq.Game_BattlerBase_mIC.call(this, item)) {
  350.     return false;
  351.   }
  352.   return ItemManager.meetsUsableItemRequirements(item, this);
  353. };

  354. //=============================================================================
  355. // Game_Actor
  356. //=============================================================================

  357. Game_Actor.prototype.isAtypeEquipped = function(atypeId) {
  358.   return this.armors().some(function(armor) {
  359.     return armor.atypeId === atypeId;
  360.   });
  361. };

  362. //=============================================================================
  363. // ItemManager
  364. //=============================================================================

  365. ItemManager.meetsUsableItemRequirements = function(item, battler) {
  366.   if (!item) return false;
  367.   if (!item.itemRequirements) {
  368.     var baseItem = DataManager.getBaseItem(item);
  369.     item.itemRequirements = JsonEx.makeDeepCopy(baseItem.itemRequirements);
  370.   }
  371.   var length = item.itemRequirements.length;
  372.   if ($gameParty.inBattle()) var battler = this.battleSubject() || battler;
  373.   for (var i = 0; i < length; ++i) {
  374.     var line = item.itemRequirements[i];
  375.     if (!line) continue;
  376.     if (!this.checkUsableItemRequirement(line, item, battler)) return false;
  377.   }
  378.   if (item.customItemRequirements && item.customItemRequirements.length >= 1) {
  379.     if (!this.checkCustomUsableItemRequirement(item, battler)) return false;
  380.   }
  381.   return true;
  382. };

  383. ItemManager.battleSubject = function() {
  384.   return BattleManager.actor() || BattleManager._subject;
  385. };

  386. ItemManager.checkUsableItemRequirement = function(line, item, battler) {
  387.   // EVAL
  388.   if (line.match(/EVAL:(.*)/i)) {
  389.     var code = String(RegExp.$1);
  390.     return this.usableItemRequirementEval(code);
  391.   }
  392.   // NOT ACTOR
  393.   if (line.match(/NOT ACTOR:(.*)/i)) {
  394.     var data = String(RegExp.$1);
  395.     return this.usableItemRequirementActor(data, battler, false);
  396.   }
  397.   // ACTOR
  398.   if (line.match(/ACTOR:(.*)/i)) {
  399.     var data = String(RegExp.$1);
  400.     return this.usableItemRequirementActor(data, battler, true);
  401.   }
  402.   // NOT ARMOR TYPE
  403.   if (line.match(/NOT ARMOR TYPE:(.*)/i)) {
  404.     var data = String(RegExp.$1);
  405.     return this.usableItemRequirementAtype(data, battler, false);
  406.   }
  407.   // ARMOR TYPE
  408.   if (line.match(/ARMOR TYPE:(.*)/i)) {
  409.     var data = String(RegExp.$1);
  410.     return this.usableItemRequirementAtype(data, battler, true);
  411.   }
  412.   // NOT ARMOR
  413.   if (line.match(/NOT ARMOR:(.*)/i)) {
  414.     var data = String(RegExp.$1);
  415.     return this.usableItemRequirementArmor(data, battler, false);
  416.   }
  417.   // ARMOR
  418.   if (line.match(/ARMOR:(.*)/i)) {
  419.     var data = String(RegExp.$1);
  420.     return this.usableItemRequirementArmor(data, battler, true);
  421.   }
  422.   if (Imported.YEP_X_Subclass) {
  423.     // NOT SUBCLASS
  424.     if (line.match(/NOT SUBCLASS:(.*)/i)) {
  425.       var data = String(RegExp.$1);
  426.       return this.usableItemRequirementSubclass(data, battler, false);
  427.     }
  428.     // SUBCLASS
  429.     if (line.match(/SUBCLASS:(.*)/i)) {
  430.       var data = String(RegExp.$1);
  431.       return this.usableItemRequirementSubclass(data, battler, true);
  432.     }
  433.     // EITHER CLASS
  434.     if (line.match(/EITHER CLASS:(.*)/i)) {
  435.       var data = String(RegExp.$1);
  436.       return this.usableItemRequirementDuoClass(data, battler, true);
  437.     }
  438.     // NEITHER CLASS
  439.     if (line.match(/NEITHER CLASS:(.*)/i)) {
  440.       var data = String(RegExp.$1);
  441.       return this.usableItemRequirementDuoClass(data, battler, false);
  442.     }
  443.   }
  444.   // NOT CLASS
  445.   if (line.match(/NOT CLASS:(.*)/i)) {
  446.     var data = String(RegExp.$1);
  447.     return this.usableItemRequirementClass(data, battler, false);
  448.   }
  449.   // CLASS
  450.   if (line.match(/CLASS:(.*)/i)) {
  451.     var data = String(RegExp.$1);
  452.     return this.usableItemRequirementClass(data, battler, true);
  453.   }
  454.   // NOT STATE
  455.   if (line.match(/NOT STATE:(.*)/i)) {
  456.     var data = String(RegExp.$1);
  457.     return this.usableItemRequirementState(data, battler, false);
  458.   }
  459.   // STATE
  460.   if (line.match(/STATE:(.*)/i)) {
  461.     var data = String(RegExp.$1);
  462.     return this.usableItemRequirementState(data, battler, true);
  463.   }
  464.   // NOT WEAPON TYPE
  465.   if (line.match(/NOT WEAPON TYPE:(.*)/i)) {
  466.     var data = String(RegExp.$1);
  467.     return this.usableItemRequirementWtype(data, battler, false);
  468.   }
  469.   // WEAPON TYPE
  470.   if (line.match(/WEAPON TYPE:(.*)/i)) {
  471.     var data = String(RegExp.$1);
  472.     return this.usableItemRequirementWtype(data, battler, true);
  473.   }
  474.   // NOT WEAPON
  475.   if (line.match(/NOT WEAPON:(.*)/i)) {
  476.     var data = String(RegExp.$1);
  477.     return this.usableItemRequirementWeapon(data, battler, false);
  478.   }
  479.   // WEAPON
  480.   if (line.match(/WEAPON:(.*)/i)) {
  481.     var data = String(RegExp.$1);
  482.     return this.usableItemRequirementWeapon(data, battler, true);
  483.   }
  484.   // SWITCH OFF
  485.   if (line.match(/SWITCH OFF:(.*)/i)) {
  486.     var data = String(RegExp.$1);
  487.     return this.usableItemRequirementSwitch(data, false);
  488.   }
  489.   // SWITCH ON
  490.   if (line.match(/SWITCH ON:(.*)/i)) {
  491.     var data = String(RegExp.$1);
  492.     return this.usableItemRequirementSwitch(data, true);
  493.   }
  494.   // VARIABLE
  495.   if (line.match(/VARIABLE[ ](\d+)[ ](.*)/i)) {
  496.     var variableId = parseInt(RegExp.$1);
  497.     var code = String(RegExp.$2);
  498.     return this.usableItemRequirementVariable(variableId, code);
  499.   }
  500.   return true;
  501. };

  502. ItemManager.usableItemRequirementEval = function(code) {
  503.   var value = false;
  504.   try {
  505.     eval(code);
  506.   } catch (e) {
  507.     Yanfly.Util.displayError(e, code, 'CUSTOM ITEM USE EVAL CODE ERROR');
  508.   }
  509.   return value;
  510. };

  511. ItemManager.usableItemRequirementActor = function(data, battler, condition) {
  512.   var array = data.split(',');
  513.   var length = array.length;
  514.   for (var i = 0; i < length; ++i) {
  515.     var actorId = parseInt(array[i].trim());
  516.     if (battler.actorId() === actorId) return condition;
  517.   }
  518.   return !condition;
  519. };

  520. ItemManager.usableItemRequirementClass = function(data, battler, condition) {
  521.   var array = data.split(',');
  522.   var length = array.length;
  523.   for (var i = 0; i < length; ++i) {
  524.     var classId = parseInt(array[i].trim());
  525.     if (battler._classId === classId) return condition;
  526.   }
  527.   return !condition;
  528. };

  529. ItemManager.usableItemRequirementDuoClass = function(data, battler, condition) {
  530.   var array = data.split(',');
  531.   var length = array.length;
  532.   for (var i = 0; i < length; ++i) {
  533.     var classId = parseInt(array[i].trim());
  534.     var subclassId = parseInt(array[i].trim());
  535.     if (battler._classId === classId || battler._subclassId === subclassId) {
  536.       return condition;
  537.     }
  538.   }
  539.   return !condition;
  540. };

  541. ItemManager.usableItemRequirementSubclass = function(data, battler, condition) {
  542.   var array = data.split(',');
  543.   var length = array.length;
  544.   for (var i = 0; i < length; ++i) {
  545.     var subclassId = parseInt(array[i].trim());
  546.     if (battler._subclassId === subclassId) return condition;
  547.   }
  548.   return !condition;
  549. };

  550. ItemManager.usableItemRequirementState = function(data, battler, condition) {
  551.   var array = data.split(',');
  552.   var length = array.length;
  553.   for (var i = 0; i < length; ++i) {
  554.     var stateId = parseInt(array[i].trim());
  555.     var state = $dataStates[stateId];
  556.     if (battler.states().contains(state)) return condition;
  557.   }
  558.   return !condition;
  559. };

  560. ItemManager.usableItemRequirementWtype = function(data, battler, condition) {
  561.   var array = data.split(',');
  562.   var length = array.length;
  563.   for (var i = 0; i < length; ++i) {
  564.     var id = parseInt(array[i].trim());
  565.     if (battler.isWtypeEquipped(id)) return condition;
  566.   }
  567.   return !condition;
  568. };

  569. ItemManager.usableItemRequirementWeapon = function(data, battler, condition) {
  570.   var array = data.split(',');
  571.   var length = array.length;
  572.   for (var i = 0; i < length; ++i) {
  573.     var id = parseInt(array[i].trim());
  574.     var equip = $dataWeapons[id];
  575.     if (battler.hasWeapon(equip)) return condition;
  576.   }
  577.   return !condition;
  578. };

  579. ItemManager.usableItemRequirementAtype = function(data, battler, condition) {
  580.   var array = data.split(',');
  581.   var length = array.length;
  582.   for (var i = 0; i < length; ++i) {
  583.     var id = parseInt(array[i].trim());
  584.     if (battler.isAtypeEquipped(id)) return condition;
  585.   }
  586.   return !condition;
  587. };

  588. ItemManager.usableItemRequirementArmor = function(data, battler, condition) {
  589.   var array = data.split(',');
  590.   var length = array.length;
  591.   for (var i = 0; i < length; ++i) {
  592.     var id = parseInt(array[i].trim());
  593.     var equip = $dataArmors[id];
  594.     if (battler.hasArmor(equip)) return condition;
  595.   }
  596.   return !condition;
  597. };

  598. ItemManager.usableItemRequirementSwitch = function(data, condition) {
  599.   var array = data.split(',');
  600.   var length = array.length;
  601.   for (var i = 0; i < length; ++i) {
  602.     var switchId = parseInt(array[i].trim());
  603.     if ($gameSwitches.value(switchId) !== condition) return false;
  604.   }
  605.   return true;
  606. };

  607. ItemManager.usableItemRequirementVariable = function(variableId, code) {
  608.   return eval('$gameVariables.value(variableId) ' + code);
  609. };

  610. ItemManager.checkCustomUsableItemRequirement = function(item, battler) {
  611.   var condition = false;
  612.   var user = battler;
  613.   var a = battler;
  614.   var b = battler;
  615.   var target = battler;
  616.   var subject = battler;
  617.   var s = $gameSwitches._data;
  618.   var v = $gameVariables._data;
  619.   var code = item.customItemRequirements;
  620.   try {
  621.     eval(code);
  622.   } catch (e) {
  623.     Yanfly.Util.displayError(e, code, 'CUSTOM ITEM USE REQUIREMENT CODE ERROR');
  624.   }
  625.   return condition;
  626. };

  627. //=============================================================================
  628. // Utilities
  629. //=============================================================================

  630. Yanfly.Util = Yanfly.Util || {};

  631. Yanfly.Util.displayError = function(e, code, message) {
  632.   console.log(message);
  633.   console.log(code || 'NON-EXISTENT');
  634.   console.error(e);
  635.   if (Utils.isNwjs() && Utils.isOptionValid('test')) {
  636.     if (!require('nw.gui').Window.get().isDevToolsOpen()) {
  637.       require('nw.gui').Window.get().showDevTools();
  638.     }
  639.   }
  640. };

  641. //=============================================================================
  642. // End of File
  643. //=============================================================================
  644. } else {

  645. var text = '================================================================\n';
  646. text += 'YEP_X_ItemRequirements requires YEP_ItemCore to be at the ';
  647. text += 'latest version to run properly.\n\nPlease go to [url]www.yanfly.moe[/url] and ';
  648. text += 'update to the latest version for the YEP_ItemCore plugin.\n';
  649. text += '================================================================\n';
  650. console.log(text);
  651. require('nw.gui').Window.get().showDevTools();

  652. } // // Imported.YEP_ItemCore
复制代码
roguelike求生RPG研发中....
梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
回帖
651
 楼主| 发表于 2019-2-27 14:54:10 | 显示全部楼层
https://rpg.blue/thread-406067-1-1.html
用这个帖子2楼的备注方法,蓝量不够直接看不到物品了...
roguelike求生RPG研发中....
回复

使用道具 举报

梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
回帖
651
 楼主| 发表于 2019-2-28 14:40:22 | 显示全部楼层
本帖最后由 黑舞嗜 于 2019-2-28 15:39 编辑

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

使用道具 举报

梦石
0
星屑
7427
在线时间
948 小时
注册时间
2017-9-27
回帖
566
发表于 2019-2-28 18:18:32 | 显示全部楼层
战斗中不可使用的物品本来就不会在战斗场景里显示。
回复

使用道具 举报

梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
回帖
651
 楼主| 发表于 2019-2-28 18:26:00 | 显示全部楼层
梦想家大魔王 发表于 2019-2-28 18:18
战斗中不可使用的物品本来就不会在战斗场景里显示。

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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部