Project1

标题: 请问这个脚本如何修改x轴和y轴 [打印本页]

作者: xkm198510    时间: 2015-1-15 14:57
标题: 请问这个脚本如何修改x轴和y轴
RUBY 代码复制
  1. #
  2. #    クイックロード(RGSS3)
  3. #  (C)2012 TYPE74RX-T
  4. #
  5.  
  6. #==============================================================================
  7. # ■ SceneManager
  8. #------------------------------------------------------------------------------
  9. #  シーン遷移を管理するモジュールです。たとえばメインメニューからアイテム画面
  10. # を呼び出し、また戻るというような階層構造を扱うことができます。
  11. #==============================================================================
  12.  
  13. class << SceneManager # module内のエイリアス
  14.   alias rx3_1201202_first_scene_class first_scene_class
  15.   def first_scene_class
  16.     # ★ クイックロードモードの条件を満たしていたらクイックロードに飛ぶ
  17.     return Scene_RX_QuickLoad if rx_quick_load?
  18.     rx3_1201202_first_scene_class  # メソッド呼び戻し
  19.   end
  20. end
  21.  
  22. module SceneManager
  23.   #--------------------------------------------------------------------------
  24.   # ★ クイックロードモードの条件を満たしているか
  25.   #--------------------------------------------------------------------------
  26.   def self.rx_quick_load?
  27.     $RX_QLOAD = 0
  28.     Input.update
  29.     $RX_QLOAD = 1 if Input.press?(:C) # 最後にロードしたファイルから始める
  30.     $RX_QLOAD = 2 if Input.press?(:B) # 最後にセーブしたファイルから始める
  31.     chk = Dir.glob('RX_SaveFileInfos.dat').size > 0 && $RX_QLOAD > 0
  32.     return chk
  33.   end
  34. end
  35.  
  36. #==============================================================================
  37. # ■ Scene_Save
  38. #------------------------------------------------------------------------------
  39. #  セーブ画面の処理を行うクラスです。
  40. #==============================================================================
  41.  
  42. class Scene_Save < Scene_File
  43.   #--------------------------------------------------------------------------
  44.   # ● セーブ成功時の処理
  45.   #--------------------------------------------------------------------------
  46.   alias rx3_1201202_on_save_success on_save_success
  47.   def on_save_success
  48.     index_save         # ★ セーブしたファイルインデックス情報を書き込む
  49.     rx3_1201202_on_save_success # メソッド呼び戻し
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ★ セーブしたファイルインデックス情報を書き込む
  53.   #--------------------------------------------------------------------------
  54.   def index_save
  55.     chk = rx_read_load_index # インデックス情報があれば、それを読み込む
  56.     file = File.open("RX_SaveFileInfos.dat", "wb")
  57.     # ファイルインデックス情報ファイルがなければ、仮に -1 を記録
  58.     chk ? Marshal.dump(@rx_load_index, file) : Marshal.dump(-1, file)
  59.     Marshal.dump(@index, file)
  60.     file.close
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ★ ロードしたファイルインデックス情報を読み込む
  64.   #--------------------------------------------------------------------------
  65.   def rx_read_load_index
  66.     chk = Dir.glob('RX_SaveFileInfos.dat').size > 0
  67.     return false unless chk
  68.     file = File.open("RX_SaveFileInfos.dat", "rb")
  69.     @rx_load_index = Marshal.load(file)
  70.     sav_id         = Marshal.load(file)
  71.     file.close
  72.     return true
  73.   end
  74. end
  75.  
  76. #==============================================================================
  77. # ■ Scene_Load
  78. #------------------------------------------------------------------------------
  79. #  ロード画面の処理を行うクラスです。
  80. #==============================================================================
  81.  
  82. class Scene_Load < Scene_File
  83.   #--------------------------------------------------------------------------
  84.   # ● ロード成功時の処理
  85.   #--------------------------------------------------------------------------
  86.   alias rx3_1201202_on_load_success on_load_success
  87.   def on_load_success
  88.     index_save         # ★ ロードしたファイルインデックス情報を書き込む
  89.     rx3_1201202_on_load_success # メソッド呼び戻し
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ★ ロードしたファイルインデックス情報を書き込む
  93.   #--------------------------------------------------------------------------
  94.   def index_save
  95.     rx_read_save_index # 先にセーブしたファイルインデックス情報を読み込む
  96.     file = File.open("RX_SaveFileInfos.dat", "wb")
  97.     Marshal.dump(@index, file)
  98.     Marshal.dump(@rx_save_index, file)
  99.     file.close
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ★ セーブしたファイルインデックス情報を読み込む
  103.   #--------------------------------------------------------------------------
  104.   def rx_read_save_index
  105.     file = File.open("RX_SaveFileInfos.dat", "rb")
  106.     rx_load_index  = Marshal.load(file)
  107.     @rx_save_index = Marshal.load(file)
  108.     file.close
  109.   end
  110. end
  111.  
  112. #==============================================================================
  113. # ★ Scene_RX_QuickLoad
  114. #------------------------------------------------------------------------------
  115. #  クイックロードの処理を行うクラスです。
  116. #==============================================================================
  117.  
  118. class Scene_RX_QuickLoad < Scene_MenuBase
  119.   #--------------------------------------------------------------------------
  120.   # ● 開始処理
  121.   #--------------------------------------------------------------------------
  122.   def start
  123.     super
  124.     quick_load
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● クイックロード
  128.   #--------------------------------------------------------------------------
  129.   def quick_load
  130.     index = read_index
  131.     if index >= 0
  132.       $game_system.on_after_load if DataManager.load_game(index)
  133.       SceneManager.goto(Scene_Map)
  134.     else
  135.       SceneManager.goto(Scene_Title)
  136.     end
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● インデックス情報をロード
  140.   #--------------------------------------------------------------------------
  141.   def read_index
  142.     file = File.open("RX_SaveFileInfos.dat", "rb")
  143.     load_index     = Marshal.load(file)
  144.     save_index     = Marshal.load(file)
  145.     file.close
  146.     return load_index if $RX_QLOAD == 1
  147.     return save_index if $RX_QLOAD == 2
  148.   end
  149. end

作者: 三途亚梦    时间: 2015-1-15 15:07
请勿只贴代码好吗?

xy有很多,谁知道你说的是哪个XY?
作者: xkm198510    时间: 2015-1-15 15:11
三途亚梦 发表于 2015-1-15 15:07
请勿只贴代码好吗?

xy有很多,谁知道你说的是哪个XY?

这是个竖版带角色的战斗脚本,我想知道,更改角色位置的x,y轴
作者: tseyik    时间: 2015-1-15 15:15
本帖最后由 tseyik 于 2015-1-15 15:17 编辑

