查看: 3508|回复: 3

[已经过期] 求解这段脚本为毛不生效

[复制链接]
梦石
0
星屑
61
在线时间
696 小时
注册时间
2011-1-4
回帖
176
发表于 2013-1-14 22:18:16 | 显示全部楼层 |阅读模式

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

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

×
这是个给技能装备上crystal的脚本
其中这段,作为一个脚本小白看了好久觉得应该是
当技能能够装备crystal时,槽里装上该crystal,队伍物品栏扣除该crystal一个并且获得原先槽里的crystal一个。
但是实际上发现在槽里已经有crystal后再装备一个新的crystal来替换掉时,只会更换装备并不会获得原先的那个crystal
  1.   def add_grathnode(skill, crystal, slot)
  2.     if @installs[skill.id].nil?
  3.       @installs[skill.id] = Array.new(skill.grathnode_slots, nil)
  4.     elsif @installs[skill.id][slot] != nil
  5.       $game_party.gain_item(@installs[skill.id][slot], 1)
  6.     end
  7.     $game_party.lose_item(crystal, 1) unless crystal.nil?
  8.     @installs[skill.id][slot] = crystal.nil? ? nil : crystal.id
  9.   end
复制代码

点评

提问请不要非法转载脚本!!!!!这个脚本是禁止转载的!!!!!!  发表于 2013-1-20 05:03
梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2013-1-15 11:52:41 | 显示全部楼层
还是发个范例吧。光看这个method是找不到问题的。

点评

英文盲坐等回复……  发表于 2013-1-16 22:43
回复

使用道具 举报

梦石
0
星屑
61
在线时间
696 小时
注册时间
2011-1-4
回帖
176
 楼主| 发表于 2013-1-16 18:13:05 | 显示全部楼层
