查看: 4219|回复: 2

[原创发布] 恐惧剑刃版QTE

[复制链接]

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
回帖
1223
发表于 2014-11-5 01:50:18 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 恐惧剑刃 于 2014-11-6 12:28 编辑

一点小东西,不敢在大神面前摆弄。
方法大多新定义,兼容性很高
超级容易整合(调整刷新)

QTE.zip (230.93 KB, 下载次数: 86)
一句话:提供思路,美化靠自己!


整合主站上的菜鸟横版,最下方
  1. class Scene_Battle
  2.   #--------------------------------------------------------------------------
  3.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  4.   #--------------------------------------------------------------------------
  5.   def update_phase4_step2(*arg)
  6.     #========================================================================
  7.     if QTE::Switch and @active_battler.is_a?(Game_Actor) and @qte_window.ko == nil
  8.       if (@active_battler.current_action.kind == 0 and
  9.         @active_battler.current_action.basic == 0) or
  10.         @active_battler.current_action.kind == 1 or
  11.         @active_battler.current_action.kind == 2
  12.         
  13.         @qte_window.x = $game_party.actors.index(@active_battler) * 160
  14.         @qte_window.visible = true
  15.         @qte_window.start
  16.         @phase4_step = 7
  17.         @active_battler.blink = true
  18.       return
  19.       end
  20.     end
  21.     #========================================================================
  22.     battler = convert_battler2(*arg)
  23.     battler.action
  24.     side_view_update_phase4_step2(*arg)
  25.   end
  26. end
复制代码


1.jpg
2.jpg


注释
  1. # - 要应用QTE只需:
  2. # - 1.(主方法)生成窗口
  3. # - 2.(主回合)回合1的时候初始化需要的数据
  4. # - 3.(主回合)插入一个新回合用来刷新QTE
  5. # - 4.(主回合)在生成行动结果之前插入QTE
  6. # - 4.(主回合)返回回合2继续执行其他内容
  7. #----------------------------------------------------------------------------
  8. # - 设置示范:
  9. # - 找到 make_basic_action_result
  10. # - if @active_battler.current_action.basic == 0 以下
  11. # - 添加
  12. # - if QTE::Switch and @active_battler.is_a?(Game_Actor) and @qte_window.ko == nil
  13. # -   @qte_window.x = $game_party.actors.index(@active_battler) * 160
  14. # -   @qte_window.visible = true
  15. # -   @qte_window.start
  16. # -   @phase4_step = 7
  17. # -   @active_battler.blink = true
  18. # -   return
  19. # - end
  20. # -
  21. # - @qte_window.ko 记录胜败
  22. # - if @qte_window.ko == "success"
  23. # - if @qte_window.ko == "fail"
复制代码


