扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 113|回复: 0

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

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    5 小时前
  • 签到天数: 114 天

    连续签到: 4 天

    [LV.6]常住居民II

    2338

    主题

    403

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10607
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13376

    灌水之王

    发表于 2024-4-19 16:33:07 | 显示全部楼层 |阅读模式
    玩空轨的时候发现他即使战斗失败也会弹出个选单让你从新战斗。接着就有了这个。插入以下脚本到mian以前。本脚本与绝大多数战斗脚本冲突(- - 这不是废话么)。仅作参考。实用价值估计不大。喜欢这个效果的可以按照我的这个修改战斗脚本。废话完毕

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

    1. PLACE = ""#==============================================================================# ■ Scene_Map#------------------------------------------------------------------------------#  处理地图画面的类。#==============================================================================class Scene_Map  #--------------------------------------------------------------------------  # ● 调用战斗  #--------------------------------------------------------------------------  def call_battle    # 清除战斗调用标志    $game_temp.battle_calling = false    # 清除菜单调用标志    $game_temp.menu_calling = false    $game_temp.menu_beep = false    # 生成遇敌计数    $game_player.make_encounter_count    # 记忆地图 BGM 、停止 BGM    $game_temp.map_bgm = $game_system.playing_bgm    $game_system.bgm_stop    # 演奏战斗开始 SE    $game_system.se_play($data_system.battle_start_se)    # 演奏战斗 BGM    $game_system.bgm_play($game_system.battle_bgm)    # 矫正主角姿势    $game_player.straighten    # 切换到战斗画面    $scene = Scene_Battle.new    # 自动存档    file = File.open(PLACE+"BattleAuto.rxdata", "wb")     #生成描绘存档文件用的角色图形    characters = []    for i in 0...$game_party.actors.size      actor = $game_party.actors[i]      characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])    end    # 写入描绘存档文件用的角色数据    Marshal.dump(characters, file)    # 写入测量游戏时间用画面计数    Marshal.dump(Graphics.frame_count, file)    # 增加 1 次存档次数    $game_system.save_count += 1    # 保存魔法编号    # (将编辑器保存的值以随机值替换)    $game_system.magic_number = $data_system.magic_number    # 写入各种游戏对像    Marshal.dump($game_system, file)    Marshal.dump($game_switches, file)    Marshal.dump($game_variables, file)    Marshal.dump($game_self_switches, file)    Marshal.dump($game_screen, file)    Marshal.dump($game_actors, file)    Marshal.dump($game_party, file)    Marshal.dump($game_troop, file)    Marshal.dump($game_map, file)    Marshal.dump($game_player, file)    file.close    endend#==============================================================================# ■ Scene_Battle (分割定义 1)#------------------------------------------------------------------------------#  处理战斗画面的类。#==============================================================================class Scene_Battle  #--------------------------------------------------------------------------  # ● 主处理  #--------------------------------------------------------------------------  def main    # 初始化战斗用的各种暂时数据    $game_temp.in_battle = true    $game_temp.battle_turn = 0    $game_temp.battle_event_flags.clear    $game_temp.battle_abort = false    $game_temp.battle_main_phase = false    $game_temp.battleback_name = $game_map.battleback_name    $game_temp.forcing_battler = nil    # 初始化战斗用事件解释器    $game_system.battle_interpreter.setup(nil, 0)    # 准备队伍    @troop_id = $game_temp.battle_troop_id    $game_troop.setup(@troop_id)    # 生成角色命令窗口    s1 = $data_system.words.attack    s2 = $data_system.words.skill    s3 = $data_system.words.guard    s4 = $data_system.words.item    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])    @actor_command_window.y = 160    @actor_command_window.back_opacity = 160    @actor_command_window.active = false    @actor_command_window.visible = false    # 生成其它窗口    @party_command_window = Window_PartyCommand.new    @help_window = Window_Help.new    @help_window.back_opacity = 160    @help_window.visible = false    @status_window = Window_BattleStatus.new    @message_window = Window_Message.new    # 生成活动块    @spriteset = Spriteset_Battle.new    # 初始化等待计数    @wait_count = 0    # 执行过渡    if $data_system.battle_transition == ""      Graphics.transition(20)    else      Graphics.transition(40, "Graphics/Transitions/" +        $data_system.battle_transition)    end    # 开始自由战斗回合    start_phase1    # 主循环    loop do      # 刷新游戏画面      Graphics.update      # 刷新输入信息      Input.update      # 刷新画面      update      # 如果画面切换的话就中断循环      if $scene != self        break      end    end    # 刷新地图    $game_map.refresh    # 准备过渡    Graphics.freeze    # 释放窗口    @actor_command_window.dispose    @party_command_window.dispose    @help_window.dispose    @status_window.dispose    @message_window.dispose    if @skill_window != nil      @skill_window.dispose    end    if @item_window != nil      @item_window.dispose    end    if @result_window != nil      @result_window.dispose    end    # 释放活动块    @spriteset.dispose    # 标题画面切换中的情况    if $scene.is_a?(Scene_Title)      # 淡入淡出画面      Graphics.transition      Graphics.freeze    end    # 战斗测试或者游戏结束以外的画面切换中的情况    if $BTEST and not $scene.is_a?(Scene_Gameover)      $scene = nil    end  end  #--------------------------------------------------------------------------  # ● 胜负判定  #--------------------------------------------------------------------------  def judge    # 全灭判定是真、并且同伴人数为 0 的情况下    if $game_party.all_dead? or $game_party.actors.size == 0      $game_system.me_play($data_system.gameover_me)      Audio.bgm_stop      # 允许失败的情况下      if $game_temp.battle_can_lose        # 还原为战斗开始前的 BGM        $game_system.bgm_play($game_temp.map_bgm)        # 战斗结束        battle_end(2)        # 返回 true        return true      else      @loseselect_window = Window_Command.new(160, ["重新开始", "放弃选择"])      @loseselect_window.z = 501      @loseselect_window.x = 240      @loseselect_window.y = 160      @loseselect_window.active = true      @loseselect_window.visible = true      @loseselect_window.index = 0       @loseselect_window.x = 240      @loseselect_window.y = 160      end      return true    end    # 如果存在任意 1 个敌人就返回 false    for enemy in $game_troop.enemies      if enemy.exist?        return false      end    end    # 开始结束战斗回合 (胜利)    start_phase5    # 返回 true    return true  end  # 刷新选项  def update_loseselect      @loseselect_window.update  if Input.trigger?(Input::C)    $game_system.se_play($data_system.decision_se)    if @loseselect_window.index == 0    file = File.open(PLACE + "BattleAuto.rxdata", "rb")    read_save_data(file)    file.close    # 还原 BGM、BGS    $game_system.bgm_play($game_system.playing_bgm)    $game_system.bgs_play($game_system.playing_bgs)    # 刷新地图 (执行并行事件)    $game_map.update    # 切换到地图画面    Graphics.transition(20)     @loseselect_window.visible = false     @loseselect_window.active = false     @loseselect_window.visible = false     $scene = Scene_Battle.new   elsif @loseselect_window.index == 1     @loseselect_window.visible = false     @loseselect_window.active = false     @loseselect_window.visible = false     $scene = Scene_Gameover.new   end  end end # 读取自动存档  def read_save_data(file)    # 读取描绘存档文件用的角色数据    characters = Marshal.load(file)    # 读取测量游戏时间用画面计数    Graphics.frame_count = Marshal.load(file)    # 读取各种游戏对像    $game_system        = Marshal.load(file)    $game_switches      = Marshal.load(file)    $game_variables     = Marshal.load(file)    $game_self_switches = Marshal.load(file)    $game_screen        = Marshal.load(file)    $game_actors        = Marshal.load(file)    $game_party         = Marshal.load(file)    $game_troop         = Marshal.load(file)    $game_map           = Marshal.load(file)    $game_player        = Marshal.load(file)    # 魔法编号与保存时有差异的情况下    # (加入编辑器的编辑过的数据)    if $game_system.magic_number != $data_system.magic_number      # 重新装载地图      $game_map.setup($game_map.map_id)      $game_player.center($game_player.x, $game_player.y)    end    # 刷新同伴成员    $game_party.refresh  end  #--------------------------------------------------------------------------  # ● 战斗结束  #     result : 結果 (0:胜利 1:失败 2:逃跑)  #--------------------------------------------------------------------------  def battle_end(result)    # 清除战斗中标志    $game_temp.in_battle = false    # 清除全体同伴的行动    $game_party.clear_actions    # 解除战斗用状态    for actor in $game_party.actors      actor.remove_states_battle    end    # 清除敌人    $game_troop.enemies.clear    # 调用战斗返回调用    if $game_temp.battle_proc != nil      $game_temp.battle_proc.call(result)      $game_temp.battle_proc = nil    end    # 切换到地图画面    $scene = Scene_Map.new  end  #--------------------------------------------------------------------------  # ● 设置战斗事件  #--------------------------------------------------------------------------  def setup_battle_event    # 正在执行战斗事件的情况下    if $game_system.battle_interpreter.running?      return    end    # 搜索全部页的战斗事件    for index in 0...$data_troops[@troop_id].pages.size      # 获取事件页      page = $data_troops[@troop_id].pages[index]      # 事件条件可以参考 c      c = page.condition      # 没有指定任何条件的情况下转到下一页      unless c.turn_valid or c.enemy_valid or             c.actor_valid or c.switch_valid        next      end      # 执行完毕的情况下转到下一页      if $game_temp.battle_event_flags[index]        next      end      # 确认回合条件      if c.turn_valid        n = $game_temp.battle_turn        a = c.turn_a        b = c.turn_b        if (b == 0 and n != a) or           (b > 0 and (n < 1 or n < a or n % b != a % b))          next        end      end      # 确认敌人条件      if c.enemy_valid        enemy = $game_troop.enemies[c.enemy_index]        if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp          next        end      end      # 确认角色条件      if c.actor_valid        actor = $game_actors[c.actor_id]        if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp          next        end      end      # 确认开关条件      if c.switch_valid        if $game_switches[c.switch_id] == false          next        end      end      # 设置事件      $game_system.battle_interpreter.setup(page.list, 0)      # 本页的范围是 [战斗] 或 [回合] 的情况下      if page.span  0      # 减少等待计数      @wait_count -= 1      return    end    # 强制行动的角色存在、    # 并且战斗事件正在执行的情况下    if $game_temp.forcing_battler == nil and       $game_system.battle_interpreter.running?      return    end    # 回合分支    case @phase    when 1  # 自由战斗回合      update_phase1    when 2  # 同伴命令回合      update_phase2    when 3  # 角色命令回合      update_phase3    when 4  # 主回合      update_phase4    when 5  # 战斗结束回合      update_phase5    end  endend复制代码
    复制代码
                 本帖来自P1论坛作者玄月,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=118574  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-14 23:07 , Processed in 0.125930 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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