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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
61
在线时间
696 小时
注册时间
2011-1-4
帖子
208
跳转到指定楼层
1
发表于 2013-1-14 22:18:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这是个给技能装备上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

Lv2.观梦者 (暗夜天使)

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

贵宾

2
发表于 2013-1-15 11:52:41 | 只看该作者
还是发个范例吧。光看这个method是找不到问题的。

点评

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
61
在线时间
696 小时
注册时间
2011-1-4
帖子
208
3
 楼主| 发表于 2013-1-16 18:13:05 | 只看该作者
Sion 发表于 2013-1-15 11:52
还是发个范例吧。光看这个method是找不到问题的。

RUBY 代码复制
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Grathnode Install
  3. #  Author: Kread-EX
  4. #  Version 1.12
  5. #  Release date: 31/12/2011
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  7.  
  8. #------------------------------------------------------------------------------
  9. #  ▼ UPDATES
  10. #------------------------------------------------------------------------------
  11. # # 28/12/2012. Fixed another bug with savefiles.
  12. # # 30/01/2012. Added option to disable grathnode menu for certain characters.
  13. # # 30/01/2012. Added option to remove grathnodes when a skill is forgetted.
  14. # # 20/01/2012. Compatibility fix.
  15. # # 19/01/2012. Loads of compatibility fixes.
  16. # # 14/01/2012. Fixed two crashing bugs with the DBS implementation.
  17. # # 10/01/2012. <max_grathnodes: 0> now works.
  18. # # 07/01/2012. Fixed a critical bug preventing the installs to be saved.
  19. # # 05/01/2012. Fixed a crashing bug in the Install menu if no skill is
  20. # # available.
  21. # # 01/01/2012. Fixed compatibility with Yanfly's TP Manager (thanks Adalwulf)
  22. # # NOW DEPRECATED. Use Yanfly's Ace Skill Menu to ensure compat. However, in
  23. # # case you don't want to, just uncomment the code at the end of the script.
  24. #------------------------------------------------------------------------------
  25. #  ▼ TERMS OF USAGE
  26. #------------------------------------------------------------------------------
  27. # #  You are free to adapt this work to suit your needs.
  28. # #  You can use this work for commercial purposes if you like it.
  29. # #  Credit is appreciated.
  30. # #
  31. # # For support:
  32. # # grimoirecastle.wordpress.com
  33. # # rpgmakerweb.com
  34. #------------------------------------------------------------------------------
  35. #  ▼ INTRODUCTION
  36. #------------------------------------------------------------------------------
  37. # # This script is inspired from the Ar Tonelico series. In a nutshell,
  38. # # it allows the player to assign special items called Grathnode crystals to
  39. # # skills in order to add special effects.
  40. # # The upgrades are actor-dependant: if two actors have the same skill, they
  41. # # can use a different set of crystals.
  42. #------------------------------------------------------------------------------
  43. #  ▼ INSTRUCTIONS
  44. #------------------------------------------------------------------------------
  45. # # First, you need to create the desired grathnode crystals. They are regular
  46. # # items, but tagged as <grathnode> in their notebox.
  47. # # Certain grathnodes are suited only for a certain type of skill. To ensure
  48. # # that a defensive skill doesn't use an offensive effect, you can choose
  49. # # the kind of scope:
  50. # # <scope: string> in the item notebox.
  51. # # String can be different values:
  52. # # for_opponent?
  53. # # for_friend?
  54. # # for_dead_friend?
  55. # # for_user?
  56. # # for_all?
  57. # #
  58. # # Every skill can contain up to 6 crystals by default, but you can lower the
  59. # # number either individually (by putting <max_grathnodes: x> if the skill
  60. # # notebox, or globally by altering the ABSOLUTE_MAX_GRATHNODES value within
  61. # # the script.
  62. # #
  63. # # The scene can be called with SceneManager.call(Scene_Grathnode), however
  64. # # I strongly recommend you to use Yanfly's Ace Menu Engine, as I prepared
  65. # # special compatibility for it.
  66. #------------------------------------------------------------------------------
  67. #  ▼ COMPATIBILITY
  68. #------------------------------------------------------------------------------
  69. # # Works with Yanfly's Battle Engine Ace. Actually, it may work better than with
  70. # # the DBS, thanks to the nice pop-ups, very GUST-ish at the conception.
  71. # #
  72. # # List of aliases and overwrites:
  73. # #
  74. # # DataManager
  75. # # load_database (alias)
  76. # # load_grathnode_notetags (new method)
  77. # #
  78. # # RPG::Item
  79. # # load_grathnode_notetags (new method)
  80. # # is_grathnode? (new method)
  81. # # grathnode_scope (new attr method)
  82. # # mp_inflation (new attr method)
  83. # # tp_inflation (new attr method)
  84. # #
  85. # # RPG::Skill
  86. # # load_grathnode_notetags (new method)
  87. # # grathnode_slots (new method)
  88. # #
  89. # # Game_Actor
  90. # # installs (new attr method)
  91. # # barring_grathnode (new attr method)
  92. # # setup (alias)
  93. # # forget_skill (alias)
  94. # # add_grathnode (new method)
  95. # # skill_mp_cost (new child method)
  96. # # skill_tp_cost (new child method)
  97. # # process_grathnode_mp_cost (new method)
  98. # # process_grathnode_tp_cost (new method)
  99. # #
  100. # # Game_Party
  101. # # last_selected_skill (new attr method)
  102. # # menu_actor (alias)
  103. # # menu_actor_next (alias)
  104. # # menu_actor_prev (alias)
  105. # #
  106. # # Scene_Grathnode (new class)
  107. # #
  108. # # Window_UpSkillList (new class)
  109. # #
  110. # # Window_GrathnodeList (new class)
  111. # #
  112. # # Window_GrathnodeInstall (new class)
  113. # #
  114. # # Scene_Battle
  115. # # apply_item_effects (alias)
  116. # # apply_grathnode_effects (new method - YEA Battle Engine only)
  117. #------------------------------------------------------------------------------
  118.  
  119. ($imported || {})['KRX-GrathnodeInstall'] = true
  120.  
  121. puts 'Load: Grathnode Install v1.12 by Kread-EX'
  122.  
  123. module KRX
  124. #===========================================================================
  125. # ■ CONFIGURATION
  126. #===========================================================================
  127.   ABSOLUTE_MAX_GRATHNODES = 5
  128.   CLEAR_FORGET_SKILL = true
  129.   SINGLE_ACTOR_INSTALL = false
  130.   SINGLE_ACTOR_INSTALL_ID = 9
  131.  
  132.   module VOCAB
  133.     GRATHNODE = 'Grathnode'
  134.   end
  135. #===========================================================================
  136. # ■ CONFIGURATION ENDS HERE
  137. #===========================================================================
  138.   module REGEXP
  139.     MAX_GRATHNODES = /<max_grathnodes:[ ]*(\d+)>/i
  140.     GRATHNODE_ITEM = /<grathnode>/i
  141.     GRATHNODE_SCOPE = /<scope:[ ]*(\w+.)>/
  142.     MP_INFLATION = /<mp_inflation:[ ]*(\d+)>/i
  143.     TP_INFLATION = /<tp_inflation:[ ]*(\d+)>/i
  144.   end
  145. end
  146.  
  147. #===========================================================================
  148. # ■ DataManager
  149. #===========================================================================
  150.  
  151. module DataManager  
  152.         #--------------------------------------------------------------------------
  153.         # ● Loads the database
  154.         #--------------------------------------------------------------------------
  155.         class << self
  156.                 alias_method(:krx_grathnode_dm_load_database, :load_database)
  157.         end
  158.         def self.load_database
  159.                 krx_grathnode_dm_load_database
  160.                 load_grathnode_notetags
  161.         end  
  162.         #--------------------------------------------------------------------------
  163.         # ● Loads the note tags
  164.         #--------------------------------------------------------------------------
  165.         def self.load_grathnode_notetags
  166.                 groups = [$data_items, $data_skills]
  167.                 for group in groups
  168.                         for obj in group
  169.                                 next if obj.nil?
  170.                                 obj.load_grathnode_notetags
  171.                         end
  172.                 end
  173.                 puts "Read: Grathnode Install Notetags"
  174.         end
  175. end
  176.  
  177. #==========================================================================
  178. # ■ RPG::Item
  179. #==========================================================================
  180.  
  181. class RPG::Item < RPG::UsableItem
  182.         #--------------------------------------------------------------------------
  183.         # ● Public instance variables
  184.         #--------------------------------------------------------------------------
  185.   attr_reader     :grathnode_scope
  186.   attr_reader     :mp_inflation
  187.   attr_reader     :tp_inflation
  188.         #--------------------------------------------------------------------------
  189.         # ● Loads the note tags
  190.         #--------------------------------------------------------------------------
  191.         def load_grathnode_notetags
  192.     @mp_inflation = @tp_inflation = 0
  193.                 @note.split(/[\r\n]+/).each do |line|
  194.                         case line
  195.                         when KRX::REGEXP::GRATHNODE_ITEM
  196.                                 @is_grathnode = true
  197.                         when KRX::REGEXP::GRATHNODE_SCOPE
  198.                                 @grathnode_scope = $1
  199.       when KRX::REGEXP::MP_INFLATION
  200.         @mp_inflation = $1.to_i
  201.       when KRX::REGEXP::TP_INFLATION
  202.         @tp_inflation = $1.to_i
  203.                         end
  204.                 end
  205.         end
  206.         #--------------------------------------------------------------------------
  207.         # ● Determine if the item is a grathnode crystal
  208.         #--------------------------------------------------------------------------
  209.         def grathnode?
  210.     @is_grathnode
  211.   end
  212. end
  213.  
  214. #==========================================================================
  215. # ■ RPG::Skill
  216. #==========================================================================
  217.  
  218. class RPG::Skill < RPG::UsableItem
  219.         #--------------------------------------------------------------------------
  220.         # ● Loads the note tags
  221.         #--------------------------------------------------------------------------
  222.         def load_grathnode_notetags
  223.                 @max_grathnodes = nil
  224.                 @note.split(/[\r\n]+/).each do |line|
  225.                         case line
  226.                         when KRX::REGEXP::MAX_GRATHNODES
  227.         @max_grathnodes = [$1.to_i, KRX::ABSOLUTE_MAX_GRATHNODES].min
  228.                         end
  229.                 end
  230.   end
  231.         #--------------------------------------------------------------------------
  232.         # ● Returns the maximum number of grathnode slots
  233.         #--------------------------------------------------------------------------
  234.         def grathnode_slots
  235.     (@max_grathnodes == nil ? KRX::ABSOLUTE_MAX_GRATHNODES : @max_grathnodes)
  236.   end
  237. end
  238.  
  239. #==========================================================================
  240. # ■ Game_Actor
  241. #==========================================================================
  242.  
  243. class Game_Actor < Game_Battler
  244.         #--------------------------------------------------------------------------
  245.         # ● Public instance variables
  246.         #--------------------------------------------------------------------------
  247.         attr_accessor        :installs
  248.   attr_accessor :barring_grathnode
  249.         #--------------------------------------------------------------------------
  250.         # ● Setup
  251.         #--------------------------------------------------------------------------
  252.         alias_method(:krx_grathnode_gp_setup, :setup)
  253.         def setup(actor_id)
  254.                 krx_grathnode_gp_setup(actor_id)
  255.                 @installs = {}
  256.     @barring_grathnode = false
  257.         end
  258.         #--------------------------------------------------------------------------
  259.         # ● Adds a grathnode crystal to a specific skill slot
  260.         #--------------------------------------------------------------------------
  261.   def add_grathnode(skill, crystal, slot)
  262.     if @installs[skill.id].nil?
  263.       @installs[skill.id] = Array.new(skill.grathnode_slots, nil)
  264.     elsif @installs[skill.id][slot] != nil
  265.       $game_party.gain_item(@installs[skill.id][slot], 1)
  266.     end
  267.     $game_party.lose_item(crystal, 1) unless crystal.nil?
  268.     @installs[skill.id][slot] = crystal.nil? ? nil : crystal.id
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   # ● Returns the MP cost for a skill
  272.   #--------------------------------------------------------------------------
  273.   def skill_mp_cost(skill)
  274.     cost = super
  275.     (cost + cost * process_grathnode_mp_cost(skill) / 100).round
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● Returns the TP cost for a skill
  279.   #--------------------------------------------------------------------------
  280.   def skill_tp_cost(skill)
  281.     cost = super
  282.     (cost + cost * process_grathnode_tp_cost(skill) / 100).round
  283.   end
  284.         #--------------------------------------------------------------------------
  285.         # ● Calculates the MP cost inflation
  286.         #--------------------------------------------------------------------------
  287.   def process_grathnode_mp_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].mp_inflation
  292.     end
  293.     return result
  294.   end
  295.         #--------------------------------------------------------------------------
  296.         # ● Calculates the TP cost inflation
  297.         #--------------------------------------------------------------------------
  298.   def process_grathnode_tp_cost(skill)
  299.     result = 0.0
  300.     return result if @installs[skill.id].nil?
  301.     @installs[skill.id].compact.each do |grathnode|
  302.       result += $data_items[grathnode].tp_inflation
  303.     end
  304.     return result
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● Forgets a skill
  308.   #--------------------------------------------------------------------------
  309.   alias_method(:krx_grathnode_ga_fs, :forget_skill)
  310.   def forget_skill(skill_id)
  311.     krx_grathnode_ga_fs(skill_id)
  312.     if KRX::CLEAR_FORGET_SKILL
  313.       skill = $data_skills[skill_id]
  314.       (0...skill.grathnode_slots).each do |i|
  315.         add_grathnode(skill, nil, i)
  316.       end
  317.     end
  318.   end
  319. end
  320.  
  321. #==========================================================================
  322. # ■ Game_Party
  323. #==========================================================================
  324.  
  325. class Game_Party < Game_Unit
  326.   #--------------------------------------------------------------------------
  327.   # ● Public instance variables
  328.   #--------------------------------------------------------------------------
  329.   attr_accessor   :last_selected_skill
  330.   #--------------------------------------------------------------------------
  331.   # ● Next actor
  332.   #--------------------------------------------------------------------------
  333.   alias_method(:krx_grathnode_gp_man, :menu_actor_next)
  334.   def menu_actor_next
  335.     if SceneManager.scene.is_a?(Scene_Grathnode)
  336.       return menu_actor if KRX::SINGLE_ACTOR_INSTALL
  337.       val = members.select {|act| !act.barring_grathnode}
  338.       index = val.index(menu_actor) || -1
  339.       index = (index + 1) % val.size
  340.       self.menu_actor = val[index]
  341.     else
  342.       krx_grathnode_gp_man
  343.     end
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● Previous actor
  347.   #--------------------------------------------------------------------------
  348.   alias_method(:krx_grathnode_gp_map, :menu_actor_prev)
  349.   def menu_actor_prev
  350.     if SceneManager.scene.is_a?(Scene_Grathnode)
  351.       return menu_actor if KRX::SINGLE_ACTOR_INSTALL
  352.       val = members.select {|act| !act.barring_grathnode}
  353.       index = val.index(menu_actor) || 1
  354.       index = (index + val.size - 1) % val.size
  355.       self.menu_actor = val[index]
  356.     else
  357.       krx_grathnode_gp_map
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● Get the current actor for menus
  362.   #--------------------------------------------------------------------------
  363.   alias_method(:krx_grathnode_gp_ma, :menu_actor)
  364.   def menu_actor
  365.     if SceneManager.scene.is_a?(Scene_Grathnode)
  366.       val = members.select {|act| !act.barring_grathnode}
  367.       return $game_actors[@menu_actor_id] || val[0]
  368.     end
  369.     return krx_grathnode_gp_ma
  370.   end
  371. end
  372.  
  373. #==========================================================================
  374. # ■ Scene_Grathnode
  375. #==========================================================================
  376.  
  377. class Scene_Grathnode < Scene_Skill
  378.         #--------------------------------------------------------------------------
  379.         # ● Object Initializate
  380.         #--------------------------------------------------------------------------
  381.   def initialize
  382.     if KRX::SINGLE_ACTOR_INSTALL
  383.       $game_party.menu_actor = $game_actors[KRX::SINGLE_ACTOR_INSTALL_ID]
  384.     end
  385.   end
  386.         #--------------------------------------------------------------------------
  387.         # ● Scene start
  388.         #--------------------------------------------------------------------------
  389.         def start
  390.     super
  391.     create_install_window
  392.         end
  393.         #--------------------------------------------------------------------------
  394.         # ● Creates the window displaying the grathnodes currently installed
  395.         #--------------------------------------------------------------------------
  396.   def create_install_window
  397.     wy = @status_window.y + @status_window.height
  398.     ww = Graphics.width / 2
  399.     wh = Graphics.height - wy
  400.                 @install_window = Window_GrathnodeInstall.new(ww, wy, ww, wh)
  401.                 @install_window.viewport = @viewport
  402.     @install_window.set_handler(:ok,     method(:on_slot_ok))
  403.     @install_window.set_handler(:cancel,     method(:on_slot_cancel))
  404.     @item_window.install_window = @install_window
  405.   end
  406.         #--------------------------------------------------------------------------
  407.         # ● Creates the window displaying the grathnodes currently owned
  408.         #--------------------------------------------------------------------------
  409.         def create_grathnodes_window
  410.     wx = 0
  411.     wy = @status_window.y + @status_window.height
  412.     ww = Graphics.width / 2
  413.     wh = Graphics.height - wy
  414.     @grathnode_window = Window_GrathnodeList.new(wx, wy, ww, wh)
  415.     @grathnode_window.viewport = @viewport
  416.     @grathnode_window.help_window = @help_window
  417.     @grathnode_window.refresh
  418.     @grathnode_window.select(0)
  419.     @grathnode_window.activate
  420.     @grathnode_window.set_handler(:ok,     method(:on_grath_ok))
  421.     @grathnode_window.set_handler(:cancel, method(:on_grath_cancel))
  422.         end
  423.         #--------------------------------------------------------------------------
  424.         # ● Creates the window displaying the skills
  425.         #--------------------------------------------------------------------------
  426.         def create_item_window
  427.     wx = 0
  428.     wy = @status_window.y + @status_window.height
  429.     ww = Graphics.width / 2
  430.     wh = Graphics.height - wy
  431.     @item_window = Window_UpSkillList.new(wx, wy, ww, wh)
  432.     @item_window.actor = @actor
  433.     @item_window.viewport = @viewport
  434.     @item_window.help_window = @help_window
  435.     @item_window.set_handler(:ok,     method(:on_item_ok))
  436.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  437.     @command_window.skill_window = @item_window
  438.         end
  439.   #--------------------------------------------------------------------------
  440.   # ● Validates the skill selection
  441.   #--------------------------------------------------------------------------
  442.   def on_item_ok
  443.     @item_window.hide
  444.     @last_index = @item_window.index
  445.     $game_party.last_selected_skill = @item_window.item
  446.     create_grathnodes_window
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   # ● Cancels the skill selection
  450.   #--------------------------------------------------------------------------
  451.   def on_item_cancel
  452.     @item_window.unselect
  453.     @item_window.update_help
  454.     @command_window.activate
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ● Validates the slot selection
  458.   #--------------------------------------------------------------------------
  459.   def on_slot_ok
  460.     sk = @item_window.item
  461.     gr = @grathnode_window.item
  462.     slot = @install_window.index
  463.     @actor.add_grathnode(sk, gr, slot)
  464.     @item_window.refresh
  465.     @install_window.unselect
  466.     @install_window.set_item(@item_window.item)
  467.     @grathnode_window.refresh
  468.     @grathnode_window.activate
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● Cancels the slot selection
  472.   #--------------------------------------------------------------------------
  473.   def on_slot_cancel
  474.     @install_window.unselect
  475.     @grathnode_window.activate
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● Validates the grathnode selection
  479.   #--------------------------------------------------------------------------
  480.   def on_grath_ok
  481.     @install_window.activate
  482.     @install_window.select(0)
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● Cancels the grathnode selection
  486.   #--------------------------------------------------------------------------
  487.   def on_grath_cancel
  488.     @item_window.select(@last_index)
  489.     @item_window.show
  490.     @item_window.activate
  491.     @grathnode_window.dispose ; @grathnode_window = nil
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● Confirms the actor switch
  495.   #--------------------------------------------------------------------------
  496.   def on_actor_change
  497.     super
  498.     @install_window.actor = @actor
  499.   end
  500. end
  501.  
  502. #==========================================================================
  503. # ■ Window_UpSkillList
  504. #==========================================================================
  505.  
  506. class Window_UpSkillList < Window_SkillList
  507.         #--------------------------------------------------------------------------
  508.         # ● Assigns the install window
  509.         #--------------------------------------------------------------------------
  510.         def install_window=(value)
  511.                 @install_window = value
  512.         end
  513.         #--------------------------------------------------------------------------
  514.         # ● Determine if the skill can be selected
  515.         #--------------------------------------------------------------------------
  516.         def enable?(item)
  517.                 return item != nil && item.grathnode_slots > 0
  518.         end
  519.         #--------------------------------------------------------------------------
  520.         # ● Refreshes the help and install windows
  521.         #--------------------------------------------------------------------------
  522.         def update_help
  523.                 super
  524.                 @install_window.set_item(item)
  525.         end
  526.         #--------------------------------------------------------------------------
  527.         # ● Returns the number of columns
  528.         #--------------------------------------------------------------------------
  529.         def col_max
  530.                 return 1
  531.         end
  532. end
  533.  
  534. #==========================================================================
  535. # ■ Window_GrathnodeInstall
  536. #==========================================================================
  537.  
  538. class Window_GrathnodeInstall < Window_Selectable
  539.         #--------------------------------------------------------------------------
  540.         # ● Public instance variables
  541.         #--------------------------------------------------------------------------
  542.   attr_accessor   :actor
  543.         #--------------------------------------------------------------------------
  544.         # ● Object Initialize
  545.         #--------------------------------------------------------------------------
  546.         def initialize(x, y, width, height)
  547.                 super
  548.                 set_item
  549.     [url=home.php?mod=space&uid=95897]@actor[/url] = $game_party.menu_actor
  550.         end
  551.         #--------------------------------------------------------------------------
  552.         # ● Refresh the contents
  553.         #--------------------------------------------------------------------------
  554.         def set_item(item = nil)
  555.                 contents.clear
  556.                 return if item.nil?
  557.     @data = Array.new(item.grathnode_slots, nil)
  558.     @installs = @actor.installs[item.id]
  559.                 draw_item_installs(item)
  560.         end
  561.         #--------------------------------------------------------------------------
  562.         # ● Displays the skill's current installs
  563.         #--------------------------------------------------------------------------
  564.         def draw_item_installs(item)
  565.     draw_horz_line(line_height * 6)
  566.                 change_color(system_color)
  567.                 contents.draw_text(4, 0, width, line_height, KRX::VOCAB::GRATHNODE)
  568.                 change_color(normal_color)
  569.     m = item.grathnode_slots
  570.                 (1..m).each {|i| contents.draw_text(4, line_height * i, width, line_height, "#{i}.")}
  571.     return if @installs.nil? || @installs.empty?
  572.                 @installs.each_index do |i|
  573.                         grath = @installs[i].nil? ? nil : $data_items[@installs[i]]
  574.                         draw_item_name(grath, 28, line_height * (i + 1), true, width - 24)
  575.     end
  576.     draw_mp(item) if @actor.process_grathnode_mp_cost(item).round > 0
  577.     draw_tp(item) if @actor.process_grathnode_tp_cost(item).round > 0
  578.   end
  579.         #--------------------------------------------------------------------------
  580.         # ● Displays the skill's MP inflation rate
  581.         #--------------------------------------------------------------------------
  582.   def draw_mp(item)
  583.     change_color(system_color)
  584.     contents.draw_text(4, line_height * 7, width, line_height, Vocab.basic(5))
  585.     change_color(normal_color)
  586.     contents.draw_text(28, line_height * 7, width, line_height,
  587.     "+#{@actor.process_grathnode_mp_cost(item).round.to_s}%")
  588.   end
  589.         #--------------------------------------------------------------------------
  590.         # ● Displays the skill's TP inflation rate
  591.         #--------------------------------------------------------------------------
  592.   def draw_tp(item)
  593.     change_color(system_color)
  594.     w = width / 4
  595.     contents.draw_text(w, line_height * 7, width, line_height, Vocab.basic(7))
  596.     change_color(normal_color)
  597.     contents.draw_text(w + 28, line_height * 7, width, line_height,
  598.     "+#{@actor.process_grathnode_tp_cost(item).round.to_s}%")
  599.         end
  600.         #--------------------------------------------------------------------------
  601.         # ● Returns the number of columns
  602.         #--------------------------------------------------------------------------
  603.         def col_max
  604.                 return 1
  605.         end
  606.   #--------------------------------------------------------------------------
  607.   # ● Returns the max number of rows
  608.   #--------------------------------------------------------------------------
  609.   def item_max
  610.     @data ? @data.size : 1
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # ● Sets the rectangle for selections
  614.   #--------------------------------------------------------------------------
  615.   def item_rect(index)
  616.     rect = Rect.new
  617.     rect.width = item_width
  618.     rect.height = item_height
  619.     rect.x = index % col_max * (item_width + spacing)
  620.     rect.y = (index / col_max * item_height) + line_height
  621.     rect
  622.   end
  623.         #--------------------------------------------------------------------------
  624.         # ● Displays an horizontal line
  625.         #--------------------------------------------------------------------------
  626.         def draw_horz_line(y)
  627.                 line_y = y + line_height / 2 - 1
  628.                 contents.fill_rect(0, line_y, contents_width, 2, line_color)
  629.         end
  630.         #--------------------------------------------------------------------------
  631.         # ● Returns the color used for horizontal lines
  632.         #--------------------------------------------------------------------------
  633.         def line_color
  634.                 color = normal_color
  635.                 color.alpha = 48
  636.                 return color
  637.         end
  638. end
  639.  
  640. #==========================================================================
  641. # ■ Window_GrathnodeList
  642. #==========================================================================
  643.  
  644. class Window_GrathnodeList < Window_ItemList
  645.         #--------------------------------------------------------------------------
  646.         # ● Determine if an item goes in the list
  647.         #--------------------------------------------------------------------------
  648.         def include?(item)
  649.     item.is_a?(RPG::Item) && item.grathnode?
  650.         end
  651.         #--------------------------------------------------------------------------
  652.         # ● Determine if the grathnode can be used
  653.         #--------------------------------------------------------------------------
  654.         def enable?(item)
  655.     return true if item.nil?
  656.     actor = $game_party.menu_actor
  657.     skill = $game_party.last_selected_skill
  658.     if !actor.installs[skill.id].nil? && actor.installs[skill.id].include?(item.id)
  659.       return false
  660.     end
  661.     if !item.grathnode_scope.nil? && !skill.send(item.grathnode_scope)
  662.       return false
  663.     end
  664.     return true
  665.         end
  666.         #--------------------------------------------------------------------------
  667.         # ● Creates the list based on the recipes
  668.         #--------------------------------------------------------------------------
  669.         def make_item_list
  670.                 @data = $game_party.items.select {|item| include?(item)}
  671.     @data.push(nil)
  672.         end
  673.         #--------------------------------------------------------------------------
  674.         # ● Returns the number of columns
  675.         #--------------------------------------------------------------------------
  676.         def col_max
  677.                 return 1
  678.         end
  679. end
  680.  
  681. #==========================================================================
  682. # ■ Scene_Battle
  683. #==========================================================================
  684.  
  685. class Scene_Battle < Scene_Base
  686.  
  687.   ## Yanfly's Ace Battle Engine implementation
  688.   if $imported["YEA-BattleEngine"]
  689.   #--------------------------------------------------------------------------
  690.   # ● Applies the effects of the skill or item
  691.   #--------------------------------------------------------------------------
  692.   alias_method(:krx_grathnode_sb_aie, :apply_item_effects)
  693.   def apply_item_effects(target, item)
  694.     apply_grathnode_effects(target, item)
  695.     krx_grathnode_sb_aie(target, item)
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ● Applies the effects of grathnodes associated to the skill
  699.   #--------------------------------------------------------------------------
  700.   def apply_grathnode_effects(target, item)
  701.     unless @subject.is_a?(Game_Actor)&& @subject.installs.keys.include?(item.id) &&
  702.     @subject.installs[item.id] != nil
  703.       return
  704.     end
  705.     @subject.installs[item.id].compact.each do |grath|
  706.       target.item_apply(@subject, $data_items[grath])
  707.     end
  708.   end
  709.   ## End of Yanfly's Ace Battle Engine implementation
  710.   ## DBS implementation
  711.   else
  712.   #--------------------------------------------------------------------------
  713.   # ● Applies the effects of the skill or item
  714.   #--------------------------------------------------------------------------
  715.   alias_method(:krx_grathnode_sb_aie, :apply_item_effects)
  716.   def apply_item_effects(target, item)
  717.     krx_grathnode_sb_aie(target, item)
  718.     apply_grathnode_effects(target, item)
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● Applies the effects of grathnodes associated to the skill
  722.   #--------------------------------------------------------------------------
  723.   def apply_grathnode_effects(target, item)
  724.     unless @subject.is_a?(Game_Actor)&& @subject.installs.keys.include?(item.id) &&
  725.     @subject.installs[item.id] != nil || target.dead?
  726.       return
  727.     end
  728.     return unless @subject.is_a?(Game_Actor)
  729.     return if @subject.installs.nil? || @subject.installs[item.id].nil?
  730.     @subject.installs[item.id].compact.each do |grath|
  731.       target.item_apply(@subject, $data_items[grath])
  732.       @log_window.display_action_results(target, $data_items[grath])
  733.     end
  734.   end # Method End
  735.   end ## End of DBS implementation
  736. end
  737.  
  738. ## Menu inclusion, with Yanfly's Ace Menu Engine
  739. if $imported["YEA-AceMenuEngine"]
  740.  
  741. #==========================================================================
  742. # ■ Scene_Menu
  743. #==========================================================================
  744.  
  745. class Scene_Menu < Scene_MenuBase
  746.         #--------------------------------------------------------------------------
  747.         # ● Switch to the actor selection
  748.         #--------------------------------------------------------------------------
  749.         def command_install
  750.     if KRX::SINGLE_ACTOR_INSTALL
  751.       SceneManager.call(Scene_Grathnode)
  752.       return
  753.     end
  754.     @status_window.select_last
  755.     @status_window.activate
  756.     @status_window.set_handler(:ok,     method(:on_install_ok))
  757.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  758.   end
  759.         #--------------------------------------------------------------------------
  760.         # ● Validates the actor selection
  761.         #--------------------------------------------------------------------------
  762.         def on_install_ok
  763.     SceneManager.call(Scene_Grathnode)
  764.   end
  765. end
  766.  
  767. #==========================================================================
  768. # ■ Window_MenuStatus
  769. #==========================================================================
  770.  
  771. class Window_MenuStatus < Window_Selectable
  772.         #--------------------------------------------------------------------------
  773.         # ● Determine if a party member can be selected
  774.         #--------------------------------------------------------------------------
  775.   alias_method(:krx_grathnode_wms_cie?, :current_item_enabled?)
  776.   def current_item_enabled?
  777.     if @handler[:ok].name == :on_install_ok
  778.       return !$game_party.members[index].barring_grathnode
  779.     end
  780.     return krx_grathnode_wms_cie?
  781.   end
  782. end
  783.  
  784. end ## End of Yanfly's Menu inclusion
  785.  
  786. ## Compatibility with Yanfly's TP Manager. Deprecated with the use of Ace Skill
  787. ## Menu
  788. =begin
  789. if $imported["YEA-TPManager"]
  790.  
  791. #==============================================================================
  792. # ■ Window_SkillCommand
  793. #==============================================================================
  794.  
  795. class Window_SkillCommand < Window_Command
  796.   #--------------------------------------------------------------------------
  797.   # ● Aliases YF's new method
  798.   #--------------------------------------------------------------------------
  799.   alias_method(:krx_grathnode_wsc_tp, :add_tp_modes)
  800.   def add_tp_modes
  801.     return if SceneManager.scene.is_a?(Scene_Grathnode)
  802.     krx_grathnode_wsc_tp
  803.   end
  804. end
  805.  
  806. #==========================================================================
  807. #  ■  Scene_Grathnode
  808. #==========================================================================
  809.  
  810. class Scene_Grathnode < Scene_Skill
  811.         #--------------------------------------------------------------------------
  812.         # ● Creates the command window
  813.         #--------------------------------------------------------------------------
  814.   def create_command_window
  815.     wy = @help_window.height
  816.     @command_window = Window_SkillCommand.new(0, wy)
  817.     @command_window.viewport = @viewport
  818.     @command_window.help_window = @help_window
  819.     @command_window.actor = @actor
  820.     @command_window.set_handler(:skill,    method(:command_skill))
  821.     @command_window.set_handler(:cancel,   method(:return_scene))
  822.     @command_window.set_handler(:pagedown, method(:next_actor))
  823.     @command_window.set_handler(:pageup,   method(:prev_actor))
  824.   end  
  825. end
  826.  
  827.  
  828. end ## End of TP Manager compatibility
  829. =end

点评

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

使用道具 举报

Lv2.观梦者 (暗夜天使)

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

贵宾

4
发表于 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
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-1-14 20:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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