搜索附件  

恐惧剑刃版QTE: QTE.zip

 

恐惧剑刃版QTE:
一点小东西,不敢在大神面前摆弄。
方法大多新定义,兼容性很高
超级容易整合(调整刷新)
一句话:提供思路,美化靠自己!

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






注释
RUBY 代码
  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"
复制代码


核心
RUBY 代码
  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  4
  176.       @R_Key_Repeat[rkey] = 0
  177.       returntrue
  178.     else
  179.       returnfalse
  180.     end
  181.   end
  182.   def trigger?(rkey)
  183.     result = GetKeyState.call(rkey)
  184.     if@R_Key_Hash[rkey] == 1and result != 0
  185.       returnfalse
  186.     end
  187.     if result != 0
  188.       @R_Key_Hash[rkey] = 1
  189.       returntrue
  190.     else
  191.       @R_Key_Hash[rkey] = 0
  192.       returnfalse
  193.     end
  194.   end
  195. end
复制代码

             本帖来自P1论坛作者恐惧剑刃,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=373343  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
         同一主题附件:
    d1.jpg
    d2.jpg
    QTE.zip (230.93 KB)

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

GMT+8, 2024-9-21 13:31 , Processed in 0.039011 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部