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

Project1

 找回密码
 注册会员
搜索
查看: 3050|回复: 3

[已经解决] 战斗中的对话选项

[复制链接]

Lv2.观梦者

梦石
0
星屑
335
在线时间
206 小时
注册时间
2011-5-31
帖子
27
发表于 2021-6-7 19:03:47 | 显示全部楼层 |阅读模式

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

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

x
请教一下各位大大,
小弟想要做到的效果如下:
「在战斗中出现对话选项,并设定X秒内选择正确的选项,
    如果时间内没有选择,就会判定战斗失败」
是否得要用脚本来达成?小弟是脚本白痴,有点困难,
但用纯事件自己搞了很久还是办不到,
逼不得已只好上来求助大大们,还请给小弟一条明路。

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

发表于 2021-6-7 21:56:35 | 显示全部楼层
本帖最后由 guoxiaomi 于 2021-6-7 23:51 编辑

只用事件是做不到的,因为并行事件在战斗中不处理

……可以在对话前打开计时器,计时器结束的时候战斗会自动结束,然后再判断?
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
帖子
234
发表于 2021-6-8 10:34:59 | 显示全部楼层
大概写了下,简单的事件测试能用

说明:超时、取消、选择错误选项 都 执行 取消的事件指令
          指定正确的选项索引,单选为数字,多选为数组
          地图、战斗都适用,不影响正常的选择

