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

Project1

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

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

[复制链接]

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
跳转到指定楼层
1
发表于 2014-11-5 01:50:18 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

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


整合主站上的菜鸟横版,最下方
RUBY 代码复制
  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






注释
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. #------------------------------------------------------------------------------
  33. # - 在战斗场景中应用QTE
  34. #------------------------------------------------------------------------------
  35. class Scene_Battle
  36.   #----------------------------------------------------------------------------
  37.   # - 主处理
  38.   #----------------------------------------------------------------------------
  39.   # - @qte_window - 展示命令及进度的窗口
  40.   #----------------------------------------------------------------------------
  41.   alias main_qte_old main
  42.   def main
  43.     @qte_window = Window_BattleQTE.new
  44.     main_qte_old
  45.     @qte_window.dispose
  46.   end
  47.   #----------------------------------------------------------------------------
  48.   # - 初始化胜败记录
  49.   #----------------------------------------------------------------------------
  50.   # - update_phase4_step1 - 主回合 - 准备行动
  51.   #----------------------------------------------------------------------------
  52.   alias update_phase4_step1_qte_old update_phase4_step1
  53.   def update_phase4_step1
  54.     @qte_window.ko = nil
  55.     update_phase4_step1_qte_old
  56.   end
  57.   #----------------------------------------------------------------------------
  58.   # - update_phase4 - 主回合 - 刷新(刷新QTE)
  59.   #----------------------------------------------------------------------------
  60.   alias update_phase4_qte_old update_phase4
  61.   def update_phase4
  62.     if @phase4_step == 7
  63.       update_phase4_step_qte
  64.     end
  65.     update_phase4_qte_old
  66.   end
  67.   #----------------------------------------------------------------------------
  68.   # - 刷新QTE
  69.   #----------------------------------------------------------------------------
  70.   # - QTE::Time * Graphics.frame_rate - 刷新次数 * 每秒种的刷新次数
  71.   # - blink - 能周期地反复使精灵亮白的闪烁。是针对指令输入中的角色使用的效果
  72.   # - animation_id - 播放一次动画
  73.   # - phase4_step - 主回合 - 开始行动
  74.   #----------------------------------------------------------------------------
  75.   def update_phase4_step_qte
  76.     if @qte_window.count > QTE::Time * Graphics.frame_rate
  77.       @active_battler.blink = false
  78.       @active_battler.animation_id = QTE::Ani[1]
  79.       @phase4_step = 2
  80.       @qte_window.ko = "fail"
  81.       @qte_window.visible = false
  82.       return
  83.     else
  84.       if Kboard.trigger?(rkey(@qte_window.command))
  85.         @qte_window.count = 0
  86.         @qte_window.index += 1
  87.       end
  88.       if @qte_window.command == nil
  89.         @active_battler.animation_id = QTE::Ani[0]
  90.         @active_battler.blink = false
  91.         @phase4_step = 2
  92.         @qte_window.ko = "success"
  93.         @qte_window.visible = false
  94.         return
  95.       end
  96.     end
  97.     @qte_window.count += 1
  98.     @qte_window.update
  99.     @qte_window.refresh
  100.   end
  101.   #----------------------------------------------------------------------------
  102.   # - 字符转键码
  103.   #----------------------------------------------------------------------------
  104.   # - 还可在这里添加更多键码
  105.   # - “;”只是为了把when和return放在一行
  106.   #----------------------------------------------------------------------------
  107.   def rkey(key)
  108.     case key
  109.     when "A" ; return 0x41
  110.     when "B" ; return 0x42
  111.     when "C" ; return 0x43
  112.     when "D" ; return 0x44
  113.     when "E" ; return 0x45
  114.     when "F" ; return 0x46
  115.     when "G" ; return 0x47
  116.     when "H" ; return 0x48
  117.     when "I" ; return 0x49
  118.     when "J" ; return 0x4A
  119.     when "K" ; return 0x4B
  120.     when "L" ; return 0x4C
  121.     when "M" ; return 0x4D
  122.     when "N" ; return 0x4E
  123.     when "O" ; return 0x4F
  124.     when "P" ; return 0x50
  125.     when "Q" ; return 0x51
  126.     when "R" ; return 0x52
  127.     when "S" ; return 0x53
  128.     when "T" ; return 0x54
  129.     when "U" ; return 0x55
  130.     when "V" ; return 0x56
  131.     when "W" ; return 0x57
  132.     when "X" ; return 0x58
  133.     when "Y" ; return 0x59
  134.     when "Z" ; return 0x5A
  135.     end
  136.   end
  137. end
  138.  
  139. #------------------------------------------------------------------------------
  140. # - 展示命令及进度的窗口
  141. #------------------------------------------------------------------------------
  142. class Window_BattleQTE < Window_Base
  143.   #----------------------------------------------------------------------------
  144.   # - 定义实例变量
  145.   #----------------------------------------------------------------------------
  146.   # index : 当前位置
  147.   # count : 限时计数
  148.   # ko    : 记录胜败
  149.   #----------------------------------------------------------------------------
  150.   attr_accessor :index, :count, :ko
  151.   #----------------------------------------------------------------------------
  152.   # - 初始化窗口
  153.   #----------------------------------------------------------------------------
  154.   def initialize
  155.     super(0, 256-30, 160, 64)
  156.     self.back_opacity = 160
  157.     self.contents = Bitmap.new(width - 32, height - 32)
  158.     self.visible = false
  159.   end
  160.   #----------------------------------------------------------------------------
  161.   # - 初始化实例变量
  162.   #----------------------------------------------------------------------------
  163.   def clear
  164.     @keys = []
  165.     @index = 0
  166.     @count = 0
  167.   end
  168.   #----------------------------------------------------------------------------
  169.   # - 新事件
  170.   #----------------------------------------------------------------------------
  171.   def start
  172.     clear
  173.     @keys = []
  174.     max = [*QTE::Number][rand(QTE::Number.begin - QTE::Number.end)]
  175.     while @keys.size < max
  176.       key = QTE::Key[rand(QTE::Key.size)]
  177.       @keys << key if !@keys.include?(key)
  178.     end
  179.     refresh
  180.   end
  181.   #----------------------------------------------------------------------------
  182.   # - 内容
  183.   #----------------------------------------------------------------------------
  184.   def refresh
  185.     self.contents.clear
  186.     self.contents.draw_text(4, 0, self.width - 40, 22, @keys[@index], 1)
  187.     self.contents.fill_rect(Rect.new(0, 25, self.width - 40, 8), Color.new(0, 0, 0))
  188.     w = ((self.width - 40) * @count) / (QTE::Time * Graphics.frame_rate)
  189.     rect = Rect.new(1, 1+25, w, 6)
  190.     self.contents.fill_rect(rect, Color.new(255, 255, 255))
  191.   end
  192.   #----------------------------------------------------------------------------
  193.   # - 当前命令
  194.   #----------------------------------------------------------------------------
  195.   def command
  196.     return @keys[@index]
  197.   end
  198. end


夏娜全键盘
RUBY 代码复制
  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 精品文章

查看全部评分

Lv4.逐梦者 (版主)

梦石
0
星屑
9497
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

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

点评

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

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9275
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

3
发表于 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
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 11:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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