這個是快速load脚本,
関角色位置有什麼関係?
作者: xkm198510    时间: 2015-1-15 16:45
应该是这个吧
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Scene_Battle
  4. #------------------------------------------------------------------------------
  5. #  戰斗畫面
  6. #==============================================================================

  7. class Scene_Battle < Scene_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 開始處理
  10.   #--------------------------------------------------------------------------
  11.   def start
  12.     super
  13.     create_spriteset
  14.     create_all_windows
  15.     BattleManager.method_wait_for_message = method(:wait_for_message)
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 開始后處理
  19.   #--------------------------------------------------------------------------
  20.   def post_start
  21.     super
  22.     battle_start
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 結束前處理
  26.   #--------------------------------------------------------------------------
  27.   def pre_terminate
  28.     super
  29.     Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map)
  30.     Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title)
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 結束處理
  34.   #--------------------------------------------------------------------------
  35.   def terminate
  36.     super
  37.     dispose_spriteset
  38.     @info_viewport.dispose
  39.     RPG::ME.stop
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 更新畫面
  43.   #--------------------------------------------------------------------------
  44.   def update
  45.     super
  46.     if BattleManager.in_turn?
  47.       process_event
  48.       process_action
  49.     end
  50.     BattleManager.judge_win_loss
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 更新畫面(基礎)
  54.   #--------------------------------------------------------------------------
  55.   def update_basic
  56.     super
  57.     $game_timer.update
  58.     $game_troop.update
  59.     @spriteset.update
  60.     update_info_viewport
  61.     update_message_open
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 更新畫面(等待用)
  65.   #--------------------------------------------------------------------------
  66.   def update_for_wait
  67.     update_basic
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 等待
  71.   #--------------------------------------------------------------------------
  72.   def wait(duration)
  73.     duration.times {|i| update_for_wait if i < duration / 2 || !show_fast? }
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 快進判定
  77.   #--------------------------------------------------------------------------
  78.   def show_fast?
  79.     Input.press?(:A) || Input.press?(:C)
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 等待(快進無效)
  83.   #--------------------------------------------------------------------------
  84.   def abs_wait(duration)
  85.     duration.times {|i| update_for_wait }
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 短時間等待(快進無效)
  89.   #--------------------------------------------------------------------------
  90.   def abs_wait_short
  91.     abs_wait(15)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 等待信息顯示的結束
  95.   #--------------------------------------------------------------------------
  96.   def wait_for_message
  97.     @message_window.update
  98.     update_for_wait while $game_message.visible
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 等待動畫顯示的結束
  102.   #--------------------------------------------------------------------------
  103.   def wait_for_animation
  104.     update_for_wait
  105.     update_for_wait while @spriteset.animation?
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 等待效果執行的結束
  109.   #--------------------------------------------------------------------------
  110.   def wait_for_effect
  111.     update_for_wait
  112.     update_for_wait while @spriteset.effect?
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 更新信息顯示的顯示端口
  116.   #--------------------------------------------------------------------------
  117.   def update_info_viewport
  118.     move_info_viewport(0)   if @party_command_window.active
  119.     move_info_viewport(128) if @actor_command_window.active
  120.     move_info_viewport(64)  if BattleManager.in_turn?
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 移動信息顯示的顯示端口
  124.   #--------------------------------------------------------------------------
  125.   def move_info_viewport(ox)
  126.     current_ox = @info_viewport.ox
  127.     @info_viewport.ox = [ox, current_ox + 16].min if current_ox < ox
  128.     @info_viewport.ox = [ox, current_ox - 16].max if current_ox > ox
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 信息窗口打開時的更新
  132.   #    在狀態窗口關閉完成前,信息窗口的打開度設置為 0 。
  133.   #--------------------------------------------------------------------------
  134.   def update_message_open
  135.     if $game_message.busy? && !@status_window.close?
  136.       @message_window.openness = 0
  137.       @status_window.close
  138.       @party_command_window.close
  139.       @actor_command_window.close
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 生成精靈組
  144.   #--------------------------------------------------------------------------
  145.   def create_spriteset
  146.     @spriteset = Spriteset_Battle.new
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 釋放精靈組
  150.   #--------------------------------------------------------------------------
  151.   def dispose_spriteset
  152.     @spriteset.dispose
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 生成所有窗口
  156.   #--------------------------------------------------------------------------
  157.   def create_all_windows
  158.     create_message_window
  159.     create_scroll_text_window
  160.     create_log_window
  161.     create_status_window
  162.     create_info_viewport
  163.     create_party_command_window
  164.     create_actor_command_window
  165.     create_help_window
  166.     create_skill_window
  167.     create_item_window
  168.     create_actor_window
  169.     create_enemy_window
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 生成信息窗口
  173.   #--------------------------------------------------------------------------
  174.   def create_message_window
  175.     @message_window = Window_Message.new
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 生成滾動文字窗口
  179.   #--------------------------------------------------------------------------
  180.   def create_scroll_text_window
  181.     @scroll_text_window = Window_ScrollText.new
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 生成日志記錄窗口
  185.   #--------------------------------------------------------------------------
  186.   def create_log_window
  187.     @log_window = Window_BattleLog.new
  188.     @log_window.method_wait = method(:wait)
  189.     @log_window.method_wait_for_effect = method(:wait_for_effect)
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 生成狀態窗口
  193.   #--------------------------------------------------------------------------
  194.   def create_status_window
  195.     @status_window = Window_BattleStatus.new
  196.     @status_window.x = 128
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 生成信息顯示的顯示端口
  200.   #--------------------------------------------------------------------------
  201.   def create_info_viewport
  202.     @info_viewport = Viewport.new
  203.     @info_viewport.rect.y = Graphics.height - @status_window.height
  204.     @info_viewport.rect.height = @status_window.height
  205.     @info_viewport.z = 100
  206.     @info_viewport.ox = 64
  207.     @status_window.viewport = @info_viewport
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 生成隊伍指令窗口
  211.   #--------------------------------------------------------------------------
  212.   def create_party_command_window
  213.     @party_command_window = Window_PartyCommand.new
  214.     @party_command_window.viewport = @info_viewport
  215.     @party_command_window.set_handler(:fight,  method(:command_fight))
  216.     @party_command_window.set_handler(:escape, method(:command_escape))
  217.     @party_command_window.unselect
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 生成角色指令窗口
  221.   #--------------------------------------------------------------------------
  222.   def create_actor_command_window
  223.     @actor_command_window = Window_ActorCommand.new
  224.     @actor_command_window.viewport = @info_viewport
  225.     @actor_command_window.set_handler(:attack, method(:command_attack))
  226.     @actor_command_window.set_handler(:skill,  method(:command_skill))
  227.     @actor_command_window.set_handler(:guard,  method(:command_guard))
  228.     @actor_command_window.set_handler(:item,   method(:command_item))
  229.     @actor_command_window.set_handler(:cancel, method(:prior_command))
  230.     @actor_command_window.x = Graphics.width
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 生成幫助窗口
  234.   #--------------------------------------------------------------------------
  235.   def create_help_window
  236.     @help_window = Window_Help.new
  237.     @help_window.visible = false
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● 生成技能窗口
  241.   #--------------------------------------------------------------------------
  242.   def create_skill_window
  243.     @skill_window = Window_BattleSkill.new(@help_window, @info_viewport)
  244.     @skill_window.set_handler(:ok,     method(:on_skill_ok))
  245.     @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● 生成物品窗口
  249.   #--------------------------------------------------------------------------
  250.   def create_item_window
  251.     @item_window = Window_BattleItem.new(@help_window, @info_viewport)
  252.     @item_window.set_handler(:ok,     method(:on_item_ok))
  253.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # ● 生成角色窗口
  257.   #--------------------------------------------------------------------------
  258.   def create_actor_window
  259.     @actor_window = Window_BattleActor.new(@info_viewport)
  260.     @actor_window.set_handler(:ok,     method(:on_actor_ok))
  261.     @actor_window.set_handler(:cancel, method(:on_actor_cancel))
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● 生成敵人窗口
  265.   #--------------------------------------------------------------------------
  266.   def create_enemy_window
  267.     @enemy_window = Window_BattleEnemy.new(@info_viewport)
  268.     @enemy_window.set_handler(:ok,     method(:on_enemy_ok))
  269.     @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 更新狀態窗口的信息
  273.   #--------------------------------------------------------------------------
  274.   def refresh_status
  275.     @status_window.refresh
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● 進行下一個指令輸入
  279.   #--------------------------------------------------------------------------
  280.   def next_command
  281.     if BattleManager.next_command
  282.       start_actor_command_selection
  283.     else
  284.       turn_start
  285.     end
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 返回上一個指令輸入
  289.   #--------------------------------------------------------------------------
  290.   def prior_command
  291.     if BattleManager.prior_command
  292.       start_actor_command_selection
  293.     else
  294.       start_party_command_selection
  295.     end
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ● 開始隊伍指令的選擇
  299.   #--------------------------------------------------------------------------
  300.   def start_party_command_selection
  301.     unless scene_changing?
  302.       refresh_status
  303.       @status_window.unselect
  304.       @status_window.open
  305.       if BattleManager.input_start
  306.         @actor_command_window.close
  307.         @party_command_window.setup
  308.       else
  309.         @party_command_window.deactivate
  310.         turn_start
  311.       end
  312.     end
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ● 指令“戰斗”
  316.   #--------------------------------------------------------------------------
  317.   def command_fight
  318.     next_command
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● 指令“撤退”
  322.   #--------------------------------------------------------------------------
  323.   def command_escape
  324.     turn_start unless BattleManager.process_escape
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● 開始角色指令的選擇
  328.   #--------------------------------------------------------------------------
  329.   def start_actor_command_selection
  330.     @status_window.select(BattleManager.actor.index)
  331.     @party_command_window.close
  332.     @actor_command_window.setup(BattleManager.actor)
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ● 指令“攻擊”
  336.   #--------------------------------------------------------------------------
  337.   def command_attack
  338.     BattleManager.actor.input.set_attack
  339.     select_enemy_selection
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 指令“技能”
  343.   #--------------------------------------------------------------------------
  344.   def command_skill
  345.     @skill_window.actor = BattleManager.actor
  346.     @skill_window.stype_id = @actor_command_window.current_ext
  347.     @skill_window.refresh
  348.     @skill_window.show.activate
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 指令“防御”
  352.   #--------------------------------------------------------------------------
  353.   def command_guard
  354.     BattleManager.actor.input.set_guard
  355.     next_command
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 指令“物品”
  359.   #--------------------------------------------------------------------------
  360.   def command_item
  361.     @item_window.refresh
  362.     @item_window.show.activate
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 開始選擇隊友
  366.   #--------------------------------------------------------------------------
  367.   def select_actor_selection
  368.     @actor_window.refresh
  369.     @actor_window.show.activate
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● 角色“確定”
  373.   #--------------------------------------------------------------------------
  374.   def on_actor_ok
  375.     BattleManager.actor.input.target_index = @actor_window.index
  376.     @actor_window.hide
  377.     @skill_window.hide
  378.     @item_window.hide
  379.     next_command
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 角色“取消”
  383.   #--------------------------------------------------------------------------
  384.   def on_actor_cancel
  385.     @actor_window.hide
  386.     case @actor_command_window.current_symbol
  387.     when :skill
  388.       @skill_window.activate
  389.     when :item
  390.       @item_window.activate
  391.     end
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # ● 開始選擇敵人
  395.   #--------------------------------------------------------------------------
  396.   def select_enemy_selection
  397.     @enemy_window.refresh
  398.     @enemy_window.show.activate
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● 敵人“確定”
  402.   #--------------------------------------------------------------------------
  403.   def on_enemy_ok
  404.     BattleManager.actor.input.target_index = @enemy_window.enemy.index
  405.     @enemy_window.hide
  406.     @skill_window.hide
  407.     @item_window.hide
  408.     next_command
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # ● 敵人“取消”
  412.   #--------------------------------------------------------------------------
  413.   def on_enemy_cancel
  414.     @enemy_window.hide
  415.     case @actor_command_window.current_symbol
  416.     when :attack
  417.       @actor_command_window.activate
  418.     when :skill
  419.       @skill_window.activate
  420.     when :item
  421.       @item_window.activate
  422.     end
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● 技能“確定”
  426.   #--------------------------------------------------------------------------
  427.   def on_skill_ok
  428.     [url=home.php?mod=space&uid=260100]@skill[/url] = @skill_window.item
  429.     BattleManager.actor.input.set_skill(@skill.id)
  430.     BattleManager.actor.last_skill.object = @skill
  431.     if [email protected]_selection?
  432.       @skill_window.hide
  433.       next_command
  434.     elsif @skill.for_opponent?
  435.       select_enemy_selection
  436.     else
  437.       select_actor_selection
  438.     end
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # ● 技能“取消”
  442.   #--------------------------------------------------------------------------
  443.   def on_skill_cancel
  444.     @skill_window.hide
  445.     @actor_command_window.activate
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 物品“確定”
  449.   #--------------------------------------------------------------------------
  450.   def on_item_ok
  451.     @item = @item_window.item
  452.     BattleManager.actor.input.set_item(@item.id)
  453.     if [email protected]_selection?
  454.       @item_window.hide
  455.       next_command
  456.     elsif @item.for_opponent?
  457.       select_enemy_selection
  458.     else
  459.       select_actor_selection
  460.     end
  461.     $game_party.last_item.object = @item
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 物品“取消”
  465.   #--------------------------------------------------------------------------
  466.   def on_item_cancel
  467.     @item_window.hide
  468.     @actor_command_window.activate
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 戰斗開始
  472.   #--------------------------------------------------------------------------
  473.   def battle_start
  474.     BattleManager.battle_start
  475.     process_event
  476.     start_party_command_selection
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ● 回合開始
  480.   #--------------------------------------------------------------------------
  481.   def turn_start
  482.     @party_command_window.close
  483.     @actor_command_window.close
  484.     @status_window.unselect
  485.     @subject =  nil
  486.     BattleManager.turn_start
  487.     @log_window.wait
  488.     @log_window.clear
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ● 回合結束
  492.   #--------------------------------------------------------------------------
  493.   def turn_end
  494.     all_battle_members.each do |battler|
  495.       battler.on_turn_end
  496.       refresh_status
  497.       @log_window.display_auto_affected_status(battler)
  498.       @log_window.wait_and_clear
  499.     end
  500.     BattleManager.turn_end
  501.     process_event
  502.     start_party_command_selection
  503.   end
  504.   #--------------------------------------------------------------------------
  505.   # ● 獲取敵我雙方的全部參戰角色
  506.   #--------------------------------------------------------------------------
  507.   def all_battle_members
  508.     $game_party.members + $game_troop.members
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● 處理事件
  512.   #--------------------------------------------------------------------------
  513.   def process_event
  514.     while !scene_changing?
  515.       $game_troop.interpreter.update
  516.       $game_troop.setup_battle_event
  517.       wait_for_message
  518.       wait_for_effect if $game_troop.all_dead?
  519.       process_forced_action
  520.       BattleManager.judge_win_loss
  521.       break unless $game_troop.interpreter.running?
  522.       update_for_wait
  523.     end
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ● 處理強制戰斗行動
  527.   #--------------------------------------------------------------------------
  528.   def process_forced_action
  529.     if BattleManager.action_forced?
  530.       last_subject = @subject
  531.       @subject = BattleManager.action_forced_battler
  532.       BattleManager.clear_action_force
  533.       process_action
  534.       @subject = last_subject
  535.     end
  536.   end
  537.   #--------------------------------------------------------------------------
  538.   # ● 處理戰斗行動
  539.   #--------------------------------------------------------------------------
  540.   def process_action
  541.     return if scene_changing?
  542.     if !@subject || [email protected]_action
  543.       @subject = BattleManager.next_subject
  544.     end
  545.     return turn_end unless @subject
  546.     if @subject.current_action
  547.       @subject.current_action.prepare
  548.       if @subject.current_action.valid?
  549.         @status_window.open
  550.         execute_action
  551.       end
  552.       @subject.remove_current_action
  553.     end
  554.     process_action_end unless @subject.current_action
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # ● 戰斗行動結束時的處理
  558.   #--------------------------------------------------------------------------
  559.   def process_action_end
  560.     @subject.on_action_end
  561.     refresh_status
  562.     @log_window.display_auto_affected_status(@subject)
  563.     @log_window.wait_and_clear
  564.     @log_window.display_current_state(@subject)
  565.     @log_window.wait_and_clear
  566.     BattleManager.judge_win_loss
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ● 執行戰斗行動
  570.   #--------------------------------------------------------------------------
  571.   def execute_action
  572.     @subject.sprite_effect_type = :whiten
  573.     use_item
  574.     @log_window.wait_and_clear
  575.   end
  576.   #--------------------------------------------------------------------------
  577.   # ● 使用技能/物品
  578.   #--------------------------------------------------------------------------
  579.   def use_item
  580.     item = @subject.current_action.item
  581.     @log_window.display_use_item(@subject, item)
  582.     @subject.use_item(item)
  583.     refresh_status
  584.     targets = @subject.current_action.make_targets.compact
  585.     show_animation(targets, item.animation_id)
  586.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ● 發動技能/物品
  590.   #--------------------------------------------------------------------------
  591.   def invoke_item(target, item)
  592.     if rand < target.item_cnt(@subject, item)
  593.       invoke_counter_attack(target, item)
  594.     elsif rand < target.item_mrf(@subject, item)
  595.       invoke_magic_reflection(target, item)
  596.     else
  597.       apply_item_effects(apply_substitute(target, item), item)
  598.     end
  599.     @subject.last_target_index = target.index
  600.   end
  601.   #--------------------------------------------------------------------------
  602.   # ● 應用技能/物品效果
  603.   #--------------------------------------------------------------------------
  604.   def apply_item_effects(target, item)
  605.     target.item_apply(@subject, item)
  606.     refresh_status
  607.     @log_window.display_action_results(target, item)
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● 發動反擊
  611.   #--------------------------------------------------------------------------
  612.   def invoke_counter_attack(target, item)
  613.     @log_window.display_counter(target, item)
  614.     attack_skill = $data_skills[target.attack_skill_id]
  615.     @subject.item_apply(target, attack_skill)
  616.     refresh_status
  617.     @log_window.display_action_results(@subject, attack_skill)
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 發動反射魔法攻擊
  621.   #--------------------------------------------------------------------------
  622.   def invoke_magic_reflection(target, item)
  623.     @log_window.display_reflection(target, item)
  624.     apply_item_effects(@subject, item)
  625.   end
  626.   #--------------------------------------------------------------------------
  627.   # ● 應用保護弱者
  628.   #--------------------------------------------------------------------------
  629.   def apply_substitute(target, item)
  630.     if check_substitute(target, item)
  631.       substitute = target.friends_unit.substitute_battler
  632.       if substitute && target != substitute
  633.         @log_window.display_substitute(substitute, target)
  634.         return substitute
  635.       end
  636.     end
  637.     target
  638.   end
  639.   #--------------------------------------------------------------------------
  640.   # ● 檢查是否能使用保護弱者
  641.   #--------------------------------------------------------------------------
  642.   def check_substitute(target, item)
  643.     target.hp < target.mhp / 4 && (!item || !item.certain?)
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● 顯示動畫
  647.   #     targets      : 目標的數組
  648.   #     animation_id : 動畫 ID(-1: 與普通攻擊一樣)
  649.   #--------------------------------------------------------------------------
  650.   def show_animation(targets, animation_id)
  651.     if animation_id < 0
  652.       show_attack_animation(targets)
  653.     else
  654.       show_normal_animation(targets, animation_id)
  655.     end
  656.     @log_window.wait
  657.     wait_for_animation
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # ● 顯示攻擊動畫
  661.   #     targets : 目標的數組
  662.   #    是角色的時候考慮雙持武器的效果(反轉動畫顯示左手武器)。
  663.   #    是敵人的時候,在那一瞬間,播放“敵人普通攻擊”的聲效。
  664.   #--------------------------------------------------------------------------
  665.   def show_attack_animation(targets)
  666.     if @subject.actor?
  667.       show_normal_animation(targets, @subject.atk_animation_id1, false)
  668.       show_normal_animation(targets, @subject.atk_animation_id2, true)
  669.     else
  670.       Sound.play_enemy_attack
  671.       abs_wait_short
  672.     end
  673.   end
  674.   #--------------------------------------------------------------------------
  675.   # ● 顯示普通動畫
  676.   #     targets      : 目標的數組
  677.   #     animation_id : 動畫ID
  678.   #     mirror       : 左右反轉
  679.   #--------------------------------------------------------------------------
  680.   def show_normal_animation(targets, animation_id, mirror = false)
  681.     animation = $data_animations[animation_id]
  682.     if animation
  683.       targets.each do |target|
  684.         target.animation_id = animation_id
  685.         target.animation_mirror = mirror
  686.         abs_wait_short unless animation.to_screen?
  687.       end
  688.       abs_wait_short if animation.to_screen?
  689.     end
  690.   end
  691. end
