Project1

标题: 双向技能 [打印本页]

作者: 雪流星    时间: 2012-2-26 02:10
标题: 双向技能
效果:
让技能或物品可以作用在敌人与我方队员身上
可以让同样的技能,使用在敌方身上与我方身上不同(也可以相同)
这样就可以只做出攻击队友来除去睡眠状态这一类的效果

使用方法:
在技能/物品备注里面填写 [for_both]
则可以指定为双向技能/物品

在技能/物品备注里面填写 [twin_item ID]
则可以指定双向技能/物品所使用的第二项技能/物品
没有填写时,默认为原技能ID+1

设定方法

下面的说明,技能与物品通用
要设定为双向技能的技能(假设为18号技能)备注中填写 [for_both]
效果范围设定为“敌方单体”

将第19号技能的效果范围设定为“我方单体”
其他的设定可以自由修改,我方的效果可以与敌方的不同。

如此选择目标时,则会先出现敌方目标窗口,
按 B 键再出现我方目标窗口。


如果第一个技能的效果范围设定为“我方单体”
那第二个技能必须设定为“敌方单体”
如此选择目标时,则会先出现我方目标窗口,
按 B 键再出现敌方目标窗口。

注意:
如果是1号技能(即普通攻击),在不修改脚本的情况下,2号技能就是防御
那这时候就可以使用 [twin_item ID] 来指定对我方使用技能的效果是几号技能
例如用 [twin_item 30],那在对我方使用攻击时,实际产生效用的是30号技能

RUBY 代码复制
  1. class RPG::UsableItem < RPG::BaseItem
  2.   #--------------------------------------------------------------------------
  3.   # ● 判断是否为双向技能
  4.   #--------------------------------------------------------------------------
  5.   def for_both?
  6.     return @for_both unless @for_both.nil?
  7.     self.note.split(/[\r\n]+/).each{ |line|
  8.       if line =~ /\[for_both\]/
  9.         return @for_both = true
  10.       end}
  11.     return @for_both = false
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 指定双向技能/物品的第二个技能/物品
  15.   #--------------------------------------------------------------------------
  16.   def twin_item
  17.     return self.id unless for_both?
  18.     return @twin_item_id unless @twin_item_id.nil?
  19.     @twin_item_id = self.id + 1
  20.     self.note.split(/[\r\n]+/).each{ |line|
  21.       if line =~ /\[twin_item (\d+)\]/
  22.         @twin_item_id = $1.to_i
  23.       end}
  24.     return @twin_item_id
  25.   end
  26. end
  27. class Scene_Battle < Scene_Base
  28.   #--------------------------------------------------------------------------
  29.   # ● 回合开始
  30.   #--------------------------------------------------------------------------
  31.   alias skill_for_both_turn_start turn_start
  32.   def turn_start
  33.     selection_reset
  34.     skill_for_both_turn_start
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 目标选择初始化
  38.   #--------------------------------------------------------------------------
  39.   def selection_reset
  40.     @from_enemy_selection = false
  41.     @from_actor_selection = false
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 取消选择敌人目标时
  45.   #--------------------------------------------------------------------------
  46.   alias skill_for_both_on_enemy_cancel on_enemy_cancel
  47.   def on_enemy_cancel
  48.     item = current_used_item
  49.     if item.for_both? && !@from_actor_selection  # 判断是否为双向技能
  50.       change_current_item_selection(item)
  51.       @from_enemy_selection = true
  52.       select_actor_selection # 开启我方队员选择窗口
  53.       @enemy_window.hide
  54.     else
  55.       selection_reset
  56.       skill_for_both_on_enemy_cancel # 呼叫原有方法
  57.     end
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 取消选择同伴目标时
  61.   #--------------------------------------------------------------------------
  62.   alias skill_for_both_on_actor_cancel on_actor_cancel
  63.   def on_actor_cancel
  64.     item = current_used_item
  65.     if item.for_both? && !@from_enemy_selection  # 判断是否为双向技能
  66.       change_current_item_selection(item)
  67.       @from_actor_selection = true
  68.       select_enemy_selection # 开启我方队员选择窗口
  69.       @actor_window.hide
  70.     else
  71.       if @actor_command_window.current_symbol == :attack
  72.         @actor_command_window.activate
  73.       end
  74.       selection_reset
  75.       skill_for_both_on_actor_cancel # 呼叫原有方法
  76.     end
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 获取当前技能/物品
  80.   #--------------------------------------------------------------------------
  81.   def current_used_item
  82.     case @actor_command_window.current_symbol
  83.     when :attack
  84.       return $data_skills[1]
  85.     when :skill
  86.       return @skill
  87.     when :item
  88.       return @item
  89.     end
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 当前技能/物品替换
  93.   #--------------------------------------------------------------------------
  94.   def change_current_item_selection(item)
  95.     case @actor_command_window.current_symbol
  96.     when :attack, :skill
  97.       BattleManager.actor.input.set_skill(item.twin_item)
  98.     when :item
  99.       BattleManager.actor.input.set_item(item.twin_item)
  100.     end
  101.   end
  102. end
  103. class Game_BattlerBase
  104.   #--------------------------------------------------------------------------
  105.   # ● 判断物品是否能使用
  106.   #--------------------------------------------------------------------------
  107.   alias skill_for_both_item_conditions_met? item_conditions_met?
  108.   def item_conditions_met?(item)
  109.     r_item_id = has_twin_item?(item)
  110.     if r_item_id
  111.       real_item = $data_items[r_item_id]
  112.       return skill_for_both_item_conditions_met?(real_item)
  113.     else
  114.       skill_for_both_item_conditions_met?(item)
  115.     end
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 判断物品是否双向物品的第二个物品
  119.   #--------------------------------------------------------------------------
  120.   def has_twin_item?(item)
  121.     $data_items.each{ |i|
  122.       next unless i
  123.       next unless i.for_both?
  124.       t_id = i.twin_item
  125.       return i.id if t_id == item.id
  126.     }
  127.     return false
  128.   end
  129. end