核心
  1. #----------------------------------------------------------------------------
  2. # - 快速反应事件(必要组件,夏娜全键盘)
  3. #----------------------------------------------------------------------------
  4. # - QTE设置
  5. #--------------------------------------------------------------------------
  6. module QTE
  7.   #--------------------------------------------------------------------------
  8.   # - 启动开关
  9.   #--------------------------------------------------------------------------
  10.   Switch = true
  11.   #--------------------------------------------------------------------------
  12.   # - 时限(秒钟) * 不是很精确
  13.   #--------------------------------------------------------------------------
  14.   Time = 2
  15.   #--------------------------------------------------------------------------
  16.   # - 动画
  17.   #--------------------------------------------------------------------------
  18.   Ani = []
  19.   Ani[0] = 20 # 胜利
  20.   Ani[1] = 19 # 失败
  21.   #--------------------------------------------------------------------------
  22.   # - 可使用键(需设置键码)
  23.   # - %w|A B C| 等同于 ["A", "B", "C"]
  24.   #--------------------------------------------------------------------------
  25.   Key = %w|A B C D E F G H I G K L M N O P Q R S T U V W X Y Z|
  26.   #--------------------------------------------------------------------------
  27.   # - 输入数量(范围表示)
  28.   #--------------------------------------------------------------------------
  29.   Number = 5..9
  30. end

  31. #------------------------------------------------------------------------------
  32. # - 在战斗场景中应用QTE
  33. #------------------------------------------------------------------------------
  34. class Scene_Battle
  35.   #----------------------------------------------------------------------------
  36.   # - 主处理
  37.   #----------------------------------------------------------------------------
  38.   # - @qte_window - 展示命令及进度的窗口
  39.   #----------------------------------------------------------------------------
  40.   alias main_qte_old main
  41.   def main
  42.     @qte_window = Window_BattleQTE.new
  43.     main_qte_old
  44.     @qte_window.dispose
  45.   end
  46.   #----------------------------------------------------------------------------
  47.   # - 初始化胜败记录
  48.   #----------------------------------------------------------------------------
  49.   # - update_phase4_step1 - 主回合 - 准备行动
  50.   #----------------------------------------------------------------------------
  51.   alias update_phase4_step1_qte_old update_phase4_step1
  52.   def update_phase4_step1
  53.     @qte_window.ko = nil
  54.     update_phase4_step1_qte_old
  55.   end
  56.   #----------------------------------------------------------------------------
  57.   # - update_phase4 - 主回合 - 刷新(刷新QTE)
  58.   #----------------------------------------------------------------------------
  59.   alias update_phase4_qte_old update_phase4
  60.   def update_phase4
  61.     if @phase4_step == 7
  62.       update_phase4_step_qte
  63.     end
  64.     update_phase4_qte_old
  65.   end
  66.   #----------------------------------------------------------------------------
  67.   # - 刷新QTE
  68.   #----------------------------------------------------------------------------
  69.   # - QTE::Time * Graphics.frame_rate - 刷新次数 * 每秒种的刷新次数
  70.   # - blink - 能周期地反复使精灵亮白的闪烁。是针对指令输入中的角色使用的效果
  71.   # - animation_id - 播放一次动画
  72.   # - phase4_step - 主回合 - 开始行动
  73.   #----------------------------------------------------------------------------
  74.   def update_phase4_step_qte
  75.     if @qte_window.count > QTE::Time * Graphics.frame_rate
  76.       @active_battler.blink = false
  77.       @active_battler.animation_id = QTE::Ani[1]
  78.       @phase4_step = 2
  79.       @qte_window.ko = "fail"
  80.       @qte_window.visible = false
  81.       return
  82.     else
  83.       if Kboard.trigger?(rkey(@qte_window.command))
  84.         @qte_window.count = 0
  85.         @qte_window.index += 1
  86.       end
  87.       if @qte_window.command == nil
  88.         @active_battler.animation_id = QTE::Ani[0]
  89.         @active_battler.blink = false
  90.         @phase4_step = 2
  91.         @qte_window.ko = "success"
  92.         @qte_window.visible = false
  93.         return
  94.       end
  95.     end
  96.     @qte_window.count += 1
  97.     @qte_window.update
  98.     @qte_window.refresh
  99.   end
  100.   #----------------------------------------------------------------------------
  101.   # - 字符转键码
  102.   #----------------------------------------------------------------------------
  103.   # - 还可在这里添加更多键码
  104.   # - “;”只是为了把when和return放在一行
  105.   #----------------------------------------------------------------------------
  106.   def rkey(key)
  107.     case key
  108.     when "A" ; return 0x41
  109.     when "B" ; return 0x42
  110.     when "C" ; return 0x43
  111.     when "D" ; return 0x44
  112.     when "E" ; return 0x45
  113.     when "F" ; return 0x46
  114.     when "G" ; return 0x47
  115.     when "H" ; return 0x48
  116.     when "I" ; return 0x49
  117.     when "J" ; return 0x4A
  118.     when "K" ; return 0x4B
  119.     when "L" ; return 0x4C
  120.     when "M" ; return 0x4D
  121.     when "N" ; return 0x4E
  122.     when "O" ; return 0x4F
  123.     when "P" ; return 0x50
  124.     when "Q" ; return 0x51
  125.     when "R" ; return 0x52
  126.     when "S" ; return 0x53
  127.     when "T" ; return 0x54
  128.     when "U" ; return 0x55
  129.     when "V" ; return 0x56
  130.     when "W" ; return 0x57
  131.     when "X" ; return 0x58
  132.     when "Y" ; return 0x59
  133.     when "Z" ; return 0x5A
  134.     end
  135.   end
  136. end

  137. #------------------------------------------------------------------------------
  138. # - 展示命令及进度的窗口
  139. #------------------------------------------------------------------------------
  140. class Window_BattleQTE < Window_Base
  141.   #----------------------------------------------------------------------------
  142.   # - 定义实例变量
  143.   #----------------------------------------------------------------------------
  144.   # index : 当前位置
  145.   # count : 限时计数
  146.   # ko    : 记录胜败
  147.   #----------------------------------------------------------------------------
  148.   attr_accessor :index, :count, :ko
  149.   #----------------------------------------------------------------------------
  150.   # - 初始化窗口
  151.   #----------------------------------------------------------------------------
  152.   def initialize
  153.     super(0, 256-30, 160, 64)
  154.     self.back_opacity = 160
  155.     self.contents = Bitmap.new(width - 32, height - 32)
  156.     self.visible = false
  157.   end
  158.   #----------------------------------------------------------------------------
  159.   # - 初始化实例变量
  160.   #----------------------------------------------------------------------------
  161.   def clear
  162.     @keys = []
  163.     @index = 0
  164.     @count = 0
  165.   end
  166.   #----------------------------------------------------------------------------
  167.   # - 新事件
  168.   #----------------------------------------------------------------------------
  169.   def start
  170.     clear
  171.     @keys = []
  172.     max = [*QTE::Number][rand(QTE::Number.begin - QTE::Number.end)]
  173.     while @keys.size < max
  174.       key = QTE::Key[rand(QTE::Key.size)]
  175.       @keys << key if !@keys.include?(key)
  176.     end
  177.     refresh
  178.   end
  179.   #----------------------------------------------------------------------------
  180.   # - 内容
  181.   #----------------------------------------------------------------------------
  182.   def refresh
  183.     self.contents.clear
  184.     self.contents.draw_text(4, 0, self.width - 40, 22, @keys[@index], 1)
  185.     self.contents.fill_rect(Rect.new(0, 25, self.width - 40, 8), Color.new(0, 0, 0))
  186.     w = ((self.width - 40) * @count) / (QTE::Time * Graphics.frame_rate)
  187.     rect = Rect.new(1, 1+25, w, 6)
  188.     self.contents.fill_rect(rect, Color.new(255, 255, 255))
  189.   end
  190.   #----------------------------------------------------------------------------
  191.   # - 当前命令
  192.   #----------------------------------------------------------------------------
  193.   def command
  194.     return @keys[@index]
  195.   end
  196. end
