Project1

标题: 合击脚本 [打印本页]

作者: 奥特曼盖亚    时间: 2013-6-30 08:27
标题: 合击脚本
谁有VA的合击脚本呀给个链接好用的并教教方法
作者: ,。、    时间: 2013-7-8 11:42
我也想要。。。。。。。。。。。。。。
作者: 786617604    时间: 2013-7-9 16:14
http://rpg.blue/forum.php?mod=viewthread&tid=247817
VA超级整合里有一个“援护系统”可以试一试。。。
作者: 奥特曼盖亚    时间: 2013-7-20 15:50
还有吗还有谁提点建议
作者: lirn    时间: 2013-7-20 21:55
  1. =begin
  2. 合体技VXAce
  3. 2012年07月15日 作成。
  4. 2012年12月05日 改訂。
  5. 配布元:
  6. http://tamurarpgvx.blog137.fc2.com/
  7. 配布記事:
  8. http://tamurarpgvx.blog137.fc2.com/blog-entry-124.html

  9. 【概要】
  10. 合体技を作成します。

  11. 【使い方】
  12. スクリプトエディタの(ここに追加)の下に、このファイルをコピーして下さい。

  13. 【機能】
  14. ①まず、どれでもいいので、スキルのメモ欄に <combi;XXX;YYY;ZZZ;AAA> と書き込みます。

  15. ②するとこのスキルは合体技となり、IDがXXX番のスキル、IDがYYY番のスキル、
  16. IDがZZZ番のスキル、IDがAAA番のスキルを、アクターが1人ずつ覚えていないと
  17. 使用できません。
  18. ひとりが複数のスキルを覚えていても駄目です。ひとつずつ分担します。

  19. また、<combi;XXX;YYY;ZZZ>とやると3人技、
  20. <combi;XXX;YYY>で二人技です。
  21. かならず > で終わりを閉じてください。

  22. なお、行動不能のアクターは参加できません。

  23. ③消費するMPは、分担するスキルのものです。合体技そのもののMPは無視します。

  24. ④スキル習得・MP・行動可能の条件を満たすと、パーティコマンドの「逃げる」の下に
  25. 「合体技」が出現します。

  26. ⑤使いたい合体技を選びます。MPが足りない・参加者が行動不能な合体技は表示されません。

  27. ⑥合体技を選んだら、参加メンバーを選びます。どういう事かと言うと、
  28. 2・3人技は、同じ技を二人が覚えていると、参加メンバーの組み合わせが複数あるためです。

  29. ⑦参加メンバーを選んだら、一番上のスキルを使う人の順目で発動します。
  30. 他のメンバーは行動(コマンド入力)できません。


  31. 【統括者について】
  32. ⑥において、一番上のスキルを担当するアクターを統括者と呼びます。
  33. 合体技の威力や発動順などは、統括者の能力値に準拠します。


  34. 【注意事項】
  35. ・XPスタイルバトルよりも下に配置して下さい。
  36. ・「生者死者両方に使えるスキル・アイテム」よりも下に配置してください。
  37. ・担当スキルが使用できない場合は合体技に参加できませんが、
  38.  スキル設定の「使用可能時」に限り、これを無視して使うことができます。


  39. 【バグ対応】
  40. 20120126 ・製作。
  41. 20120305 ・5人以上のパーティに対応。
  42.      ・パターンが複数ある技を使用した後、パターンが少ない技を選ぶとエラーが
  43.       発生するのを修正。
  44. 20120309 ・戦闘テストに対応。
  45. 20120310 ・XPスタ Cルバトルとの競合に対策実施。
  46. 20120311 ・使える合体技が無い場合は、「合体技」を選択できないようにした。
  47. 20120317 ・前ターンで使った合体技が使えなくなった場合、
  48.             空欄が選べてしまう不具合を修正。
  49.           ・TP技に対応。
  50. 20120329 ・反撃で敵を倒したときにエラー落ちする不具合を修正。
  51. 20120402 ・合体技発動不可の場合には、指定のスキルを発動するようにした。
  52. 20120403 ・行動可能な人数と同じ必要人数の合体技を選択後、その合体技が
  53.             使用不可能になった際に不具合が起きる現象を修正。
  54. 20120420 ・処理を軽量化。
  55.           ・反撃で倒されるとエラー落ちする不具合の修正。
  56. 20120503  ・アクターが目標のスキルでエラー落ちするのを修正。
  57.           ・<combi;~>を複数記述した時、構成スキルを選択できるようにした。
  58. 20120505  ・<combi;~>を複数記述した時、同じスキルが複数表示されるのを修正。
  59. 20120507 ・参加メンバーパターンがおかしくなっていたのを修正。
  60. 20120715 ・合体技の効果が「使用者に行動不能ステート」の場合、エラーが出るのを修正。
  61.      ・ターゲットを「使用者」にしたとき、エラーが起こるのを修正。
  62. 20121205 ・スキル封印、スキルタイプ封印のときは合体技に参加できない。

  63. =end
  64. module Tamura_Combi
  65.   #合体技が使用不可能な場合、以下のIDのスキルが発動します。7番は「様子を見る」。
  66.   UNUSE = 7
  67. end


  68. #==============================================================================
  69. # ■ DataManager
  70. #==============================================================================
  71. module DataManager
  72.   #--------------------------------------------------------------------------
  73.   # ● 戦闘テスト用のデータベースをロード
  74.   #--------------------------------------------------------------------------
  75.   def self.load_battle_test_database_combi
  76.     load_battle_test_database_combi_default
  77.     $com = Combination.new
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● クラスメソッドのエイリアス
  81.   #--------------------------------------------------------------------------
  82.   class << self
  83.     alias :load_battle_test_database_combi_default :load_battle_test_database
  84.     alias :load_battle_test_database :load_battle_test_database_combi
  85.   end
  86. end

  87. #==============================================================================
  88. # ■ BattleManager
  89. #==============================================================================
  90. module BattleManager
  91.   #--------------------------------------------------------------------------
  92.   # ● 次の行動主体の取得 ☆再定義
  93.   #--------------------------------------------------------------------------
  94.   def self.next_subject
  95.     loop do
  96.       battler = @action_battlers.shift
  97.       return nil unless battler
  98.       #統括者でない合体技参加メンバーは飛ばす
  99.       if battler.actor? and battler.combi_join != nil
  100.         next if battler.combi_join != 0
  101.       end
  102.       #以下デフォルト処理
  103.       next unless battler.index && battler.alive?
  104.       return battler
  105.     end
  106.   end
  107. end

  108. #==============================================================================
  109. # ■ Game_Action
  110. #------------------------------------------------------------------------------
  111. #  ・合体技のターゲットが「使用者」である場合、参加メンバー全員を返します。
  112. #  ・「生者死者双方に使えるアイテム」との競合回避を図っています。
  113. #==============================================================================
  114. class Game_Action
  115.   #--------------------------------------------------------------------------
  116.   # ● 味方に対するターゲット
  117.   #--------------------------------------------------------------------------
  118.   def targets_for_friends
  119.     if item.for_user?
  120.       if item.note =~ /<combi;/ #合体技なら、参加メンバーを返す。
  121.         members = []
  122.         $game_party.members.each { |actor|
  123.           members.push actor if actor.combi_join != nil
  124.         }
  125.         return members
  126.       else
  127.         [subject]
  128.       end
  129.     #以下、「生者死者双方に使えるアイテム」との競合回避。
  130.     elsif item.for_dead_friend?
  131.       if item.for_one?
  132.         if /<生者にも効果>/ =~ item.note
  133.           [friends_unit.smooth_target_all(@target_index)] #生死関わらず。
  134.         else
  135.           [friends_unit.smooth_dead_target(@target_index)]
  136.         end
  137.       else
  138.         if /<生者にも効果>/ =~ item.note
  139.           friends_unit.members #全メンバーを返す。
  140.         else
  141.           friends_unit.dead_members
  142.         end
  143.       end
  144.     elsif item.for_friend?
  145.       if item.for_one?
  146.         [friends_unit.smooth_target(@target_index)]
  147.       else
  148.         friends_unit.alive_members
  149.       end
  150.     end
  151.   end
  152. end
  153. #==============================================================================
  154. # ■ Game_BattlerBase
  155. #==============================================================================
  156. class Game_BattlerBase
  157.   #--------------------------------------------------------------------------
  158.   # ● 公開インスタンス変数
  159.   #--------------------------------------------------------------------------
  160.   attr_accessor :combi_join         # 合体技発動の時、何番目のスキルを担当するか。
  161.                                     #0~3の数字が入る。
  162.   #--------------------------------------------------------------------------
  163.   # ● コマンド入力可能判定  ☆再定義
  164.   #--------------------------------------------------------------------------
  165.   def inputable?
  166.     return false if self.combi_join != nil
  167.     normal? && !auto_battle?
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● スキルの使用可能条件チェック
  171.   #  合体技が使用可能かどうかの時に使用する。
  172.   #  通常の使用可非判定と違うのは、スキルの「使用可能時」を無視するということ。
  173.   #--------------------------------------------------------------------------
  174.   def skill_conditions_met_combi?(skill)
  175.     #usable_item_conditions_met?(skill) &&
  176.     movable? &&
  177.     skill_wtype_ok?(skill) && skill_cost_payable?(skill) &&
  178.     !skill_sealed?(skill.id) && !skill_type_sealed?(skill.stype_id)
  179.   end
  180. end


  181. #==============================================================================
  182. # ■ Scene_Title
  183. #==============================================================================
  184. class Scene_Title < Scene_Base
  185.   #--------------------------------------------------------------------------
  186.   # ● コマンド : ニューゲーム
  187.   #--------------------------------------------------------------------------
  188.   def command_new_game_combi
  189.     command_new_game_combi_default
  190.     $com = Combination.new
  191.   end
  192.   alias_method :command_new_game_combi_default, :command_new_game
  193.   alias_method :command_new_game, :command_new_game_combi
  194. end


  195. #==============================================================================
  196. # ■ Scene_Load
  197. #==============================================================================
  198. class Scene_Load < Scene_File
  199.   #--------------------------------------------------------------------------
  200.   # ● セーブファイル[決定]
  201.   #--------------------------------------------------------------------------
  202.   def on_savefile_ok_combi
  203.     on_savefile_ok_combi_default
  204.     $com = Combination.new
  205.   end
  206.   alias_method :on_savefile_ok_combi_default, :on_savefile_ok
  207.   alias_method :on_savefile_ok, :on_savefile_ok_combi
  208. end


  209. #==============================================================================
  210. # ■ Scene_Battle
  211. #==============================================================================
  212. class Scene_Battle < Scene_Base
  213.   attr_reader   :combi_skill_win
  214.   #--------------------------------------------------------------------------
  215.   # ● 開始処理
  216.   #--------------------------------------------------------------------------
  217.   def battle_start_combi_scene_battle
  218.     battle_start_combi_scene_battle_default
  219.     #合体技の数値計算
  220.     #p "combi_call_C" #test
  221.     #$combi_skill_works = [] #配列[発動可能な合体技,その構成メンバーID]
  222.     #$combi_skill_works = $com.search_combi_skill
  223.     #start_combi_scene_battle_default
  224.     cancel_combi_join #合体技参加をクリア。
  225.     @combi_skill_win.refresh
  226.     @party_command_window.refresh
  227.   end
  228.   alias :battle_start_combi_scene_battle_default :battle_start
  229.   alias :battle_start :battle_start_combi_scene_battle
  230.   #--------------------------------------------------------------------------
  231.   # ● 合体技参加をクリア。
  232.   #--------------------------------------------------------------------------
  233.   def cancel_combi_join
  234.     for i in 0 ... $game_party.members.size
  235.       $game_party.members[i].combi_join = nil if $game_party.members[i] != nil
  236.     end   
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 終了処理
  240.   #--------------------------------------------------------------------------
  241.   def terminate_combi_scene_battle
  242.     terminate_combi_scene_battle_default
  243.     @combi_skill_win.dispose
  244.   end
  245.   alias :terminate_combi_scene_battle_default :terminate
  246.   alias :terminate :terminate_combi_scene_battle
  247.   #--------------------------------------------------------------------------
  248.   # ● 全ウィンドウの作成
  249.   #--------------------------------------------------------------------------
  250.   def create_all_windows_combi
  251.     create_all_windows_combi_default
  252.     @combi_skill_win = Window_CombinationSkills.new
  253.     @combi_join_win = Window_CombinationJoin.new
  254.   end
  255.   alias :create_all_windows_combi_default :create_all_windows
  256.   alias :create_all_windows :create_all_windows_combi
  257.   #--------------------------------------------------------------------------
  258.   # ● パーティコマンドウィンドウの作成
  259.   #--------------------------------------------------------------------------
  260.   def create_party_command_window_combi
  261.     create_party_command_window_combi_default
  262.     @party_command_window.set_handler(:combiskill, method(:command_combi_skill))
  263.   end
  264.   alias :create_party_command_window_combi_default :create_party_command_window
  265.   alias :create_party_command_window :create_party_command_window_combi
  266.   #--------------------------------------------------------------------------
  267.   # ● 合体技の選択へ。
  268.   #--------------------------------------------------------------------------
  269.   def command_combi_skill
  270.     @combi_skill_win.visible = true
  271.     @combi_skill_win.active = true
  272.     @help_window.visible = true
  273.     @combi_skill_win.help_window = @help_window
  274.     @combi_join_win.help_window = @help_window
  275.     @combi_skill_win.combi_join_win = @combi_join_win
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● 敵キャラ[決定]
  279.   #--------------------------------------------------------------------------
  280.   def on_enemy_ok_combi
  281.     if @combi_join_win.visible
  282.       $main_combi_actor.input.target_index =
  283.         @enemy_window.enemy.index #ターゲット入力
  284.       @enemy_window.hide
  285.       @combi_join_win.visible = false
  286.       next_command
  287.     else
  288.       on_enemy_ok_combi_default
  289.     end
  290.   end
  291.   alias :on_enemy_ok_combi_default :on_enemy_ok
  292.   alias :on_enemy_ok :on_enemy_ok_combi
  293.   #--------------------------------------------------------------------------
  294.   # ● 敵キャラ[キャンセル]
  295.   #--------------------------------------------------------------------------
  296.   def on_enemy_cancel_combi
  297.     if @combi_join_win.visible
  298.       @enemy_window.hide
  299.       @combi_join_win.active = true
  300.       @combi_join_win.z = 100
  301.     else
  302.       on_enemy_cancel_combi_default
  303.     end
  304.   end
  305.   alias :on_enemy_cancel_combi_default :on_enemy_cancel
  306.   alias :on_enemy_cancel :on_enemy_cancel_combi
  307.   #--------------------------------------------------------------------------
  308.   # ● アクター[決定]
  309.   #--------------------------------------------------------------------------
  310.   def on_actor_ok_combi
  311.     if @combi_join_win.visible
  312.       $main_combi_actor.input.target_index =
  313.         @actor_window.index #ターゲット入力
  314.       @actor_window.hide
  315.       @combi_join_win.visible = false
  316.       next_command
  317.     else
  318.       on_actor_ok_combi_default
  319.     end
  320.   end
  321.   alias :on_actor_ok_combi_default :on_actor_ok
  322.   alias :on_actor_ok :on_actor_ok_combi
  323.   #--------------------------------------------------------------------------
  324.   # ● アクター[キャンセル]
  325.   #--------------------------------------------------------------------------
  326.   def on_actor_cancel_combi
  327.     if @combi_join_win.visible
  328.       @actor_window.hide
  329.       @combi_join_win.active = true
  330.       @combi_join_win.z = 100
  331.     else
  332.       on_actor_cancel_combi_default
  333.     end
  334.   end
  335.   alias :on_actor_cancel_combi_default :on_actor_cancel
  336.   alias :on_actor_cancel :on_actor_cancel_combi
  337.   #--------------------------------------------------------------------------
  338.   # ● ターン終了
  339.   #--------------------------------------------------------------------------
  340.   def turn_end_combi
  341.     turn_end_combi_default
  342.     cancel_combi_join #合体技参加フラグをOFF
  343.     #$combi_skill_works = []
  344.     #p "combi_call_A" #test
  345.     #$combi_skill_works = $com.search_combi_skill
  346.     $main_combi_actor = nil
  347.     @combi_skill_win.index = 0 #カーソルを戻す。
  348.     @combi_skill_win.refresh
  349.   end
  350.   alias :turn_end_combi_default :turn_end
  351.   alias :turn_end :turn_end_combi
  352.   #--------------------------------------------------------------------------
  353.   # ● パーティコマンド選択の開始
  354.   #--------------------------------------------------------------------------
  355.   def start_party_command_selection_combi
  356.     cancel_combi_join #合体技参加フラグをOFF
  357.     @combi_join_win.z = 100
  358.     start_party_command_selection_combi_default
  359.   end
  360.   alias :start_party_command_selection_combi_default :start_party_command_selection
  361.   alias :start_party_command_selection :start_party_command_selection_combi
  362.   #--------------------------------------------------------------------------
  363.   # ● スキル/アイテムの使用
  364.   #--------------------------------------------------------------------------
  365.   def use_item_combi
  366.     item = Marshal.load(Marshal.dump(@subject.current_action.item))
  367.     if item.note =~ /<combi;/ and combi_skill_usable? == false
  368.       @subject.current_action.set_skill(Tamura_Combi::UNUSE) #使用不可能
  369.     end
  370.     use_item_combi_default
  371.         
  372.     #合体技のMPを消費する。
  373.     if @subject.actor? and @subject.alive?
  374.       #item = @subject.current_action.item
  375.       if item.note =~ /<combi;/
  376.         for i in 0 ... $game_party.members.size
  377.           actor = $game_party.members[i]
  378.           if actor.combi_join != nil
  379.             part_skill = $data_skills[$combi_need[actor.combi_join]]
  380.             if part_skill != nil
  381.               actor.mp -= actor.skill_mp_cost(part_skill)
  382.               actor.tp -= actor.skill_tp_cost(part_skill)
  383.             end
  384.           end
  385.         end
  386.       end
  387.     else
  388.       #反撃技など。
  389.     end
  390.   end
  391.   alias :use_item_combi_default :use_item
  392.   alias :use_item :use_item_combi
  393.   #--------------------------------------------------------------------------
  394.   # ● 合体技が使用可能であるか。
  395.   # スキルが使用可能か・行動不能か・
  396.   #--------------------------------------------------------------------------
  397.   def combi_skill_usable?
  398.     for i in 0 ... $game_party.members.size
  399.       actor = $game_party.members[i]
  400.       next if actor.combi_join == nil
  401.       part_skill = $data_skills[$combi_need[actor.combi_join]]
  402.       return false if part_skill == nil
  403.       return false unless actor.skill_conditions_met_combi?(part_skill)
  404.     end
  405.     return true
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # ● ももまる様製作「XPスタイルバトル」競合対策
  409.   #--------------------------------------------------------------------------
  410.   def actor_selection_item
  411.     return @combi_skill_win.skill if @combi_join_win.visible #合体技
  412.     case @actor_command_window.current_symbol
  413.     when :attack ; $data_skills[BattleManager.actor.attack_skill_id]
  414.     when :skill  ; @skill
  415.     when :item   ; @item
  416.     when :guard  ; $data_skills[BattleManager.actor.guard_skill_id]
  417.     else ; nil
  418.     end
  419.   end
  420. end

  421. #==============================================================================
  422. # ■ Window_PartyCommand
  423. #------------------------------------------------------------------------------
  424. #  バトル画面で、戦うか逃げるかを選択するウィンドウです。
  425. #==============================================================================
  426. class Window_PartyCommand < Window_Command
  427.   #--------------------------------------------------------------------------
  428.   # ● コマンドリストの作成
  429.   #--------------------------------------------------------------------------
  430.   def make_command_list_combi
  431.     make_command_list_combi_default
  432.     if $combi_skill_works == [] #使える合体技なし。
  433.       add_command("合体技", :combiskill , false)
  434.     else
  435.       add_command("合体技", :combiskill , true)
  436.     end
  437.   end
  438.   alias :make_command_list_combi_default :make_command_list
  439.   alias :make_command_list :make_command_list_combi
  440.   #--------------------------------------------------------------------------
  441.   # ● コマンドリストの作成
  442.   #--------------------------------------------------------------------------
  443.   def setup_combi
  444.     $combi_skill_works = $com.search_combi_skill
  445.     setup_combi_default
  446.   end
  447.   alias :setup_combi_default :setup
  448.   alias :setup :setup_combi
  449. end


  450. #==============================================================================
  451. # ■ Window_CombinationSkills
  452. #------------------------------------------------------------------------------
  453. #  合体技を選択するウィンドウです。
  454. #==============================================================================
  455. class Window_CombinationSkills  < Window_Selectable
  456.   #--------------------------------------------------------------------------
  457.   # ● オブジェクト初期化
  458.   #     x      : ウィンドウの X 座標
  459.   #     y      : ウィンドウの Y 座標
  460.   #     width  : ウィンドウの幅
  461.   #     height : ウィンドウの高さ
  462.   #     actor  : アクター
  463.   #--------------------------------------------------------------------------
  464.   def initialize
  465.     super(0, 72, 544, 344)
  466.     @index = 0
  467.     @combi_join_win = nil
  468.     self.visible = false
  469.     self.active = false
  470.     self.set_handler(:ok,     method(:on_combi_skill_ok))
  471.     self.set_handler(:cancel, method(:on_combi_skill_cancel))
  472.     refresh
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # ● 桁数の取得
  476.   #--------------------------------------------------------------------------
  477.   def col_max
  478.     return 2
  479.   end
  480.   #--------------------------------------------------------------------------
  481.   # ● 項目数の取得
  482.   #--------------------------------------------------------------------------
  483.   def item_max
  484.     @data ? @data.size : 1
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● スキルの取得
  488.   #--------------------------------------------------------------------------
  489.   def skill
  490.     return @data[self.index]
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● リフレッシュ
  494.   #--------------------------------------------------------------------------
  495.   def refresh
  496.     if $combi_skill_works != nil
  497.       @data = []
  498.       still = []
  499.       for i in 0 ... $combi_skill_works.size
  500.         skill_id = $combi_skill_works[i][0]
  501.         skill=$data_skills[skill_id]
  502.         next if still.include?(skill.id)
  503.         @data.push(skill)
  504.         still.push(skill.id)
  505.       end
  506.       @item_max = @data.size
  507.       create_contents
  508.       for i in 0...@item_max
  509.         draw_item(i)
  510.       end
  511.     end
  512.     update_help
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # ● 項目の描画
  516.   #     index : 項目番号
  517.   #--------------------------------------------------------------------------
  518.   def draw_item(index)
  519.     rect = item_rect(index)
  520.     self.contents.clear_rect(rect)
  521.     skill = @data[index]
  522.     if skill != nil
  523.       rect.width -= 4
  524.       draw_item_name(skill, rect.x, rect.y, true)
  525.     end
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # ● ヘルプテキスト更新
  529.   #--------------------------------------------------------------------------
  530.   def update_help
  531.     @help_window.set_item(skill) if @help_window != nil
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ● 参加メンバー決定ウィンドウに選択したスキルを受け渡す時に使用。
  535.   #--------------------------------------------------------------------------
  536.   def combi_join_win=(combi_join_win)
  537.     @combi_join_win = combi_join_win
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● [決定]
  541.   #--------------------------------------------------------------------------
  542.   def on_combi_skill_ok
  543.     @combi_join_win.index = @index
  544.     @combi_join_win.active = true
  545.     @combi_join_win.visible = true
  546.     self.active = false
  547.     self.visible = false
  548.     @combi_join_win.skill = skill
  549.     @combi_join_win.prepare
  550.     @combi_join_win.combi_skill_win = self
  551.     @help_window.visible = false
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # ● [キャンセル]
  555.   #--------------------------------------------------------------------------
  556.   def on_combi_skill_cancel
  557.     self.active =false
  558.     self.visible =false
  559.     @help_window.visible = false
  560.     SceneManager.scene.start_party_command_selection
  561.   end
  562. end


  563. #==============================================================================
  564. # ■ Window_CombinationJoin
  565. #------------------------------------------------------------------------------
  566. #  合体技に参加するメンバーを決定するウィンドウです。
  567. #==============================================================================
  568. class Window_CombinationJoin < Window_Base
  569.   attr_accessor :pattern
  570.   attr_accessor :combi_main_actor #統括者
  571.   #--------------------------------------------------------------------------
  572.   # ● オブジェクト初期化
  573.   #     x      : ウィンドウの X 座標
  574.   #     y      : ウィンドウの Y 座標
  575.   #     width  : ウィンドウの幅
  576.   #     height : ウィンドウの高さ
  577.   #     actor  : アクター
  578.   #--------------------------------------------------------------------------
  579.   def initialize
  580.     super(0, 0, 544, 384)
  581.     [url=home.php?mod=space&uid=260100]@skill[/url] = nil #合体技スキル
  582.     @index = 0 #合体技ウィンドウのindex
  583.     @pattern = 0 #参加メンバーのパターン
  584.     @combi_main_actor = nil #統括者(参加メンバーの一番目のアク ^ー)。
  585.     self.z = 100
  586.     self.visible = false
  587.     self.active = false
  588.   end
  589.   #--------------------------------------------------------------------------
  590.   # ● 合体技ウィンドウのindexを入力
  591.   #--------------------------------------------------------------------------
  592.   def index=(index)
  593.     @index = index
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● スキルを入力
  597.   #--------------------------------------------------------------------------
  598.   def skill=(skill)
  599.     @skill = skill
  600.   end
  601.   #--------------------------------------------------------------------------
  602.   # ● 合体技ウィンドウ。こちらから操作するために受け取る。
  603.   #--------------------------------------------------------------------------
  604.   def combi_skill_win=(combi_skill_win)
  605.     @combi_skill_win = combi_skill_win
  606.   end
  607.   #--------------------------------------------------------------------------
  608.   # ● 合体技ウィンドウ。こちらから操作するために受け取る。
  609.   #--------------------------------------------------------------------------
  610.   def help_window=(help_window)
  611.     @help_window = help_window
  612.   end
  613.   #--------------------------------------------------------------------------
  614.   # ● 準備
  615.   #--------------------------------------------------------------------------
  616.   def prepare
  617.     #$combi_need = $com.need_skills(@skill) #合体技に必要なスキルのID
  618.     skill_id = @skill.id
  619.     $combi_patterns = []
  620.     $combi_skill_works.each do |combi_skill|
  621.       if combi_skill[0] == skill_id
  622.         $combi_patterns.push combi_skill
  623.       end
  624.     end
  625.     #p $combi_patterns #test
  626.     @big_pattern = 0
  627.     $combi_need = Marshal.load(Marshal.dump($combi_patterns[@big_pattern][2]))
  628.     refresh
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ● リフレッシュ
  632.   #--------------------------------------------------------------------------
  633.   def refresh
  634.     skill_id = $combi_patterns[@big_pattern][0]
  635.     @pattern = 0 if $combi_patterns[@big_pattern][1][@pattern] == nil
  636.     @join_pattern = Marshal.load(Marshal.dump($combi_patterns[@big_pattern][1][@pattern]))
  637.     $combi_need = Marshal.load(Marshal.dump($combi_patterns[@big_pattern][2]))
  638.     create_contents
  639.     draw_item_name(@skill, 0, 0, true)
  640.     self.contents.draw_text(220, 0*24, 270, line_height, "に参加するメンバーを選んでください。", 0)
  641.     draw_item_name(@skill, 0, 1*24, true)
  642.     self.contents.draw_text(220, 1*24, 270, line_height, "は以下の技の合体技です。", 0)

  643.     self.contents.draw_text(0, 3*24, 100, line_height, "スキル名", 0)
  644.     self.contents.draw_text(200, 3*24, 100, line_height, "MP", 0)
  645.     self.contents.draw_text(290, 3*24, 100, line_height, "使用者", 0)
  646.    
  647.     for i in 0 ... $combi_need.size
  648.       #p $combi_need #test
  649.       part_skill=$data_skills[$combi_need[i]]
  650.       draw_item_name(part_skill,0 , (i+4)*24, true)
  651.       actor = $game_party.members[@join_pattern[i]]
  652.       draw_actor_name(actor, 290, (i+4)*24)
  653.       #統括者の取得。
  654.       @main_combi_actor = actor if i == 0
  655.       if part_skill != nil
  656.         if actor.skill_mp_cost(part_skill) >0 #MPコストを表示する
  657.           self.contents.draw_text(200, (i+4)*24, 100, line_height , actor.skill_mp_cost(part_skill), 0)
  658.         elsif actor.skill_tp_cost(part_skill) > 0 #TPコスト表示
  659.           str = "TP" + actor.skill_tp_cost(part_skill).to_s
  660.           self.contents.draw_text(200, (i+4)*24, 100, line_height , str, 0)
  661.         end
  662.       end
  663.     end

  664.     self.contents.draw_text(0, ($combi_need.size + 5)*24, 270, line_height, "←→:参加メンバーの変更", 0)
  665.     self.contents.draw_text(0, ($combi_need.size + 6)*24, 270, line_height, "決定:このメンバーで使用する。", 0)
  666.     self.contents.draw_text(0, ($combi_need.size + 7)*24, 270, line_height, "キャンセル:合体技の選択に戻る", 0)
  667.     #@join_pattern = Marshal.load(Marshal.dump($combi_skill_works[@index][1][@pattern]))
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 項目の描画
  671.   #     index : 項目番号
  672.   #--------------------------------------------------------------------------
  673.   def draw_item(index)
  674.     rect = item_rect(index)
  675.     self.contents.clear_rect(rect)
  676.     if skill != nil
  677.       rect.width -= 4
  678.       draw_item_name(skill, rect.x, rect.y, true)
  679.     end
  680.   end
  681.   #--------------------------------------------------------------------------
  682.   # ● 更新
  683.   #--------------------------------------------------------------------------
  684.   def update
  685.     super
  686.     if self.active
  687.       on_combi_join_ok if (Input.trigger?(:C))
  688.       on_combi_join_cancel if (Input.trigger?(:B))
  689.       on_combi_join_right if Input.repeat?(:RIGHT) #(Input.trigger?(:RIGHT))
  690.       on_combi_join_left if Input.repeat?(:LEFT) #(Input.trigger?(:LEFT))  
  691.     end
  692.   end
  693.   #--------------------------------------------------------------------------
  694.   # ● [決定]
  695.   #--------------------------------------------------------------------------
  696.   def on_combi_join_ok
  697.     $main_combi_actor = @main_combi_actor
  698.     $main_combi_actor.input.set_skill(@skill.id) #統括者にスキル入力。
  699.     $main_combi_actor.last_skill.object = @skill
  700.     decision_join_member #combi_join入力
  701.     self.z = 10
  702.     self.active = false
  703.     #self.visible = false #ここではまだ表示し、表示をフラグとして扱う。
  704.     #必要であればターゲット選択へ。
  705.     if [email protected]_selection?
  706.       self.visible = false
  707.       SceneManager.scene.next_command
  708.     elsif @skill.for_opponent?
  709.       SceneManager.scene.select_enemy_selection
  710.     else
  711.       SceneManager.scene.select_actor_selection
  712.     end
  713.   end
  714.   #--------------------------------------------------------------------------
  715.   # ● [キャンセル]
  716.   #--------------------------------------------------------------------------
  717.   def on_combi_join_cancel
  718.     @combi_skill_win.active = true
  719.     @combi_skill_win.visible = true
  720.     @help_window.visible = true
  721.     self.active =false
  722.     self.visible =false
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ● [右] パターン+1
  726.   #--------------------------------------------------------------------------
  727.   def on_combi_join_right
  728.     self.pattern += 1
  729.     #if self.pattern == $combi_skill_works[@index][1].size
  730.     if self.pattern == $combi_patterns[@big_pattern][1].size
  731.       self.pattern = 0
  732.       @big_pattern += 1
  733.       if @big_pattern == $combi_patterns.size
  734.         @big_pattern = 0
  735.       end
  736.     end
  737.     self.refresh
  738.   end
  739.   #--------------------------------------------------------------------------
  740.   # ● [左] パターン-1
  741.   #--------------------------------------------------------------------------
  742.   def on_combi_join_left
  743.     self.pattern -= 1
  744.     if self.pattern < 0
  745.       @big_pattern -= 1
  746.       if @big_pattern < 0
  747.         @big_pattern = $combi_patterns.size - 1
  748.       end
  749.       self.pattern = $combi_patterns[@big_pattern][1].size - 1
  750.     end
  751.     self.refresh
  752.   end
  753.   #--------------------------------------------------------------------------
  754.   # ● 参加メンバー決定ウィンドウで使用。参加メンバーを決定し、combi_join入力。
  755.   #--------------------------------------------------------------------------
  756.   def decision_join_member
  757.     cancel_combi_join
  758.     $main_combi_actor = @main_combi_actor
  759.     #p "C" #test
  760.     #p @join_pattern #test
  761.     for j in 0 ... @join_pattern.size
  762.       $game_party.members[@join_pattern[j]].combi_join = j
  763.     end
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 合体技参加をクリア。
  767.   #--------------------------------------------------------------------------
  768.   def cancel_combi_join
  769.     #p "B" #test
  770.     #p @join_pattern #test
  771.     for i in 0 ... $game_party.members.size
  772.       $game_party.members[i].combi_join = nil if $game_party.members[i] != nil
  773.     end
  774.     $main_combi_actor = nil
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● ヘルプテキスト更新
  778.   #--------------------------------------------------------------------------
  779.   def update_help
  780.     @help_window.set_text(skill == nil ? "" : skill.description)
  781.   end
  782. end


  783. #==============================================================================
  784. # ■ Combination
  785. #------------------------------------------------------------------------------
  786. #  合体技が発動可能かを調べる。
  787. #
  788. # actor_works : [ [[分担パターン1],[分担パターン2],……], [スキル②のパターン達],……]
  789. #==============================================================================
  790. #total_skill_arr[0] : 合体技スキルのID
  791. #total_skill_arr[1] : 合体技の参加パターン
  792. #total_skill_arr[2] : 合体技の構成スキルIDの配列

  793. class Combination
  794.   #すべてのスキルを調べ、合体技を抜き出す。
  795.   def search_combi_skill
  796.     total_skill_arr=[]
  797.     actor_works = []
  798.     for i in 1 ... $data_skills.size
  799.       need = []
  800.       need = need_skills($data_skills[i])
  801.       if need != []
  802.         #p $data_skills[i].name #test
  803.         need.each do |n|
  804.           skill_arr=[]
  805.           skill_arr.push i
  806.           actor_works = combination_usable?(n)
  807.           #p actor_works #test
  808.           if actor_works != []
  809.             skill_arr.push actor_works
  810.             skill_arr.push n
  811.             total_skill_arr.push skill_arr
  812.           end
  813.           #p skill_arr #test
  814.         end
  815.       end
  816.     end
  817.     #p create_party_skills #test
  818.     #p total_skill_arr #test
  819.     return total_skill_arr
  820.   end
  821.   
  822.   #スキルIDを受け取り、合体技に必要なIDを調べてneed配列を返す。
  823.   #なお、合体技でない場合は空の配列を返す。
  824.   def need_skills(skill)
  825.     return false if skill.id == nil
  826.     note = skill.note
  827.     if /<combi;/ =~ note
  828.       str1 = note.scan(/<combi(\S+)>/)
  829.       need = []
  830.       str1.each do |s|
  831.         #p s #test
  832.         need_one = []
  833.         str2 = s[0].scan(/;(\d+)/)
  834.         for str in str2
  835.           need_one.push str[0].to_i
  836.         end
  837.         need.push need_one
  838.       end
  839.       #p need #test
  840.       return need
  841.     end
  842.     return []
  843.   end
  844.   
  845.   
  846.   #使用可能なスキルIDの配列を作る。
  847.   # [[1],[2,3],[]] で、一人目がスキル1番、二人目がスキル2,3番習得。
  848.   # 3人目 ヘ行動不能か、スキル無し。
  849.   def create_party_skills
  850.     party_skills = []
  851.     for actor in $game_party.members
  852.       ini_skills_id = []
  853.       unless actor.movable?
  854.         party_skills.push []
  855.         next
  856.       end
  857.       for i in 0 ... actor.skills.size
  858.         skill = $data_skills[actor.skills[i].id]
  859.         next unless actor.skill_conditions_met_combi?(skill)
  860.         #if skill.mp_cost > actor.mp
  861.         #  next
  862.         #elsif skill.tp_cost > actor.tp
  863.         #  next
  864.         #end
  865.         ini_skills_id.push skill.id
  866.       end
  867.       party_skills.push ini_skills_id
  868.     end
  869.     return party_skills
  870.   end
  871.   
  872.   #もし、合体技の構成スキル3番を、1番目のアクターが、担当できるのなら、
  873.   #[X,X,1]といったような配列を作る。これをパターンの数だけ作る。すなわち
  874.   #[[1,3,2],[3,2,1],[3,4,1]]のような配列を最終的に作る。
  875.   def combination_usable?(need)
  876.     @need = need #必要スキルのIDの配列。
  877.     @actor_works = []
  878.     [url=home.php?mod=space&uid=95897]@actor[/url] = []
  879.     @party_skills = create_party_skills
  880.    
  881.     #まず、全ての習得パターンを書き出す。
  882.     @pre_actor_works = [] #途中経過を記録する配列。
  883.     @new_actor_works = [] #そのさらに途中経過を一時保管。
  884.     return [] if @party_skills.size < @need.size #人数不足。
  885.    
  886.     for i in 0 ... @need.size
  887.       if i == 0
  888.         for j in 0 ... @party_skills.size
  889.           if @party_skills[j].include?(@need[i])
  890.             @pre_actor_works.push [j]
  891.           end
  892.         end
  893.       else
  894.         @new_actor_works = []
  895.         for k in 0 ... @pre_actor_works.size
  896.           for j in 0 ... @party_skills.size #パーティを一人ずつ調べる。
  897.             next if @pre_actor_works[k].include?(j)
  898.             if @party_skills[j].include?(@need[i])
  899.               #p k.to_s + "" + j.to_s if i == 3
  900.               now_research_arr = Marshal.load(Marshal.dump(@pre_actor_works[k]))
  901.               now_research_arr.push j
  902.               @new_actor_works.push now_research_arr
  903.             end
  904.           end
  905.         end
  906.         @pre_actor_works = Marshal.load(Marshal.dump(@new_actor_works))
  907.       end
  908.     end
  909.     return @pre_actor_works
  910.   end
  911.   
  912. end


  913. #=end
复制代码
来源,不记得了。
作者: lirn    时间: 2013-7-20 22:44
没试过,大概是这样。

在需要合体技的备注栏写入<combi;技能ID;技能ID;技能ID;技能ID>,在条件符合的情况下在逃跑下方使用
作者: 奥特曼盖亚    时间: 2013-7-23 20:10
lirn没有用呀
作者: 伪3D春哥    时间: 2013-7-24 13:33
看样子像是外源脚本
求简化




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