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

Project1

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

[已经解决] 战斗时能否实现按住某个键退出战斗?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-10-18
帖子
445
跳转到指定楼层
1
发表于 2010-11-13 20:19:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 八云紫 于 2010-11-14 23:01 编辑

看到RPG冒险队的的战斗系统..能够按住Q键一段时间后能退出战斗..
但是我复制这个脚本的时候出现错误了..解决不了..
有没其他的这样的脚本?按住某个键退出战斗
我不再捣蛋了

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-10-18
帖子
445
2
 楼主| 发表于 2010-11-14 20:53:49 | 只看该作者
自己坐沙发自己顶自己

点评

难道自己顶自己的帖子都不行...我又没顶贴...委屈...  发表于 2010-11-14 23:04

评分

参与人数 1星屑 -20 收起 理由
八云紫 -20 自己做沙发可是需要收费的.

查看全部评分

我不再捣蛋了
回复 支持 反对

使用道具 举报

Lv3.寻梦者

可以吃的头衔

梦石
0
星屑
1000
在线时间
423 小时
注册时间
2010-10-17
帖子
602
3
发表于 2010-11-14 21:12:57 | 只看该作者
本帖最后由 fux4 于 2010-11-14 21:26 编辑

回复 捣蛋 的帖子

替换Scene_Battle,Shift逃跑
  1. #==============================================================================
  2. # ■ Scene_Battle
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle < Scene_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 开始处理
  9.   #--------------------------------------------------------------------------
  10.   def start
  11.     super
  12.     $game_temp.in_battle = true
  13.     @spriteset = Spriteset_Battle.new
  14.     @message_window = Window_BattleMessage.new
  15.     @action_battlers = []
  16.     create_info_viewport
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 开始後处理
  20.   #--------------------------------------------------------------------------
  21.   def post_start
  22.     super
  23.     process_battle_start
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 结束处理
  27.   #--------------------------------------------------------------------------
  28.   def terminate
  29.     super
  30.     dispose_info_viewport
  31.     @message_window.dispose
  32.     @spriteset.dispose
  33.     unless $scene.is_a?(Scene_Gameover)
  34.       $scene = nil if $BTEST
  35.     end
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 基本更新处理
  39.   #     main : 从main里调用
  40.   #--------------------------------------------------------------------------
  41.   def update_basic(main = false)
  42.     Graphics.update unless main     # 更新游戏画面
  43.     Input.update unless main        # 更新输入处理
  44.     $game_system.update             # 更新计时器
  45.     $game_troop.update              # 更新敌人队伍
  46.     @spriteset.update               # 更新活动块组
  47.     @message_window.update          # 更新讯息窗口
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 等待
  51.   #     duration : 等待时间(祯数)
  52.   #     no_fast  : 无效化瞬间显示
  53.   #    一个在场景类更新中等待时间用的方法。一般来说,update每祯都会被调用一次。
  54.   #    但是在战斗中不容易掌握流程,所以这个方法是作为一个例外使用。
  55.   #--------------------------------------------------------------------------
  56.   def wait(duration, no_fast = false)
  57.     for i in 0...duration
  58.       update_basic
  59.       break if not no_fast and i >= duration / 2 and show_fast?
  60.     end
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 等待讯息结束
  64.   #--------------------------------------------------------------------------
  65.   def wait_for_message
  66.     @message_window.update
  67.     while $game_message.visible
  68.       update_basic
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 等待动画结束
  73.   #--------------------------------------------------------------------------
  74.   def wait_for_animation
  75.     while @spriteset.animation?
  76.       update_basic
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 判断是否瞬间显示
  81.   #--------------------------------------------------------------------------
  82.   def show_fast?
  83.     return (Input.press?(Input::A) or Input.press?(Input::C))
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 更新画面
  87.   #--------------------------------------------------------------------------
  88.   def update
  89.     super
  90.     update_basic(true)
  91.     update_info_viewport                  # 更新资讯显示端口
  92.     if $game_message.visible
  93.       @info_viewport.visible = false
  94.       @message_window.visible = true
  95.     end
  96.     unless $game_message.visible          # 除非讯息显示中
  97.       return if judge_win_loss            # 判断胜负结果
  98.       update_scene_change
  99.       if @target_enemy_window != nil
  100.         update_target_enemy_selection     # 选择目标敌人
  101.       elsif @target_actor_window != nil
  102.         update_target_actor_selection     # 选择目标角色
  103.       elsif @skill_window != nil
  104.         update_skill_selection            # 选择技能
  105.       elsif @item_window != nil
  106.         update_item_selection             # 选择物品
  107.       elsif @party_command_window.active
  108.         update_party_command_selection    # 选择队伍命令
  109.       elsif @actor_command_window.active
  110.         update_actor_command_selection    # 选择角色命令
  111.       else
  112.         process_battle_event              # 战斗事件处理
  113.         process_action                    # 战斗行动
  114.         process_battle_event              # 战斗事件处理
  115.       end
  116.     end
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 生成资讯显示端口
  120.   #--------------------------------------------------------------------------
  121.   def create_info_viewport
  122.     @info_viewport = Viewport.new(0, 288, 544, 128)
  123.     @info_viewport.z = 100
  124.     @status_window = Window_BattleStatus.new
  125.     @party_command_window = Window_PartyCommand.new
  126.     @actor_command_window = Window_ActorCommand.new
  127.     @status_window.viewport = @info_viewport
  128.     @party_command_window.viewport = @info_viewport
  129.     @actor_command_window.viewport = @info_viewport
  130.     @status_window.x = 128
  131.     @actor_command_window.x = 544
  132.     @info_viewport.visible = false
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 释放资讯显示端口
  136.   #--------------------------------------------------------------------------
  137.   def dispose_info_viewport
  138.     @status_window.dispose
  139.     @party_command_window.dispose
  140.     @actor_command_window.dispose
  141.     @info_viewport.dispose
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 更新资讯显示端口
  145.   #--------------------------------------------------------------------------
  146.   def update_info_viewport
  147.     @party_command_window.update
  148.     @actor_command_window.update
  149.     @status_window.update
  150.     if @party_command_window.active and @info_viewport.ox > 0
  151.       @info_viewport.ox -= 16
  152.     elsif @actor_command_window.active and @info_viewport.ox < 128
  153.       @info_viewport.ox += 16
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 战斗事件处理
  158.   #--------------------------------------------------------------------------
  159.   def process_battle_event
  160.     loop do
  161.       return if judge_win_loss
  162.       return if $game_temp.next_scene != nil
  163.       $game_troop.interpreter.update
  164.       $game_troop.setup_battle_event
  165.       wait_for_message
  166.       process_action if $game_troop.forcing_battler != nil
  167.       return unless $game_troop.interpreter.running?
  168.       update_basic
  169.     end
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 判断胜负结果
  173.   #--------------------------------------------------------------------------
  174.   def judge_win_loss
  175.     if $game_temp.in_battle
  176.       if $game_party.all_dead?
  177.         process_defeat
  178.         return true
  179.       elsif $game_troop.all_dead?
  180.         process_victory
  181.         return true
  182.       else
  183.         return false
  184.       end
  185.     else
  186.       return true
  187.     end
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 结束战斗
  191.   #     result : 结果(0:胜利,1:逃跑,2:失败)
  192.   #--------------------------------------------------------------------------
  193.   def battle_end(result)
  194.     if result == 2 and not $game_troop.can_lose
  195.       call_gameover
  196.     else
  197.       $game_party.clear_actions
  198.       $game_party.remove_states_battle
  199.       $game_troop.clear
  200.       if $game_temp.battle_proc != nil
  201.         $game_temp.battle_proc.call(result)
  202.         $game_temp.battle_proc = nil
  203.       end
  204.       unless $BTEST
  205.         $game_temp.map_bgm.play
  206.         $game_temp.map_bgs.play
  207.       end
  208.       $scene = Scene_Map.new
  209.       @message_window.clear
  210.       Graphics.fadeout(30)
  211.     end
  212.     $game_temp.in_battle = false
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● 转到输入下一个角色的命令
  216.   #--------------------------------------------------------------------------
  217.   def next_actor
  218.     loop do
  219.       if @actor_index == $game_party.members.size-1
  220.         start_main
  221.         return
  222.       end
  223.       @status_window.index = @actor_index += 1
  224.       @active_battler = $game_party.members[@actor_index]
  225.       if @active_battler.auto_battle
  226.         @active_battler.make_action
  227.         next
  228.       end
  229.       break if @active_battler.inputable?
  230.     end
  231.     start_actor_command_selection
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 转到输入上一个角色的命令
  235.   #--------------------------------------------------------------------------
  236.   def prior_actor
  237.     loop do
  238.       if @actor_index == 0
  239.         start_party_command_selection
  240.         return
  241.       end
  242.       @status_window.index = @actor_index -= 1
  243.       @active_battler = $game_party.members[@actor_index]
  244.       next if @active_battler.auto_battle
  245.       break if @active_battler.inputable?
  246.     end
  247.     start_actor_command_selection
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 开始队伍命令选择
  251.   #--------------------------------------------------------------------------
  252.   def start_party_command_selection
  253.     if $game_temp.in_battle
  254.       @status_window.refresh
  255.       @status_window.index = @actor_index = -1
  256.       @active_battler = nil
  257.       @info_viewport.visible = true
  258.       @message_window.visible = false
  259.       @party_command_window.active = true
  260.       @party_command_window.index = 0
  261.       @actor_command_window.active = false
  262.       $game_party.clear_actions
  263.       if $game_troop.surprise or not $game_party.inputable?
  264.         start_main
  265.       end
  266.     end
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 更新队伍命令选择
  270.   #--------------------------------------------------------------------------
  271.   def update_party_command_selection
  272.     if Input.trigger?(Input::C)
  273.       case @party_command_window.index
  274.       when 0  # 战斗
  275.         Sound.play_decision
  276.         @status_window.index = @actor_index = -1
  277.         next_actor
  278.       when 1  # 逃跑
  279.         if $game_troop.can_escape == false
  280.           Sound.play_buzzer
  281.           return
  282.         end
  283.         Sound.play_decision
  284.         process_escape
  285.       end
  286.     elsif  Input.trigger?(Input::A)
  287.         execute_action_escape2
  288.     end
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 开始角色命令选择
  292.   #--------------------------------------------------------------------------
  293.   def start_actor_command_selection
  294.     @party_command_window.active = false
  295.     @actor_command_window.setup(@active_battler)
  296.     @actor_command_window.active = true
  297.     @actor_command_window.index = 0
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 更新角色命令选择
  301.   #--------------------------------------------------------------------------
  302.   def update_actor_command_selection
  303.     if Input.trigger?(Input::B)
  304.       Sound.play_cancel
  305.       prior_actor
  306.     elsif Input.trigger?(Input::C)
  307.       case @actor_command_window.index
  308.       when 0  # 攻击
  309.         Sound.play_decision
  310.         @active_battler.action.set_attack
  311.         start_target_enemy_selection
  312.       when 1  # 技能
  313.         Sound.play_decision
  314.         start_skill_selection
  315.       when 2  # 防御
  316.         Sound.play_decision
  317.         @active_battler.action.set_guard
  318.         next_actor
  319.       when 3  # 物品
  320.         Sound.play_decision
  321.         start_item_selection
  322.       end
  323.     elsif  Input.trigger?(Input::A)
  324.         @active_battler.name = "全体"
  325.         execute_action_escape2
  326.     end
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # ● 开始敌人目标选择
  330.   #--------------------------------------------------------------------------
  331.   def start_target_enemy_selection
  332.     @target_enemy_window = Window_TargetEnemy.new
  333.     @target_enemy_window.y = @info_viewport.rect.y
  334.     @info_viewport.rect.x += @target_enemy_window.width
  335.     @info_viewport.ox += @target_enemy_window.width
  336.     @actor_command_window.active = false
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 结束敌人目标选择
  340.   #--------------------------------------------------------------------------
  341.   def end_target_enemy_selection
  342.     @info_viewport.rect.x -= @target_enemy_window.width
  343.     @info_viewport.ox -= @target_enemy_window.width
  344.     @target_enemy_window.dispose
  345.     @target_enemy_window = nil
  346.     if @actor_command_window.index == 0
  347.       @actor_command_window.active = true
  348.     end
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 更新敌人目标选择
  352.   #--------------------------------------------------------------------------
  353.   def update_target_enemy_selection
  354.     @target_enemy_window.update
  355.     if Input.trigger?(Input::B)
  356.       Sound.play_cancel
  357.       end_target_enemy_selection
  358.     elsif Input.trigger?(Input::C)
  359.       Sound.play_decision
  360.       @active_battler.action.target_index = @target_enemy_window.enemy.index
  361.       end_target_enemy_selection
  362.       end_skill_selection
  363.       end_item_selection
  364.       next_actor
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 开始同伴目标选择
  369.   #--------------------------------------------------------------------------
  370.   def start_target_actor_selection
  371.     @target_actor_window = Window_BattleStatus.new
  372.     @target_actor_window.index = 0
  373.     @target_actor_window.active = true
  374.     @target_actor_window.y = @info_viewport.rect.y
  375.     @info_viewport.rect.x += @target_actor_window.width
  376.     @info_viewport.ox += @target_actor_window.width
  377.     @actor_command_window.active = false
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ● 结束同伴目标选择
  381.   #--------------------------------------------------------------------------
  382.   def end_target_actor_selection
  383.     @info_viewport.rect.x -= @target_actor_window.width
  384.     @info_viewport.ox -= @target_actor_window.width
  385.     @target_actor_window.dispose
  386.     @target_actor_window = nil
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● 更新同伴目标选择
  390.   #--------------------------------------------------------------------------
  391.   def update_target_actor_selection
  392.     @target_actor_window.update
  393.     if Input.trigger?(Input::B)
  394.       Sound.play_cancel
  395.       end_target_actor_selection
  396.     elsif Input.trigger?(Input::C)
  397.       Sound.play_decision
  398.       @active_battler.action.target_index = @target_actor_window.index
  399.       end_target_actor_selection
  400.       end_skill_selection
  401.       end_item_selection
  402.       next_actor
  403.     end
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ● 开始技能选择
  407.   #--------------------------------------------------------------------------
  408.   def start_skill_selection
  409.     @help_window = Window_Help.new
  410.     @skill_window = Window_Skill.new(0, 56, 544, 232, @active_battler)
  411.     @skill_window.help_window = @help_window
  412.     @actor_command_window.active = false
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 结束技能选择
  416.   #--------------------------------------------------------------------------
  417.   def end_skill_selection
  418.     if @skill_window != nil
  419.       @skill_window.dispose
  420.       @skill_window = nil
  421.       @help_window.dispose
  422.       @help_window = nil
  423.     end
  424.     @actor_command_window.active = true
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 更新技能选择
  428.   #--------------------------------------------------------------------------
  429.   def update_skill_selection
  430.     @skill_window.active = true
  431.     @skill_window.update
  432.     @help_window.update
  433.     if Input.trigger?(Input::B)
  434.       Sound.play_cancel
  435.       end_skill_selection
  436.     elsif Input.trigger?(Input::C)
  437.       @skill = @skill_window.skill
  438.       if @skill != nil
  439.         @active_battler.last_skill_id = @skill.id
  440.       end
  441.       if @active_battler.skill_can_use?(@skill)
  442.         Sound.play_decision
  443.         determine_skill
  444.       else
  445.         Sound.play_buzzer
  446.       end
  447.     end
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● 确认技能
  451.   #--------------------------------------------------------------------------
  452.   def determine_skill
  453.     @active_battler.action.set_skill(@skill.id)
  454.     @skill_window.active = false
  455.     if @skill.need_selection?
  456.       if @skill.for_opponent?
  457.         start_target_enemy_selection
  458.       else
  459.         start_target_actor_selection
  460.       end
  461.     else
  462.       end_skill_selection
  463.       next_actor
  464.     end
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 开始物品选择
  468.   #--------------------------------------------------------------------------
  469.   def start_item_selection
  470.     @help_window = Window_Help.new
  471.     @item_window = Window_Item.new(0, 56, 544, 232)
  472.     @item_window.help_window = @help_window
  473.     @actor_command_window.active = false
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 结束物品选择
  477.   #--------------------------------------------------------------------------
  478.   def end_item_selection
  479.     if @item_window != nil
  480.       @item_window.dispose
  481.       @item_window = nil
  482.       @help_window.dispose
  483.       @help_window = nil
  484.     end
  485.     @actor_command_window.active = true
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● 更新物品选择
  489.   #--------------------------------------------------------------------------
  490.   def update_item_selection
  491.     @item_window.active = true
  492.     @item_window.update
  493.     @help_window.update
  494.     if Input.trigger?(Input::B)
  495.       Sound.play_cancel
  496.       end_item_selection
  497.     elsif Input.trigger?(Input::C)
  498.       @item = @item_window.item
  499.       if @item != nil
  500.         $game_party.last_item_id = @item.id
  501.       end
  502.       if $game_party.item_can_use?(@item)
  503.         Sound.play_decision
  504.         determine_item
  505.       else
  506.         Sound.play_buzzer
  507.       end
  508.     end
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● 确认物品
  512.   #--------------------------------------------------------------------------
  513.   def determine_item
  514.     @active_battler.action.set_item(@item.id)
  515.     @item_window.active = false
  516.     if @item.need_selection?
  517.       if @item.for_opponent?
  518.         start_target_enemy_selection
  519.       else
  520.         start_target_actor_selection
  521.       end
  522.     else
  523.       end_item_selection
  524.       next_actor
  525.     end
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # ● 战斗开始处理
  529.   #--------------------------------------------------------------------------
  530.   def process_battle_start
  531.     @message_window.clear
  532.     wait(10)
  533.     for name in $game_troop.enemy_names
  534.       text = sprintf(Vocab::Emerge, name)
  535.       $game_message.texts.push(text)
  536.     end
  537.     if $game_troop.preemptive
  538.       text = sprintf(Vocab::Preemptive, $game_party.name)
  539.       $game_message.texts.push(text)
  540.     elsif $game_troop.surprise
  541.       text = sprintf(Vocab::Surprise, $game_party.name)
  542.       $game_message.texts.push(text)
  543.     end
  544.     wait_for_message
  545.     @message_window.clear
  546.     make_escape_ratio
  547.     process_battle_event
  548.     start_party_command_selection
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 生成逃跑机率
  552.   #--------------------------------------------------------------------------
  553.   def make_escape_ratio
  554.     actors_agi = $game_party.average_agi
  555.     enemies_agi = $game_troop.average_agi
  556.     @escape_ratio = 150 - 100 * enemies_agi / actors_agi
  557.   end
  558.   #--------------------------------------------------------------------------
  559.   # ● 逃跑处理
  560.   #--------------------------------------------------------------------------
  561.   def process_escape
  562.     @info_viewport.visible = false
  563.     @message_window.visible = true
  564.     text = sprintf(Vocab::EscapeStart, $game_party.name)
  565.     $game_message.texts.push(text)
  566.     if $game_troop.preemptive
  567.       success = true
  568.     else
  569.       success = (rand(100) < @escape_ratio)
  570.     end
  571.     Sound.play_escape
  572.     if success
  573.       wait_for_message
  574.       battle_end(1)
  575.     else
  576.       @escape_ratio += 10
  577.       $game_message.texts.push('\.' + Vocab::EscapeFailure)
  578.       wait_for_message
  579.       $game_party.clear_actions
  580.       start_main
  581.     end
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # ● 胜利处理
  585.   #--------------------------------------------------------------------------
  586.   def process_victory
  587.     @info_viewport.visible = false
  588.     @message_window.visible = true
  589.     RPG::BGM.stop
  590.     $game_system.battle_end_me.play
  591.     unless $BTEST
  592.       $game_temp.map_bgm.play
  593.       $game_temp.map_bgs.play
  594.     end
  595.     display_exp_and_gold
  596.     display_drop_items
  597.     display_level_up
  598.     battle_end(0)
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ● 显示所获得的金钱和经验值
  602.   #--------------------------------------------------------------------------
  603.   def display_exp_and_gold
  604.     exp = $game_troop.exp_total
  605.     gold = $game_troop.gold_total
  606.     $game_party.gain_gold(gold)
  607.     text = sprintf(Vocab::Victory, $game_party.name)
  608.     $game_message.texts.push('\|' + text)
  609.     if exp > 0
  610.       text = sprintf(Vocab::ObtainExp, exp)
  611.       $game_message.texts.push('\.' + text)
  612.     end
  613.     if gold > 0
  614.       text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
  615.       $game_message.texts.push('\.' + text)
  616.     end
  617.     wait_for_message
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 显示所获得的掉落物品
  621.   #--------------------------------------------------------------------------
  622.   def display_drop_items
  623.     drop_items = $game_troop.make_drop_items
  624.     for item in drop_items
  625.       $game_party.gain_item(item, 1)
  626.       text = sprintf(Vocab::ObtainItem, item.name)
  627.       $game_message.texts.push(text)
  628.     end
  629.     wait_for_message
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 显示升级
  633.   #--------------------------------------------------------------------------
  634.   def display_level_up
  635.     exp = $game_troop.exp_total
  636.     for actor in $game_party.existing_members
  637.       last_level = actor.level
  638.       last_skills = actor.skills
  639.       actor.gain_exp(exp, true)
  640.     end
  641.     wait_for_message
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # ● 失败处理
  645.   #--------------------------------------------------------------------------
  646.   def process_defeat
  647.     @info_viewport.visible = false
  648.     @message_window.visible = true
  649.     text = sprintf(Vocab::Defeat, $game_party.name)
  650.     $game_message.texts.push(text)
  651.     wait_for_message
  652.     battle_end(2)
  653.   end
  654.   #--------------------------------------------------------------------------
  655.   # ● 执行画面切换
  656.   #--------------------------------------------------------------------------
  657.   def update_scene_change
  658.     case $game_temp.next_scene
  659.     when "map"
  660.       call_map
  661.     when "gameover"
  662.       call_gameover
  663.     when "title"
  664.       call_title
  665.     else
  666.       $game_temp.next_scene = nil
  667.     end
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 切换至地图画面
  671.   #--------------------------------------------------------------------------
  672.   def call_map
  673.     $game_temp.next_scene = nil
  674.     battle_end(1)
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ● 切换至游戏结束画面
  678.   #--------------------------------------------------------------------------
  679.   def call_gameover
  680.     $game_temp.next_scene = nil
  681.     $scene = Scene_Gameover.new
  682.     @message_window.clear
  683.   end
  684.   #--------------------------------------------------------------------------
  685.   # ● 切换至标题画面
  686.   #--------------------------------------------------------------------------
  687.   def call_title
  688.     $game_temp.next_scene = nil
  689.     $scene = Scene_Title.new
  690.     @message_window.clear
  691.     Graphics.fadeout(60)
  692.   end
  693.   #--------------------------------------------------------------------------
  694.   # ● 开始执行战斗处理
  695.   #--------------------------------------------------------------------------
  696.   def start_main
  697.     $game_troop.increase_turn
  698.     @info_viewport.visible = false
  699.     @info_viewport.ox = 0
  700.     @message_window.visible = true
  701.     @party_command_window.active = false
  702.     @actor_command_window.active = false
  703.     @status_window.index = @actor_index = -1
  704.     @active_battler = nil
  705.     @message_window.clear
  706.     $game_troop.make_actions
  707.     make_action_orders
  708.     wait(20)
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● 生成行动顺序
  712.   #--------------------------------------------------------------------------
  713.   def make_action_orders
  714.     @action_battlers = []
  715.     unless $game_troop.surprise
  716.       @action_battlers += $game_party.members
  717.     end
  718.     unless $game_troop.preemptive
  719.       @action_battlers += $game_troop.members
  720.     end
  721.     for battler in @action_battlers
  722.       battler.action.make_speed
  723.     end
  724.     @action_battlers.sort! do |a,b|
  725.       b.action.speed - a.action.speed
  726.     end
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● 战斗行动处理
  730.   #--------------------------------------------------------------------------
  731.   def process_action
  732.     return if judge_win_loss
  733.     return if $game_temp.next_scene != nil
  734.     set_next_active_battler
  735.     if @active_battler == nil
  736.       turn_end
  737.       return
  738.     end
  739.     @message_window.clear
  740.     wait(5)
  741.     @active_battler.white_flash = true
  742.     unless @active_battler.action.forcing
  743.       @active_battler.action.prepare
  744.     end
  745.     if @active_battler.action.valid?
  746.       execute_action
  747.     end
  748.     unless @active_battler.action.forcing
  749.       @message_window.clear
  750.       remove_states_auto
  751.       display_current_state
  752.     end
  753.     @active_battler.white_flash = false
  754.     @message_window.clear
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # ● 执行战斗行动
  758.   #--------------------------------------------------------------------------
  759.   def execute_action
  760.     case @active_battler.action.kind
  761.     when 0  # 基本
  762.       case @active_battler.action.basic
  763.       when 0  # 攻击
  764.         execute_action_attack
  765.       when 1  # 防御
  766.         execute_action_guard
  767.       when 2  # 逃跑
  768.         execute_action_escape
  769.       when 3  # 等待
  770.         execute_action_wait
  771.       end
  772.     when 1  # 使用技能
  773.       execute_action_skill
  774.     when 2  # 使用物品
  775.       execute_action_item
  776.     end
  777.   end
  778.   #--------------------------------------------------------------------------
  779.   # ● 回合结束
  780.   #--------------------------------------------------------------------------
  781.   def turn_end
  782.     $game_troop.turn_ending = true
  783.     $game_party.slip_damage_effect
  784.     $game_troop.slip_damage_effect
  785.     $game_party.do_auto_recovery
  786.     $game_troop.preemptive = false
  787.     $game_troop.surprise = false
  788.     process_battle_event
  789.     $game_troop.turn_ending = false
  790.     start_party_command_selection
  791.   end
  792.   #--------------------------------------------------------------------------
  793.   # ● 设置下一战斗者行动
  794.   #    当「强制战斗行动」事件命令被执行时,设置该战斗者并将他从列表中移除
  795.   #    否则从列表顶端开始。当角色不在队伍之中时(可能因事件命令而离开)则
  796.   #    直接跳过。
  797.   #--------------------------------------------------------------------------
  798.   def set_next_active_battler
  799.     loop do
  800.       if $game_troop.forcing_battler != nil
  801.         @active_battler = $game_troop.forcing_battler
  802.         @action_battlers.delete(@active_battler)
  803.         $game_troop.forcing_battler = nil
  804.       else
  805.         @active_battler = @action_battlers.shift
  806.       end
  807.       return if @active_battler == nil
  808.       return if @active_battler.index != nil
  809.     end
  810.   end
  811.   #--------------------------------------------------------------------------
  812.   # ● 自动解除状态
  813.   #--------------------------------------------------------------------------
  814.   def remove_states_auto
  815.     last_st = @active_battler.states
  816.     @active_battler.remove_states_auto
  817.     if @active_battler.states != last_st
  818.       wait(5)
  819.       display_state_changes(@active_battler)
  820.       wait(30)
  821.       @message_window.clear
  822.     end
  823.   end
  824.   #--------------------------------------------------------------------------
  825.   # ● 显示当前状态
  826.   #--------------------------------------------------------------------------
  827.   def display_current_state
  828.     state_text = @active_battler.most_important_state_text
  829.     unless state_text.empty?
  830.       wait(5)
  831.       text = @active_battler.name + state_text
  832.       @message_window.add_instant_text(text)
  833.       wait(45)
  834.       @message_window.clear
  835.     end
  836.   end
  837.   #--------------------------------------------------------------------------
  838.   # ● 执行战斗行动:攻击
  839.   #--------------------------------------------------------------------------
  840.   def execute_action_attack
  841.     text = sprintf(Vocab::DoAttack, @active_battler.name)
  842.     @message_window.add_instant_text(text)
  843.     targets = @active_battler.action.make_targets
  844.     display_attack_animation(targets)
  845.     wait(20)
  846.     for target in targets
  847.       target.attack_effect(@active_battler)
  848.       display_action_effects(target)
  849.     end
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # ● 执行战斗行动:防御
  853.   #--------------------------------------------------------------------------
  854.   def execute_action_guard
  855.     text = sprintf(Vocab::DoGuard, @active_battler.name)
  856.     @message_window.add_instant_text(text)
  857.     wait(45)
  858.   end
  859.   #--------------------------------------------------------------------------
  860.   # ● 执行战斗行动:逃跑
  861.   #--------------------------------------------------------------------------
  862.   def execute_action_escape
  863.     text = sprintf(Vocab::DoEscape, @active_battler.name)
  864.     @message_window.add_instant_text(text)
  865.     @active_battler.escape
  866.     Sound.play_escape
  867.     wait(45)
  868.   end
  869.   def execute_action_escape2
  870.     @info_viewport.visible = false
  871.     @message_window.visible = true
  872.     if $game_troop.preemptive
  873.       success = true
  874.     else
  875.       success = true
  876.     end
  877.       battle_end(1)
  878.       $game_party.clear_actions
  879.       start_main
  880.     Sound.play_escape
  881.     wait(45)
  882.     $scene = Scene_Map.new
  883.   end
  884.   #--------------------------------------------------------------------------
  885.   # ● 执行战斗行动:等待
  886.   #--------------------------------------------------------------------------
  887.   def execute_action_wait
  888.     text = sprintf(Vocab::DoWait, @active_battler.name)
  889.     @message_window.add_instant_text(text)
  890.     wait(45)
  891.   end
  892.   #--------------------------------------------------------------------------
  893.   # ● 执行战斗行动:使用技能
  894.   #--------------------------------------------------------------------------
  895.   def execute_action_skill
  896.     skill = @active_battler.action.skill
  897.     text = @active_battler.name + skill.message1
  898.     @message_window.add_instant_text(text)
  899.     unless skill.message2.empty?
  900.       wait(10)
  901.       @message_window.add_instant_text(skill.message2)
  902.     end
  903.     targets = @active_battler.action.make_targets
  904.     display_animation(targets, skill.animation_id)
  905.     @active_battler.mp -= @active_battler.calc_mp_cost(skill)
  906.     $game_temp.common_event_id = skill.common_event_id
  907.     for target in targets
  908.       target.skill_effect(@active_battler, skill)
  909.       display_action_effects(target, skill)
  910.     end
  911.   end
  912.   #--------------------------------------------------------------------------
  913.   # ● 执行战斗行动:使用物品
  914.   #--------------------------------------------------------------------------
  915.   def execute_action_item
  916.     item = @active_battler.action.item
  917.     text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
  918.     @message_window.add_instant_text(text)
  919.     targets = @active_battler.action.make_targets
  920.     display_animation(targets, item.animation_id)
  921.     $game_party.consume_item(item)
  922.     $game_temp.common_event_id = item.common_event_id
  923.     for target in targets
  924.       target.item_effect(@active_battler, item)
  925.       display_action_effects(target, item)
  926.     end
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # ● 显示动画
  930.   #     targets      : 目标数组
  931.   #     animation_id : 动画 ID(─1:与普通攻击相同)
  932.   #--------------------------------------------------------------------------
  933.   def display_animation(targets, animation_id)
  934.     if animation_id < 0
  935.       display_attack_animation(targets)
  936.     else
  937.       display_normal_animation(targets, animation_id)
  938.     end
  939.     wait(20)
  940.     wait_for_animation
  941.   end
  942.   #--------------------------------------------------------------------------
  943.   # ● 显示攻击动画
  944.   #     targets : 目标数组
  945.   #    敌人的场合,播放「敌人普通攻击」音效和等待。
  946.   #    角色的场合,则包含双刀派(将左手武器动画翻转作为右手武器动画)。
  947.   #--------------------------------------------------------------------------
  948.   def display_attack_animation(targets)
  949.     if @active_battler.is_a?(Game_Enemy)
  950.       Sound.play_enemy_attack
  951.       wait(15, true)
  952.     else
  953.       aid1 = @active_battler.atk_animation_id
  954.       aid2 = @active_battler.atk_animation_id2
  955.       display_normal_animation(targets, aid1, false)
  956.       display_normal_animation(targets, aid2, true)
  957.     end
  958.     wait_for_animation
  959.   end
  960.   #--------------------------------------------------------------------------
  961.   # ● 显示普通动画
  962.   #     targets      : 目标数组
  963.   #     animation_id : 动画 ID
  964.   #     mirror       : 横向翻转
  965.   #--------------------------------------------------------------------------
  966.   def display_normal_animation(targets, animation_id, mirror = false)
  967.     animation = $data_animations[animation_id]
  968.     if animation != nil
  969.       to_screen = (animation.position == 3)       # 判断位置是否为画面
  970.       for target in targets.uniq
  971.         target.animation_id = animation_id
  972.         target.animation_mirror = mirror
  973.         wait(20, true) unless to_screen           # 单体,等待
  974.       end
  975.       wait(20, true) if to_screen                 # 全体,等待
  976.     end
  977.   end
  978.   #--------------------------------------------------------------------------
  979.   # ● 显示行动结果
  980.   #     target : 目标
  981.   #     obj    : 技能或物品
  982.   #--------------------------------------------------------------------------
  983.   def display_action_effects(target, obj = nil)
  984.     unless target.skipped
  985.       line_number = @message_window.line_number
  986.       wait(5)
  987.       display_critical(target, obj)
  988.       display_damage(target, obj)
  989.       display_state_changes(target, obj)
  990.       if line_number == @message_window.line_number
  991.         display_failure(target, obj) unless target.states_active?
  992.       end
  993.       if line_number != @message_window.line_number
  994.         wait(30)
  995.       end
  996.       @message_window.back_to(line_number)
  997.     end
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # ● 显示会心一击
  1001.   #     target : 目标
  1002.   #     obj    : 技能或物品
  1003.   #--------------------------------------------------------------------------
  1004.   def display_critical(target, obj = nil)
  1005.     if target.critical
  1006.       if target.actor?
  1007.         text = Vocab::CriticalToActor
  1008.       else
  1009.         text = Vocab::CriticalToEnemy
  1010.       end
  1011.       @message_window.add_instant_text(text)
  1012.       wait(20)
  1013.     end
  1014.   end
  1015.   #--------------------------------------------------------------------------
  1016.   # ● 显示伤害
  1017.   #     target : 目标
  1018.   #     obj    : 技能或物品
  1019.   #--------------------------------------------------------------------------
  1020.   def display_damage(target, obj = nil)
  1021.     if target.missed
  1022.       display_miss(target, obj)
  1023.     elsif target.evaded
  1024.       display_evasion(target, obj)
  1025.     else
  1026.       display_hp_damage(target, obj)
  1027.       display_mp_damage(target, obj)
  1028.     end
  1029.   end
  1030.   #--------------------------------------------------------------------------
  1031.   # ● 显示落空
  1032.   #     target : 目标
  1033.   #     obj    : 技能或物品
  1034.   #--------------------------------------------------------------------------
  1035.   def display_miss(target, obj = nil)
  1036.     if obj == nil or obj.physical_attack
  1037.       if target.actor?
  1038.         text = sprintf(Vocab::ActorNoHit, target.name)
  1039.       else
  1040.         text = sprintf(Vocab::EnemyNoHit, target.name)
  1041.       end
  1042.       Sound.play_miss
  1043.     else
  1044.       text = sprintf(Vocab::ActionFailure, target.name)
  1045.     end
  1046.     @message_window.add_instant_text(text)
  1047.     wait(30)
  1048.   end
  1049.   #--------------------------------------------------------------------------
  1050.   # ● 显示逃跑
  1051.   #     target : 目标
  1052.   #     obj    : 技能或物品
  1053.   #--------------------------------------------------------------------------
  1054.   def display_evasion(target, obj = nil)
  1055.     if target.actor?
  1056.       text = sprintf(Vocab::ActorEvasion, target.name)
  1057.     else
  1058.       text = sprintf(Vocab::EnemyEvasion, target.name)
  1059.     end
  1060.     Sound.play_evasion
  1061.     @message_window.add_instant_text(text)
  1062.     wait(30)
  1063.   end
  1064.   #--------------------------------------------------------------------------
  1065.   # ● 显示体力伤害
  1066.   #     target : 目标
  1067.   #     obj    : 技能或物品
  1068.   #--------------------------------------------------------------------------
  1069.   def display_hp_damage(target, obj = nil)
  1070.     if target.hp_damage == 0                # 无伤害
  1071.       return if obj != nil and obj.damage_to_mp
  1072.       return if obj != nil and obj.base_damage == 0
  1073.       fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
  1074.       text = sprintf(fmt, target.name)
  1075.     elsif target.absorbed                   # 吸收
  1076.       fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  1077.       text = sprintf(fmt, target.name, Vocab::hp, target.hp_damage)
  1078.     elsif target.hp_damage > 0              # 伤害
  1079.       if target.actor?
  1080.         text = sprintf(Vocab::ActorDamage, target.name, target.hp_damage)
  1081.         Sound.play_actor_damage
  1082.         $game_troop.screen.start_shake(5, 5, 10)
  1083.       else
  1084.         text = sprintf(Vocab::EnemyDamage, target.name, target.hp_damage)
  1085.         Sound.play_enemy_damage
  1086.         target.blink = true
  1087.       end
  1088.     else                                    # 回复
  1089.       fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  1090.       text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
  1091.       Sound.play_recovery
  1092.     end
  1093.     @message_window.add_instant_text(text)
  1094.     wait(30)
  1095.   end
  1096.   #--------------------------------------------------------------------------
  1097.   # ● 显示魔力伤害
  1098.   #     target : 目标
  1099.   #     obj    : 技能或物品
  1100.   #--------------------------------------------------------------------------
  1101.   def display_mp_damage(target, obj = nil)
  1102.     return if target.dead?
  1103.     return if target.mp_damage == 0
  1104.     if target.absorbed                      # 吸收
  1105.       fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  1106.       text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
  1107.     elsif target.mp_damage > 0              # 伤害
  1108.       fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
  1109.       text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
  1110.     else                                    # 回复
  1111.       fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  1112.       text = sprintf(fmt, target.name, Vocab::mp, -target.mp_damage)
  1113.       Sound.play_recovery
  1114.     end
  1115.     @message_window.add_instant_text(text)
  1116.     wait(30)
  1117.   end
  1118.   #--------------------------------------------------------------------------
  1119.   # ● 显示更改状态
  1120.   #     target : 目标
  1121.   #     obj    : 技能或物品
  1122.   #--------------------------------------------------------------------------
  1123.   def display_state_changes(target, obj = nil)
  1124.     return if target.missed or target.evaded
  1125.     return unless target.states_active?
  1126.     if @message_window.line_number < 4
  1127.       @message_window.add_instant_text("")
  1128.     end
  1129.     display_added_states(target, obj)
  1130.     display_removed_states(target, obj)
  1131.     display_remained_states(target, obj)
  1132.     if @message_window.last_instant_text.empty?
  1133.       @message_window.back_one
  1134.     else
  1135.       wait(10)
  1136.     end
  1137.   end
  1138.   #--------------------------------------------------------------------------
  1139.   # ● 显示附加状态
  1140.   #     target : 目标
  1141.   #     obj    : 技能或物品
  1142.   #--------------------------------------------------------------------------
  1143.   def display_added_states(target, obj = nil)
  1144.     for state in target.added_states
  1145.       if target.actor?
  1146.         next if state.message1.empty?
  1147.         text = target.name + state.message1
  1148.       else
  1149.         next if state.message2.empty?
  1150.         text = target.name + state.message2
  1151.       end
  1152.       if state.id == 1                      # 无法战斗
  1153.         target.perform_collapse
  1154.       end
  1155.       @message_window.replace_instant_text(text)
  1156.       wait(20)
  1157.     end
  1158.   end
  1159.   #--------------------------------------------------------------------------
  1160.   # ● 显示移除状态
  1161.   #     target : 目标
  1162.   #     obj    : 技能或物品
  1163.   #--------------------------------------------------------------------------
  1164.   def display_removed_states(target, obj = nil)
  1165.     for state in target.removed_states
  1166.       next if state.message4.empty?
  1167.       text = target.name + state.message4
  1168.       @message_window.replace_instant_text(text)
  1169.       wait(20)
  1170.     end
  1171.   end
  1172.   #--------------------------------------------------------------------------
  1173.   # ● 显示不变状态
  1174.   #     target : 目标
  1175.   #     obj    : 技能或物品
  1176.   #    当尝试将以睡着的人附加睡眠状态等时用的。
  1177.   #--------------------------------------------------------------------------
  1178.   def display_remained_states(target, obj = nil)
  1179.     for state in target.remained_states
  1180.       next if state.message3.empty?
  1181.       text = target.name + state.message3
  1182.       @message_window.replace_instant_text(text)
  1183.       wait(20)
  1184.     end
  1185.   end
  1186.   #--------------------------------------------------------------------------
  1187.   # ● 显示失败
  1188.   #     target : 目标(角色)
  1189.   #     obj    : 技能或物品
  1190.   #--------------------------------------------------------------------------
  1191.   def display_failure(target, obj)
  1192.     text = sprintf(Vocab::ActionFailure, target.name)
  1193.     @message_window.add_instant_text(text)
  1194.     wait(20)
  1195.   end
  1196. end

复制代码

评分

参与人数 2星屑 +706 收起 理由
八云紫 + 700 认可答案
捣蛋 + 6 认可答案

查看全部评分

……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-10-18
帖子
445
4
 楼主| 发表于 2010-11-14 21:20:28 | 只看该作者
回复 fux4 的帖子

不行啊...战斗的时候逃跑了..画面是非战斗时候.但是音乐还是在战斗..和人物对话不行..
应该还是在战斗的状态中....

点评

可以了...但是我贪心点..能不能有华丽版本呢?  发表于 2010-11-14 21:34
板凳已修正  发表于 2010-11-14 21:26
我不再捣蛋了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-6 08:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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