复制代码


夏娜全键盘
  1. #----------------------------------------------------------------------------
  2. # - 夏娜全键盘(已用可删)
  3. #----------------------------------------------------------------------------
  4. module Kboard
  5.   module_function
  6.   @R_Key_Hash = {}
  7.   @R_Key_Repeat = {}
  8.   GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
  9.   def press?(rkey)
  10.     return GetKeyState.call(rkey) != 0
  11.   end
  12.   def repeat?(rkey)
  13.     result = GetKeyState.call(rkey)
  14.     if result != 0
  15.       if @R_Key_Repeat[rkey].nil?
  16.         @R_Key_Repeat[rkey] = 0
  17.         return true
  18.       end
  19.       @R_Key_Repeat[rkey] += 1
  20.     else
  21.       @R_Key_Repeat[rkey] = nil
  22.       @R_Key_Hash[rkey] = 0
  23.     end
  24.     if !@R_Key_Repeat[rkey].nil? and @R_Key_Repeat[rkey] > 4
  25.       @R_Key_Repeat[rkey] = 0
  26.       return true
  27.     else
  28.       return false
  29.     end
  30.   end
  31.   def trigger?(rkey)
  32.     result = GetKeyState.call(rkey)
  33.     if @R_Key_Hash[rkey] == 1 and result != 0
  34.       return false
  35.     end
  36.     if result != 0
  37.       @R_Key_Hash[rkey] = 1
  38.       return true
  39.     else
  40.       @R_Key_Hash[rkey] = 0
  41.       return false
  42.     end
  43.   end
  44. end
复制代码

评分

参与人数 2星屑 +110 收起 理由
【凌】 + 10 我很赞同
RyanBern + 100 精品文章

查看全部评分

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2014-11-5 10:27:24 | 显示全部楼层
看起来比我写的那个要短啊,我那个东西放到战斗中其实很不好用。不过好处就是即插即用,不用修改战斗核心。
话说最近QTE热度貌似很高,不过这玩意在RM游戏中不常见啊……

点评

早就想做了。只不过程度不够。。。  发表于 2014-11-5 12:00
我就喜欢兼容度高的。  发表于 2014-11-5 11:42
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2014-11-6 22:11:15 | 显示全部楼层
夏娜全键盘(已用可删)这一句是说用你的这个以前夏娜那个就能删掉了?

点评

那你的这一个和夏娜的那个原版有什么区别呢0.0  发表于 2014-11-7 21:50
这句话明显不是这个意思,你要自行补充被省略的部分。夏娜的全键盘脚本(如果[你已经在使用]一个,那么就可以删除[这个QTE脚本中的那个])  发表于 2014-11-7 09:24
如果工程中已经使用了的话  发表于 2014-11-6 23:56
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部