Project1

标题: 某装备装上自动附加某个状态,装备卸下后状态消除? [打印本页]

作者: shengfeng    时间: 2017-7-13 18:56
标题: 某装备装上自动附加某个状态,装备卸下后状态消除?
请求好心人
作者: 300英雄    时间: 2017-7-13 20:15
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Passive States v1.02
  4. # -- Last Updated: 2012.01.23
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-PassiveStates"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.01.23 - Compatibility Update: Doppelganger
  15. # 2012.01.08 - Added passive state checks for adding/removing states.
  16. # 2011.12.14 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # This script allows for actors, classes, weapons, armours, and enemies to have
  22. # passives that are based off of states. Passive states will be active at all
  23. # times and are immune to restrictions and will only disappear if the battler
  24. # dies. Once the battler revives, the passives will return.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Actor Notetags - These notetags go in the actors notebox in the database.
  34. # -----------------------------------------------------------------------------
  35. # <passive state: x>
  36. # <passive state: x, x>
  37. # This will cause state x to be always on (unless the battler is dead). To have
  38. # multiple passives, insert multiples of this notetag.
  39. #
  40. # -----------------------------------------------------------------------------
  41. # Class Notetags - These notetags go in the class notebox in the database.
  42. # -----------------------------------------------------------------------------
  43. # <passive state: x>
  44. # <passive state: x, x>
  45. # This will cause state x to be always on (unless the battler is dead). To have
  46. # multiple passives, insert multiples of this notetag.
  47. #
  48. # -----------------------------------------------------------------------------
  49. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  50. # -----------------------------------------------------------------------------
  51. # <passive state: x>
  52. # <passive state: x, x>
  53. # This will cause state x to be always on (unless the battler is dead). To have
  54. # multiple passives, insert multiples of this notetag.
  55. #
  56. # -----------------------------------------------------------------------------
  57. # Armour Notetags - These notetags go in the armours notebox in the database.
  58. # -----------------------------------------------------------------------------
  59. # <passive state: x>
  60. # <passive state: x, x>
  61. # This will cause state x to be always on (unless the battler is dead). To have
  62. # multiple passives, insert multiples of this notetag.
  63. #
  64. # -----------------------------------------------------------------------------
  65. # Enemy Notetags - These notetags go in the enemies notebox in the database.
  66. # -----------------------------------------------------------------------------
  67. # <passive state: x>
  68. # <passive state: x, x>
  69. # This will cause state x to be always on (unless the battler is dead). To have
  70. # multiple passives, insert multiples of this notetag.
  71. #
  72. #==============================================================================
  73. # ▼ Compatibility
  74. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  75. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  76. # it will run with RPG Maker VX without adjusting.
  77. #
  78. #==============================================================================
  79. # ▼ Editting anything past this point may potentially result in causing
  80. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  81. # halitosis so edit at your own risk.
  82. #==============================================================================

  83. module YEA
  84.   module REGEXP
  85.   module BASEITEM
  86.    
  87.     PASSIVE_STATE =
  88.       /<(?:PASSIVE_STATE|passive state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  89.    
  90.   end # BASEITEM
  91.   end # REGEXP
  92. end # YEA

  93. #==============================================================================
  94. # ■ DataManager
  95. #==============================================================================

  96. module DataManager
  97.   
  98.   #--------------------------------------------------------------------------
  99.   # alias method: load_database
  100.   #--------------------------------------------------------------------------
  101.   class <<self; alias load_database_pst load_database; end
  102.   def self.load_database
  103.     load_database_pst
  104.     load_notetags_pst
  105.   end
  106.   
  107.   #--------------------------------------------------------------------------
  108.   # new method: load_notetags_pst
  109.   #--------------------------------------------------------------------------
  110.   def self.load_notetags_pst
  111.     groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
  112.       $data_enemies]
  113.     for group in groups
  114.       for obj in group
  115.         next if obj.nil?
  116.         obj.load_notetags_pst
  117.       end
  118.     end
  119.   end
  120.   
  121. end # DataManager

  122. #==============================================================================
  123. # ■ RPG::BaseItem
  124. #==============================================================================

  125. class RPG::BaseItem
  126.   
  127.   #--------------------------------------------------------------------------
  128.   # public instance variables
  129.   #--------------------------------------------------------------------------
  130.   attr_accessor :passive_states
  131.   
  132.   #--------------------------------------------------------------------------
  133.   # common cache: load_notetags_pst
  134.   #--------------------------------------------------------------------------
  135.   def load_notetags_pst
  136.     @passive_states = []
  137.     #---
  138.     self.note.split(/[\r\n]+/).each { |line|
  139.       case line
  140.       #---
  141.       when YEA::REGEXP::BASEITEM::PASSIVE_STATE
  142.         $1.scan(/\d+/).each { |num|
  143.         @passive_states.push(num.to_i) if num.to_i > 0 }
  144.       #---
  145.       end
  146.     } # self.note.split
  147.     #---
  148.   end
  149.   
  150. end # RPG::BaseItem

  151. #==============================================================================
  152. # ■ Game_BattlerBase
  153. #==============================================================================

  154. class Game_BattlerBase
  155.   
  156.   #--------------------------------------------------------------------------
  157.   # alias method: state?
  158.   #--------------------------------------------------------------------------
  159.   alias game_battlerbase_state_check_pst state?
  160.   def state?(state_id)
  161.     return true if passive_state?(state_id)
  162.     return game_battlerbase_state_check_pst(state_id)
  163.   end
  164.   
  165.   #--------------------------------------------------------------------------
  166.   # alias method: states
  167.   #--------------------------------------------------------------------------
  168.   alias game_battlerbase_states_pst states
  169.   def states
  170.     array = game_battlerbase_states_pst
  171.     array |= passive_states
  172.     return array
  173.   end
  174.   
  175.   #--------------------------------------------------------------------------
  176.   # new method: passive_state?
  177.   #--------------------------------------------------------------------------
  178.   def passive_state?(state_id)
  179.     @passive_states = [] if @passive_states.nil?
  180.     return @passive_states.include?(state_id)
  181.   end
  182.   
  183.   #--------------------------------------------------------------------------
  184.   # new method: passive_states
  185.   #--------------------------------------------------------------------------
  186.   def passive_states
  187.     array = []
  188.     if actor?
  189.       for state_id in self.actor.passive_states
  190.         array.push($data_states[state_id]) if passive_state_addable?(state_id)
  191.       end
  192. #~       for state_id in self.skills.passive_states
  193. #~         array.push($data_states[state_id]) if passive_state_addable?(state_id)
  194. #~       end
  195.       for state_id in self.class.passive_states
  196.         array.push($data_states[state_id]) if passive_state_addable?(state_id)
  197.       end
  198.       for equip in equips
  199.         next if equip.nil?
  200.         for state_id in equip.passive_states
  201.           array.push($data_states[state_id]) if passive_state_addable?(state_id)
  202.         end
  203.       end
  204.     else # enemy
  205.       for state_id in self.enemy.passive_states
  206.         array.push($data_states[state_id]) if passive_state_addable?(state_id)
  207.       end
  208.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  209.         for state_id in self.class.passive_states
  210.           array.push($data_states[state_id]) if passive_state_addable?(state_id)
  211.         end
  212.       end
  213.     end
  214.     create_passive_state_array(array)
  215.     sort_passive_states(array)
  216.     set_passive_state_turns(array)
  217.     return array
  218.   end
  219.   
  220.   #--------------------------------------------------------------------------
  221.   # new method: create_passive_state_array
  222.   #--------------------------------------------------------------------------
  223.   def create_passive_state_array(array)
  224.     @passive_states = []
  225.     for state in array
  226.       @passive_states.push(state.id)
  227.     end
  228.   end
  229.   
  230.   #--------------------------------------------------------------------------
  231.   # new method: passive_state_addable?
  232.   #--------------------------------------------------------------------------
  233.   def passive_state_addable?(state_id)
  234.     return false if $data_states[state_id].nil?
  235.     return alive?
  236.   end
  237.   
  238.   #--------------------------------------------------------------------------
  239.   # new method: set_passive_state_turns
  240.   #--------------------------------------------------------------------------
  241.   def sort_passive_states(array)
  242.     array.sort! do |state_a, state_b|
  243.       if state_a.priority != state_b.priority
  244.         state_b.priority <=> state_a.priority
  245.       else
  246.         state_a.id <=> state_b.id
  247.       end
  248.     end
  249.     return array
  250.   end
  251.   
  252.   #--------------------------------------------------------------------------
  253.   # new method: set_passive_state_turns
  254.   #--------------------------------------------------------------------------
  255.   def set_passive_state_turns(array)
  256.     for state in array
  257.       @state_turns[state.id] = 0 unless @states.include?(state.id)
  258.       @state_steps[state.id] = 0 unless @states.include?(state.id)
  259.     end
  260.   end
  261.   
  262. end # Game_BattlerBase

  263. #==============================================================================
  264. # ■ Game_Battler
  265. #==============================================================================

  266. class Game_Battler < Game_BattlerBase
  267.   
  268.   #--------------------------------------------------------------------------
  269.   # alias method: state_addable?
  270.   #--------------------------------------------------------------------------
  271.   alias game_battler_state_addable_ps state_addable?
  272.   def state_addable?(state_id)
  273.     return false if passive_state?(state_id)
  274.     return game_battler_state_addable_ps(state_id)
  275.   end
  276.   
  277.   #--------------------------------------------------------------------------
  278.   # alias method: remove_state
  279.   #--------------------------------------------------------------------------
  280.   alias game_battler_remove_state_ps remove_state
  281.   def remove_state(state_id)
  282.     return if passive_state?(state_id)
  283.     game_battler_remove_state_ps(state_id)
  284.   end
  285.   
  286. end # Game_Battler

  287. #==============================================================================
  288. #
  289. # ▼ End of File
  290. #
  291. #==============================================================================
复制代码

除了技能不行,其他都可以,不知道为什么,技能难做还是怎么的,故意没有技能。
<passive state: x>写在除了技能以外的备注栏里面。<passive state: x,y,z>可多写的。随你写多少。
作者: shengfeng    时间: 2017-7-13 20:21
Ⅹ是不是代表状态的编号
作者: 15968715431    时间: 2017-7-14 09:38
本帖最后由 15968715431 于 2017-7-14 09:40 编辑

https://rpg.blue/thread-343892-1-1.html
   可以用这个。光环技能。  战斗开始直接附加状态。  对敌人、角色都有效果。 全体。

只要学会指定技能。就会施放。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1