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

Project1

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

[已经解决] 战斗中选择敌人目标弹错误

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-10-18
帖子
445
跳转到指定楼层
1
发表于 2011-6-2 23:26:30 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 捣蛋 于 2011-6-3 21:25 编辑

下面这个是战斗画面.到人物1行动.


当人物1选择攻击怪物的时候,就是下面这个图


最后.我想更改人物1行动指令的时候.比如说我想人物1更改为防御.于是按esc.
就弹出下面这个错误了




下面是原脚本
  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.         
  103.         update_target_actor_selection     # 选择目标角色
  104.       elsif @skill_window != nil
  105.         update_skill_selection            # 选择技能
  106.       elsif @item_window != nil
  107.         update_item_selection             # 选择物品
  108.       elsif @party_command_window.active
  109.         update_party_command_selection    # 选择队伍命令
  110.       elsif @actor_command_window.active
  111.         update_actor_command_selection    # 选择角色命令
  112.       else
  113.         process_battle_event              # 战斗事件处理
  114.         process_action                    # 战斗行动
  115.         process_battle_event              # 战斗事件处理
  116.       end
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 生成资讯显示端口
  121.   #--------------------------------------------------------------------------
  122.   def create_info_viewport
  123.     @info_viewport = Viewport.new(0, 288, 544, 128)
  124.     @info_viewport.z = 100
  125.     @status_window = Window_BattleStatus.new
  126.     @party_command_window = Window_PartyCommand.new
  127.     @actor_command_window = Window_ActorCommand.new
  128.     @status_window.viewport = @info_viewport
  129.     @party_command_window.viewport = @info_viewport
  130.     @actor_command_window.viewport = @info_viewport
  131.     @status_window.x = 128
  132.     @actor_command_window.x = 544
  133.     @info_viewport.visible = false
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 释放资讯显示端口
  137.   #--------------------------------------------------------------------------
  138.   def dispose_info_viewport
  139.     @status_window.dispose
  140.     @party_command_window.dispose
  141.     @actor_command_window.dispose
  142.     @info_viewport.dispose
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 更新资讯显示端口
  146.   #--------------------------------------------------------------------------
  147.   def update_info_viewport
  148.     @party_command_window.update
  149.     @actor_command_window.update
  150.     @status_window.update
  151.     if @party_command_window.active and @info_viewport.ox > 0
  152.       @info_viewport.ox -= 16
  153.     elsif @actor_command_window.active and @info_viewport.ox < 128
  154.       @info_viewport.ox += 16
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 战斗事件处理
  159.   #--------------------------------------------------------------------------
  160.   def process_battle_event
  161.     loop do
  162.       return if judge_win_loss
  163.       return if $game_temp.next_scene != nil
  164.       $game_troop.interpreter.update
  165.       $game_troop.setup_battle_event
  166.       wait_for_message
  167.       process_action if $game_troop.forcing_battler != nil
  168.       return unless $game_troop.interpreter.running?
  169.       update_basic
  170.     end
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● 判断胜负结果
  174.   #--------------------------------------------------------------------------
  175.   def judge_win_loss
  176.     if $game_temp.in_battle
  177.       if $game_party.all_dead?
  178.         process_defeat
  179.         return true
  180.       elsif $game_troop.all_dead?
  181.         process_victory
  182.         return true
  183.       else
  184.         return false
  185.       end
  186.     else
  187.       return true
  188.     end
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 结束战斗
  192.   #     result : 结果(0:胜利,1:逃跑,2:失败)
  193.   #--------------------------------------------------------------------------
  194.   def battle_end(result)
  195.     if result == 2 and not $game_troop.can_lose
  196.       call_gameover
  197.     else
  198.       $game_party.clear_actions
  199.       $game_party.remove_states_battle
  200.       $game_troop.clear
  201.       if $game_temp.battle_proc != nil
  202.         $game_temp.battle_proc.call(result)
  203.         $game_temp.battle_proc = nil
  204.       end
  205.       unless $BTEST
  206.         $game_temp.map_bgm.play
  207.         $game_temp.map_bgs.play
  208.       end
  209.       $scene = Scene_Map.new
  210.       @message_window.clear
  211.       Graphics.fadeout(30)
  212.     end
  213.     $game_temp.in_battle = false
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 转到输入下一个角色的命令
  217.   #--------------------------------------------------------------------------
  218.   def next_actor
  219.     loop do
  220.       if @actor_index == $game_party.members.size-1
  221.         start_main
  222.         return
  223.       end
  224.       @status_window.index = @actor_index += 1
  225.       @active_battler = $game_party.members[@actor_index]
  226.       if @active_battler.auto_battle
  227.         @active_battler.make_action
  228.         next
  229.       end
  230.       break if @active_battler.inputable?
  231.     end
  232.     start_actor_command_selection
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # ● 转到输入上一个角色的命令
  236.   #--------------------------------------------------------------------------
  237.   def prior_actor
  238.     loop do
  239.       if @actor_index == 0
  240.         start_party_command_selection
  241.         return
  242.       end
  243.       @status_window.index = @actor_index -= 1
  244.       @active_battler = $game_party.members[@actor_index]
  245.       next if @active_battler.auto_battle
  246.       break if @active_battler.inputable?
  247.     end
  248.     start_actor_command_selection
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 开始队伍命令选择
  252.   #--------------------------------------------------------------------------
  253.   def start_party_command_selection
  254.     if $game_temp.in_battle
  255.       @status_window.refresh
  256.       @status_window.index = @actor_index = -1
  257.       @active_battler = nil
  258.       @info_viewport.visible = true
  259.       @message_window.visible = false
  260.       @party_command_window.active = true
  261.       @party_command_window.index = 0
  262.       @actor_command_window.active = false
  263.       $game_party.clear_actions
  264.       if $game_troop.surprise or not $game_party.inputable?
  265.         start_main
  266.       end
  267.     end
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 更新队伍命令选择
  271.   #--------------------------------------------------------------------------
  272.   def update_party_command_selection
  273.     if Input.trigger?(Input::C)
  274.       case @party_command_window.index
  275.       when 0  # 战斗
  276.         Sound.play_decision
  277.         @status_window.index = @actor_index = -1
  278.         next_actor
  279.       when 1  # 逃跑
  280.         if $game_troop.can_escape == false
  281.           Sound.play_buzzer
  282.           return
  283.         end
  284.         Sound.play_decision
  285.         process_escape
  286.       end
  287.     end
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ● 开始角色命令选择
  291.   #--------------------------------------------------------------------------
  292.   def start_actor_command_selection
  293.     @party_command_window.active = false
  294.     @actor_command_window.setup(@active_battler)
  295.     @actor_command_window.active = true
  296.     @actor_command_window.index = 0
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 更新角色命令选择
  300.   #--------------------------------------------------------------------------
  301.   def update_actor_command_selection
  302.     if Input.trigger?(Input::B)
  303.       Sound.play_cancel
  304.       prior_actor
  305.     elsif Input.trigger?(Input::C)
  306.       case @actor_command_window.index
  307.       when 0  # 攻击
  308.         Sound.play_decision
  309.         @active_battler.action.set_attack
  310.         start_target_enemy_selection
  311.       when 1  # 技能
  312.         Sound.play_decision
  313.         start_skill_selection
  314.       when 2  # 防御
  315.         Sound.play_decision
  316.         @active_battler.action.set_guard
  317.         next_actor
  318.       when 3  # 物品
  319.         Sound.play_decision
  320.         start_item_selection
  321.       end
  322.     end
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● 开始敌人目标选择
  326.   #--------------------------------------------------------------------------
  327.   def start_target_enemy_selection
  328.     @target_enemy_window = Window_TargetEnemy.new
  329.     @target_enemy_window.y = @info_viewport.rect.y
  330.     @info_viewport.rect.x += @target_enemy_window.width
  331.     @info_viewport.ox += @target_enemy_window.width
  332.     @actor_command_window.active = false
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ● 结束敌人目标选择
  336.   #--------------------------------------------------------------------------
  337.   def end_target_enemy_selection
  338.     @info_viewport.rect.x -= @target_enemy_window.width
  339.     @info_viewport.ox -= @target_enemy_window.width
  340.     @target_enemy_window.dispose
  341.     @target_enemy_window = nil
  342.     if @actor_command_window.index == 0
  343.       @actor_command_window.active = true
  344.     end
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 更新敌人目标选择
  348.   #--------------------------------------------------------------------------
  349.   def update_target_enemy_selection
  350.     @target_enemy_window.update
  351.     if Input.trigger?(Input::B)
  352.       @item_window.visible=false
  353.       Sound.play_cancel
  354.       end_target_enemy_selection
  355.     elsif Input.trigger?(Input::C)
  356.       Sound.play_decision
  357.       @active_battler.action.target_index = @target_enemy_window.enemy.index
  358.       end_target_enemy_selection
  359.       end_skill_selection
  360.       end_item_selection
  361.       next_actor
  362.     end
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 开始同伴目标选择
  366.   #--------------------------------------------------------------------------
  367.   def start_target_actor_selection
  368.     @target_actor_window = Window_BattleStatus.new
  369.     @target_actor_window.index = 0
  370.     @target_actor_window.active = true
  371.     @target_actor_window.y = @info_viewport.rect.y
  372.     @info_viewport.rect.x += @target_actor_window.width
  373.     @info_viewport.ox += @target_actor_window.width
  374.     @actor_command_window.active = false
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 结束同伴目标选择
  378.   #--------------------------------------------------------------------------
  379.   def end_target_actor_selection
  380.     @info_viewport.rect.x -= @target_actor_window.width
  381.     @info_viewport.ox -= @target_actor_window.width
  382.     @target_actor_window.dispose
  383.     @target_actor_window = nil
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 更新同伴目标选择
  387.   #--------------------------------------------------------------------------
  388.   def update_target_actor_selection
  389.     @target_actor_window.update
  390.     if Input.trigger?(Input::B)
  391.        @item_window.visible=true
  392.       Sound.play_cancel
  393.       end_target_actor_selection
  394.     elsif Input.trigger?(Input::C)
  395.       Sound.play_decision
  396.       @active_battler.action.target_index = @target_actor_window.index
  397.       end_target_actor_selection
  398.       end_skill_selection
  399.       end_item_selection
  400.       next_actor
  401.     end
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● 开始技能选择
  405.   #--------------------------------------------------------------------------
  406.   def start_skill_selection
  407.     @help_window = Window_Help.new
  408.     @skill_window = Window_Skill.new(0, 56, 544, 232, @active_battler)
  409.     @skill_window.help_window = @help_window
  410.     @actor_command_window.active = false
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ● 结束技能选择
  414.   #--------------------------------------------------------------------------
  415.   def end_skill_selection
  416.     if @skill_window != nil
  417.       @skill_window.dispose
  418.       @skill_window = nil
  419.       @help_window.dispose
  420.       @help_window = nil
  421.     end
  422.     @actor_command_window.active = true
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● 更新技能选择
  426.   #--------------------------------------------------------------------------
  427.   def update_skill_selection
  428.     @skill_window.active = true
  429.     @skill_window.update
  430.     @help_window.update
  431.     if Input.trigger?(Input::B)
  432.       Sound.play_cancel
  433.       end_skill_selection
  434.     elsif Input.trigger?(Input::C)
  435.       @skill = @skill_window.skill
  436.       if @skill != nil
  437.         @active_battler.last_skill_id = @skill.id
  438.       end
  439.       if @active_battler.skill_can_use?(@skill)
  440.         Sound.play_decision
  441.         determine_skill
  442.       else
  443.         Sound.play_buzzer
  444.       end
  445.     end
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 确认技能
  449.   #--------------------------------------------------------------------------
  450.   def determine_skill
  451.     @active_battler.action.set_skill(@skill.id)
  452.     @skill_window.active = false
  453.     if @skill.need_selection?
  454.       if @skill.for_opponent?
  455.         start_target_enemy_selection
  456.       else
  457.         start_target_actor_selection
  458.       end
  459.     else
  460.       end_skill_selection
  461.       next_actor
  462.     end
  463.   end
  464.   #--------------------------------------------------------------------------
  465.   # ● 开始物品选择
  466.   #--------------------------------------------------------------------------
  467.   def start_item_selection
  468.     @help_window = Window_Help.new
  469.     @item_window = Window_Item.new(0, 56, 544, 232)
  470.     @item_window.help_window = @help_window
  471.     @actor_command_window.active = false
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ● 结束物品选择
  475.   #--------------------------------------------------------------------------
  476.   def end_item_selection
  477.     if @item_window != nil
  478.       @item_window.dispose
  479.       @item_window = nil
  480.       @help_window.dispose
  481.       @help_window = nil
  482.     end
  483.     @actor_command_window.active = true
  484.   end
  485.   #--------------------------------------------------------------------------
  486.   # ● 更新物品选择
  487.   #--------------------------------------------------------------------------
  488.   def update_item_selection
  489.     @item_window.active = true
  490.     @item_window.update
  491.     @help_window.update
  492.     if Input.trigger?(Input::B)
  493. #~       @item_window.visible=true
  494.       Sound.play_cancel
  495.       end_item_selection
  496.     elsif Input.trigger?(Input::C)
  497.       @item = @item_window.item
  498.       if @item != nil
  499.         $game_party.last_item_id = @item.id
  500.       end
  501.      @item_window.visible=false
  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.   #--------------------------------------------------------------------------
  870.   # ● 执行战斗行动:等待
  871.   #--------------------------------------------------------------------------
  872.   def execute_action_wait
  873.     text = sprintf(Vocab::DoWait, @active_battler.name)
  874.     @message_window.add_instant_text(text)
  875.     wait(45)
  876.   end
  877.   #--------------------------------------------------------------------------
  878.   # ● 执行战斗行动:使用技能
  879.   #--------------------------------------------------------------------------
  880.   def execute_action_skill
  881.     skill = @active_battler.action.skill
  882.     text = @active_battler.name + skill.message1
  883.     @message_window.add_instant_text(text)
  884.     unless skill.message2.empty?
  885.       wait(10)
  886.       @message_window.add_instant_text(skill.message2)
  887.     end
  888.     targets = @active_battler.action.make_targets
  889.     display_animation(targets, skill.animation_id)
  890.     @active_battler.mp -= @active_battler.calc_mp_cost(skill)
  891.     $game_temp.common_event_id = skill.common_event_id
  892.     for target in targets
  893.       target.skill_effect(@active_battler, skill)
  894.       display_action_effects(target, skill)
  895.     end
  896.   end
  897.   #--------------------------------------------------------------------------
  898.   # ● 执行战斗行动:使用物品
  899.   #--------------------------------------------------------------------------
  900.   def execute_action_item
  901.     item = @active_battler.action.item
  902.     text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
  903.     @message_window.add_instant_text(text)
  904.     targets = @active_battler.action.make_targets
  905.     display_animation(targets, item.animation_id)
  906.     $game_party.consume_item(item)
  907.     $game_temp.common_event_id = item.common_event_id
  908.     for target in targets
  909.       target.item_effect(@active_battler, item)
  910.       display_action_effects(target, item)
  911.     end
  912.   end
  913.   #--------------------------------------------------------------------------
  914.   # ● 显示动画
  915.   #     targets      : 目标数组
  916.   #     animation_id : 动画 ID(─1:与普通攻击相同)
  917.   #--------------------------------------------------------------------------
  918.   def display_animation(targets, animation_id)
  919.     if animation_id < 0
  920.       display_attack_animation(targets)
  921.     else
  922.       display_normal_animation(targets, animation_id)
  923.     end
  924.     wait(20)
  925.     wait_for_animation
  926.   end
  927.   #--------------------------------------------------------------------------
  928.   # ● 显示攻击动画
  929.   #     targets : 目标数组
  930.   #    敌人的场合,播放「敌人普通攻击」音效和等待。
  931.   #    角色的场合,则包含双刀派(将左手武器动画翻转作为右手武器动画)。
  932.   #--------------------------------------------------------------------------
  933.   def display_attack_animation(targets)
  934.     if @active_battler.is_a?(Game_Enemy)
  935.       Sound.play_enemy_attack
  936.       wait(15, true)
  937.     else
  938.       aid1 = @active_battler.atk_animation_id
  939.       aid2 = @active_battler.atk_animation_id2
  940.       display_normal_animation(targets, aid1, false)
  941.       display_normal_animation(targets, aid2, true)
  942.     end
  943.     wait_for_animation
  944.   end
  945.   #--------------------------------------------------------------------------
  946.   # ● 显示普通动画
  947.   #     targets      : 目标数组
  948.   #     animation_id : 动画 ID
  949.   #     mirror       : 横向翻转
  950.   #--------------------------------------------------------------------------
  951.   def display_normal_animation(targets, animation_id, mirror = false)
  952.     animation = $data_animations[animation_id]
  953.     if animation != nil
  954.       to_screen = (animation.position == 3)       # 判断位置是否为画面
  955.       for target in targets.uniq
  956.         target.animation_id = animation_id
  957.         target.animation_mirror = mirror
  958.         wait(20, true) unless to_screen           # 单体,等待
  959.       end
  960.       wait(20, true) if to_screen                 # 全体,等待
  961.     end
  962.   end
  963.   #--------------------------------------------------------------------------
  964.   # ● 显示行动结果
  965.   #     target : 目标
  966.   #     obj    : 技能或物品
  967.   #--------------------------------------------------------------------------
  968.   def display_action_effects(target, obj = nil)
  969.     unless target.skipped
  970.       line_number = @message_window.line_number
  971.       wait(5)
  972.       display_critical(target, obj)
  973.       display_damage(target, obj)
  974.       display_state_changes(target, obj)
  975.       if line_number == @message_window.line_number
  976.         display_failure(target, obj) unless target.states_active?
  977.       end
  978.       if line_number != @message_window.line_number
  979.         wait(30)
  980.       end
  981.       @message_window.back_to(line_number)
  982.     end
  983.   end
  984.   #--------------------------------------------------------------------------
  985.   # ● 显示会心一击
  986.   #     target : 目标
  987.   #     obj    : 技能或物品
  988.   #--------------------------------------------------------------------------
  989.   def display_critical(target, obj = nil)
  990.     if target.critical
  991.       if target.actor?
  992.         text = Vocab::CriticalToActor
  993.       else
  994.         text = Vocab::CriticalToEnemy
  995.       end
  996.       @message_window.add_instant_text(text)
  997.       wait(20)
  998.     end
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # ● 显示伤害
  1002.   #     target : 目标
  1003.   #     obj    : 技能或物品
  1004.   #--------------------------------------------------------------------------
  1005.   def display_damage(target, obj = nil)
  1006.     if target.missed
  1007.       display_miss(target, obj)
  1008.     elsif target.evaded
  1009.       display_evasion(target, obj)
  1010.     else
  1011.       display_hp_damage(target, obj)
  1012.       display_mp_damage(target, obj)
  1013.     end
  1014.   end
  1015.   #--------------------------------------------------------------------------
  1016.   # ● 显示落空
  1017.   #     target : 目标
  1018.   #     obj    : 技能或物品
  1019.   #--------------------------------------------------------------------------
  1020.   def display_miss(target, obj = nil)
  1021.     if obj == nil or obj.physical_attack
  1022.       if target.actor?
  1023.         text = sprintf(Vocab::ActorNoHit, target.name)
  1024.       else
  1025.         text = sprintf(Vocab::EnemyNoHit, target.name)
  1026.       end
  1027.       Sound.play_miss
  1028.     else
  1029.       text = sprintf(Vocab::ActionFailure, target.name)
  1030.     end
  1031.     @message_window.add_instant_text(text)
  1032.     wait(30)
  1033.   end
  1034.   #--------------------------------------------------------------------------
  1035.   # ● 显示逃跑
  1036.   #     target : 目标
  1037.   #     obj    : 技能或物品
  1038.   #--------------------------------------------------------------------------
  1039.   def display_evasion(target, obj = nil)
  1040.     if target.actor?
  1041.       text = sprintf(Vocab::ActorEvasion, target.name)
  1042.     else
  1043.       text = sprintf(Vocab::EnemyEvasion, target.name)
  1044.     end
  1045.     Sound.play_evasion
  1046.     @message_window.add_instant_text(text)
  1047.     wait(30)
  1048.   end
  1049.   #--------------------------------------------------------------------------
  1050.   # ● 显示体力伤害
  1051.   #     target : 目标
  1052.   #     obj    : 技能或物品
  1053.   #--------------------------------------------------------------------------
  1054.   def display_hp_damage(target, obj = nil)
  1055.     if target.hp_damage == 0                # 无伤害
  1056.       return if obj != nil and obj.damage_to_mp
  1057.       return if obj != nil and obj.base_damage == 0
  1058.       fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
  1059.       text = sprintf(fmt, target.name)
  1060.     elsif target.absorbed                   # 吸收
  1061.       fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  1062.       text = sprintf(fmt, target.name, Vocab::hp, target.hp_damage)
  1063.     elsif target.hp_damage > 0              # 伤害
  1064.       if target.actor?
  1065.         text = sprintf(Vocab::ActorDamage, target.name, target.hp_damage)
  1066.         Sound.play_actor_damage
  1067.         $game_troop.screen.start_shake(5, 5, 10)
  1068.       else
  1069.         text = sprintf(Vocab::EnemyDamage, target.name, target.hp_damage)
  1070.         Sound.play_enemy_damage
  1071.         target.blink = true
  1072.       end
  1073.     else                                    # 回复
  1074.       fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  1075.       text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
  1076.       Sound.play_recovery
  1077.     end
  1078.     @message_window.add_instant_text(text)
  1079.     wait(30)
  1080.   end
  1081.   #--------------------------------------------------------------------------
  1082.   # ● 显示魔力伤害
  1083.   #     target : 目标
  1084.   #     obj    : 技能或物品
  1085.   #--------------------------------------------------------------------------
  1086.   def display_mp_damage(target, obj = nil)
  1087.     return if target.dead?
  1088.     return if target.mp_damage == 0
  1089.     if target.absorbed                      # 吸收
  1090.       fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  1091.       text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
  1092.     elsif target.mp_damage > 0              # 伤害
  1093.       fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
  1094.       text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
  1095.     else                                    # 回复
  1096.       fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  1097.       text = sprintf(fmt, target.name, Vocab::mp, -target.mp_damage)
  1098.       Sound.play_recovery
  1099.     end
  1100.     @message_window.add_instant_text(text)
  1101.     wait(30)
  1102.   end
  1103.   #--------------------------------------------------------------------------
  1104.   # ● 显示更改状态
  1105.   #     target : 目标
  1106.   #     obj    : 技能或物品
  1107.   #--------------------------------------------------------------------------
  1108.   def display_state_changes(target, obj = nil)
  1109.     return if target.missed or target.evaded
  1110.     return unless target.states_active?
  1111.     if @message_window.line_number < 4
  1112.       @message_window.add_instant_text("")
  1113.     end
  1114.     display_added_states(target, obj)
  1115.     display_removed_states(target, obj)
  1116.     display_remained_states(target, obj)
  1117.     if @message_window.last_instant_text.empty?
  1118.       @message_window.back_one
  1119.     else
  1120.       wait(10)
  1121.     end
  1122.   end
  1123.   #--------------------------------------------------------------------------
  1124.   # ● 显示附加状态
  1125.   #     target : 目标
  1126.   #     obj    : 技能或物品
  1127.   #--------------------------------------------------------------------------
  1128.   def display_added_states(target, obj = nil)
  1129.     for state in target.added_states
  1130.       if target.actor?
  1131.         next if state.message1.empty?
  1132.         text = target.name + state.message1
  1133.       else
  1134.         next if state.message2.empty?
  1135.         text = target.name + state.message2
  1136.       end
  1137.       if state.id == 1                      # 无法战斗
  1138.         target.perform_collapse
  1139.       end
  1140.       @message_window.replace_instant_text(text)
  1141.       wait(20)
  1142.     end
  1143.   end
  1144.   #--------------------------------------------------------------------------
  1145.   # ● 显示移除状态
  1146.   #     target : 目标
  1147.   #     obj    : 技能或物品
  1148.   #--------------------------------------------------------------------------
  1149.   def display_removed_states(target, obj = nil)
  1150.     for state in target.removed_states
  1151.       next if state.message4.empty?
  1152.       text = target.name + state.message4
  1153.       @message_window.replace_instant_text(text)
  1154.       wait(20)
  1155.     end
  1156.   end
  1157.   #--------------------------------------------------------------------------
  1158.   # ● 显示不变状态
  1159.   #     target : 目标
  1160.   #     obj    : 技能或物品
  1161.   #    当尝试将以睡着的人附加睡眠状态等时用的。
  1162.   #--------------------------------------------------------------------------
  1163.   def display_remained_states(target, obj = nil)
  1164.     for state in target.remained_states
  1165.       next if state.message3.empty?
  1166.       text = target.name + state.message3
  1167.       @message_window.replace_instant_text(text)
  1168.       wait(20)
  1169.     end
  1170.   end
  1171.   #--------------------------------------------------------------------------
  1172.   # ● 显示失败
  1173.   #     target : 目标(角色)
  1174.   #     obj    : 技能或物品
  1175.   #--------------------------------------------------------------------------
  1176.   def display_failure(target, obj)
  1177.     text = sprintf(Vocab::ActionFailure, target.name)
  1178.     @message_window.add_instant_text(text)
  1179.     wait(20)
  1180.   end
  1181. end