作者: 杂兵天下的马甲    时间: 2012-2-26 11:33
6R总是比WP慢不只一两步。
  1. #==============================================================================
  2. #
  3. # ▼ YSA Battle Add-On: Invert Targets
  4. # -- Last Updated: 2012.02.19
  5. # -- Level: Easy
  6. # -- Requires Optional:
  7. #  + Yanfly Engine Ace - Ace Battle Engine
  8. #
  9. #==============================================================================

  10. $imported = {} if $imported.nil?
  11. $imported["YSA-InvertTargets"] = true

  12. #==============================================================================
  13. # ▼ Updates
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # 2012.02.19 - Add notetag <no invert>.
  16. # 2012.01.03 - Fix a critical bug after an inverted skill.
  17. # 2012.01.03 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Instructions
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # To install this script, open up your script editor and copy/paste this script
  23. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  24. #
  25. # -----------------------------------------------------------------------------
  26. # Skill and Item Notetags
  27. # -----------------------------------------------------------------------------
  28. # <no invert>
  29. # Make the skill/item cannot be inverted.
  30. #
  31. #==============================================================================
  32. # ▼ Compatibility
  33. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  34. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  35. # it will run with RPG Maker VX without adjusting.
  36. #
  37. #==============================================================================

  38. module YSA
  39.   module INVERT_TARGETS
  40.    
  41.     # Select key which will invert the targets selection.
  42.     INVERT_KEY = :SHIFT
  43.    
  44.   end
  45. end

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

  51. module YSA
  52.   module REGEXP
  53.   module USABLEITEM
  54.    
  55.     NO_INVERT = /<(?:NO_INVERT|no invert)>/i
  56.    
  57.   end # USABLEITEM
  58.   end # REGEXP
  59. end # YSA

  60. #==============================================================================
  61. # ■ DataManager
  62. #==============================================================================

  63. module DataManager
  64.   
  65.   #--------------------------------------------------------------------------
  66.   # alias method: load_database
  67.   #--------------------------------------------------------------------------
  68.   class <<self; alias load_database_invt load_database; end
  69.   def self.load_database
  70.     load_database_invt
  71.     load_notetags_invt
  72.   end
  73.   
  74.   #--------------------------------------------------------------------------
  75.   # new method: load_notetags_invt
  76.   #--------------------------------------------------------------------------
  77.   def self.load_notetags_invt
  78.     groups = [$data_skills, $data_items]
  79.     for group in groups
  80.       for obj in group
  81.         next if obj.nil?
  82.         obj.load_notetags_invt
  83.       end
  84.     end
  85.   end
  86.   
  87. end # DataManager

  88. #==============================================================================
  89. # ■ RPG::UsableItem
  90. #==============================================================================

  91. class RPG::UsableItem < RPG::BaseItem

  92.   #--------------------------------------------------------------------------
  93.   # public instance variables
  94.   #--------------------------------------------------------------------------
  95.   attr_accessor :no_invert
  96.   
  97.   #--------------------------------------------------------------------------
  98.   # common cache: load_notetags_invt
  99.   #--------------------------------------------------------------------------
  100.   def load_notetags_invt
  101.     @no_invert = false
  102.     #---
  103.     self.note.split(/[\r\n]+/).each { |line|
  104.       case line
  105.       #---
  106.       when YSA::REGEXP::USABLEITEM::NO_INVERT
  107.         @no_invert = true
  108.       #---
  109.       end
  110.     } # self.note.split
  111.     #---
  112.   end
  113.   
  114. end # RPG::UsableItem

  115. #==============================================================================
  116. # ■ Game_Action
  117. #==============================================================================

  118. class Game_Action

  119.   #--------------------------------------------------------------------------
  120.   # alias method: friends_unit
  121.   #--------------------------------------------------------------------------
  122.   alias invert_target_friends_unit friends_unit
  123.   def friends_unit
  124.     subject.invert_target? ? subject.opponents_unit : invert_target_friends_unit
  125.   end

  126.   #--------------------------------------------------------------------------
  127.   # alias method: opponents_unit
  128.   #--------------------------------------------------------------------------
  129.   alias invert_target_opponents_unit opponents_unit
  130.   def opponents_unit
  131.     subject.invert_target? ? subject.friends_unit : invert_target_opponents_unit
  132.   end
  133.   
  134.   #--------------------------------------------------------------------------
  135.   # alias method: set_skill
  136.   #--------------------------------------------------------------------------
  137.   alias invert_target_set_skill set_skill
  138.   def set_skill(skill_id)
  139.     invert_target_set_skill(skill_id)
  140.     subject.invert_target = false
  141.   end
  142.   
  143.   #--------------------------------------------------------------------------
  144.   # alias method: set_item
  145.   #--------------------------------------------------------------------------
  146.   alias invert_target_set_item set_item
  147.   def set_item(skill_id)
  148.     invert_target_set_item(skill_id)
  149.     subject.invert_target = false
  150.   end
  151.    
  152. end # Game_Action

  153. #==============================================================================
  154. # ■ Game_Battler
  155. #==============================================================================

  156. class Game_Battler < Game_BattlerBase
  157.   
  158.   #--------------------------------------------------------------------------
  159.   # public instance variables
  160.   #--------------------------------------------------------------------------
  161.   attr_accessor :invert_target

  162.   #--------------------------------------------------------------------------
  163.   # alias method: initialize
  164.   #--------------------------------------------------------------------------
  165.   alias invert_target_initialize initialize
  166.   def initialize
  167.     invert_target_initialize
  168.     @invert_target = false
  169.   end
  170.   
  171.   #--------------------------------------------------------------------------
  172.   # new method: invert_target?
  173.   #--------------------------------------------------------------------------
  174.   def invert_target?
  175.     @invert_target
  176.   end
  177.   
  178. end # Game_Battler

  179. #==============================================================================
  180. # ■ Scene_Battle
  181. #==============================================================================

  182. class Scene_Battle < Scene_Base
  183.   
  184.   #--------------------------------------------------------------------------
  185.   # alias method: update_basic
  186.   #--------------------------------------------------------------------------
  187.   alias scene_battle_update_basic_invtrg update_basic
  188.   def update_basic
  189.     scene_battle_update_basic_invtrg
  190.     update_input_invert_target
  191.   end
  192.   
  193.   #--------------------------------------------------------------------------
  194.   # new method: update_input_invert_target
  195.   #--------------------------------------------------------------------------
  196.   def update_input_invert_target
  197.     return unless BattleManager.actor
  198.     return unless @actor_window.active || @enemy_window.active
  199.     if Input.trigger?(YSA::INVERT_TARGETS::INVERT_KEY)
  200.       return if BattleManager.actor.input.item.no_invert
  201.       BattleManager.actor.invert_target = !BattleManager.actor.invert_target
  202.       if @actor_window.active
  203.         @actor_window.unselect
  204.         @actor_window.hide.deactivate
  205.         case @actor_command_window.current_symbol
  206.         when :skill
  207.           @skill_window.show
  208.         when :item
  209.           @item_window.show
  210.         end
  211.         select_enemy_selection
  212.       elsif @enemy_window.active
  213.         @enemy_window.hide.deactivate
  214.         case @actor_command_window.current_symbol
  215.         when :skill
  216.           @skill_window.hide
  217.         when :item
  218.           @item_window.hide
  219.         end
  220.         if $imported["YEA-BattleEngine"]
  221.           scene_battle_select_actor_selection_abe
  222.         else
  223.           select_actor_selection
  224.         end        
  225.       end
  226.     end
  227.   end
  228.   
  229.   #--------------------------------------------------------------------------
  230.   # alias method: on_actor_cancel
  231.   #--------------------------------------------------------------------------
  232.   alias scene_battle_on_actor_cancel_invtrg on_actor_cancel
  233.   def on_actor_cancel
  234.     scene_battle_on_actor_cancel_invtrg
  235.     BattleManager.actor.invert_target = false
  236.   end
  237.   
  238.   #--------------------------------------------------------------------------
  239.   # alias method: on_enemy_cancel
  240.   #--------------------------------------------------------------------------
  241.   alias scene_battle_on_enemy_cancel_invtrg on_enemy_cancel
  242.   def on_enemy_cancel
  243.     scene_battle_on_enemy_cancel_invtrg
  244.     BattleManager.actor.invert_target = false
  245.   end
  246.   
  247.   #--------------------------------------------------------------------------
  248.   # alias method: turn_end
  249.   #--------------------------------------------------------------------------
  250.   alias scene_battle_turn_end_invtrg turn_end
  251.   def turn_end
  252.     scene_battle_turn_end_invtrg
  253.     for actor in $game_party.members
  254.       actor.invert_target = false
  255.     end
  256.   end
  257.   
  258. end # Scene_Battle

  259. #==============================================================================
  260. #
  261. # ▼ End of File
  262. #
  263. #==============================================================================
