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

Project1

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

[已经过期] 如何让这个脚本对技能的注释也有效?

[复制链接]

Lv2.观梦者

梦石
0
星屑
685
在线时间
661 小时
注册时间
2012-10-21
帖子
350
跳转到指定楼层
1
发表于 2014-9-2 23:40:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这是一个元素吸收的脚本,受到相应元素攻击时不受伤害反而加血,

这个脚本能对玩家、职业、武器装备、状态、敌人的进行元素吸收,只要注释写<element absorb: x>,x是元素id就好
但是技能不行……我想让它也能够读取技能中的注释,使得学习某个技能后也能拥有这样的吸收效果,请问要怎么改呢?

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Element Absorb v1.01
  4. # -- Last Updated: 2012.01.23
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-Element Absorb"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.23 - Compatibility Update: Doppelganger
  17. # 2011.12.14 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # Absorbing elements have been taken out of RPG Maker VX Ace despite being a
  23. # possible feature in the past RPG Maker iterations. This script brings back
  24. # the ability to absorb elemental rates by applying them as traits for actors,
  25. # classes, weapons, armours, enemies, and states.
  26. #
  27. # If a target is inherently strong against the element absorbed, then more
  28. # will be absorbed. If the target is inherently weak to the element absorbed,
  29. # then less will be absorbed. The rate of which absorption takes effect is
  30. # dependent on the target's natural affinity to the element.
  31. #
  32. #==============================================================================
  33. # ▼ Instructions
  34. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35. # To install this script, open up your script editor and copy/paste this script
  36. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  37. #
  38. # -----------------------------------------------------------------------------
  39. # Actor Notetags - These notetags go in the actors notebox in the database.
  40. # -----------------------------------------------------------------------------
  41. # <element absorb: x>
  42. # <element absorb: x, x>
  43. # Grants a trait to absorb element x and heal the battler.
  44. #
  45. # -----------------------------------------------------------------------------
  46. # Class Notetags - These notetags go in the class notebox in the database.
  47. # -----------------------------------------------------------------------------
  48. # <element absorb: x>
  49. # <element absorb: x, x>
  50. # Grants a trait to absorb element x and heal the battler.
  51. #
  52. # -----------------------------------------------------------------------------
  53. # Weapons Notetags - These notetags go in the weapons notebox in the database.
  54. # -----------------------------------------------------------------------------
  55. # <element absorb: x>
  56. # <element absorb: x, x>
  57. # Grants a trait to absorb element x and heal the battler.
  58. #
  59. # -----------------------------------------------------------------------------
  60. # Armour Notetags - These notetags go in the armours notebox in the database.
  61. # -----------------------------------------------------------------------------
  62. # <element absorb: x>
  63. # <element absorb: x, x>
  64. # Grants a trait to absorb element x and heal the battler.
  65. #
  66. # -----------------------------------------------------------------------------
  67. # Enemy Notetags - These notetags go in the enemies notebox in the database.
  68. # -----------------------------------------------------------------------------
  69. # <element absorb: x>
  70. # <element absorb: x, x>
  71. # Grants a trait to absorb element x and heal the battler.
  72. #
  73. # -----------------------------------------------------------------------------
  74. # State Notetags - These notetags go in the states notebox in the database.
  75. # -----------------------------------------------------------------------------
  76. # <element absorb: x>
  77. # <element absorb: x, x>
  78. # Grants a trait to absorb element x and heal the battler.
  79. #
  80. #==============================================================================
  81. # ▼ Compatibility
  82. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  83. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  84. # it will run with RPG Maker VX without adjusting.
  85. #
  86. #==============================================================================
  87.  
  88. module YEA
  89.   module ELEMENT_ABSORB
  90.  
  91.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92.     # - Absorption Settings -
  93.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  94.     # Here, you can change how the game handles absorption when there are
  95.     # multiple elements being calculated. If the following setting is set to
  96.     # true, then the absorption takes priority. If false, then absorption is
  97.     # ignored and the damage is calculated normally.
  98.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  99.     MULTI_ELEMENT_ABSORB_PRIORITY = true
  100.  
  101.   end # ELEMENT_ABSORB
  102. end # YEA
  103.  
  104. #==============================================================================
  105. # ▼ Editting anything past this point may potentially result in causing
  106. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  107. # halitosis so edit at your own risk.
  108. #==============================================================================
  109.  
  110. module YEA
  111.   module REGEXP
  112.   module BASEITEM
  113.  
  114.     ELE_ABSORB = /<(?:ELEMENT_ABSORB|element absorb):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  115.  
  116.   end # BASEITEM
  117.   end # REGEXP
  118. end # YEA
  119.  
  120. #==============================================================================
  121. # ■ DataManager
  122. #==============================================================================
  123.  
  124. module DataManager
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # alias method: load_database
  128.   #--------------------------------------------------------------------------
  129.   class <<self; alias load_database_eabs load_database; end
  130.   def self.load_database
  131.     load_database_eabs
  132.     load_notetags_eabs
  133.   end
  134.  
  135.   #--------------------------------------------------------------------------
  136.   # new method: load_notetags_eabs
  137.   #--------------------------------------------------------------------------
  138.   def self.load_notetags_eabs
  139.     groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
  140.       $data_enemies, $data_states]
  141.     for group in groups
  142.       for obj in group
  143.         next if obj.nil?
  144.         obj.load_notetags_eabs
  145.       end
  146.     end
  147.   end
  148.  
  149. end # DataManager
  150.  
  151. #==============================================================================
  152. # ■ RPG::BaseItem
  153. #==============================================================================
  154.  
  155. class RPG::BaseItem
  156.  
  157.   #--------------------------------------------------------------------------
  158.   # public instance variables
  159.   #--------------------------------------------------------------------------
  160.   attr_accessor :element_absorb
  161.  
  162.   #--------------------------------------------------------------------------
  163.   # common cache: load_notetags_eabs
  164.   #--------------------------------------------------------------------------
  165.   def load_notetags_eabs
  166.     @element_absorb = []
  167.     #---
  168.     self.note.split(/[\r\n]+/).each { |line|
  169.       case line
  170.       #---
  171.       when YEA::REGEXP::BASEITEM::ELE_ABSORB
  172.         $1.scan(/\d+/).each { |num|
  173.         @element_absorb.push(num.to_i) if num.to_i > 0 }
  174.       #---
  175.       end
  176.     } # self.note.split
  177.     #---
  178.   end
  179.  
  180. end # RPG::BaseItem
  181.  
  182. #==============================================================================
  183. # ■ Game_BattlerBase
  184. #==============================================================================
  185.  
  186. class Game_BattlerBase
  187.  
  188.   #--------------------------------------------------------------------------
  189.   # alias method: element_rate
  190.   #--------------------------------------------------------------------------
  191.   alias game_battler_element_rate_eabs element_rate
  192.   def element_rate(element_id)
  193.     result = game_battler_element_rate_eabs(element_id)
  194.     if element_absorb?(element_id)
  195.       result = [result - 2.0, -0.01].min
  196.     end
  197.     return result
  198.   end
  199.  
  200.   #--------------------------------------------------------------------------
  201.   # new method: element_absorb?
  202.   #--------------------------------------------------------------------------
  203.   def element_absorb?(element_id)
  204.     if actor?
  205.       return true if self.actor.element_absorb.include?(element_id)
  206.       return true if self.class.element_absorb.include?(element_id)
  207.       for equip in equips
  208.         next if equip.nil?
  209.         return true if equip.element_absorb.include?(element_id)
  210.       end
  211.     else
  212.       return true if self.enemy.element_absorb.include?(element_id)
  213.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  214.         return true if self.class.element_absorb.include?(element_id)
  215.       end
  216.     end
  217.     for state in states
  218.       next if state.nil?
  219.       return true if state.element_absorb.include?(element_id)
  220.     end
  221.     return false
  222.   end
  223.  
  224. end # Game_BattlerBase
  225.  
  226. #==============================================================================
  227. # ■ Game_Battler
  228. #==============================================================================
  229.  
  230. class Game_Battler < Game_BattlerBase
  231.  
  232.   #--------------------------------------------------------------------------
  233.   # alias method: elements_max_rate
  234.   #--------------------------------------------------------------------------
  235.   alias game_battler_elements_max_rate_eabs elements_max_rate
  236.   def elements_max_rate(elements)
  237.     result = game_battler_elements_max_rate_eabs(elements)
  238.     if YEA::ELEMENT_ABSORB::MULTI_ELEMENT_ABSORB_PRIORITY
  239.       for element_id in elements
  240.         next unless element_absorb?(element_id)
  241.         result = [result - 2.0, -0.01].min
  242.         return result
  243.       end
  244.     end
  245.     return result
  246.   end
  247.  
  248. end # Game_Battler
  249.  
  250. #==============================================================================
  251. #
  252. # ▼ End of File
  253. #
  254. #==============================================================================

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2014-9-3 12:48:13 | 只看该作者
重定义 DataManager.load_notetags_eabs 、Game_BattlerBase#element_absorb? 方法。

点评

1.我在def self.load_notetags_eabs里,groups = [$data_actors……里面添加了$data_skills,但是无效…… 2.element_absorb?里要怎么改?return true if self.skill.element_absorb.inclu?   发表于 2014-9-3 12:55

评分

参与人数 1星屑 +132 收起 理由
VIPArcher + 132 喵。

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
685
在线时间
661 小时
注册时间
2012-10-21
帖子
350
3
 楼主| 发表于 2014-9-3 12:56:41 | 只看该作者
Game_BattlerBase#element_absorb?
里面添加
      return true if self.skill.element_absorb.include?(element_id)
就出错了……

点评

自己理解着改吧。我只说,依样画葫芦是改不出来的  发表于 2014-9-4 12:30
敌人没有技能的话,就会使得效果无效吧?不会出bug弹错吧?  发表于 2014-9-3 17:08
请在理解的基础上修改,尤其要理解 Game_BattlerBase 和 Game_Actor 。友情提示:默认脚本中敌人是没有技能的  发表于 2014-9-3 16:06
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-13 01:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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