查看: 2528|回复: 4

[已经解决] 请问如何使用盗取技能脚本后,学习的和盗取的技能不一样?

[复制链接]
梦石
0
星屑
254
在线时间
316 小时
注册时间
2015-7-2
回帖
1629

开拓者

发表于 2016-1-21 18:59:08 | 显示全部楼层 |阅读模式

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

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

×
脚本[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Skill Steal v1.00
# -- Last Updated: 2011.12.10
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-SkillSteal"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.10 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script enables items and skills to have skill stealing properties. When
# an actor uses that said item or skill on an enemy and the enemy has skills
# that can be stolen, that actor will learn all of the skills the enemy has to
# provide. This skill stealing system is madeakin to the Final Fantasy X's
# Lancet skill from Kimahri.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <skill steal>
# If this skill targets an enemy, the actor who uses it will learn all of the
# stealable skills the enemy knows in its action list.
#
# <stealable skill>
# A skill with this notetag can be stolen from enemies if it is listed within
# the enemy's action list.
#
# -----------------------------------------------------------------------------
# Item Notetags - These notetags go in the items notebox in the database.
# -----------------------------------------------------------------------------
# <skill steal>
# If this item targets an enemy, the actor who uses it will learn all of the
# stealable skills the enemy knows in its action list.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module SKILL_STEAL
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Battlelog Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # These are the various battlelog settings made for skill stealing. Change
    # the text and message duration for a successful skill stealing.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    MSG_SKILL_STEAL = "%s 模仿了 %s 从 %s!" # Text for successful steal.
    MSG_DURATION    = 4                       # Lower number = shorter duration.
   
  end # SKILL_STEAL
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module USABLEITEM
   
    SKILL_STEAL     = /<(?:SKILL_STEAL|skill steal)>/i
    STEALABLE_SKILL = /<(?:STEALABLE_SKILL|stealable skill)>/i
   
  end # USABLEITEM
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_ss load_database; end
  def self.load_database
    load_database_ss
    load_notetags_ss
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_ss
  #--------------------------------------------------------------------------
  def self.load_notetags_ss
    groups = [$data_skills, $data_items]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_ss
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :skill_steal
  attr_accessor :stealable_skill
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_ss
  #--------------------------------------------------------------------------
  def load_notetags_ss
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::USABLEITEM::SKILL_STEAL
        @skill_steal = true
      when YEA::REGEXP::USABLEITEM::STEALABLE_SKILL
        next unless self.is_a?(RPG::Skill)
        @stealable_skill = true
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::UsableItem

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # alias method: item_user_effect
  #--------------------------------------------------------------------------
  alias game_battler_item_user_effect_ss item_user_effect
  def item_user_effect(user, item)
    game_battler_item_user_effect_ss(user, item)
    item_skill_steal_effect(user, item)
  end
  
  #--------------------------------------------------------------------------
  # new method: item_skill_steal_effect
  #--------------------------------------------------------------------------
  def item_skill_steal_effect(user, item)
    return unless item.skill_steal
    return unless user.actor?
    return if self.actor?
    for skill in stealable_skills
      next if user.skill_learn?(skill)
      @result.success = true
      break
    end
  end
  
end # Game_Battler

#==============================================================================
# ■ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
  
  #--------------------------------------------------------------------------
  # stealable_skills
  #--------------------------------------------------------------------------
  def stealable_skills
    array = []
    for action in enemy.actions
      skill = $data_skills[action.skill_id]
      array.push(skill) if skill.stealable_skill
    end
    return array
  end
  
end # Game_Enemy

#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: apply_item_effects
  #--------------------------------------------------------------------------
  alias scene_battle_apply_item_effects_ss apply_item_effects
  def apply_item_effects(target, item)
    scene_battle_apply_item_effects_ss(target, item)
    apply_skill_steal(target, item)
  end
  
  #--------------------------------------------------------------------------
  # new method: apply_skill_steal
  #--------------------------------------------------------------------------
  def apply_skill_steal(target, item)
    return unless item.skill_steal
    return if target.actor?
    return unless @subject.actor?
    for skill in target.stealable_skills
      next if @subject.skill_learn?(skill)
      @subject.learn_skill(skill.id)
      string = YEA::SKILL_STEAL::MSG_SKILL_STEAL
      skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
      text = sprintf(string, @subject.name, skill_text, target.name)
      @log_window.add_text(text)
      YEA::SKILL_STEAL::MSG_DURATION.times do @log_window.wait end
      @log_window.back_one
    end
  end
  
end # Scene_Battle

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

这是盗取敌方技能的脚本。
问题在于,假设说我盗取了敌方的技能A,但是掌握的却是技能B,如何设置?
不要告诉我一个一个事件设置,虽然那样……理论上也可以……
测试你的东方project认知程度?那就来玩[url=https://store.steampowered.com/app/930840/TouHouAsked/]《东方百问》[/url]吧!
东方风自作曲认知企划绝赞咕咕咕中

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-1-21 20:34:34 | 显示全部楼层
本帖最后由 cinderelmini 于 2016-1-21 20:39 编辑

在【module SKILL_STEAL】里面添加了个哈希表做技能对应,
然后在【Game_Enemy】里面调整了偷盗的技能ID获取。
(未测试,BUG未知……)
点击展开/收起
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Skill Steal v1.00
  4. # -- Last Updated: 2011.12.10
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

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

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2011.12.10 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # This script enables items and skills to have skill stealing properties. When
  20. # an actor uses that said item or skill on an enemy and the enemy has skills
  21. # that can be stolen, that actor will learn all of the skills the enemy has to
  22. # provide. This skill stealing system is madeakin to the Final Fantasy X's
  23. # Lancet skill from Kimahri.
  24. #
  25. #==============================================================================
  26. # ▼ Instructions
  27. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. # To install this script, open up your script editor and copy/paste this script
  29. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  30. #
  31. # -----------------------------------------------------------------------------
  32. # Skill Notetags - These notetags go in the skills notebox in the database.
  33. # -----------------------------------------------------------------------------
  34. # <skill steal>
  35. # If this skill targets an enemy, the actor who uses it will learn all of the
  36. # stealable skills the enemy knows in its action list.
  37. #
  38. # <stealable skill>
  39. # A skill with this notetag can be stolen from enemies if it is listed within
  40. # the enemy's action list.
  41. #
  42. # -----------------------------------------------------------------------------
  43. # Item Notetags - These notetags go in the items notebox in the database.
  44. # -----------------------------------------------------------------------------
  45. # <skill steal>
  46. # If this item targets an enemy, the actor who uses it will learn all of the
  47. # stealable skills the enemy knows in its action list.
  48. #
  49. #==============================================================================
  50. # ▼ Compatibility
  51. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  52. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  53. # it will run with RPG Maker VX without adjusting.
  54. #
  55. #==============================================================================

  56. module YEA::SKILL_STEAL::STEAL_SKILLS
  57.   module SKILL_STEAL

  58.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  59.     # - Battlelog Settings -
  60.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  61.     # These are the various battlelog settings made for skill stealing. Change
  62.     # the text and message duration for a successful skill stealing.
  63.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  64.     MSG_SKILL_STEAL = "%s 模仿了 %s 从 %s!" # Text for successful steal.
  65.     MSG_DURATION    = 4                       # Lower number = shorter duration.
  66.    
  67.     STEAL_SKILLS = {# 偷盗的目标技能ID => 实际偷到的技能ID
  68.                     # 不设置的话就直接学偷盗的目标技能
  69.                     1 => 11,
  70.                     2 => 21,
  71.                     3 => 22,
  72.                     # 自己扩展,有多少就写多少
  73.                     }

  74.   end # SKILL_STEAL
  75. end # YEA

  76. #==============================================================================
  77. # ▼ Editting anything past this point may potentially result in causing
  78. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  79. # halitosis so edit at your own risk.
  80. #==============================================================================

  81. module YEA
  82.   module REGEXP
  83.   module USABLEITEM

  84.     SKILL_STEAL     = /<(?:SKILL_STEAL|skill steal)>/i
  85.     STEALABLE_SKILL = /<(?:STEALABLE_SKILL|stealable skill)>/i

  86.   end # USABLEITEM
  87.   end # REGEXP
  88. end # YEA

  89. #==============================================================================
  90. # ■ DataManager
  91. #==============================================================================

  92. module DataManager

  93.   #--------------------------------------------------------------------------
  94.   # alias method: load_database
  95.   #--------------------------------------------------------------------------
  96.   class <<self; alias load_database_ss load_database; end
  97.   def self.load_database
  98.     load_database_ss
  99.     load_notetags_ss
  100.   end

  101.   #--------------------------------------------------------------------------
  102.   # new method: load_notetags_ss
  103.   #--------------------------------------------------------------------------
  104.   def self.load_notetags_ss
  105.     groups = [$data_skills, $data_items]
  106.     for group in groups
  107.       for obj in group
  108.         next if obj.nil?
  109.         obj.load_notetags_ss
  110.       end
  111.     end
  112.   end

  113. end # DataManager

  114. #==============================================================================
  115. # ■ RPG::UsableItem
  116. #==============================================================================

  117. class RPG::UsableItem < RPG::BaseItem

  118.   #--------------------------------------------------------------------------
  119.   # public instance variables
  120.   #--------------------------------------------------------------------------
  121.   attr_accessor :skill_steal
  122.   attr_accessor :stealable_skill

  123.   #--------------------------------------------------------------------------
  124.   # common cache: load_notetags_ss
  125.   #--------------------------------------------------------------------------
  126.   def load_notetags_ss
  127.     #---
  128.     self.note.split(/[\r\n]+/).each { |line|
  129.       case line
  130.       #---
  131.       when YEA::REGEXP::USABLEITEM::SKILL_STEAL
  132.         @skill_steal = true
  133.       when YEA::REGEXP::USABLEITEM::STEALABLE_SKILL
  134.         next unless self.is_a?(RPG::Skill)
  135.         @stealable_skill = true
  136.       #---
  137.       end
  138.     } # self.note.split
  139.     #---
  140.   end

  141. end # RPG::UsableItem

  142. #==============================================================================
  143. # ■ Game_Battler
  144. #==============================================================================

  145. class Game_Battler < Game_BattlerBase

  146.   #--------------------------------------------------------------------------
  147.   # alias method: item_user_effect
  148.   #--------------------------------------------------------------------------
  149.   alias game_battler_item_user_effect_ss item_user_effect
  150.   def item_user_effect(user, item)
  151.     game_battler_item_user_effect_ss(user, item)
  152.     item_skill_steal_effect(user, item)
  153.   end

  154.   #--------------------------------------------------------------------------
  155.   # new method: item_skill_steal_effect
  156.   #--------------------------------------------------------------------------
  157.   def item_skill_steal_effect(user, item)
  158.     return unless item.skill_steal
  159.     return unless user.actor?
  160.     return if self.actor?
  161.     for skill in stealable_skills
  162.       next if user.skill_learn?(skill)
  163.       @result.success = true
  164.       break
  165.     end
  166.   end

  167. end # Game_Battler

  168. #==============================================================================
  169. # ■ Game_Enemy
  170. #==============================================================================

  171. class Game_Enemy < Game_Battler

  172.   #--------------------------------------------------------------------------
  173.   # stealable_skills
  174.   #--------------------------------------------------------------------------
  175.   def stealable_skills
  176.     array = []
  177.     for action in enemy.actions
  178.       # 如果设置对应列表里有偷盗对应技能ID的话就代入,否则直接代入行动技能ID
  179.       steal_skill_id = YEA::SKILL_STEAL::STEAL_SKILLS[action.skill_id] || action.skill_id
  180.       skill_1 = $data_skills[action.skill_id]   # 偷盗目标技能
  181.       skill_2 = $data_skills[steal_skill_id]     # 实际偷到的技能
  182.       array.push(skill_2) if skill_1.stealable_skill
  183.     end
  184.     return array
  185.   end

  186. end # Game_Enemy

  187. #==============================================================================
  188. # ■ Scene_Battle
  189. #==============================================================================

  190. class Scene_Battle < Scene_Base

  191.   #--------------------------------------------------------------------------
  192.   # alias method: apply_item_effects
  193.   #--------------------------------------------------------------------------
  194.   alias scene_battle_apply_item_effects_ss apply_item_effects
  195.   def apply_item_effects(target, item)
  196.     scene_battle_apply_item_effects_ss(target, item)
  197.     apply_skill_steal(target, item)
  198.   end

  199.   #--------------------------------------------------------------------------
  200.   # new method: apply_skill_steal
  201.   #--------------------------------------------------------------------------
  202.   def apply_skill_steal(target, item)
  203.     return unless item.skill_steal
  204.     return if target.actor?
  205.     return unless @subject.actor?
  206.     for skill in target.stealable_skills
  207.       next if @subject.skill_learn?(skill)
  208.       @subject.learn_skill(skill.id)
  209.       string = YEA::SKILL_STEAL::MSG_SKILL_STEAL
  210.       skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
  211.       text = sprintf(string, @subject.name, skill_text, target.name)
  212.       @log_window.add_text(text)
  213.       YEA::SKILL_STEAL::MSG_DURATION.times do @log_window.wait end
  214.       @log_window.back_one
  215.     end
  216.   end

  217. end # Scene_Battle

  218. #==============================================================================
  219. #
  220. # ▼ End of File
  221. #
  222. #==============================================================================
复制代码

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
254
在线时间
316 小时
注册时间
2015-7-2
回帖
1629

开拓者

 楼主| 发表于 2016-1-22 00:03:24 | 显示全部楼层
cinderelmini 发表于 2016-1-21 20:34
在【module SKILL_STEAL】里面添加了个哈希表做技能对应,
然后在【Game_Enemy】里面调整了偷盗的技能ID获 ...

4.png
启动游戏时报错
测试你的东方project认知程度?那就来玩[url=https://store.steampowered.com/app/930840/TouHouAsked/]《东方百问》[/url]吧!
东方风自作曲认知企划绝赞咕咕咕中
回复

使用道具 举报

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-1-22 19:53:06 | 显示全部楼层
落雪鸦杀 发表于 2016-1-22 00:03
启动游戏时报错

【module YEA::SKILL_STEAL::STEAL_SKILLS】》【module YEA】
后面那段忘记删掉了…………

点评

多谢!  发表于 2016-1-22 22:51
回复

使用道具 举报

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-1-22 19:53:28 | 显示全部楼层
落雪鸦杀 发表于 2016-1-22 00:03
启动游戏时报错

【module YEA::SKILL_STEAL::STEAL_SKILLS】》【module YEA】
后面那段忘记删掉了…………

点评

手残hhhhhh  发表于 2016-1-23 14:20
卧槽……岂可修……肿么就连楼了…………  发表于 2016-1-23 14:10
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部