复制代码

作者: xkm198510    时间: 2015-1-15 16:47
还有这个,不知道那个是
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Sprite_Battler
  4. #------------------------------------------------------------------------------
  5. #  显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
  6. #==============================================================================

  7. class Sprite_Battler < Sprite_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_accessor :battler
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对象
  14.   #--------------------------------------------------------------------------
  15.   def initialize(viewport, battler = nil)
  16.     super(viewport)
  17.     [url=home.php?mod=space&uid=133701]@battler[/url] = battler
  18.     @battler_visible = false
  19.     @effect_type = nil
  20.     @effect_duration = 0
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 释放
  24.   #--------------------------------------------------------------------------
  25.   def dispose
  26.     bitmap.dispose if bitmap
  27.     super
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● 更新画面
  31.   #--------------------------------------------------------------------------
  32.   def update
  33.     super
  34.     if @battler
  35.       @use_sprite = @battler.use_sprite?
  36.       if @use_sprite
  37.         update_bitmap
  38.         update_origin
  39.         update_position
  40.       end
  41.       setup_new_effect
  42.       setup_new_animation
  43.       update_effect
  44.     else
  45.       self.bitmap = nil
  46.       @effect_type = nil
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 更新源位图(Source Bitmap)
  51.   #--------------------------------------------------------------------------
  52.   def update_bitmap
  53.     new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
  54.     if bitmap != new_bitmap
  55.       self.bitmap = new_bitmap
  56.       init_visibility
  57.     end
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 初始化可视状态
  61.   #--------------------------------------------------------------------------
  62.   def init_visibility
  63.     @battler_visible = @battler.alive?
  64.     self.opacity = 0 unless @battler_visible
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 更新原点
  68.   #--------------------------------------------------------------------------
  69.   def update_origin
  70.     if bitmap
  71.       self.ox = bitmap.width / 2
  72.       self.oy = bitmap.height
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 更新位置
  77.   #--------------------------------------------------------------------------
  78.   def update_position
  79.     self.x = @battler.screen_x
  80.     self.y = @battler.screen_y
  81.     self.z = @battler.screen_z
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 设置新的效果
  85.   #--------------------------------------------------------------------------
  86.   def setup_new_effect
  87.     if !@battler_visible && @battler.alive?
  88.       start_effect(:appear)
  89.     elsif @battler_visible && @battler.hidden?
  90.       start_effect(:disappear)
  91.     end
  92.     if @battler_visible && @battler.sprite_effect_type
  93.       start_effect(@battler.sprite_effect_type)
  94.       @battler.sprite_effect_type = nil
  95.     end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 效果开始
  99.   #--------------------------------------------------------------------------
  100.   def start_effect(effect_type)
  101.     @effect_type = effect_type
  102.     case @effect_type
  103.     when :appear
  104.       @effect_duration = 16
  105.       @battler_visible = true
  106.     when :disappear
  107.       @effect_duration = 32
  108.       @battler_visible = false
  109.     when :whiten
  110.       @effect_duration = 16
  111.       @battler_visible = true
  112.     when :blink
  113.       @effect_duration = 20
  114.       @battler_visible = true
  115.     when :collapse
  116.       @effect_duration = 48
  117.       @battler_visible = false
  118.     when :boss_collapse
  119.       @effect_duration = bitmap.height
  120.       @battler_visible = false
  121.     when :instant_collapse
  122.       @effect_duration = 16
  123.       @battler_visible = false
  124.     end
  125.     revert_to_normal
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 返回普通设置
  129.   #--------------------------------------------------------------------------
  130.   def revert_to_normal
  131.     self.blend_type = 0
  132.     self.color.set(0, 0, 0, 0)
  133.     self.opacity = 255
  134.     self.ox = bitmap.width / 2 if bitmap
  135.     self.src_rect.y = 0
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 设置新的动画
  139.   #--------------------------------------------------------------------------
  140.   def setup_new_animation
  141.     if @battler.animation_id > 0
  142.       animation = $data_animations[@battler.animation_id]
  143.       mirror = @battler.animation_mirror
  144.       start_animation(animation, mirror)
  145.       @battler.animation_id = 0
  146.     end
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 判定效果是否执行中
  150.   #--------------------------------------------------------------------------
  151.   def effect?
  152.     @effect_type != nil
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 更新效果
  156.   #--------------------------------------------------------------------------
  157.   def update_effect
  158.     if @effect_duration > 0
  159.       @effect_duration -= 1
  160.       case @effect_type
  161.       when :whiten
  162.         update_whiten
  163.       when :blink
  164.         update_blink
  165.       when :appear
  166.         update_appear
  167.       when :disappear
  168.         update_disappear
  169.       when :collapse
  170.         update_collapse
  171.       when :boss_collapse
  172.         update_boss_collapse
  173.       when :instant_collapse
  174.         update_instant_collapse
  175.       end
  176.       @effect_type = nil if @effect_duration == 0
  177.     end
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 更新白闪烁效果
  181.   #--------------------------------------------------------------------------
  182.   def update_whiten
  183.     self.color.set(255, 255, 255, 0)
  184.     self.color.alpha = 128 - (16 - @effect_duration) * 10
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 更新明灭效果
  188.   #--------------------------------------------------------------------------
  189.   def update_blink
  190.     self.opacity = (@effect_duration % 10 < 5) ? 255 : 0
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 更新出现效果
  194.   #--------------------------------------------------------------------------
  195.   def update_appear
  196.     self.opacity = (16 - @effect_duration) * 16
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 更新消灭效果
  200.   #--------------------------------------------------------------------------
  201.   def update_disappear
  202.     self.opacity = 256 - (32 - @effect_duration) * 10
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 更新击溃效果
  206.   #--------------------------------------------------------------------------
  207.   def update_collapse
  208.     self.blend_type = 1
  209.     self.color.set(255, 128, 128, 128)
  210.     self.opacity = 256 - (48 - @effect_duration) * 6
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 更新击溃首领效果
  214.   #--------------------------------------------------------------------------
  215.   def update_boss_collapse
  216.     alpha = @effect_duration * 120 / bitmap.height
  217.     self.ox = bitmap.width / 2 + @effect_duration % 2 * 4 - 2
  218.     self.blend_type = 1
  219.     self.color.set(255, 255, 255, 255 - alpha)
  220.     self.opacity = alpha
  221.     self.src_rect.y -= 1
  222.     Sound.play_boss_collapse2 if @effect_duration % 20 == 19
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 更新瞬间消失效果
  226.   #--------------------------------------------------------------------------
  227.   def update_instant_collapse
  228.     self.opacity = 0
  229.   end
  230. end