Sion 发表于 2013-1-15 11:52
还是发个范例吧。光看这个method是找不到问题的。
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Grathnode Install
  3. #  Author: Kread-EX
  4. #  Version 1.12
  5. #  Release date: 31/12/2011
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

  7. #------------------------------------------------------------------------------
  8. #  ▼ UPDATES
  9. #------------------------------------------------------------------------------
  10. # # 28/12/2012. Fixed another bug with savefiles.
  11. # # 30/01/2012. Added option to disable grathnode menu for certain characters.
  12. # # 30/01/2012. Added option to remove grathnodes when a skill is forgetted.
  13. # # 20/01/2012. Compatibility fix.
  14. # # 19/01/2012. Loads of compatibility fixes.
  15. # # 14/01/2012. Fixed two crashing bugs with the DBS implementation.
  16. # # 10/01/2012. <max_grathnodes: 0> now works.
  17. # # 07/01/2012. Fixed a critical bug preventing the installs to be saved.
  18. # # 05/01/2012. Fixed a crashing bug in the Install menu if no skill is
  19. # # available.
  20. # # 01/01/2012. Fixed compatibility with Yanfly's TP Manager (thanks Adalwulf)
  21. # # NOW DEPRECATED. Use Yanfly's Ace Skill Menu to ensure compat. However, in
  22. # # case you don't want to, just uncomment the code at the end of the script.
  23. #------------------------------------------------------------------------------
  24. #  ▼ TERMS OF USAGE
  25. #------------------------------------------------------------------------------
  26. # #  You are free to adapt this work to suit your needs.
  27. # #  You can use this work for commercial purposes if you like it.
  28. # #  Credit is appreciated.
  29. # #
  30. # # For support:
  31. # # grimoirecastle.wordpress.com
  32. # # rpgmakerweb.com
  33. #------------------------------------------------------------------------------
  34. #  ▼ INTRODUCTION
  35. #------------------------------------------------------------------------------
  36. # # This script is inspired from the Ar Tonelico series. In a nutshell,
  37. # # it allows the player to assign special items called Grathnode crystals to
  38. # # skills in order to add special effects.
  39. # # The upgrades are actor-dependant: if two actors have the same skill, they
  40. # # can use a different set of crystals.
  41. #------------------------------------------------------------------------------
  42. #  ▼ INSTRUCTIONS
  43. #------------------------------------------------------------------------------
  44. # # First, you need to create the desired grathnode crystals. They are regular
  45. # # items, but tagged as <grathnode> in their notebox.
  46. # # Certain grathnodes are suited only for a certain type of skill. To ensure
  47. # # that a defensive skill doesn't use an offensive effect, you can choose
  48. # # the kind of scope:
  49. # # <scope: string> in the item notebox.
  50. # # String can be different values:
  51. # # for_opponent?
  52. # # for_friend?
  53. # # for_dead_friend?
  54. # # for_user?
  55. # # for_all?
  56. # #
  57. # # Every skill can contain up to 6 crystals by default, but you can lower the
  58. # # number either individually (by putting <max_grathnodes: x> if the skill
  59. # # notebox, or globally by altering the ABSOLUTE_MAX_GRATHNODES value within
  60. # # the script.
  61. # #
  62. # # The scene can be called with SceneManager.call(Scene_Grathnode), however
  63. # # I strongly recommend you to use Yanfly's Ace Menu Engine, as I prepared
  64. # # special compatibility for it.
  65. #------------------------------------------------------------------------------
  66. #  ▼ COMPATIBILITY
  67. #------------------------------------------------------------------------------
  68. # # Works with Yanfly's Battle Engine Ace. Actually, it may work better than with
  69. # # the DBS, thanks to the nice pop-ups, very GUST-ish at the conception.
  70. # #
  71. # # List of aliases and overwrites:
  72. # #
  73. # # DataManager
  74. # # load_database (alias)
  75. # # load_grathnode_notetags (new method)
  76. # #
  77. # # RPG::Item
  78. # # load_grathnode_notetags (new method)
  79. # # is_grathnode? (new method)
  80. # # grathnode_scope (new attr method)
  81. # # mp_inflation (new attr method)
  82. # # tp_inflation (new attr method)
  83. # #
  84. # # RPG::Skill
  85. # # load_grathnode_notetags (new method)
  86. # # grathnode_slots (new method)
  87. # #
  88. # # Game_Actor
  89. # # installs (new attr method)
  90. # # barring_grathnode (new attr method)
  91. # # setup (alias)
  92. # # forget_skill (alias)
  93. # # add_grathnode (new method)
  94. # # skill_mp_cost (new child method)
  95. # # skill_tp_cost (new child method)
  96. # # process_grathnode_mp_cost (new method)
  97. # # process_grathnode_tp_cost (new method)
  98. # #
  99. # # Game_Party
  100. # # last_selected_skill (new attr method)
  101. # # menu_actor (alias)
  102. # # menu_actor_next (alias)
  103. # # menu_actor_prev (alias)
  104. # #
  105. # # Scene_Grathnode (new class)
  106. # #
  107. # # Window_UpSkillList (new class)
  108. # #
  109. # # Window_GrathnodeList (new class)
  110. # #
  111. # # Window_GrathnodeInstall (new class)
  112. # #
  113. # # Scene_Battle
  114. # # apply_item_effects (alias)
  115. # # apply_grathnode_effects (new method - YEA Battle Engine only)
  116. #------------------------------------------------------------------------------

  117. ($imported || {})['KRX-GrathnodeInstall'] = true

  118. puts 'Load: Grathnode Install v1.12 by Kread-EX'

  119. module KRX
  120. #===========================================================================
  121. # ■ CONFIGURATION
  122. #===========================================================================
  123.   ABSOLUTE_MAX_GRATHNODES = 5
  124.   CLEAR_FORGET_SKILL = true
  125.   SINGLE_ACTOR_INSTALL = false
  126.   SINGLE_ACTOR_INSTALL_ID = 9
  127.   
  128.   module VOCAB
  129.     GRATHNODE = 'Grathnode'
  130.   end
  131. #===========================================================================
  132. # ■ CONFIGURATION ENDS HERE
  133. #===========================================================================
  134.   module REGEXP
  135.     MAX_GRATHNODES = /<max_grathnodes:[ ]*(\d+)>/i
  136.     GRATHNODE_ITEM = /<grathnode>/i
  137.     GRATHNODE_SCOPE = /<scope:[ ]*(\w+.)>/
  138.     MP_INFLATION = /<mp_inflation:[ ]*(\d+)>/i
  139.     TP_INFLATION = /<tp_inflation:[ ]*(\d+)>/i
  140.   end
  141. end
  142.   
  143. #===========================================================================
  144. # ■ DataManager
  145. #===========================================================================

  146. module DataManager  
  147.         #--------------------------------------------------------------------------
  148.         # ● Loads the database
  149.         #--------------------------------------------------------------------------
  150.         class << self
  151.                 alias_method(:krx_grathnode_dm_load_database, :load_database)
  152.         end
  153.         def self.load_database
  154.                 krx_grathnode_dm_load_database
  155.                 load_grathnode_notetags
  156.         end  
  157.         #--------------------------------------------------------------------------
  158.         # ● Loads the note tags
  159.         #--------------------------------------------------------------------------
  160.         def self.load_grathnode_notetags
  161.                 groups = [$data_items, $data_skills]
  162.                 for group in groups
  163.                         for obj in group
  164.                                 next if obj.nil?
  165.                                 obj.load_grathnode_notetags
  166.                         end
  167.                 end
  168.                 puts "Read: Grathnode Install Notetags"
  169.         end
  170. end

  171. #==========================================================================
  172. # ■ RPG::Item
  173. #==========================================================================

  174. class RPG::Item < RPG::UsableItem
  175.         #--------------------------------------------------------------------------
  176.         # ● Public instance variables
  177.         #--------------------------------------------------------------------------
  178.   attr_reader     :grathnode_scope
  179.   attr_reader     :mp_inflation
  180.   attr_reader     :tp_inflation
  181.         #--------------------------------------------------------------------------
  182.         # ● Loads the note tags
  183.         #--------------------------------------------------------------------------
  184.         def load_grathnode_notetags
  185.     @mp_inflation = @tp_inflation = 0
  186.                 @note.split(/[\r\n]+/).each do |line|
  187.                         case line
  188.                         when KRX::REGEXP::GRATHNODE_ITEM
  189.                                 @is_grathnode = true
  190.                         when KRX::REGEXP::GRATHNODE_SCOPE
  191.                                 @grathnode_scope = $1
  192.       when KRX::REGEXP::MP_INFLATION
  193.         @mp_inflation = $1.to_i
  194.       when KRX::REGEXP::TP_INFLATION
  195.         @tp_inflation = $1.to_i
  196.                         end
  197.                 end
  198.         end
  199.         #--------------------------------------------------------------------------
  200.         # ● Determine if the item is a grathnode crystal
  201.         #--------------------------------------------------------------------------
  202.         def grathnode?
  203.     @is_grathnode
  204.   end
  205. end

  206. #==========================================================================
  207. # ■ RPG::Skill
  208. #==========================================================================

  209. class RPG::Skill < RPG::UsableItem
  210.         #--------------------------------------------------------------------------
  211.         # ● Loads the note tags
  212.         #--------------------------------------------------------------------------
  213.         def load_grathnode_notetags
  214.                 @max_grathnodes = nil
  215.                 @note.split(/[\r\n]+/).each do |line|
  216.                         case line
  217.                         when KRX::REGEXP::MAX_GRATHNODES
  218.         @max_grathnodes = [$1.to_i, KRX::ABSOLUTE_MAX_GRATHNODES].min
  219.                         end
  220.                 end
  221.   end
  222.         #--------------------------------------------------------------------------
  223.         # ● Returns the maximum number of grathnode slots
  224.         #--------------------------------------------------------------------------
  225.         def grathnode_slots
  226.     (@max_grathnodes == nil ? KRX::ABSOLUTE_MAX_GRATHNODES : @max_grathnodes)
  227.   end
  228. end

  229. #==========================================================================
  230. # ■ Game_Actor
  231. #==========================================================================

  232. class Game_Actor < Game_Battler
  233.         #--------------------------------------------------------------------------
  234.         # ● Public instance variables
  235.         #--------------------------------------------------------------------------
  236.         attr_accessor        :installs
  237.   attr_accessor :barring_grathnode
  238.         #--------------------------------------------------------------------------
  239.         # ● Setup
  240.         #--------------------------------------------------------------------------
  241.         alias_method(:krx_grathnode_gp_setup, :setup)
  242.         def setup(actor_id)
  243.                 krx_grathnode_gp_setup(actor_id)
  244.                 @installs = {}
  245.     @barring_grathnode = false
  246.         end
  247.         #--------------------------------------------------------------------------
  248.         # ● Adds a grathnode crystal to a specific skill slot
  249.         #--------------------------------------------------------------------------
  250.   def add_grathnode(skill, crystal, slot)
  251.     if @installs[skill.id].nil?
  252.       @installs[skill.id] = Array.new(skill.grathnode_slots, nil)
  253.     elsif @installs[skill.id][slot] != nil
  254.       $game_party.gain_item(@installs[skill.id][slot], 1)
  255.     end
  256.     $game_party.lose_item(crystal, 1) unless crystal.nil?
  257.     @installs[skill.id][slot] = crystal.nil? ? nil : crystal.id
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● Returns the MP cost for a skill
  261.   #--------------------------------------------------------------------------
  262.   def skill_mp_cost(skill)
  263.     cost = super
  264.     (cost + cost * process_grathnode_mp_cost(skill) / 100).round
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● Returns the TP cost for a skill
  268.   #--------------------------------------------------------------------------
  269.   def skill_tp_cost(skill)
  270.     cost = super
  271.     (cost + cost * process_grathnode_tp_cost(skill) / 100).round
  272.   end
  273.         #--------------------------------------------------------------------------
  274.         # ● Calculates the MP cost inflation
  275.         #--------------------------------------------------------------------------
  276.   def process_grathnode_mp_cost(skill)
  277.     result = 0.0
  278.     return result if @installs[skill.id].nil?
  279.     @installs[skill.id].compact.each do |grathnode|
  280.       result += $data_items[grathnode].mp_inflation
  281.     end
  282.     return result
  283.   end
  284.         #--------------------------------------------------------------------------
  285.         # ● Calculates the TP cost inflation
  286.         #--------------------------------------------------------------------------
  287.   def process_grathnode_tp_cost(skill)
  288.     result = 0.0
  289.     return result if @installs[skill.id].nil?
  290.     @installs[skill.id].compact.each do |grathnode|
  291.       result += $data_items[grathnode].tp_inflation
  292.     end
  293.     return result
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● Forgets a skill
  297.   #--------------------------------------------------------------------------
  298.   alias_method(:krx_grathnode_ga_fs, :forget_skill)
  299.   def forget_skill(skill_id)
  300.     krx_grathnode_ga_fs(skill_id)
  301.     if KRX::CLEAR_FORGET_SKILL
  302.       skill = $data_skills[skill_id]
  303.       (0...skill.grathnode_slots).each do |i|
  304.         add_grathnode(skill, nil, i)
  305.       end
  306.     end
  307.   end
  308. end

  309. #==========================================================================
  310. # ■ Game_Party
  311. #==========================================================================

  312. class Game_Party < Game_Unit
  313.   #--------------------------------------------------------------------------
  314.   # ● Public instance variables
  315.   #--------------------------------------------------------------------------
  316.   attr_accessor   :last_selected_skill
  317.   #--------------------------------------------------------------------------
  318.   # ● Next actor
  319.   #--------------------------------------------------------------------------
  320.   alias_method(:krx_grathnode_gp_man, :menu_actor_next)
  321.   def menu_actor_next
  322.     if SceneManager.scene.is_a?(Scene_Grathnode)
  323.       return menu_actor if KRX::SINGLE_ACTOR_INSTALL
  324.       val = members.select {|act| !act.barring_grathnode}
  325.       index = val.index(menu_actor) || -1
  326.       index = (index + 1) % val.size
  327.       self.menu_actor = val[index]
  328.     else
  329.       krx_grathnode_gp_man
  330.     end
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● Previous actor
  334.   #--------------------------------------------------------------------------
  335.   alias_method(:krx_grathnode_gp_map, :menu_actor_prev)
  336.   def menu_actor_prev
  337.     if SceneManager.scene.is_a?(Scene_Grathnode)
  338.       return menu_actor if KRX::SINGLE_ACTOR_INSTALL
  339.       val = members.select {|act| !act.barring_grathnode}
  340.       index = val.index(menu_actor) || 1
  341.       index = (index + val.size - 1) % val.size
  342.       self.menu_actor = val[index]
  343.     else
  344.       krx_grathnode_gp_map
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● Get the current actor for menus
  349.   #--------------------------------------------------------------------------
  350.   alias_method(:krx_grathnode_gp_ma, :menu_actor)
  351.   def menu_actor
  352.     if SceneManager.scene.is_a?(Scene_Grathnode)
  353.       val = members.select {|act| !act.barring_grathnode}
  354.       return $game_actors[@menu_actor_id] || val[0]
  355.     end
  356.     return krx_grathnode_gp_ma
  357.   end
  358. end

  359. #==========================================================================
  360. # ■ Scene_Grathnode
  361. #==========================================================================

  362. class Scene_Grathnode < Scene_Skill
  363.         #--------------------------------------------------------------------------
  364.         # ● Object Initializate
  365.         #--------------------------------------------------------------------------
  366.   def initialize
  367.     if KRX::SINGLE_ACTOR_INSTALL
  368.       $game_party.menu_actor = $game_actors[KRX::SINGLE_ACTOR_INSTALL_ID]
  369.     end
  370.   end
  371.         #--------------------------------------------------------------------------
  372.         # ● Scene start
  373.         #--------------------------------------------------------------------------
  374.         def start
  375.     super
  376.     create_install_window
  377.         end
  378.         #--------------------------------------------------------------------------
  379.         # ● Creates the window displaying the grathnodes currently installed
  380.         #--------------------------------------------------------------------------
  381.   def create_install_window
  382.     wy = @status_window.y + @status_window.height
  383.     ww = Graphics.width / 2
  384.     wh = Graphics.height - wy
  385.                 @install_window = Window_GrathnodeInstall.new(ww, wy, ww, wh)
  386.                 @install_window.viewport = @viewport
  387.     @install_window.set_handler(:ok,     method(:on_slot_ok))
  388.     @install_window.set_handler(:cancel,     method(:on_slot_cancel))
  389.     @item_window.install_window = @install_window
  390.   end
  391.         #--------------------------------------------------------------------------
  392.         # ● Creates the window displaying the grathnodes currently owned
  393.         #--------------------------------------------------------------------------
  394.         def create_grathnodes_window
  395.     wx = 0
  396.     wy = @status_window.y + @status_window.height
  397.     ww = Graphics.width / 2
  398.     wh = Graphics.height - wy
  399.     @grathnode_window = Window_GrathnodeList.new(wx, wy, ww, wh)
  400.     @grathnode_window.viewport = @viewport
  401.     @grathnode_window.help_window = @help_window
  402.     @grathnode_window.refresh
  403.     @grathnode_window.select(0)
  404.     @grathnode_window.activate
  405.     @grathnode_window.set_handler(:ok,     method(:on_grath_ok))
  406.     @grathnode_window.set_handler(:cancel, method(:on_grath_cancel))
  407.         end
  408.         #--------------------------------------------------------------------------
  409.         # ● Creates the window displaying the skills
  410.         #--------------------------------------------------------------------------
  411.         def create_item_window
  412.     wx = 0
  413.     wy = @status_window.y + @status_window.height
  414.     ww = Graphics.width / 2
  415.     wh = Graphics.height - wy
  416.     @item_window = Window_UpSkillList.new(wx, wy, ww, wh)
  417.     @item_window.actor = @actor
  418.     @item_window.viewport = @viewport
  419.     @item_window.help_window = @help_window
  420.     @item_window.set_handler(:ok,     method(:on_item_ok))
  421.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  422.     @command_window.skill_window = @item_window
  423.         end
  424.   #--------------------------------------------------------------------------
  425.   # ● Validates the skill selection
  426.   #--------------------------------------------------------------------------
  427.   def on_item_ok
  428.     @item_window.hide
  429.     @last_index = @item_window.index
  430.     $game_party.last_selected_skill = @item_window.item
  431.     create_grathnodes_window
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # ● Cancels the skill selection
  435.   #--------------------------------------------------------------------------
  436.   def on_item_cancel
  437.     @item_window.unselect
  438.     @item_window.update_help
  439.     @command_window.activate
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # ● Validates the slot selection
  443.   #--------------------------------------------------------------------------
  444.   def on_slot_ok
  445.     sk = @item_window.item
  446.     gr = @grathnode_window.item
  447.     slot = @install_window.index
  448.     @actor.add_grathnode(sk, gr, slot)
  449.     @item_window.refresh
  450.     @install_window.unselect
  451.     @install_window.set_item(@item_window.item)
  452.     @grathnode_window.refresh
  453.     @grathnode_window.activate
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● Cancels the slot selection
  457.   #--------------------------------------------------------------------------
  458.   def on_slot_cancel
  459.     @install_window.unselect
  460.     @grathnode_window.activate
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● Validates the grathnode selection
  464.   #--------------------------------------------------------------------------
  465.   def on_grath_ok
  466.     @install_window.activate
  467.     @install_window.select(0)
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # ● Cancels the grathnode selection
  471.   #--------------------------------------------------------------------------
  472.   def on_grath_cancel
  473.     @item_window.select(@last_index)
  474.     @item_window.show
  475.     @item_window.activate
  476.     @grathnode_window.dispose ; @grathnode_window = nil
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ● Confirms the actor switch
  480.   #--------------------------------------------------------------------------
  481.   def on_actor_change
  482.     super
  483.     @install_window.actor = @actor
  484.   end
  485. end

  486. #==========================================================================
  487. # ■ Window_UpSkillList
  488. #==========================================================================
  489.        
  490. class Window_UpSkillList < Window_SkillList
  491.         #--------------------------------------------------------------------------
  492.         # ● Assigns the install window
  493.         #--------------------------------------------------------------------------
  494.         def install_window=(value)
  495.                 @install_window = value
  496.         end
  497.         #--------------------------------------------------------------------------
  498.         # ● Determine if the skill can be selected
  499.         #--------------------------------------------------------------------------
  500.         def enable?(item)
  501.                 return item != nil && item.grathnode_slots > 0
  502.         end
  503.         #--------------------------------------------------------------------------
  504.         # ● Refreshes the help and install windows
  505.         #--------------------------------------------------------------------------
  506.         def update_help
  507.                 super
  508.                 @install_window.set_item(item)
  509.         end
  510.         #--------------------------------------------------------------------------
  511.         # ● Returns the number of columns
  512.         #--------------------------------------------------------------------------
  513.         def col_max
  514.                 return 1
  515.         end
  516. end

  517. #==========================================================================
  518. # ■ Window_GrathnodeInstall
  519. #==========================================================================
  520.        
  521. class Window_GrathnodeInstall < Window_Selectable
  522.         #--------------------------------------------------------------------------
  523.         # ● Public instance variables
  524.         #--------------------------------------------------------------------------
  525.   attr_accessor   :actor
  526.         #--------------------------------------------------------------------------
  527.         # ● Object Initialize
  528.         #--------------------------------------------------------------------------
  529.         def initialize(x, y, width, height)
  530.                 super
  531.                 set_item
  532.     [url=home.php?mod=space&uid=95897]@actor[/url] = $game_party.menu_actor
  533.         end
  534.         #--------------------------------------------------------------------------
  535.         # ● Refresh the contents
  536.         #--------------------------------------------------------------------------
  537.         def set_item(item = nil)
  538.                 contents.clear
  539.                 return if item.nil?
  540.     @data = Array.new(item.grathnode_slots, nil)
  541.     @installs = @actor.installs[item.id]
  542.                 draw_item_installs(item)
  543.         end
  544.         #--------------------------------------------------------------------------
  545.         # ● Displays the skill's current installs
  546.         #--------------------------------------------------------------------------
  547.         def draw_item_installs(item)
  548.     draw_horz_line(line_height * 6)
  549.                 change_color(system_color)
  550.                 contents.draw_text(4, 0, width, line_height, KRX::VOCAB::GRATHNODE)
  551.                 change_color(normal_color)
  552.     m = item.grathnode_slots
  553.                 (1..m).each {|i| contents.draw_text(4, line_height * i, width, line_height, "#{i}.")}
  554.     return if @installs.nil? || @installs.empty?
  555.                 @installs.each_index do |i|
  556.                         grath = @installs[i].nil? ? nil : $data_items[@installs[i]]
  557.                         draw_item_name(grath, 28, line_height * (i + 1), true, width - 24)
  558.     end
  559.     draw_mp(item) if @actor.process_grathnode_mp_cost(item).round > 0
  560.     draw_tp(item) if @actor.process_grathnode_tp_cost(item).round > 0
  561.   end
  562.         #--------------------------------------------------------------------------
  563.         # ● Displays the skill's MP inflation rate
  564.         #--------------------------------------------------------------------------
  565.   def draw_mp(item)
  566.     change_color(system_color)
  567.     contents.draw_text(4, line_height * 7, width, line_height, Vocab.basic(5))
  568.     change_color(normal_color)
  569.     contents.draw_text(28, line_height * 7, width, line_height,
  570.     "+#{@actor.process_grathnode_mp_cost(item).round.to_s}%")
  571.   end
  572.         #--------------------------------------------------------------------------
  573.         # ● Displays the skill's TP inflation rate
  574.         #--------------------------------------------------------------------------
  575.   def draw_tp(item)
  576.     change_color(system_color)
  577.     w = width / 4
  578.     contents.draw_text(w, line_height * 7, width, line_height, Vocab.basic(7))
  579.     change_color(normal_color)
  580.     contents.draw_text(w + 28, line_height * 7, width, line_height,
  581.     "+#{@actor.process_grathnode_tp_cost(item).round.to_s}%")
  582.         end
  583.         #--------------------------------------------------------------------------
  584.         # ● Returns the number of columns
  585.         #--------------------------------------------------------------------------
  586.         def col_max
  587.                 return 1
  588.         end
  589.   #--------------------------------------------------------------------------
  590.   # ● Returns the max number of rows
  591.   #--------------------------------------------------------------------------
  592.   def item_max
  593.     @data ? @data.size : 1
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● Sets the rectangle for selections
  597.   #--------------------------------------------------------------------------
  598.   def item_rect(index)
  599.     rect = Rect.new
  600.     rect.width = item_width
  601.     rect.height = item_height
  602.     rect.x = index % col_max * (item_width + spacing)
  603.     rect.y = (index / col_max * item_height) + line_height
  604.     rect
  605.   end
  606.         #--------------------------------------------------------------------------
  607.         # ● Displays an horizontal line
  608.         #--------------------------------------------------------------------------
  609.         def draw_horz_line(y)
  610.                 line_y = y + line_height / 2 - 1
  611.                 contents.fill_rect(0, line_y, contents_width, 2, line_color)
  612.         end
  613.         #--------------------------------------------------------------------------
  614.         # ● Returns the color used for horizontal lines
  615.         #--------------------------------------------------------------------------
  616.         def line_color
  617.                 color = normal_color
  618.                 color.alpha = 48
  619.                 return color
  620.         end
  621. end

  622. #==========================================================================
  623. # ■ Window_GrathnodeList
  624. #==========================================================================
  625.        
  626. class Window_GrathnodeList < Window_ItemList
  627.         #--------------------------------------------------------------------------
  628.         # ● Determine if an item goes in the list
  629.         #--------------------------------------------------------------------------
  630.         def include?(item)
  631.     item.is_a?(RPG::Item) && item.grathnode?
  632.         end
  633.         #--------------------------------------------------------------------------
  634.         # ● Determine if the grathnode can be used
  635.         #--------------------------------------------------------------------------
  636.         def enable?(item)
  637.     return true if item.nil?
  638.     actor = $game_party.menu_actor
  639.     skill = $game_party.last_selected_skill
  640.     if !actor.installs[skill.id].nil? && actor.installs[skill.id].include?(item.id)
  641.       return false
  642.     end
  643.     if !item.grathnode_scope.nil? && !skill.send(item.grathnode_scope)
  644.       return false
  645.     end
  646.     return true
  647.         end
  648.         #--------------------------------------------------------------------------
  649.         # ● Creates the list based on the recipes
  650.         #--------------------------------------------------------------------------
  651.         def make_item_list
  652.                 @data = $game_party.items.select {|item| include?(item)}
  653.     @data.push(nil)
  654.         end
  655.         #--------------------------------------------------------------------------
  656.         # ● Returns the number of columns
  657.         #--------------------------------------------------------------------------
  658.         def col_max
  659.                 return 1
  660.         end
  661. end

  662. #==========================================================================
  663. # ■ Scene_Battle
  664. #==========================================================================

  665. class Scene_Battle < Scene_Base
  666.   
  667.   ## Yanfly's Ace Battle Engine implementation
  668.   if $imported["YEA-BattleEngine"]
  669.   #--------------------------------------------------------------------------
  670.   # ● Applies the effects of the skill or item
  671.   #--------------------------------------------------------------------------
  672.   alias_method(:krx_grathnode_sb_aie, :apply_item_effects)
  673.   def apply_item_effects(target, item)
  674.     apply_grathnode_effects(target, item)
  675.     krx_grathnode_sb_aie(target, item)
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ● Applies the effects of grathnodes associated to the skill
  679.   #--------------------------------------------------------------------------
  680.   def apply_grathnode_effects(target, item)
  681.     unless @subject.is_a?(Game_Actor)&& @subject.installs.keys.include?(item.id) &&
  682.     @subject.installs[item.id] != nil
  683.       return
  684.     end
  685.     @subject.installs[item.id].compact.each do |grath|
  686.       target.item_apply(@subject, $data_items[grath])
  687.     end
  688.   end
  689.   ## End of Yanfly's Ace Battle Engine implementation
  690.   ## DBS implementation
  691.   else
  692.   #--------------------------------------------------------------------------
  693.   # ● Applies the effects of the skill or item
  694.   #--------------------------------------------------------------------------
  695.   alias_method(:krx_grathnode_sb_aie, :apply_item_effects)
  696.   def apply_item_effects(target, item)
  697.     krx_grathnode_sb_aie(target, item)
  698.     apply_grathnode_effects(target, item)
  699.   end
  700.   #--------------------------------------------------------------------------
  701.   # ● Applies the effects of grathnodes associated to the skill
  702.   #--------------------------------------------------------------------------
  703.   def apply_grathnode_effects(target, item)
  704.     unless @subject.is_a?(Game_Actor)&& @subject.installs.keys.include?(item.id) &&
  705.     @subject.installs[item.id] != nil || target.dead?
  706.       return
  707.     end
  708.     return unless @subject.is_a?(Game_Actor)
  709.     return if @subject.installs.nil? || @subject.installs[item.id].nil?
  710.     @subject.installs[item.id].compact.each do |grath|
  711.       target.item_apply(@subject, $data_items[grath])
  712.       @log_window.display_action_results(target, $data_items[grath])
  713.     end
  714.   end # Method End
  715.   end ## End of DBS implementation
  716. end

  717. ## Menu inclusion, with Yanfly's Ace Menu Engine
  718. if $imported["YEA-AceMenuEngine"]

  719. #==========================================================================
  720. # ■ Scene_Menu
  721. #==========================================================================
  722.        
  723. class Scene_Menu < Scene_MenuBase
  724.         #--------------------------------------------------------------------------
  725.         # ● Switch to the actor selection
  726.         #--------------------------------------------------------------------------
  727.         def command_install
  728.     if KRX::SINGLE_ACTOR_INSTALL
  729.       SceneManager.call(Scene_Grathnode)
  730.       return
  731.     end
  732.     @status_window.select_last
  733.     @status_window.activate
  734.     @status_window.set_handler(:ok,     method(:on_install_ok))
  735.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  736.   end
  737.         #--------------------------------------------------------------------------
  738.         # ● Validates the actor selection
  739.         #--------------------------------------------------------------------------
  740.         def on_install_ok
  741.     SceneManager.call(Scene_Grathnode)
  742.   end
  743. end

  744. #==========================================================================
  745. # ■ Window_MenuStatus
  746. #==========================================================================
  747.        
  748. class Window_MenuStatus < Window_Selectable
  749.         #--------------------------------------------------------------------------
  750.         # ● Determine if a party member can be selected
  751.         #--------------------------------------------------------------------------
  752.   alias_method(:krx_grathnode_wms_cie?, :current_item_enabled?)
  753.   def current_item_enabled?
  754.     if @handler[:ok].name == :on_install_ok
  755.       return !$game_party.members[index].barring_grathnode
  756.     end
  757.     return krx_grathnode_wms_cie?
  758.   end
  759. end

  760. end ## End of Yanfly's Menu inclusion

  761. ## Compatibility with Yanfly's TP Manager. Deprecated with the use of Ace Skill
  762. ## Menu
  763. =begin
  764. if $imported["YEA-TPManager"]

  765. #==============================================================================
  766. # ■ Window_SkillCommand
  767. #==============================================================================

  768. class Window_SkillCommand < Window_Command
  769.   #--------------------------------------------------------------------------
  770.   # ● Aliases YF's new method
  771.   #--------------------------------------------------------------------------
  772.   alias_method(:krx_grathnode_wsc_tp, :add_tp_modes)
  773.   def add_tp_modes
  774.     return if SceneManager.scene.is_a?(Scene_Grathnode)
  775.     krx_grathnode_wsc_tp
  776.   end
  777. end

  778. #==========================================================================
  779. #  ■  Scene_Grathnode
  780. #==========================================================================

  781. class Scene_Grathnode < Scene_Skill
  782.         #--------------------------------------------------------------------------
  783.         # ● Creates the command window
  784.         #--------------------------------------------------------------------------
  785.   def create_command_window
  786.     wy = @help_window.height
  787.     @command_window = Window_SkillCommand.new(0, wy)
  788.     @command_window.viewport = @viewport
  789.     @command_window.help_window = @help_window
  790.     @command_window.actor = @actor
  791.     @command_window.set_handler(:skill,    method(:command_skill))
  792.     @command_window.set_handler(:cancel,   method(:return_scene))
  793.     @command_window.set_handler(:pagedown, method(:next_actor))
  794.     @command_window.set_handler(:pageup,   method(:prev_actor))
  795.   end  
  796. end


  797. end ## End of TP Manager compatibility
  798. =end
复制代码

点评

现在我也想知道为毛这段脚本不生效……我已经到作者的网页去留言了  发表于 2013-1-16 22:27
回复

使用道具 举报

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2013-1-16 22:51:27 | 显示全部楼层
这样改……我居然没发现……
  1.   def add_grathnode(skill, crystal, slot)
  2.     if @installs[skill.id].nil?
  3.       @installs[skill.id] = Array.new(skill.grathnode_slots, nil)
  4.     elsif @installs[skill.id][slot] != nil
  5.       item = $data_items[@installs[skill.id][slot]]
  6.       $game_party.gain_item(item, 1)
  7.     end
  8.     $game_party.lose_item(crystal, 1) unless crystal.nil?
  9.     @installs[skill.id][slot] = crystal.nil? ? nil : crystal.id
  10.   end
复制代码
另外,120行左右少了个等号
  1. ($imported ||= {})['KRX-GrathnodeInstall'] = true
复制代码
你运行不会报错吗……

点评

省了等号应该不至于报错,好像变成二选一的不是左边的就是右边的,而右边的是 {},哈哈...真有意思...  发表于 2013-1-17 01:05
= =没报错,真奇葩……  发表于 2013-1-16 23:06
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部