使用:(中间别加其他指令)
          【脚本】next_timer_choose(*, *)
          【显示选择项】

  1. class Game_Temp
  2.   attr_accessor :timer_choosing, :timer_right_option
  3.   alias ori_initialize initialize
  4.   def initialize
  5.     ori_initialize
  6.     @timer_choosing = false
  7.     @timer_right_option = nil
  8.   end
  9. end

  10. class Interpreter
  11.   def next_timer_choose(duration, right_index)
  12.     @list[@index + 1].parameters[1] = 5
  13.     $game_system.timer = duration * Graphics.frame_rate
  14.     $game_system.timer_working = true
  15.     $game_temp.timer_choosing = true
  16.     $game_temp.timer_right_option = right_index
  17.     return
  18.   end
  19. end

  20. class Window_Message < Window_Selectable
  21.   alias ori_terminate_message terminate_message
  22.   def terminate_message
  23.     ori_terminate_message
  24.     if $game_temp.timer_choosing == true
  25.       $game_temp.timer_choosing = false
  26.       $game_temp.timer_right_option = nil
  27.       $game_system.timer_working = false
  28.     end
  29.   end
  30.   
  31.   def update
  32.     super
  33.     # 渐变的情况下
  34.     if @fade_in
  35.       self.contents_opacity += 24
  36.       if @input_number_window != nil
  37.         @input_number_window.contents_opacity += 24
  38.       end
  39.       if self.contents_opacity == 255
  40.         @fade_in = false
  41.       end
  42.       return
  43.     end
  44.     # 输入数值的情况下
  45.     if @input_number_window != nil
  46.       @input_number_window.update
  47.       # 确定
  48.       if Input.trigger?(Input::C)
  49.         $game_system.se_play($data_system.decision_se)
  50.         $game_variables[$game_temp.num_input_variable_id] =
  51.           @input_number_window.number
  52.         $game_map.need_refresh = true
  53.         # 释放输入数值窗口
  54.         @input_number_window.dispose
  55.         @input_number_window = nil
  56.         terminate_message
  57.       end
  58.       return
  59.     end
  60.     # 显示信息中的情况下
  61.     if @contents_showing
  62.       # 如果不是在显示选择项中就显示暂停标志
  63.       if $game_temp.choice_max == 0
  64.         self.pause = true
  65.       end
  66. #—————————————————↓—————————————————————      
  67.       if $game_temp.timer_choosing == true && $game_system.timer < 1
  68.         $game_system.se_play($data_system.cancel_se)
  69.         $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  70.         terminate_message
  71.         return
  72.       end
  73. #—————————————————↑—————————————————————      
  74.       # 取消
  75.       if Input.trigger?(Input::B)
  76.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  77.           $game_system.se_play($data_system.cancel_se)
  78.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)         
  79.           terminate_message
  80.         end
  81.       end
  82.       # 确定
  83.       if Input.trigger?(Input::C)
  84.         if $game_temp.choice_max > 0
  85. #—————————————————↓—————————————————————         
  86.           if $game_temp.timer_choosing == true
  87.             judge = case $game_temp.timer_right_option
  88.                     when Numeric then
  89.                       $game_temp.timer_right_option == self.index
  90.                     when Array then
  91.                       $game_temp.timer_right_option.include?(self.index)
  92.                     end
  93.             if judge == true
  94.               $game_system.se_play($data_system.decision_se)
  95.               $game_temp.choice_proc.call(self.index)
  96.             else
  97.               $game_system.se_play($data_system.buzzer_se)
  98.               $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  99.             end
  100.           else
  101.             $game_system.se_play($data_system.decision_se)
  102.             $game_temp.choice_proc.call(self.index)
  103.           end
  104. #—————————————————↑—————————————————————         
  105.         end
  106.         terminate_message
  107.       end
  108.       return
  109.     end
  110.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  111.     if @fade_out == false and $game_temp.message_text != nil
  112.       @contents_showing = true
  113.       $game_temp.message_window_showing = true
  114.       reset_window
  115.       refresh
  116.       Graphics.frame_reset
  117.       self.visible = true
  118.       self.contents_opacity = 0
  119.       if @input_number_window != nil
  120.         @input_number_window.contents_opacity = 0
  121.       end
  122.       @fade_in = true
  123.       return
  124.     end
  125.     # 没有可以显示的信息、但是窗口为可见的情况下
  126.     if self.visible
  127.       @fade_out = true
  128.       self.opacity -= 48
  129.       if self.opacity == 0
  130.         self.visible = false
  131.         @fade_out = false
  132.         $game_temp.message_window_showing = false
  133.       end
  134.       return
  135.     end
  136.   end
  137. end

  138. # 下面是一个延伸问题,战斗出现选项时FPS骤降
  139. # 暂时解决,但不知会否引出其他bug
  140. class Scene_Battle
  141.     def update
  142.     # 执行战斗事件中的情况下
  143.     if $game_system.battle_interpreter.running?
  144.       # 刷新解释器
  145.       $game_system.battle_interpreter.update
  146.       # 强制行动的战斗者不存在的情况下
  147.       if $game_temp.forcing_battler == nil
  148.         # 执行战斗事件结束的情况下
  149.         unless $game_system.battle_interpreter.running?
  150.           # 继续战斗的情况下、再执行战斗事件的设置
  151.           unless judge
  152.             setup_battle_event
  153.           end
  154.         end
  155.         # 如果不是结束战斗回合的情况下
  156.         if @phase != 5
  157.           # 刷新状态窗口         
  158.           # ————————————————————————————————
  159.           @status_window.refresh unless $game_temp.message_window_showing
  160.           # ————————————————————————————————
  161.         end
  162.       end
  163.     end
  164.     # 系统 (计时器)、刷新画面
  165.     $game_system.update
  166.     $game_screen.update
  167.     # 计时器为 0 的情况下
  168.     if $game_system.timer_working and $game_system.timer == 0
  169.       # 中断战斗
  170.       $game_temp.battle_abort = true
  171.     end
  172.     # 刷新窗口
  173.     @help_window.update
  174.     @party_command_window.update
  175.     @actor_command_window.update
  176.     @status_window.update
  177.     @message_window.update
  178.     # 刷新活动块
  179.     @spriteset.update
  180.     # 处理过渡中的情况下
  181.     if $game_temp.transition_processing
  182.       # 清除处理过渡中标志
  183.       $game_temp.transition_processing = false
  184.       # 执行过渡
  185.       if $game_temp.transition_name == ""
  186.         Graphics.transition(20)
  187.       else
  188.         Graphics.transition(40, "Graphics/Transitions/" +
  189.           $game_temp.transition_name)
  190.       end
  191.     end
  192.     # 显示信息窗口中的情况下
  193.     if $game_temp.message_window_showing
  194.       return
  195.     end
  196.     # 显示效果中的情况下
  197.     if @spriteset.effect?
  198.       return
  199.     end
  200.     # 游戏结束的情况下
  201.     if $game_temp.gameover
  202.       # 切换到游戏结束画面
  203.       $scene = Scene_Gameover.new
  204.       return
  205.     end
  206.     # 返回标题画面的情况下
  207.     if $game_temp.to_title
  208.       # 切换到标题画面
  209.       $scene = Scene_Title.new
  210.       return
  211.     end
  212.     # 中断战斗的情况下
  213.     if $game_temp.battle_abort
  214.       # 还原为战斗前的 BGM
  215.       $game_system.bgm_play($game_temp.map_bgm)
  216.       # 战斗结束
  217.       battle_end(1)
  218.       return
  219.     end
  220.     # 等待中的情况下
  221.     if @wait_count > 0
  222.       # 减少等待计数
  223.       @wait_count -= 1
  224.       return
  225.     end
  226.     # 强制行动的角色存在、
  227.     # 并且战斗事件正在执行的情况下
  228.     if $game_temp.forcing_battler == nil and
  229.        $game_system.battle_interpreter.running?
  230.       return
  231.     end
  232.     # 回合分支
  233.     case @phase
  234.     when 1  # 自由战斗回合
  235.       update_phase1
  236.     when 2  # 同伴命令回合
  237.       update_phase2
  238.     when 3  # 角色命令回合
  239.       update_phase3
  240.     when 4  # 主回合
  241.       update_phase4
  242.     when 5  # 战斗结束回合
  243.       update_phase5
  244.     end
  245.   end
  246. end
复制代码
temp.jpg

评分

参与人数 3星屑 +100 +3 收起 理由
RyanBern + 100 + 1 认可答案
uishi121 + 1 塞糖
Cupidk爱呗茶 + 1 塞糖

查看全部评分

回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
335
在线时间
206 小时
注册时间
2011-5-31
帖子
27
 楼主| 发表于 2021-6-8 19:31:06 | 显示全部楼层
RPGzh500223 发表于 2021-6-8 10:34
大概写了下,简单的事件测试能用  

说明:超时、取消、选择错误选项 都 执行 取消的事件指令

谢谢大大!有达到我想要的效果了!
虽然跟Fuki对话框有冲突到 ~ 目前正在疑难排解中!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-18 17:59

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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