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

Project1

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

[原创发布] 战斗时全灭情况下显示重新战斗选项(不喜勿入)

 关闭 [复制链接]

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

跳转到指定楼层
1
发表于 2009-2-12 07:43:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 后知后觉 于 2009-12-5 00:39 编辑

玩空轨的时候发现他即使战斗失败也会弹出个选单让你从新战斗。接着就有了这个。插入以下脚本到mian以前。本脚本与绝大多数战斗脚本冲突(- - 这不是废话么)。仅作参考。实用价值估计不大。喜欢这个效果的可以按照我的这个修改战斗脚本。废话完毕

顺便贴个范例:http://rpg.blue/upload_program/d ... ��项_114912608.rar

  1. PLACE = ""
  2. #==============================================================================
  3. # ■ Scene_Map
  4. #------------------------------------------------------------------------------
  5. #  处理地图画面的类。
  6. #==============================================================================

  7. class Scene_Map
  8.   #--------------------------------------------------------------------------
  9.   # ● 调用战斗
  10.   #--------------------------------------------------------------------------
  11.   def call_battle
  12.     # 清除战斗调用标志
  13.     $game_temp.battle_calling = false
  14.     # 清除菜单调用标志
  15.     $game_temp.menu_calling = false
  16.     $game_temp.menu_beep = false
  17.     # 生成遇敌计数
  18.     $game_player.make_encounter_count
  19.     # 记忆地图 BGM 、停止 BGM
  20.     $game_temp.map_bgm = $game_system.playing_bgm
  21.     $game_system.bgm_stop
  22.     # 演奏战斗开始 SE
  23.     $game_system.se_play($data_system.battle_start_se)
  24.     # 演奏战斗 BGM
  25.     $game_system.bgm_play($game_system.battle_bgm)
  26.     # 矫正主角姿势
  27.     $game_player.straighten
  28.     # 切换到战斗画面
  29.     $scene = Scene_Battle.new
  30.     # 自动存档
  31.     file = File.open(PLACE+"BattleAuto.rxdata", "wb")
  32.      #生成描绘存档文件用的角色图形
  33.     characters = []
  34.     for i in 0...$game_party.actors.size
  35.       actor = $game_party.actors[i]
  36.       characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])
  37.     end
  38.     # 写入描绘存档文件用的角色数据
  39.     Marshal.dump(characters, file)
  40.     # 写入测量游戏时间用画面计数
  41.     Marshal.dump(Graphics.frame_count, file)
  42.     # 增加 1 次存档次数
  43.     $game_system.save_count += 1
  44.     # 保存魔法编号
  45.     # (将编辑器保存的值以随机值替换)
  46.     $game_system.magic_number = $data_system.magic_number
  47.     # 写入各种游戏对像
  48.     Marshal.dump($game_system, file)
  49.     Marshal.dump($game_switches, file)
  50.     Marshal.dump($game_variables, file)
  51.     Marshal.dump($game_self_switches, file)
  52.     Marshal.dump($game_screen, file)
  53.     Marshal.dump($game_actors, file)
  54.     Marshal.dump($game_party, file)
  55.     Marshal.dump($game_troop, file)
  56.     Marshal.dump($game_map, file)
  57.     Marshal.dump($game_player, file)
  58.     file.close  
  59.   end
  60. end

  61. #==============================================================================
  62. # ■ Scene_Battle (分割定义 1)
  63. #------------------------------------------------------------------------------
  64. #  处理战斗画面的类。
  65. #==============================================================================

  66. class Scene_Battle
  67.   #--------------------------------------------------------------------------
  68.   # ● 主处理
  69.   #--------------------------------------------------------------------------
  70.   def main
  71.     # 初始化战斗用的各种暂时数据
  72.     $game_temp.in_battle = true
  73.     $game_temp.battle_turn = 0
  74.     $game_temp.battle_event_flags.clear
  75.     $game_temp.battle_abort = false
  76.     $game_temp.battle_main_phase = false
  77.     $game_temp.battleback_name = $game_map.battleback_name
  78.     $game_temp.forcing_battler = nil
  79.     # 初始化战斗用事件解释器
  80.     $game_system.battle_interpreter.setup(nil, 0)
  81.     # 准备队伍
  82.     @troop_id = $game_temp.battle_troop_id
  83.     $game_troop.setup(@troop_id)
  84.     # 生成角色命令窗口
  85.     s1 = $data_system.words.attack
  86.     s2 = $data_system.words.skill
  87.     s3 = $data_system.words.guard
  88.     s4 = $data_system.words.item
  89.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  90.     @actor_command_window.y = 160
  91.     @actor_command_window.back_opacity = 160
  92.     @actor_command_window.active = false
  93.     @actor_command_window.visible = false
  94.     # 生成其它窗口
  95.     @party_command_window = Window_PartyCommand.new
  96.     @help_window = Window_Help.new
  97.     @help_window.back_opacity = 160
  98.     @help_window.visible = false
  99.     @status_window = Window_BattleStatus.new
  100.     @message_window = Window_Message.new
  101.     # 生成活动块
  102.     @spriteset = Spriteset_Battle.new
  103.     # 初始化等待计数
  104.     @wait_count = 0
  105.     # 执行过渡
  106.     if $data_system.battle_transition == ""
  107.       Graphics.transition(20)
  108.     else
  109.       Graphics.transition(40, "Graphics/Transitions/" +
  110.         $data_system.battle_transition)
  111.     end
  112.     # 开始自由战斗回合
  113.     start_phase1
  114.     # 主循环
  115.     loop do
  116.       # 刷新游戏画面
  117.       Graphics.update
  118.       # 刷新输入信息
  119.       Input.update
  120.       # 刷新画面
  121.       update
  122.       # 如果画面切换的话就中断循环
  123.       if $scene != self
  124.         break
  125.       end
  126.     end
  127.     # 刷新地图
  128.     $game_map.refresh
  129.     # 准备过渡
  130.     Graphics.freeze
  131.     # 释放窗口
  132.     @actor_command_window.dispose
  133.     @party_command_window.dispose
  134.     @help_window.dispose
  135.     @status_window.dispose
  136.     @message_window.dispose
  137.     if @skill_window != nil
  138.       @skill_window.dispose
  139.     end
  140.     if @item_window != nil
  141.       @item_window.dispose
  142.     end
  143.     if @result_window != nil
  144.       @result_window.dispose
  145.     end
  146.     # 释放活动块
  147.     @spriteset.dispose
  148.     # 标题画面切换中的情况
  149.     if $scene.is_a?(Scene_Title)
  150.       # 淡入淡出画面
  151.       Graphics.transition
  152.       Graphics.freeze
  153.     end
  154.     # 战斗测试或者游戏结束以外的画面切换中的情况
  155.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  156.       $scene = nil
  157.     end
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 胜负判定
  161.   #--------------------------------------------------------------------------
  162.   def judge
  163.     # 全灭判定是真、并且同伴人数为 0 的情况下
  164.     if $game_party.all_dead? or $game_party.actors.size == 0
  165.       $game_system.me_play($data_system.gameover_me)
  166.       Audio.bgm_stop
  167.       # 允许失败的情况下
  168.       if $game_temp.battle_can_lose
  169.         # 还原为战斗开始前的 BGM
  170.         $game_system.bgm_play($game_temp.map_bgm)
  171.         # 战斗结束
  172.         battle_end(2)
  173.         # 返回 true
  174.         return true
  175.       else
  176.       @loseselect_window = Window_Command.new(160, ["重新开始", "放弃选择"])
  177.       @loseselect_window.z = 501
  178.       @loseselect_window.x = 240
  179.       @loseselect_window.y = 160
  180.       @loseselect_window.active = true
  181.       @loseselect_window.visible = true
  182.       @loseselect_window.index = 0
  183.       @loseselect_window.x = 240
  184.       @loseselect_window.y = 160
  185.       end
  186.       return true
  187.     end
  188.     # 如果存在任意 1 个敌人就返回 false
  189.     for enemy in $game_troop.enemies
  190.       if enemy.exist?
  191.         return false
  192.       end
  193.     end
  194.     # 开始结束战斗回合 (胜利)
  195.     start_phase5
  196.     # 返回 true
  197.     return true
  198.   end
  199.   # 刷新选项
  200.   def update_loseselect   
  201.   @loseselect_window.update
  202.   if Input.trigger?(Input::C)
  203.     $game_system.se_play($data_system.decision_se)
  204.     if @loseselect_window.index == 0
  205.     file = File.open(PLACE + "BattleAuto.rxdata", "rb")
  206.     read_save_data(file)
  207.     file.close
  208.     # 还原 BGM、BGS
  209.     $game_system.bgm_play($game_system.playing_bgm)
  210.     $game_system.bgs_play($game_system.playing_bgs)
  211.     # 刷新地图 (执行并行事件)
  212.     $game_map.update
  213.     # 切换到地图画面
  214.     Graphics.transition(20)
  215.      @loseselect_window.visible = false
  216.      @loseselect_window.active = false
  217.      @loseselect_window.visible = false
  218.      $scene = Scene_Battle.new
  219.    elsif @loseselect_window.index == 1
  220.      @loseselect_window.visible = false
  221.      @loseselect_window.active = false
  222.      @loseselect_window.visible = false
  223.      $scene = Scene_Gameover.new
  224.    end
  225.   end
  226. end
  227. # 读取自动存档
  228.   def read_save_data(file)
  229.     # 读取描绘存档文件用的角色数据
  230.     characters = Marshal.load(file)
  231.     # 读取测量游戏时间用画面计数
  232.     Graphics.frame_count = Marshal.load(file)
  233.     # 读取各种游戏对像
  234.     $game_system        = Marshal.load(file)
  235.     $game_switches      = Marshal.load(file)
  236.     $game_variables     = Marshal.load(file)
  237.     $game_self_switches = Marshal.load(file)
  238.     $game_screen        = Marshal.load(file)
  239.     $game_actors        = Marshal.load(file)
  240.     $game_party         = Marshal.load(file)
  241.     $game_troop         = Marshal.load(file)
  242.     $game_map           = Marshal.load(file)
  243.     $game_player        = Marshal.load(file)
  244.     # 魔法编号与保存时有差异的情况下
  245.     # (加入编辑器的编辑过的数据)
  246.     if $game_system.magic_number != $data_system.magic_number
  247.       # 重新装载地图
  248.       $game_map.setup($game_map.map_id)
  249.       $game_player.center($game_player.x, $game_player.y)
  250.     end
  251.     # 刷新同伴成员
  252.     $game_party.refresh
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 战斗结束
  256.   #     result : 結果 (0:胜利 1:失败 2:逃跑)
  257.   #--------------------------------------------------------------------------
  258.   def battle_end(result)
  259.     # 清除战斗中标志
  260.     $game_temp.in_battle = false
  261.     # 清除全体同伴的行动
  262.     $game_party.clear_actions
  263.     # 解除战斗用状态
  264.     for actor in $game_party.actors
  265.       actor.remove_states_battle
  266.     end
  267.     # 清除敌人
  268.     $game_troop.enemies.clear
  269.     # 调用战斗返回调用
  270.     if $game_temp.battle_proc != nil
  271.       $game_temp.battle_proc.call(result)
  272.       $game_temp.battle_proc = nil
  273.     end
  274.     # 切换到地图画面
  275.     $scene = Scene_Map.new
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● 设置战斗事件
  279.   #--------------------------------------------------------------------------
  280.   def setup_battle_event
  281.     # 正在执行战斗事件的情况下
  282.     if $game_system.battle_interpreter.running?
  283.       return
  284.     end
  285.     # 搜索全部页的战斗事件
  286.     for index in 0...$data_troops[@troop_id].pages.size
  287.       # 获取事件页
  288.       page = $data_troops[@troop_id].pages[index]
  289.       # 事件条件可以参考 c
  290.       c = page.condition
  291.       # 没有指定任何条件的情况下转到下一页
  292.       unless c.turn_valid or c.enemy_valid or
  293.              c.actor_valid or c.switch_valid
  294.         next
  295.       end
  296.       # 执行完毕的情况下转到下一页
  297.       if $game_temp.battle_event_flags[index]
  298.         next
  299.       end
  300.       # 确认回合条件
  301.       if c.turn_valid
  302.         n = $game_temp.battle_turn
  303.         a = c.turn_a
  304.         b = c.turn_b
  305.         if (b == 0 and n != a) or
  306.            (b > 0 and (n < 1 or n < a or n % b != a % b))
  307.           next
  308.         end
  309.       end
  310.       # 确认敌人条件
  311.       if c.enemy_valid
  312.         enemy = $game_troop.enemies[c.enemy_index]
  313.         if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
  314.           next
  315.         end
  316.       end
  317.       # 确认角色条件
  318.       if c.actor_valid
  319.         actor = $game_actors[c.actor_id]
  320.         if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
  321.           next
  322.         end
  323.       end
  324.       # 确认开关条件
  325.       if c.switch_valid
  326.         if $game_switches[c.switch_id] == false
  327.           next
  328.         end
  329.       end
  330.       # 设置事件
  331.       $game_system.battle_interpreter.setup(page.list, 0)
  332.       # 本页的范围是 [战斗] 或 [回合] 的情况下
  333.       if page.span <= 1
  334.         # 设置执行结束标志
  335.         $game_temp.battle_event_flags[index] = true
  336.       end
  337.       return
  338.     end
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ● 刷新画面
  342.   #--------------------------------------------------------------------------
  343.   def update
  344.     # 执行战斗事件中的情况下
  345.     if $game_system.battle_interpreter.running?
  346.       # 刷新解释器
  347.       $game_system.battle_interpreter.update
  348.       # 强制行动的战斗者不存在的情况下
  349.       if $game_temp.forcing_battler == nil
  350.         # 执行战斗事件结束的情况下
  351.         unless $game_system.battle_interpreter.running?
  352.           # 继续战斗的情况下、再执行战斗事件的设置
  353.           unless judge
  354.             setup_battle_event
  355.           end
  356.         end
  357.         # 如果不是结束战斗回合的情况下
  358.         if @phase != 5
  359.           # 刷新状态窗口
  360.           @status_window.refresh
  361.         end
  362.       end
  363.     end
  364.     # 系统 (计时器)、刷新画面
  365.     $game_system.update
  366.     $game_screen.update
  367.     # 计时器为 0 的情况下
  368.     if $game_system.timer_working and $game_system.timer == 0
  369.       # 中断战斗
  370.       $game_temp.battle_abort = true
  371.     end
  372.     # 刷新窗口
  373.     @help_window.update
  374.     @party_command_window.update
  375.     @actor_command_window.update
  376.     @status_window.update
  377.     @message_window.update
  378.     # 刷新活动块
  379.     @spriteset.update
  380.     # 处理过渡中的情况下
  381.     if $game_temp.transition_processing
  382.       # 清除处理过渡中标志
  383.       $game_temp.transition_processing = false
  384.       # 执行过渡
  385.       if $game_temp.transition_name == ""
  386.         Graphics.transition(20)
  387.       else
  388.         Graphics.transition(40, "Graphics/Transitions/" +
  389.           $game_temp.transition_name)
  390.       end
  391.     end
  392.     if @loseselect_window != nil && @loseselect_window.active
  393.       update_loseselect
  394.     return
  395.     end
  396.     # 显示信息窗口中的情况下
  397.     if $game_temp.message_window_showing
  398.       return
  399.     end
  400.     # 显示效果中的情况下
  401.     if @spriteset.effect?
  402.       return
  403.     end
  404.     # 游戏结束的情况下
  405.     if $game_temp.gameover
  406.       # 切换到游戏结束画面
  407.       $scene = Scene_Gameover.new
  408.       return
  409.     end
  410.     # 返回标题画面的情况下
  411.     if $game_temp.to_title
  412.       # 切换到标题画面
  413.       $scene = Scene_Title.new
  414.       return
  415.     end
  416.     # 中断战斗的情况下
  417.     if $game_temp.battle_abort
  418.       # 还原为战斗前的 BGM
  419.       $game_system.bgm_play($game_temp.map_bgm)
  420.       # 战斗结束
  421.       battle_end(1)
  422.       return
  423.     end
  424.     # 等待中的情况下
  425.     if @wait_count > 0
  426.       # 减少等待计数
  427.       @wait_count -= 1
  428.       return
  429.     end
  430.     # 强制行动的角色存在、
  431.     # 并且战斗事件正在执行的情况下
  432.     if $game_temp.forcing_battler == nil and
  433.        $game_system.battle_interpreter.running?
  434.       return
  435.     end
  436.     # 回合分支
  437.     case @phase
  438.     when 1  # 自由战斗回合
  439.       update_phase1
  440.     when 2  # 同伴命令回合
  441.       update_phase2
  442.     when 3  # 角色命令回合
  443.       update_phase3
  444.     when 4  # 主回合
  445.       update_phase4
  446.     when 5  # 战斗结束回合
  447.       update_phase5
  448.     end
  449.   end
  450. end
复制代码

Lv1.梦旅人

梦石
0
星屑
167
在线时间
434 小时
注册时间
2009-1-1
帖子
643
2
发表于 2009-2-12 08:28:04 | 只看该作者
看上去不错,最好有范例工程
最近在研究XAS
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

3
 楼主| 发表于 2009-2-12 14:32:00 | 只看该作者
需要范例么 - -。直接新建一个工程然后进行战斗(需败)就可以看到效果
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

4
 楼主| 发表于 2009-3-7 02:02:16 | 只看该作者
挖坟 = = 原来这么多人不喜 - =
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-9-24
帖子
409
5
发表于 2009-3-7 02:45:10 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

6
 楼主| 发表于 2009-3-7 03:22:00 | 只看该作者
我怎么老犯同一个错误 = = 。在224行之前加上这句就解决了@loseselect_window.dispose
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2009-3-6
帖子
14
7
发表于 2009-3-27 01:03:44 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 05:03

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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