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

Project1

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

[已经解决] 求一个延长状态脚本

[复制链接]

Lv2.观梦者

梦石
0
星屑
285
在线时间
17 小时
注册时间
2020-8-2
帖子
11
跳转到指定楼层
1
发表于 2020-8-27 13:36:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如题,求一个技能延长目标状态的脚本

Lv5.捕梦者

梦石
0
星屑
26264
在线时间
5355 小时
注册时间
2016-3-8
帖子
1655
2
发表于 2020-8-27 13:50:23 | 只看该作者
本帖最后由 alexncf125 于 2020-8-27 14:08 编辑

https://yanflychannel.wordpress. ... buff-state-manager/
唔...我没在用...有问题不要找我...不过应该有你要的效果...
RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Buff & State Manager v1.07
  4. # -- Last Updated: 2012.01.26
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-Buff&StateManager"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.26 - Bug Fixed: Remaining turns aren't drawn in excess.
  17. # 2012.01.23 - Compatibility Update: Doppelganger
  18. # 2012.01.11 - Compatibility Update: Field State Effects
  19. # 2012.01.09 - Bug Fixed: Remaining turns weren't drawn properly again.
  20. # 2012.01.07 - Bug Fixed: Remaining turns weren't drawn properly.
  21. # 2011.12.30 - Bug Fixed: Decimals are no longer shown on states turns.
  22. # 2011.12.28 - Added <state x turn: +y> for actors, classes, weapons, armours,
  23. #              enemies, and states.
  24. # 2011.12.27 - Started Script and Finished.
  25. #
  26. #==============================================================================
  27. # ▼ Introduction
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # This script alters some of the basic mechanics revolving behind states,
  30. # buffs, and debuffs that aren't adjustable within RPG Maker VX Ace by default
  31. # such as being able to affect the turns remaining on a state, buff, or debuff
  32. # without affecting anything else or even adjusting how many times a buff (or
  33. # debuff) can be applied to an actor.
  34. #
  35. #==============================================================================
  36. # ▼ Instructions
  37. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. # To install this script, open up your script editor and copy/paste this script
  39. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  40. #
  41. # -----------------------------------------------------------------------------
  42. # Actor Notetags - These notetags go in the actors notebox in the database.
  43. # -----------------------------------------------------------------------------
  44. # <max buff stat: +x>
  45. # <max buff stat: -x>
  46. # Increases or decreases the maximum times that particular stat can be buffed
  47. # by x. Note that the max increase here is still limited by the module constant
  48. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  49. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  50. #
  51. # <max debuff stat: +x>
  52. # <max debuff stat: -x>
  53. # Increases or decreases the maximum times that particular stat can be debuffed
  54. # by x. Note that the max decrease here is still limited by the module constant
  55. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  56. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  57. #
  58. # <state x turn: +y>
  59. # <state x turn: -y>
  60. # When the battler is affected by state x, additional modifiers are made to the
  61. # number of turns remaining for state x by y amount. The modifiers cannot
  62. # reduce turns to under 0.
  63. #
  64. # -----------------------------------------------------------------------------
  65. # Class Notetags - These notetags go in the class notebox in the database.
  66. # -----------------------------------------------------------------------------
  67. # <max buff stat: +x>
  68. # <max buff stat: -x>
  69. # Increases or decreases the maximum times that particular stat can be buffed
  70. # by x. Note that the max increase here is still limited by the module constant
  71. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  72. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  73. #
  74. # <max debuff stat: +x>
  75. # <max debuff stat: -x>
  76. # Increases or decreases the maximum times that particular stat can be debuffed
  77. # by x. Note that the max decrease here is still limited by the module constant
  78. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  79. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  80. #
  81. # <state x turn: +y>
  82. # <state x turn: -y>
  83. # When the battler is affected by state x, additional modifiers are made to the
  84. # number of turns remaining for state x by y amount. The modifiers cannot
  85. # reduce turns to under 0.
  86. #
  87. # -----------------------------------------------------------------------------
  88. # Skill Notetags - These notetags go in the skill notebox in the database.
  89. # -----------------------------------------------------------------------------
  90. # <state x turn: +y>
  91. # <state x turn: -y>
  92. # If the target is affected by state x, this will alter the turns remaining on
  93. # that state by y turns if the state can be removed by turns. If the state goes
  94. # under 0 turns, the state will be removed.
  95. #
  96. # <buff stat turn: +x>
  97. # <buff stat turn: -x>
  98. # If the target's stat is buffed, this will alter the turns remaining on that
  99. # buff by x turns. If the buff's remaining turns go under 0, the buff will be
  100. # removed.
  101. #
  102. # <debuff stat turn: +x>
  103. # <debuff stat turn: -x>
  104. # If the target's stat is debuffed, this will alter the turns remaining on that
  105. # debuff by x turns. If the debuff's remaining turns go under 0, the debuff
  106. # will be removed.
  107. #
  108. # -----------------------------------------------------------------------------
  109. # Item Notetags - These notetags go in the item notebox in the database.
  110. # -----------------------------------------------------------------------------
  111. # <state x turn: +y>
  112. # <state x turn: -y>
  113. # If the target is affected by state x, this will alter the turns remaining on
  114. # that state by y turns if the state can be removed by turns. If the state goes
  115. # under 0 turns, the state will be removed.
  116. #
  117. # <buff stat turn: +x>
  118. # <buff stat turn: -x>
  119. # If the target's stat is buffed, this will alter the turns remaining on that
  120. # buff by x turns. If the buff's remaining turns go under 0, the buff will be
  121. # removed.
  122. #
  123. # <debuff stat turn: +x>
  124. # <debuff stat turn: -x>
  125. # If the target's stat is debuffed, this will alter the turns remaining on that
  126. # debuff by x turns. If the debuff's remaining turns go under 0, the debuff
  127. # will be removed.
  128. #
  129. # -----------------------------------------------------------------------------
  130. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  131. # -----------------------------------------------------------------------------
  132. # <max buff stat: +x>
  133. # <max buff stat: -x>
  134. # Increases or decreases the maximum times that particular stat can be buffed
  135. # by x. Note that the max increase here is still limited by the module constant
  136. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  137. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  138. #
  139. # <max debuff stat: +x>
  140. # <max debuff stat: -x>
  141. # Increases or decreases the maximum times that particular stat can be debuffed
  142. # by x. Note that the max decrease here is still limited by the module constant
  143. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  144. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  145. #
  146. # <state x turn: +y>
  147. # <state x turn: -y>
  148. # When the battler is affected by state x, additional modifiers are made to the
  149. # number of turns remaining for state x by y amount. The modifiers cannot
  150. # reduce turns to under 0.
  151. #
  152. # -----------------------------------------------------------------------------
  153. # Armour Notetags - These notetags go in the armour notebox in the database.
  154. # -----------------------------------------------------------------------------
  155. # <max buff stat: +x>
  156. # <max buff stat: -x>
  157. # Increases or decreases the maximum times that particular stat can be buffed
  158. # by x. Note that the max increase here is still limited by the module constant
  159. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  160. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  161. #
  162. # <max debuff stat: +x>
  163. # <max debuff stat: -x>
  164. # Increases or decreases the maximum times that particular stat can be debuffed
  165. # by x. Note that the max decrease here is still limited by the module constant
  166. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  167. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  168. #
  169. # <state x turn: +y>
  170. # <state x turn: -y>
  171. # When the battler is affected by state x, additional modifiers are made to the
  172. # number of turns remaining for state x by y amount. The modifiers cannot
  173. # reduce turns to under 0.
  174. #
  175. # -----------------------------------------------------------------------------
  176. # Enemy Notetags - These notetags go in the enemies notebox in the database.
  177. # -----------------------------------------------------------------------------
  178. # <max buff stat: +x>
  179. # <max buff stat: -x>
  180. # Increases or decreases the maximum times that particular stat can be buffed
  181. # by x. Note that the max increase here is still limited by the module constant
  182. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  183. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  184. #
  185. # <max debuff stat: +x>
  186. # <max debuff stat: -x>
  187. # Increases or decreases the maximum times that particular stat can be debuffed
  188. # by x. Note that the max decrease here is still limited by the module constant
  189. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  190. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  191. #
  192. # <state x turn: +y>
  193. # <state x turn: -y>
  194. # When the battler is affected by state x, additional modifiers are made to the
  195. # number of turns remaining for state x by y amount. The modifiers cannot
  196. # reduce turns to under 0.
  197. #
  198. # -----------------------------------------------------------------------------
  199. # State Notetags - These notetags go in the states notebox in the database.
  200. # -----------------------------------------------------------------------------
  201. # <max buff stat: +x>
  202. # <max buff stat: -x>
  203. # Increases or decreases the maximum times that particular stat can be buffed
  204. # by x. Note that the max increase here is still limited by the module constant
  205. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  206. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  207. #
  208. # <max debuff stat: +x>
  209. # <max debuff stat: -x>
  210. # Increases or decreases the maximum times that particular stat can be debuffed
  211. # by x. Note that the max decrease here is still limited by the module constant
  212. # MAXIMUM_BUFF_LIMIT. Replace "stat" with "MAXHP", "MAXMP", "ATK", "DEF",
  213. # "MAT", "MDF", "AGI", "LUK", or "ALL" for those respective stats.
  214. #
  215. # <reapply ignore>
  216. # If this state is cast on a battler with the state already applied, turns
  217. # remaining will not be reset nor will turns be added on.
  218. #
  219. # <reapply reset>
  220. # If this state is cast on a battler with the state already applied, the turns
  221. # will be reset to the default amount of turns the state normally starts with.
  222. #
  223. # <reapply total>
  224. # If this state is cast on a battler with the state already applied, the turns
  225. # will be added on to the current amount of turns remaining giving the battler
  226. # a total of the remaining turns with the default turns for the state.
  227. #
  228. # <state x turn: +y>
  229. # <state x turn: -y>
  230. # When the battler is affected by state x, additional modifiers are made to the
  231. # number of turns remaining for state x by y amount. The modifiers cannot
  232. # reduce turns to under 0.
  233. #
  234. #==============================================================================
  235. # ▼ Compatibility
  236. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  237. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  238. # it will run with RPG Maker VX without adjusting.
  239. #
  240. #==============================================================================
  241.  
  242. module YEA
  243.   module BUFF_STATE_MANAGER
  244.  
  245.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  246.     # - Draw Remaining Turns -
  247.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  248.     # This setting will cause the game to show the number of turns remaining
  249.     # for a state in battle (if the state will remove itself through turns).
  250.     # Adjust the settings below to change the font size and the y coordinate
  251.     # adjustment to where the turns remaining appear if you so desire.
  252.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  253.     SHOW_REMAINING_TURNS = true     # Show the turns remaining?
  254.     TURNS_REMAINING_SIZE = 18       # Font size used for turns remaining.
  255.     TURNS_REMAINING_Y    = -4       # Adjusts location of the text.
  256.  
  257.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  258.     # - Buff Settings -
  259.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  260.     # These settings adjust how buffs play out in your game and the way they
  261.     # modify a battler's stats such as the maximum times a stat can be buffed
  262.     # and the buff boost formula. Note that these maximums apply to both buffs
  263.     # and debuffs.
  264.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  265.     DEFAULT_BUFF_LIMIT = 4     # Normal times you can buff a stat. Default: 2
  266.     MAXIMUM_BUFF_LIMIT = 8     # Maximum times you can buff a stat. Default: 2
  267.  
  268.     # This is the formula used to apply the rate used for buffs and debuffs.
  269.     BUFF_BOOST_FORMULA = "buff_level(param_id) * 0.25 + 1.0"
  270.  
  271.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  272.     # - Reapplying State Settings -
  273.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  274.     # These settings adjust how the rules apply to states when they are
  275.     # reapplied onto an actor with the state already intact. If you wish to
  276.     # have specific states use different rules, use notetags to have them
  277.     # adjust turns differently.
  278.     #   0 - Ignored. Default VX setting.
  279.     #   1 - Turns reset back to existing turns. Default VX Ace Setting.
  280.     #   2 - Default turns added onto existing turns.
  281.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  282.     REAPPLY_STATE_RULES = 1
  283.  
  284.   end # BUFF_STATE_MANAGER
  285. end # YEA
  286.  
  287. #==============================================================================
  288. # ▼ Editting anything past this point may potentially result in causing
  289. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  290. # halitosis so edit at your own risk.
  291. #==============================================================================
  292.  
  293. module YEA
  294.   module REGEXP
  295.   module BASEITEM
  296.  
  297.     MAX_BUFF = /<(?:MAX_BUFF|max buff)[ ](.*):[ ]([\+\-]\d+)>/i
  298.     MAX_DEBUFF = /<(?:MAX_DEBUFF|max debuff)[ ](.*):[ ]([\+\-]\d+)>/i
  299.     CHANGE_STATE_TURN = /<(?:state)[ ](\d+)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i
  300.     STATE_REAPPLY_IGNORE = /<(?:REAPPLY_IGNORE|reapply ignore)>/i
  301.     STATE_REAPPLY_RESET = /<(?:REAPPLY_RESET|reapply reset)>/i
  302.     STATE_REAPPLY_TOTAL = /<(?:REAPPLY_TOTAL|reapply total)>/i
  303.  
  304.   end # BASEITEM
  305.   module USABLEITEM
  306.  
  307.     CHANGE_STATE_TURN = /<(?:state)[ ](\d+)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i
  308.     CHANGE_BUFF_TURN = /<(?:buff)[ ](.*)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i
  309.     CHANGE_DEBUFF_TURN = /<(?:debuff)[ ](.*)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i
  310.  
  311.   end # USABLEITEM
  312.   end # REGEXP
  313. end # YEA
  314.  
  315. #==============================================================================
  316. # ■ DataManager
  317. #==============================================================================
  318.  
  319. module DataManager
  320.  
  321.   #--------------------------------------------------------------------------
  322.   # alias method: load_database
  323.   #--------------------------------------------------------------------------
  324.   class <<self; alias load_database_bsm load_database; end
  325.   def self.load_database
  326.     load_database_bsm
  327.     load_notetags_bsm
  328.   end
  329.  
  330.   #--------------------------------------------------------------------------
  331.   # new method: load_notetags_bsm
  332.   #--------------------------------------------------------------------------
  333.   def self.load_notetags_bsm
  334.     groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
  335.       $data_enemies, $data_states, $data_skills, $data_items]
  336.     for group in groups
  337.       for obj in group
  338.         next if obj.nil?
  339.         obj.load_notetags_bsm
  340.       end
  341.     end
  342.   end
  343.  
  344. end # DataManager
  345.  
  346. #==============================================================================
  347. # ■ RPG::BaseItem
  348. #==============================================================================
  349.  
  350. class RPG::BaseItem
  351.  
  352.   #--------------------------------------------------------------------------
  353.   # public instance variables
  354.   #--------------------------------------------------------------------------
  355.   attr_accessor :max_buff
  356.   attr_accessor :max_debuff
  357.   attr_accessor :change_state_turns
  358.   attr_accessor :state_reapply_rules
  359.  
  360.   #--------------------------------------------------------------------------
  361.   # common cache: load_notetags_bsm
  362.   #--------------------------------------------------------------------------
  363.   def load_notetags_bsm
  364.     @change_state_turns = {}
  365.     @max_buff = {
  366.       0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0 }
  367.     @max_debuff = {
  368.       0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0 }
  369.     if self.is_a?(RPG::State)
  370.       @state_reapply_rules = YEA::BUFF_STATE_MANAGER::REAPPLY_STATE_RULES
  371.     end
  372.     #---
  373.     self.note.split(/[\r\n]+/).each { |line|
  374.       case line
  375.       #---
  376.       when YEA::REGEXP::BASEITEM::MAX_BUFF
  377.         case $1.upcase
  378.         when "MAXHP", "MHP", "HP"
  379.           @max_buff[0] = $2.to_i
  380.         when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP"
  381.           @max_buff[1] = $2.to_i
  382.         when "ATK"
  383.           @max_buff[2] = $2.to_i
  384.         when "DEF"
  385.           @max_buff[3] = $2.to_i
  386.         when "MAT", "INT", "SPI"
  387.           @max_buff[4] = $2.to_i
  388.         when "MDF", "RES"
  389.           @max_buff[5] = $2.to_i
  390.         when "AGI"
  391.           @max_buff[6] = $2.to_i
  392.         when "LUK"
  393.           @max_buff[7] = $2.to_i
  394.         when "ALL"
  395.           for i in 0...8; @max_buff[i] = $2.to_i; end
  396.         end
  397.       #---
  398.       when YEA::REGEXP::BASEITEM::MAX_DEBUFF
  399.         case $1.upcase
  400.         when "MAXHP", "MHP", "HP"
  401.           @max_debuff[0] = $2.to_i
  402.         when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP"
  403.           @max_debuff[1] = $2.to_i
  404.         when "ATK"
  405.           @max_debuff[2] = $2.to_i
  406.         when "DEF"
  407.           @max_debuff[3] = $2.to_i
  408.         when "MAT", "INT", "SPI"
  409.           @max_debuff[4] = $2.to_i
  410.         when "MDF", "RES"
  411.           @max_debuff[5] = $2.to_i
  412.         when "AGI"
  413.           @max_debuff[6] = $2.to_i
  414.         when "LUK"
  415.           @max_debuff[7] = $2.to_i
  416.         when "ALL"
  417.           for i in 0...8; @max_debuff[i] = $2.to_i; end
  418.         end
  419.       #---
  420.       when YEA::REGEXP::BASEITEM::CHANGE_STATE_TURN
  421.         @change_state_turns[$1.to_i] = $2.to_i
  422.       #---
  423.       when YEA::REGEXP::BASEITEM::STATE_REAPPLY_IGNORE
  424.         next unless self.is_a?(RPG::State)
  425.         @state_reapply_rules = 0
  426.       when YEA::REGEXP::BASEITEM::STATE_REAPPLY_RESET
  427.         next unless self.is_a?(RPG::State)
  428.         @state_reapply_rules = 1
  429.       when YEA::REGEXP::BASEITEM::STATE_REAPPLY_TOTAL
  430.         next unless self.is_a?(RPG::State)
  431.         @state_reapply_rules = 2
  432.       #---
  433.       end
  434.     } # self.note.split
  435.     #---
  436.   end
  437.  
  438. end # RPG::BaseItem
  439.  
  440. #==============================================================================
  441. # ■ RPG::UsableItem
  442. #==============================================================================
  443.  
  444. class RPG::UsableItem < RPG::BaseItem
  445.  
  446.   #--------------------------------------------------------------------------
  447.   # public instance variables
  448.   #--------------------------------------------------------------------------
  449.   attr_accessor :change_state_turns
  450.   attr_accessor :change_buff_turns
  451.   attr_accessor :change_debuff_turns
  452.  
  453.   #--------------------------------------------------------------------------
  454.   # common cache: load_notetags_bsm
  455.   #--------------------------------------------------------------------------
  456.   def load_notetags_bsm
  457.     @change_state_turns = {}
  458.     @change_buff_turns = {}
  459.     @change_debuff_turns = {}
  460.     #---
  461.     self.note.split(/[\r\n]+/).each { |line|
  462.       case line
  463.       #---
  464.       when YEA::REGEXP::USABLEITEM::CHANGE_STATE_TURN
  465.         @change_state_turns[$1.to_i] = $2.to_i
  466.       when YEA::REGEXP::USABLEITEM::CHANGE_BUFF_TURN
  467.         case $1.upcase
  468.         when "MAXHP", "MHP", "HP"
  469.           @change_buff_turns[0] = $2.to_i
  470.         when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP"
  471.           @change_buff_turns[1] = $2.to_i
  472.         when "ATK"
  473.           @change_buff_turns[2] = $2.to_i
  474.         when "DEF"
  475.           @change_buff_turns[3] = $2.to_i
  476.         when "MAT", "INT", "SPI"
  477.           @change_buff_turns[4] = $2.to_i
  478.         when "MDF", "RES"
  479.           @change_buff_turns[5] = $2.to_i
  480.         when "AGI"
  481.           @change_buff_turns[6] = $2.to_i
  482.         when "LUK"
  483.           @change_buff_turns[7] = $2.to_i
  484.         when "ALL"
  485.           for i in 0...8; @change_buff_turns[i] = $2.to_i; end
  486.         end
  487.       when YEA::REGEXP::USABLEITEM::CHANGE_DEBUFF_TURN
  488.         case $1.upcase
  489.         when "MAXHP", "MHP", "HP"
  490.           @change_debuff_turns[0] = $2.to_i
  491.         when "MAXMP", "MMP", "MP", "MAXSP", "SP", "MSP"
  492.           @change_debuff_turns[1] = $2.to_i
  493.         when "ATK"
  494.           @change_debuff_turns[2] = $2.to_i
  495.         when "DEF"
  496.           @change_debuff_turns[3] = $2.to_i
  497.         when "MAT", "INT", "SPI"
  498.           @change_debuff_turns[4] = $2.to_i
  499.         when "MDF", "RES"
  500.           @change_debuff_turns[5] = $2.to_i
  501.         when "AGI"
  502.           @change_debuff_turns[6] = $2.to_i
  503.         when "LUK"
  504.           @change_debuff_turns[7] = $2.to_i
  505.         when "ALL"
  506.           for i in 0...8; @change_debuff_turns[i] = $2.to_i; end
  507.         end
  508.       end
  509.     } # self.note.split
  510.     #---
  511.   end
  512.  
  513. end # class RPG::UsableItem
  514.  
  515. #==============================================================================
  516. # ■ Game_BattlerBase
  517. #==============================================================================
  518.  
  519. class Game_BattlerBase
  520.  
  521.   #--------------------------------------------------------------------------
  522.   # overwrite method: param_buff_rate
  523.   #--------------------------------------------------------------------------
  524.   def param_buff_rate(param_id)
  525.     return eval(YEA::BUFF_STATE_MANAGER::BUFF_BOOST_FORMULA)
  526.   end
  527.  
  528.   #--------------------------------------------------------------------------
  529.   # new method: max_buff_limit
  530.   #--------------------------------------------------------------------------
  531.   def max_buff_limit(param_id)
  532.     n = YEA::BUFF_STATE_MANAGER::DEFAULT_BUFF_LIMIT
  533.     if actor?
  534.       n += self.actor.max_buff[param_id]
  535.       n += self.class.max_buff[param_id]
  536.       for equip in equips
  537.         next if equip.nil?
  538.         n += equip.max_buff[param_id]
  539.       end
  540.     else
  541.       n += self.enemy.max_buff[param_id]
  542.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  543.         n += self.class.max_buff[param_id]
  544.       end
  545.     end
  546.     for state in states
  547.       next if state.nil?
  548.       n += state.max_buff[param_id]
  549.     end
  550.     return [[n.to_i, 0].max, YEA::BUFF_STATE_MANAGER::MAXIMUM_BUFF_LIMIT].min
  551.   end
  552.  
  553.   #--------------------------------------------------------------------------
  554.   # new method: max_debuff_limit
  555.   #--------------------------------------------------------------------------
  556.   def max_debuff_limit(param_id)
  557.     n = YEA::BUFF_STATE_MANAGER::DEFAULT_BUFF_LIMIT
  558.     if actor?
  559.       n += self.actor.max_debuff[param_id]
  560.       n += self.class.max_debuff[param_id]
  561.       for equip in equips
  562.         next if equip.nil?
  563.         n += equip.max_debuff[param_id]
  564.       end
  565.     else
  566.       n += self.enemy.max_debuff[param_id]
  567.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  568.         n += self.class.max_debuff[param_id]
  569.       end
  570.     end
  571.     for state in states
  572.       next if state.nil?
  573.       n += state.max_debuff[param_id]
  574.     end
  575.     return [[n.to_i, 0].max, YEA::BUFF_STATE_MANAGER::MAXIMUM_BUFF_LIMIT].min
  576.   end
  577.  
  578.   #--------------------------------------------------------------------------
  579.   # overwrite method: buff_icon_index
  580.   #--------------------------------------------------------------------------
  581.   def buff_icon_index(buff_level, param_id)
  582.     if buff_level > 0
  583.       return ICON_BUFF_START + ([buff_level - 1, 1].min) * 8 + param_id
  584.     elsif buff_level < 0
  585.       return ICON_DEBUFF_START + ([-buff_level - 1, -1].max) * 8 + param_id
  586.     else
  587.       return 0
  588.     end
  589.   end
  590.  
  591.   #--------------------------------------------------------------------------
  592.   # new method: buff_turns
  593.   #--------------------------------------------------------------------------
  594.   def buff_turns(param_id)
  595.     return @buff_turns.include?(param_id) ? @buff_turns[param_id] : 0
  596.   end
  597.  
  598.   #--------------------------------------------------------------------------
  599.   # new method: buff_level
  600.   #--------------------------------------------------------------------------
  601.   def buff_level(param_id)
  602.     return 0 if @buffs[param_id].nil?
  603.     buff_maximum = max_buff_limit(param_id)
  604.     debuff_maximum = max_debuff_limit(param_id)
  605.     return [[@buffs[param_id], buff_maximum].min, -debuff_maximum].max
  606.   end
  607.  
  608.   #--------------------------------------------------------------------------
  609.   # new method: buff_change_turns
  610.   #--------------------------------------------------------------------------
  611.   def buff_change_turns(param_id, value)
  612.     @buff_turns[param_id] = 0 if @buff_turns[param_id].nil?
  613.     @buff_turns[param_id] = [value, 0].max
  614.   end
  615.  
  616.   #--------------------------------------------------------------------------
  617.   # new method: state_turns
  618.   #--------------------------------------------------------------------------
  619.   def state_turns(state_id)
  620.     state_id = state_id.id if state_id.is_a?(RPG::State)
  621.     return @state_turns.include?(state_id) ? @state_turns[state_id] : 0
  622.   end
  623.  
  624.   #--------------------------------------------------------------------------
  625.   # new method: state_steps
  626.   #--------------------------------------------------------------------------
  627.   def state_steps(state_id)
  628.     state_id = state_id.id if state_id.is_a?(RPG::State)
  629.     return @state_steps.include?(state_id) ? @state_steps[state_id] : 0
  630.   end
  631.  
  632.   #--------------------------------------------------------------------------
  633.   # new method: state_change_turns
  634.   #--------------------------------------------------------------------------
  635.   def state_change_turns(state_id, value)
  636.     state_id = state_id.id if state_id.is_a?(RPG::State)
  637.     @state_turns[state_id] = 0 if @state_turns[state_id].nil?
  638.     @state_turns[state_id] = [value, 0].max
  639.   end
  640.  
  641.   #--------------------------------------------------------------------------
  642.   # new method: state_turn_mod
  643.   #--------------------------------------------------------------------------
  644.   def state_turn_mod(state_id)
  645.     return 0 if $data_states[state_id].nil?
  646.     state = $data_states[state_id]
  647.     n = state.min_turns + rand(1 + [state.max_turns - state.min_turns, 0].max)
  648.     if actor?
  649.       if self.actor.change_state_turns.include?(state_id)
  650.         n += self.actor.change_state_turns[state_id]
  651.       end
  652.       if self.class.change_state_turns.include?(state_id)
  653.         n += self.class.change_state_turns[state_id]
  654.       end
  655.       for equip in equips
  656.         next if equip.nil?
  657.         next unless equip.change_state_turns.include?(state_id)
  658.         n += equip.change_state_turns[state_id]
  659.       end
  660.     else
  661.       if self.enemy.change_state_turns.include?(state_id)
  662.         n += self.enemy.change_state_turns[state_id]
  663.       end
  664.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  665.         if self.class.change_state_turns.include?(state_id)
  666.           n += self.class.change_state_turns[state_id]
  667.         end
  668.       end
  669.     end
  670.     for state in states
  671.       next if state.nil?
  672.       next unless state.change_state_turns.include?(state_id)
  673.       n += state.change_state_turns[state_id]
  674.     end
  675.     return [n, 0].max
  676.   end
  677.  
  678. end # Game_BattlerBase
  679.  
  680. #==============================================================================
  681. # ■ Game_Battler
  682. #==============================================================================
  683.  
  684. class Game_Battler < Game_BattlerBase
  685.  
  686.   #--------------------------------------------------------------------------
  687.   # overwrite method: buff_max?
  688.   #--------------------------------------------------------------------------
  689.   def buff_max?(param_id)
  690.     return @buffs[param_id] == max_buff_limit(param_id)
  691.   end
  692.  
  693.   #--------------------------------------------------------------------------
  694.   # overwrite method: debuff_max?
  695.   #--------------------------------------------------------------------------
  696.   def debuff_max?(param_id)
  697.     return @buffs[param_id] == -max_debuff_limit(param_id)
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # overwrite method: add_state
  702.   #--------------------------------------------------------------------------
  703.   def add_state(state_id)
  704.     return if $data_states[state_id].nil?
  705.     state_rules = $data_states[state_id].state_reapply_rules
  706.     return if state_rules == 0 && state?(state_id)
  707.     if state_addable?(state_id)
  708.       add_new_state(state_id) unless state?(state_id)
  709.       reset_state_counts(state_id) if state_rules == 1
  710.       total_state_counts(state_id) if state_rules == 2
  711.       @result.added_states.push(state_id).uniq!
  712.     end
  713.   end
  714.  
  715.   #--------------------------------------------------------------------------
  716.   # overwrite method: state_removed?
  717.   #--------------------------------------------------------------------------
  718.   def state_removed?(state_id)
  719.     return false
  720.   end
  721.  
  722.   #--------------------------------------------------------------------------
  723.   # overwrite method: reset_state_counts
  724.   #--------------------------------------------------------------------------
  725.   def reset_state_counts(state_id)
  726.     state = $data_states[state_id]
  727.     @state_turns[state_id] = state_turn_mod(state_id)
  728.     @state_steps[state_id] = state.steps_to_remove
  729.   end
  730.  
  731.   #--------------------------------------------------------------------------
  732.   # new method: total_state_counts
  733.   #--------------------------------------------------------------------------
  734.   def total_state_counts(state_id)
  735.     state = $data_states[state_id]
  736.     value = state_turn_mod(state_id)
  737.     state_change_turns(state_id, value + state_turns(state_id))
  738.   end
  739.  
  740.   #--------------------------------------------------------------------------
  741.   # alias method: item_user_effect
  742.   #--------------------------------------------------------------------------
  743.   alias game_battler_item_user_effect_bsm item_user_effect
  744.   def item_user_effect(user, item)
  745.     game_battler_item_user_effect_bsm(user, item)
  746.     apply_state_turn_changes(user, item)
  747.     apply_buff_turn_changes(user, item)
  748.     apply_debuff_turn_changes(user, item)
  749.   end
  750.  
  751.   #--------------------------------------------------------------------------
  752.   # new method: apply_state_turn_changes
  753.   #--------------------------------------------------------------------------
  754.   def apply_state_turn_changes(user, item)
  755.     return if item.nil?
  756.     return unless $game_party.in_battle
  757.     for key in item.change_state_turns
  758.       state_id = key[0]
  759.       next if field_state?(state_id)
  760.       next unless state?(state_id)
  761.       next unless $data_states[state_id].auto_removal_timing > 0
  762.       state_change_turns(state_id, key[1] + state_turns(state_id))
  763.       remove_state(state_id) if state_turns(state_id) <= 0
  764.       @result.success = true
  765.     end
  766.   end
  767.  
  768.   #--------------------------------------------------------------------------
  769.   # new method: field_state?
  770.   #--------------------------------------------------------------------------
  771.   def field_state?(state_id)
  772.     return false unless $imported["YEA-FieldStateEffects"]
  773.     return false unless $game_party.in_battle
  774.     return false unless SceneManager.scene_is?(Scene_Battle)
  775.     return BattleManager.field_state?(state_id)
  776.   end
  777.  
  778.   #--------------------------------------------------------------------------
  779.   # new method: apply_buff_turn_changes
  780.   #--------------------------------------------------------------------------
  781.   def apply_buff_turn_changes(user, item)
  782.     return if item.nil?
  783.     return unless $game_party.in_battle
  784.     for key in item.change_buff_turns
  785.       param_id = key[0]
  786.       next unless buff?(param_id)
  787.       buff_change_turns(param_id, key[1] + buff_turns(param_id))
  788.       remove_buff(param_id) if buff_turns(param_id) < 0
  789.       @result.success = true
  790.     end
  791.   end
  792.  
  793.   #--------------------------------------------------------------------------
  794.   # new method: apply_debuff_turn_changes
  795.   #--------------------------------------------------------------------------
  796.   def apply_debuff_turn_changes(user, item)
  797.     return if item.nil?
  798.     return unless $game_party.in_battle
  799.     for key in item.change_debuff_turns
  800.       param_id = key[0]
  801.       next unless debuff?(param_id)
  802.       buff_change_turns(param_id, key[1] + buff_turns(param_id))
  803.       remove_buff(param_id) if buff_turns(param_id) < 0
  804.       @result.success = true
  805.     end
  806.   end
  807.  
  808. end # Game_Battler
  809.  
  810. #==============================================================================
  811. # ■ Window_Base
  812. #==============================================================================
  813.  
  814. class Window_Base < Window
  815.  
  816.   #--------------------------------------------------------------------------
  817.   # alias method: draw_actor_icons
  818.   #--------------------------------------------------------------------------
  819.   alias window_base_draw_actor_icons_bsm draw_actor_icons
  820.   def draw_actor_icons(actor, dx, dy, dw = 96)
  821.     window_base_draw_actor_icons_bsm(actor, dx, dy, dw)
  822.     draw_actor_icon_turns(actor, dx, dy, dw)
  823.   end
  824.  
  825.   #--------------------------------------------------------------------------
  826.   # new method: draw_actor_icon_turns
  827.   #--------------------------------------------------------------------------
  828.   def draw_actor_icon_turns(actor, dx, dy, dw)
  829.     return unless YEA::BUFF_STATE_MANAGER::SHOW_REMAINING_TURNS
  830.     return unless SceneManager.scene_is?(Scene_Battle)
  831.     reset_font_settings
  832.     contents.font.out_color.alpha = 255
  833.     contents.font.bold = true
  834.     contents.font.size = YEA::BUFF_STATE_MANAGER::TURNS_REMAINING_SIZE
  835.     bx = dx
  836.     dy += YEA::BUFF_STATE_MANAGER::TURNS_REMAINING_Y
  837.     #---
  838.     for state in actor.states
  839.       break if dx + 24 >= dw + bx
  840.       next if state.icon_index <= 0
  841.       turns = actor.state_turns(state.id).to_i
  842.       if $imported["YEA-FieldStateEffects"] &&
  843.       BattleManager.field_state?(state.id)
  844.         turns = BattleManager.field_state_turns(state.id)
  845.       end
  846.       if state.auto_removal_timing > 0 && turns < 100
  847.         draw_text(dx, dy, 24, line_height, turns, 2)
  848.       end
  849.       dx += 24
  850.     end
  851.     #---
  852.     for i in 0...8
  853.       break if dx + 24 >= dw + bx
  854.       next if actor.buff_icon_index(actor.buff_level(i), i) == 0
  855.       turns = actor.buff_turns(i).to_i
  856.       draw_text(dx, dy, 24, line_height, turns, 2) if turns < 100
  857.       dx += 24
  858.     end
  859.     #---
  860.     contents.font.out_color = Font.default_out_color
  861.     reset_font_settings
  862.   end
  863.  
  864. end # Window_Base
  865.  
  866. #==============================================================================
  867. #
  868. # ▼ End of File
  869. #
  870. #==============================================================================
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
285
在线时间
17 小时
注册时间
2020-8-2
帖子
11
3
 楼主| 发表于 2020-8-27 15:35:05 | 只看该作者
alexncf125 发表于 2020-8-27 13:50
https://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/buff-state-manager/
唔...我没在用...有问 ...

谢谢你了,就是要的这个,上次给弄丢了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-16 04:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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