复制代码

作者: xkm198510    时间: 2015-1-15 16:48
这个也发吧。
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Game_Battler
  4. #------------------------------------------------------------------------------
  5. #  處理戰鬥者的類。Game_Actor 和 Game_Enemy 類的父類。
  6. #==============================================================================

  7. class Game_Battler < Game_BattlerBase
  8.   #--------------------------------------------------------------------------
  9.   # ● 常量(使用效果)
  10.   #--------------------------------------------------------------------------
  11.   EFFECT_RECOVER_HP     = 11              # 恢復 HP
  12.   EFFECT_RECOVER_MP     = 12              # 恢復 MP
  13.   EFFECT_GAIN_TP        = 13              # 增加 TP
  14.   EFFECT_ADD_STATE      = 21              # 附加狀態
  15.   EFFECT_REMOVE_STATE   = 22              # 解除狀態
  16.   EFFECT_ADD_BUFF       = 31              # 強化能力
  17.   EFFECT_ADD_DEBUFF     = 32              # 弱化能力
  18.   EFFECT_REMOVE_BUFF    = 33              # 解除能力強化
  19.   EFFECT_REMOVE_DEBUFF  = 34              # 解除能力弱化
  20.   EFFECT_SPECIAL        = 41              # 特殊效果
  21.   EFFECT_GROW           = 42              # 能力提升
  22.   EFFECT_LEARN_SKILL    = 43              # 學會技能
  23.   EFFECT_COMMON_EVENT   = 44              # 公共事件
  24.   #--------------------------------------------------------------------------
  25.   # ● 常量(特殊效果)
  26.   #--------------------------------------------------------------------------
  27.   SPECIAL_EFFECT_ESCAPE = 0               # 撤退
  28.   #--------------------------------------------------------------------------
  29.   # ● 定義實例變量
  30.   #--------------------------------------------------------------------------
  31.   attr_reader   :battler_name             # 戰鬥圖像文件名
  32.   attr_reader   :battler_hue              # 戰鬥圖像色相
  33.   attr_reader   :action_times             # 行動回數
  34.   attr_reader   :actions                  # 戰鬥行動(行動方)
  35.   attr_reader   :speed                    # 行動速度
  36.   attr_reader   :result                   # 行動結果(目標方)
  37.   attr_accessor :last_target_index        # 最后目標的索引
  38.   attr_accessor :animation_id             # 動畫 ID
  39.   attr_accessor :animation_mirror         # 動畫左右反轉的標志
  40.   attr_accessor :sprite_effect_type       # 精靈的效果
  41.   #--------------------------------------------------------------------------
  42.   # ● 初始化對象
  43.   #--------------------------------------------------------------------------
  44.   def initialize
  45.     @battler_name = ""
  46.     @battler_hue = 0
  47.     @actions = []
  48.     @speed = 0
  49.     @result = Game_ActionResult.new(self)
  50.     @last_target_index = 0
  51.     @guarding = false
  52.     clear_sprite_effects
  53.     super
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 清除精靈的效果
  57.   #--------------------------------------------------------------------------
  58.   def clear_sprite_effects
  59.     @animation_id = 0
  60.     @animation_mirror = false
  61.     @sprite_effect_type = nil
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 清除戰鬥行動
  65.   #--------------------------------------------------------------------------
  66.   def clear_actions
  67.     @actions.clear
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 清除狀態信息
  71.   #--------------------------------------------------------------------------
  72.   def clear_states
  73.     super
  74.     @result.clear_status_effects
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 附加狀態
  78.   #--------------------------------------------------------------------------
  79.   def add_state(state_id)
  80.     if state_addable?(state_id)
  81.       add_new_state(state_id) unless state?(state_id)
  82.       reset_state_counts(state_id)
  83.       @result.added_states.push(state_id).uniq!
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 判定狀態是否可以附加
  88.   #--------------------------------------------------------------------------
  89.   def state_addable?(state_id)
  90.     alive? && $data_states[state_id] && !state_resist?(state_id) &&
  91.       !state_removed?(state_id) && !state_restrict?(state_id)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 判定狀態是否已被解除
  95.   #--------------------------------------------------------------------------
  96.   def state_removed?(state_id)
  97.     @result.removed_states.include?(state_id)
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 判定狀態是否受到行動限制影響而無法附加
  101.   #--------------------------------------------------------------------------
  102.   def state_restrict?(state_id)
  103.     $data_states[state_id].remove_by_restriction && restriction > 0
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 附加新的狀態
  107.   #--------------------------------------------------------------------------
  108.   def add_new_state(state_id)
  109.     die if state_id == death_state_id
  110.     @states.push(state_id)
  111.     on_restrict if restriction > 0
  112.     sort_states
  113.     refresh
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 行動受到限制時的處理
  117.   #--------------------------------------------------------------------------
  118.   def on_restrict
  119.     clear_actions
  120.     states.each do |state|
  121.       remove_state(state.id) if state.remove_by_restriction
  122.     end
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 重置狀態計數(回合數或步數)
  126.   #--------------------------------------------------------------------------
  127.   def reset_state_counts(state_id)
  128.     state = $data_states[state_id]
  129.     variance = 1 + [state.max_turns - state.min_turns, 0].max
  130.     @state_turns[state_id] = state.min_turns + rand(variance)
  131.     @state_steps[state_id] = state.steps_to_remove
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 解除狀態
  135.   #--------------------------------------------------------------------------
  136.   def remove_state(state_id)
  137.     if state?(state_id)
  138.       revive if state_id == death_state_id
  139.       erase_state(state_id)
  140.       refresh
  141.       @result.removed_states.push(state_id).uniq!
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 死亡
  146.   #--------------------------------------------------------------------------
  147.   def die
  148.     @hp = 0
  149.     clear_states
  150.     clear_buffs
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 復活
  154.   #--------------------------------------------------------------------------
  155.   def revive
  156.     @hp = 1 if @hp == 0
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 撤退
  160.   #--------------------------------------------------------------------------
  161.   def escape
  162.     hide if $game_party.in_battle
  163.     clear_actions
  164.     clear_states
  165.     Sound.play_escape
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 強化能力
  169.   #--------------------------------------------------------------------------
  170.   def add_buff(param_id, turns)
  171.     return unless alive?
  172.     @buffs[param_id] += 1 unless buff_max?(param_id)
  173.     erase_buff(param_id) if debuff?(param_id)
  174.     overwrite_buff_turns(param_id, turns)
  175.     @result.added_buffs.push(param_id).uniq!
  176.     refresh
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 弱化能力
  180.   #--------------------------------------------------------------------------
  181.   def add_debuff(param_id, turns)
  182.     return unless alive?
  183.     @buffs[param_id] -= 1 unless debuff_max?(param_id)
  184.     erase_buff(param_id) if buff?(param_id)
  185.     overwrite_buff_turns(param_id, turns)
  186.     @result.added_debuffs.push(param_id).uniq!
  187.     refresh
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 解除能力強化/弱化狀態
  191.   #--------------------------------------------------------------------------
  192.   def remove_buff(param_id)
  193.     return unless alive?
  194.     return if @buffs[param_id] == 0
  195.     erase_buff(param_id)
  196.     @buff_turns.delete(param_id)
  197.     @result.removed_buffs.push(param_id).uniq!
  198.     refresh
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 消除能力強化/弱化
  202.   #--------------------------------------------------------------------------
  203.   def erase_buff(param_id)
  204.     @buffs[param_id] = 0
  205.     @buff_turns[param_id] = 0
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 判定能力強化狀態
  209.   #--------------------------------------------------------------------------
  210.   def buff?(param_id)
  211.     @buffs[param_id] > 0
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # ● 判定能力弱化狀態
  215.   #--------------------------------------------------------------------------
  216.   def debuff?(param_id)
  217.     @buffs[param_id] < 0
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 判定能力強化是否為最大程度
  221.   #--------------------------------------------------------------------------
  222.   def buff_max?(param_id)
  223.     @buffs[param_id] == 2
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 判定能力弱化是否為最大程度
  227.   #--------------------------------------------------------------------------
  228.   def debuff_max?(param_id)
  229.     @buffs[param_id] == -2
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 重新設置能力強化/弱化的回合數
  233.   #    如果新的回合數比較短,保持原值。
  234.   #--------------------------------------------------------------------------
  235.   def overwrite_buff_turns(param_id, turns)
  236.     @buff_turns[param_id] = turns if @buff_turns[param_id].to_i < turns
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 更新狀態的回總數數
  240.   #--------------------------------------------------------------------------
  241.   def update_state_turns
  242.     states.each do |state|
  243.       @state_turns[state.id] -= 1 if @state_turns[state.id] > 0
  244.     end
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 更新強化/弱化的回總數數
  248.   #--------------------------------------------------------------------------
  249.   def update_buff_turns
  250.     @buff_turns.keys.each do |param_id|
  251.       @buff_turns[param_id] -= 1 if @buff_turns[param_id] > 0
  252.     end
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 解除戰鬥狀態
  256.   #--------------------------------------------------------------------------
  257.   def remove_battle_states
  258.     states.each do |state|
  259.       remove_state(state.id) if state.remove_at_battle_end
  260.     end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 解除所有的強化/弱化狀態
  264.   #--------------------------------------------------------------------------
  265.   def remove_all_buffs
  266.     @buffs.size.times {|param_id| remove_buff(param_id) }
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 狀態的自動解除
  270.   #     timing : 時機(1:行動結束 2:回合結束)
  271.   #--------------------------------------------------------------------------
  272.   def remove_states_auto(timing)
  273.     states.each do |state|
  274.       if @state_turns[state.id] == 0 && state.auto_removal_timing == timing
  275.         remove_state(state.id)
  276.       end
  277.     end
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 強化/弱化的自動解除
  281.   #--------------------------------------------------------------------------
  282.   def remove_buffs_auto
  283.     @buffs.size.times do |param_id|
  284.       next if @buffs[param_id] == 0 || @buff_turns[param_id] > 0
  285.       remove_buff(param_id)
  286.     end
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 受到傷害時解除狀態
  290.   #--------------------------------------------------------------------------
  291.   def remove_states_by_damage
  292.     states.each do |state|
  293.       if state.remove_by_damage && rand(100) < state.chance_by_damage
  294.         remove_state(state.id)
  295.       end
  296.     end
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 決定行動回數
  300.   #--------------------------------------------------------------------------
  301.   def make_action_times
  302.     action_plus_set.inject(1) {|r, p| rand < p ? r + 1 : r }
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 生成戰鬥行動
  306.   #--------------------------------------------------------------------------
  307.   def make_actions
  308.     clear_actions
  309.     return unless movable?
  310.     @actions = Array.new(make_action_times) { Game_Action.new(self) }
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 決定行動速度
  314.   #--------------------------------------------------------------------------
  315.   def make_speed
  316.     @speed = @actions.collect {|action| action.speed }.min || 0
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● 獲取當前戰鬥行動
  320.   #--------------------------------------------------------------------------
  321.   def current_action
  322.     @actions[0]
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● 移除當前戰鬥行動
  326.   #--------------------------------------------------------------------------
  327.   def remove_current_action
  328.     @actions.shift
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # ● 強制戰鬥行動
  332.   #--------------------------------------------------------------------------
  333.   def force_action(skill_id, target_index)
  334.     clear_actions
  335.     action = Game_Action.new(self, true)
  336.     action.set_skill(skill_id)
  337.     if target_index == -2
  338.       action.target_index = last_target_index
  339.     elsif target_index == -1
  340.       action.decide_random_target
  341.     else
  342.       action.target_index = target_index
  343.     end
  344.     @actions.push(action)
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 計算傷害
  348.   #--------------------------------------------------------------------------
  349.   def make_damage_value(user, item)
  350.     value = item.damage.eval(user, self, $game_variables)
  351.     value *= item_element_rate(user, item)
  352.     value *= pdr if item.physical?
  353.     value *= mdr if item.magical?
  354.     value *= rec if item.damage.recover?
  355.     value = apply_critical(value) if @result.critical
  356.     value = apply_variance(value, item.damage.variance)
  357.     value = apply_guard(value)
  358.     @result.make_damage(value.to_i, item)
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 獲取技能/物品的屬性修正值
  362.   #--------------------------------------------------------------------------
  363.   def item_element_rate(user, item)
  364.     if item.damage.element_id < 0
  365.       user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements)
  366.     else
  367.       element_rate(item.damage.element_id)
  368.     end
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ● 獲取屬性的最大修正值,返回所有屬性中最有效的一個
  372.   #     elements : 屬性 ID 數組
  373.   #--------------------------------------------------------------------------
  374.   def elements_max_rate(elements)
  375.     elements.inject([0.0]) {|r, i| r.push(element_rate(i)) }.max
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● 應用關鍵一擊
  379.   #--------------------------------------------------------------------------
  380.   def apply_critical(damage)
  381.     damage * 3
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # ● 應用離散度
  385.   #--------------------------------------------------------------------------
  386.   def apply_variance(damage, variance)
  387.     amp = [damage.abs * variance / 100, 0].max.to_i
  388.     var = rand(amp + 1) + rand(amp + 1) - amp
  389.     damage >= 0 ? damage + var : damage - var
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 應用防御修正
  393.   #--------------------------------------------------------------------------
  394.   def apply_guard(damage)
  395.     damage / (damage > 0 && guard? ? 2 * grd : 1)
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 處理傷害
  399.   #    調用前需要設置好
  400.   #    @result.hp_damage   @result.mp_damage
  401.   #    @result.hp_drain    @result.mp_drain
  402.   #--------------------------------------------------------------------------
  403.   def execute_damage(user)
  404.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  405.     self.hp -= @result.hp_damage
  406.     self.mp -= @result.mp_damage
  407.     user.hp += @result.hp_drain
  408.     user.mp += @result.mp_drain
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # ● 技能/使用物品
  412.   #    對使用目標使用完畢后,應用對于使用目標以外的效果。
  413.   #--------------------------------------------------------------------------
  414.   def use_item(item)
  415.     pay_skill_cost(item) if item.is_a?(RPG::Skill)
  416.     consume_item(item)   if item.is_a?(RPG::Item)
  417.     item.effects.each {|effect| item_global_effect_apply(effect) }
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 消耗物品
  421.   #--------------------------------------------------------------------------
  422.   def consume_item(item)
  423.     $game_party.consume_item(item)
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ● 應用對于使用目標以外的效果
  427.   #--------------------------------------------------------------------------
  428.   def item_global_effect_apply(effect)
  429.     if effect.code == EFFECT_COMMON_EVENT
  430.       $game_temp.reserve_common_event(effect.data_id)
  431.     end
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # ● 技能/物品的應用測試
  435.   #    如果使用目標的 HP 或者 MP 全滿時,禁止使用恢復道具。
  436.   #--------------------------------------------------------------------------
  437.   def item_test(user, item)
  438.     return false if item.for_dead_friend? != dead?
  439.     return true if $game_party.in_battle
  440.     return true if item.for_opponent?
  441.     return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
  442.     return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
  443.     return true if item_has_any_valid_effects?(user, item)
  444.     return false
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● 判定技能/物品是否有效果
  448.   #--------------------------------------------------------------------------
  449.   def item_has_any_valid_effects?(user, item)
  450.     item.effects.any? {|effect| item_effect_test(user, item, effect) }
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 計算技能/物品的反擊幾率
  454.   #--------------------------------------------------------------------------
  455.   def item_cnt(user, item)
  456.     return 0 unless item.physical?          # 攻擊類型不是物理攻擊
  457.     return 0 unless opposite?(user)         # 隊友無法反擊
  458.     return cnt                              # 返回反擊幾率
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 計算技能/物品的反射幾率
  462.   #--------------------------------------------------------------------------
  463.   def item_mrf(user, item)
  464.     return mrf if item.magical?             # 是魔法攻擊則返回反射魔法幾率
  465.     return 0
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # ● 計算技能/物品的成功幾率
  469.   #--------------------------------------------------------------------------
  470.   def item_hit(user, item)
  471.     rate = item.success_rate * 0.01         # 獲取成功幾率
  472.     rate *= user.hit if item.physical?      # 物理攻擊:計算成功幾率的乘積
  473.     return rate                             # 返回計算后的成功幾率
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 計算技能/物品的閃避幾率
  477.   #--------------------------------------------------------------------------
  478.   def item_eva(user, item)
  479.     return eva if item.physical?            # 是物理攻擊則返回閃避幾率
  480.     return mev if item.magical?             # 是魔法攻擊則返回閃避魔法幾率
  481.     return 0
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ● 計算技能/物品的必殺幾率
  485.   #--------------------------------------------------------------------------
  486.   def item_cri(user, item)
  487.     item.damage.critical ? user.cri * (1 - cev) : 0
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ● 應用普通攻擊的效果
  491.   #--------------------------------------------------------------------------
  492.   def attack_apply(attacker)
  493.     item_apply(attacker, $data_skills[attacker.attack_skill_id])
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ● 應用技能/物品的效果
  497.   #--------------------------------------------------------------------------
  498.   def item_apply(user, item)
  499.     @result.clear
  500.     @result.used = item_test(user, item)
  501.     @result.missed = (@result.used && rand >= item_hit(user, item))
  502.     @result.evaded = ([email protected] && rand < item_eva(user, item))
  503.     if @result.hit?
  504.       unless item.damage.none?
  505.         @result.critical = (rand < item_cri(user, item))
  506.         make_damage_value(user, item)
  507.         execute_damage(user)
  508.       end
  509.       item.effects.each {|effect| item_effect_apply(user, item, effect) }
  510.       item_user_effect(user, item)
  511.     end
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● 測試使用效果
  515.   #--------------------------------------------------------------------------
  516.   def item_effect_test(user, item, effect)
  517.     case effect.code
  518.     when EFFECT_RECOVER_HP
  519.       hp < mhp || effect.value1 < 0 || effect.value2 < 0
  520.     when EFFECT_RECOVER_MP
  521.       mp < mmp || effect.value1 < 0 || effect.value2 < 0
  522.     when EFFECT_ADD_STATE
  523.       !state?(effect.data_id)
  524.     when EFFECT_REMOVE_STATE
  525.       state?(effect.data_id)
  526.     when EFFECT_ADD_BUFF
  527.       !buff_max?(effect.data_id)
  528.     when EFFECT_ADD_DEBUFF
  529.       !debuff_max?(effect.data_id)
  530.     when EFFECT_REMOVE_BUFF
  531.       buff?(effect.data_id)
  532.     when EFFECT_REMOVE_DEBUFF
  533.       debuff?(effect.data_id)
  534.     when EFFECT_LEARN_SKILL
  535.       actor? && !skills.include?($data_skills[effect.data_id])
  536.     else
  537.       true
  538.     end
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ● 應用使用效果
  542.   #--------------------------------------------------------------------------
  543.   def item_effect_apply(user, item, effect)
  544.     method_table = {
  545.       EFFECT_RECOVER_HP    => :item_effect_recover_hp,
  546.       EFFECT_RECOVER_MP    => :item_effect_recover_mp,
  547.       EFFECT_GAIN_TP       => :item_effect_gain_tp,
  548.       EFFECT_ADD_STATE     => :item_effect_add_state,
  549.       EFFECT_REMOVE_STATE  => :item_effect_remove_state,
  550.       EFFECT_ADD_BUFF      => :item_effect_add_buff,
  551.       EFFECT_ADD_DEBUFF    => :item_effect_add_debuff,
  552.       EFFECT_REMOVE_BUFF   => :item_effect_remove_buff,
  553.       EFFECT_REMOVE_DEBUFF => :item_effect_remove_debuff,
  554.       EFFECT_SPECIAL       => :item_effect_special,
  555.       EFFECT_GROW          => :item_effect_grow,
  556.       EFFECT_LEARN_SKILL   => :item_effect_learn_skill,
  557.       EFFECT_COMMON_EVENT  => :item_effect_common_event,
  558.     }
  559.     method_name = method_table[effect.code]
  560.     send(method_name, user, item, effect) if method_name
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 應用“恢復 HP”效果
  564.   #--------------------------------------------------------------------------
  565.   def item_effect_recover_hp(user, item, effect)
  566.     value = (mhp * effect.value1 + effect.value2) * rec
  567.     value *= user.pha if item.is_a?(RPG::Item)
  568.     value = value.to_i
  569.     @result.hp_damage -= value
  570.     @result.success = true
  571.     self.hp += value
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # ● 應用“恢復 MP”效果
  575.   #--------------------------------------------------------------------------
  576.   def item_effect_recover_mp(user, item, effect)
  577.     value = (mmp * effect.value1 + effect.value2) * rec
  578.     value *= user.pha if item.is_a?(RPG::Item)
  579.     value = value.to_i
  580.     @result.mp_damage -= value
  581.     @result.success = true if value != 0
  582.     self.mp += value
  583.   end
  584.   #--------------------------------------------------------------------------
  585.   # ● 應用“增加 TP”效果
  586.   #--------------------------------------------------------------------------
  587.   def item_effect_gain_tp(user, item, effect)
  588.     value = effect.value1.to_i
  589.     @result.tp_damage -= value
  590.     @result.success = true if value != 0
  591.     self.tp += value
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ● 應用“附加狀態”效果
  595.   #--------------------------------------------------------------------------
  596.   def item_effect_add_state(user, item, effect)
  597.     if effect.data_id == 0
  598.       item_effect_add_state_attack(user, item, effect)
  599.     else
  600.       item_effect_add_state_normal(user, item, effect)
  601.     end
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # ● 應用“狀態附加”效果:普通攻擊
  605.   #--------------------------------------------------------------------------
  606.   def item_effect_add_state_attack(user, item, effect)
  607.     user.atk_states.each do |state_id|
  608.       chance = effect.value1
  609.       chance *= state_rate(state_id)
  610.       chance *= user.atk_states_rate(state_id)
  611.       chance *= luk_effect_rate(user)
  612.       if rand < chance
  613.         add_state(state_id)
  614.         @result.success = true
  615.       end
  616.     end
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● 應用“狀態附加”效果:普通
  620.   #--------------------------------------------------------------------------
  621.   def item_effect_add_state_normal(user, item, effect)
  622.     chance = effect.value1
  623.     chance *= state_rate(effect.data_id) if opposite?(user)
  624.     chance *= luk_effect_rate(user)      if opposite?(user)
  625.     if rand < chance
  626.       add_state(effect.data_id)
  627.       @result.success = true
  628.     end
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ● 應用“狀態解除”效果
  632.   #--------------------------------------------------------------------------
  633.   def item_effect_remove_state(user, item, effect)
  634.     chance = effect.value1
  635.     if rand < chance
  636.       remove_state(effect.data_id)
  637.       @result.success = true
  638.     end
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 應用“強化能力”效果
  642.   #--------------------------------------------------------------------------
  643.   def item_effect_add_buff(user, item, effect)
  644.     add_buff(effect.data_id, effect.value1)
  645.     @result.success = true
  646.   end
  647.   #--------------------------------------------------------------------------
  648.   # ● 應用“弱化能力”效果
  649.   #--------------------------------------------------------------------------
  650.   def item_effect_add_debuff(user, item, effect)
  651.     chance = debuff_rate(effect.data_id) * luk_effect_rate(user)
  652.     if rand < chance
  653.       add_debuff(effect.data_id, effect.value1)
  654.       @result.success = true
  655.     end
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 應用“解除能力強化”效果
  659.   #--------------------------------------------------------------------------
  660.   def item_effect_remove_buff(user, item, effect)
  661.     remove_buff(effect.data_id) if @buffs[effect.data_id] > 0
  662.     @result.success = true
  663.   end
  664.   #--------------------------------------------------------------------------
  665.   # ● 應用“解除能力弱化”效果
  666.   #--------------------------------------------------------------------------
  667.   def item_effect_remove_debuff(user, item, effect)
  668.     remove_buff(effect.data_id) if @buffs[effect.data_id] < 0
  669.     @result.success = true
  670.   end
  671.   #--------------------------------------------------------------------------
  672.   # ● 應用“特殊效果”效果
  673.   #--------------------------------------------------------------------------
  674.   def item_effect_special(user, item, effect)
  675.     case effect.data_id
  676.     when SPECIAL_EFFECT_ESCAPE
  677.       escape
  678.     end
  679.     @result.success = true
  680.   end
  681.   #--------------------------------------------------------------------------
  682.   # ● 應用“能力提升”效果
  683.   #--------------------------------------------------------------------------
  684.   def item_effect_grow(user, item, effect)
  685.     add_param(effect.data_id, effect.value1.to_i)
  686.     @result.success = true
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # ● 應用“學會技能”效果
  690.   #--------------------------------------------------------------------------
  691.   def item_effect_learn_skill(user, item, effect)
  692.     learn_skill(effect.data_id) if actor?
  693.     @result.success = true
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● 應用“公共事件”效果
  697.   #--------------------------------------------------------------------------
  698.   def item_effect_common_event(user, item, effect)
  699.   end
  700.   #--------------------------------------------------------------------------
  701.   # ● 對技能/物品使用者的效果
  702.   #--------------------------------------------------------------------------
  703.   def item_user_effect(user, item)
  704.     user.tp += item.tp_gain * user.tcr
  705.   end
  706.   #--------------------------------------------------------------------------
  707.   # ● 獲取幸運影響程度
  708.   #--------------------------------------------------------------------------
  709.   def luk_effect_rate(user)
  710.     [1.0 + (user.luk - luk) * 0.001, 0.0].max
  711.   end
  712.   #--------------------------------------------------------------------------
  713.   # ● 判定是否敵對關系
  714.   #--------------------------------------------------------------------------
  715.   def opposite?(battler)
  716.     actor? != battler.actor?
  717.   end
  718.   #--------------------------------------------------------------------------
  719.   # ● 在地圖上受到傷害時的效果
  720.   #--------------------------------------------------------------------------
  721.   def perform_map_damage_effect
  722.   end
  723.   #--------------------------------------------------------------------------
  724.   # ● 初始化目標 TP
  725.   #--------------------------------------------------------------------------
  726.   def init_tp
  727.     self.tp = rand * 25
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # ● 清除 TP
  731.   #--------------------------------------------------------------------------
  732.   def clear_tp
  733.     self.tp = 0
  734.   end
  735.   #--------------------------------------------------------------------------
  736.   # ● 受到傷害時增加的 TP
  737.   #--------------------------------------------------------------------------
  738.   def charge_tp_by_damage(damage_rate)
  739.     self.tp += 50 * damage_rate * tcr
  740.   end
  741.   #--------------------------------------------------------------------------
  742.   # ● HP 自動恢復
  743.   #--------------------------------------------------------------------------
  744.   def regenerate_hp
  745.     damage = -(mhp * hrg).to_i
  746.     perform_map_damage_effect if $game_party.in_battle && damage > 0
  747.     @result.hp_damage = [damage, max_slip_damage].min
  748.     self.hp -= @result.hp_damage
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 獲取連續傷害最大值
  752.   #--------------------------------------------------------------------------
  753.   def max_slip_damage
  754.     $data_system.opt_slip_death ? hp : [hp - 1, 0].max
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # ● MP 自動恢復
  758.   #--------------------------------------------------------------------------
  759.   def regenerate_mp
  760.     @result.mp_damage = -(mmp * mrg).to_i
  761.     self.mp -= @result.mp_damage
  762.   end
  763.   #--------------------------------------------------------------------------
  764.   # ● TP 自動恢復
  765.   #--------------------------------------------------------------------------
  766.   def regenerate_tp
  767.     self.tp += 100 * trg
  768.   end
  769.   #--------------------------------------------------------------------------
  770.   # ● 全部自動恢復
  771.   #--------------------------------------------------------------------------
  772.   def regenerate_all
  773.     if alive?
  774.       regenerate_hp
  775.       regenerate_mp
  776.       regenerate_tp
  777.     end
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ● 戰鬥開始處理
  781.   #--------------------------------------------------------------------------
  782.   def on_battle_start
  783.     init_tp unless preserve_tp?
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # ● 戰鬥行動結束時的處理
  787.   #--------------------------------------------------------------------------
  788.   def on_action_end
  789.     @result.clear
  790.     remove_states_auto(1)
  791.     remove_buffs_auto
  792.   end
  793.   #--------------------------------------------------------------------------
  794.   # ● 回合結束處理
  795.   #--------------------------------------------------------------------------
  796.   def on_turn_end
  797.     @result.clear
  798.     regenerate_all
  799.     update_state_turns
  800.     update_buff_turns
  801.     remove_states_auto(2)
  802.   end
  803.   #--------------------------------------------------------------------------
  804.   # ● 戰鬥結束處理
  805.   #--------------------------------------------------------------------------
  806.   def on_battle_end
  807.     @result.clear
  808.     remove_battle_states
  809.     remove_all_buffs
  810.     clear_actions
  811.     clear_tp unless preserve_tp?
  812.     appear
  813.   end
  814.   #--------------------------------------------------------------------------
  815.   # ● 被傷害時的處理
  816.   #--------------------------------------------------------------------------
  817.   def on_damage(value)
  818.     remove_states_by_damage
  819.     charge_tp_by_damage(value.to_f / mhp)
  820.   end
  821. end
复制代码





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