复制代码

作者: 雪流星    时间: 2012-2-26 12:24
本帖最后由 雪流星 于 2012-2-25 22:25 编辑
杂兵天下的马甲 发表于 2012-2-25 21:33
6R总是比WP慢不只一两步。


嗯,他的脚本默认所有技能都能双向选择
而且是直接修改 Game_Action 中的目标
这样的话就没办法我方跟敌方效果不同了{:1_3:}@
作者: 逆天RPG    时间: 2013-7-22 00:03
瓦擦,弄了半天才发现理解错了。还以为是对目标使用技能的同时为反方附加使用另外技能。{:2_271:}
作者: a1578032454    时间: 2013-7-23 20:21
脚本可以说是将原来VA上的技能设置的缺陷补上了?
作者: 447476402    时间: 2014-2-11 00:03
sideview 的横版和这个是不是冲突了啊? cp和这个会不会有冲突?
作者: 猩红之月    时间: 2014-12-27 19:34
本帖最后由 猩红之月 于 2015-1-2 20:44 编辑

我设置了没反应啊。
这是我的游戏工程,楼主帮我看看是哪里出问题了

360软件小助手截图20150102204148.png (55.05 KB, 下载次数: 29)

360软件小助手截图20150102204148.png

360软件小助手截图20150102204201.png (51.71 KB, 下载次数: 30)

360软件小助手截图20150102204201.png

360软件小助手截图20150102204230.png (1.05 KB, 下载次数: 30)

360软件小助手截图20150102204230.png





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