复制代码
希望大大们帮助解决
我不再捣蛋了

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-10-18
帖子
445
2
 楼主| 发表于 2011-6-3 20:30:51 | 只看该作者
没有人能帮忙解决磨..
自己顶了
我不再捣蛋了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
466 小时
注册时间
2006-2-25
帖子
1863
3
发表于 2011-6-3 21:12:15 | 只看该作者
你是不是改过脚本呃...
第353行貌似应该改成
@item_window.visible = true unless @item_window.nil?
还有第502行应该也有问题的..
@item_window.visible=false
应该放在第505行determin_item之下
else之上

这样应该就OK了...没测试过..你试试吧
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-10-18
帖子
445
4
 楼主| 发表于 2011-6-3 21:18:11 | 只看该作者
诡异の猫 发表于 2011-6-3 21:12
你是不是改过脚本呃...
第353行貌似应该改成
@item_window.visible = true unless @item_window.nil?

还是猫猫厉害..解决了...
在哪里认可你能够拿多点分呢?

点评

你没发悬赏贴所以没办法拿分呃- - 你可以结贴等版猪来加分吧- - 以后发帖按最后一个选项“悬赏贴”就行..别浪费系统赠送的100分好人卡 哈哈  发表于 2011-6-3 21:21
我不再捣蛋了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 14:44

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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