赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 4 |
经验 | 1120 |
最后登录 | 2021-3-9 |
在线时间 | 50 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 428
- 在线时间
- 50 小时
- 注册时间
- 2017-1-10
- 帖子
- 28
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
看到一个不错的东西,输入箭头挑战,但是不知道怎么在大地图中触发
这是原地址貌似
https://atelierrgss.wordpress.com/rgss3-chain-commands-m/
大地图版,下面是战斗中的,技能备注了没用。。。求大神帮忙
#=============================================================================== # +++ MOG - 输入挑战 (v1.4) +++ #=============================================================================== # By Moghunter # [url]https://atelierrgss.wordpress.com/[/url] #=============================================================================== # 输入挑战成功时开启开关 # # 需要以下图片. (Graphics/System) # # Chain_Cursor.png # Chain_Command.png # Chain_Layout.png # Chain_Timer_Layout.png # Chain_Timer_Meter.png # #=============================================================================== # # 使用脚本来显示输入挑战画面. # # chain_commands(挑战ID) # #=============================================================================== #============================================================================== # ● Histórico (Version History) #============================================================================== # v 1.4 - Correção do crash aleatório. # v 1.3 - Melhoria no sistema de dispose # v 1.2 - Melhoria na codificação e correção de alguns glitches. # v 1.1 - Animação de fade ao sair da cena de chain. # - Opção de definir a prioridade da hud na tela. #============================================================================== module MOG_CHAIN_COMMANDS #============================================================================== # CHAIN_COMMAND = { 挑战ID => [指令] } # # 挑战ID = 挑战的ID,同时也是开启开关的ID,当挑战成功时,该ID的开关也会被开启。 # 指令 = 按键顺序. # (下面是全部可用的指令) # # "Down" ,"Up" ,"Left" ,"Right" ,"Shift" ,"D" ,"S" ,"A" ,"Z" ,"X" ,"Q" ,"W" # # 例子: # # CHAIN_SWITCH_COMMAND = { # 25=>["Down","D","S","Right"], # 59=>["Down","Up","Left","Right","Shift","D","S","A","Z","X","Q","W"], # 80=>["Shift","D"] # } #============================================================================== CHAIN_SWITCH_COMMAND = { 5=>["X","Right","Left","Z","Z"], 6=>["Left","Right","Left","Right","Left","Right","Q","Z","Up","A","S", "Down","D","Z","Right","Up","Up","Z","W","Left","Down","D","A","W"], 8=>["Up","Down","Left","Right","Z"] } #输入时间. (单位为帧) *60帧 = 1秒 CHAIN_INPUT_DURATION = 30 #输入正确时播放的音效. CHAIN_RIGHT_SE = "Chime1" #输入错误时播放的音效. CHAIN_WRONG_SE = "Buzzer1" #全部自动正确输入的开关 CHAIN_AUTOMATIC_MODE_SWITCH_ID = 19 #输入挑战图片的Z坐标 CHAIN_HUD_Z = 300 end #=============================================================================== # ■ Chain Commands #=============================================================================== class Chain_Commands include MOG_CHAIN_COMMANDS #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize @action_id = $game_temp.chain_switch_id @chain_command = CHAIN_SWITCH_COMMAND[@action_id] @chain_command = ["?"] if @chain_command == nil duration = [[CHAIN_INPUT_DURATION, 1].max, 9999].min @timer_max = duration * @chain_command.size @timer = @timer_max @slide_time = [[60 / duration, 10].max, 60].min @change_time = 0 if $game_switches[CHAIN_AUTOMATIC_MODE_SWITCH_ID] @auto = true else @auto = false end @com = 0 end #-------------------------------------------------------------------------- # ● Main #-------------------------------------------------------------------------- def main dispose @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap2 create_chain_command create_cusrsor create_layout create_meter create_text create_number Graphics.transition loop do Graphics.update Input.update update break if SceneManager.scene != self end dispose end #-------------------------------------------------------------------------- # ● Create Cursor #-------------------------------------------------------------------------- def create_cusrsor @fy_time = 0 @fy = 0 @com_index = 0 @cursor = Sprite.new @cursor.bitmap = Cache.system("Chain_Cursor") @cursor.z = 4 + CHAIN_HUD_Z @cursor_space = ((@bitmap_cw + 5) * @chain_command.size) / 2 if @chain_command.size <= 20 @cursor.x = (544 / 2) - @cursor_space + @cursor_space * @com_index else @cursor.x = (544 / 2) end @cursor.y = (416 / 2) + 30 end #-------------------------------------------------------------------------- # ● Create Chain Command #-------------------------------------------------------------------------- def create_chain_command @image = Cache.system("Chain_Command") width_max = ((@image.width / 13) + 5) * @chain_command.size @bitmap = Bitmap.new(width_max,@image.height * 2) @bitmap_cw = @image.width / 13 @bitmap_ch = @image.height index = 0 for i in @chain_command command_list_check(i) bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch) if index == 0 @bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect) else @bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect) end index += 1 end @sprite = Sprite.new @sprite.bitmap = @bitmap if @chain_command.size <= 15 @sprite.x = (544 / 2) - ((@bitmap_cw + 5) * @chain_command.size) / 2 @new_x = 0 else @sprite.x = (544 / 2) @new_x = @sprite.x end @sprite.y = (416 / 2) + 30 - @bitmap_ch - 15 @sprite.z = 3 + CHAIN_HUD_Z @sprite.zoom_x = 1.5 @sprite.zoom_y = 1.5 end #-------------------------------------------------------------------------- # * create_layout #-------------------------------------------------------------------------- def create_layout @back = Plane.new @back.bitmap = Cache.system("Chain_Layout") @back.z = 0 @layout = Sprite.new @layout.bitmap = Cache.system("Chain_Timer_Layout") @layout.z = 1 + CHAIN_HUD_Z @layout.x = 160 @layout.y = 150 end #-------------------------------------------------------------------------- # * create_meter #-------------------------------------------------------------------------- def create_meter @meter_flow = 0 @meter_image = Cache.system("Chain_Timer_Meter") @meter_bitmap = Bitmap.new(@meter_image.width,@meter_image.height) @meter_range = @meter_image.width / 3 @meter_width = @meter_range * @timer / @timer_max @meter_height = @meter_image.height @meter_src_rect = Rect.new(@meter_range, 0, @meter_width, @meter_height) @meter_bitmap.blt(0,0, @meter_image, @meter_src_rect) @meter_sprite = Sprite.new @meter_sprite.bitmap = @meter_bitmap @meter_sprite.z = 2 + CHAIN_HUD_Z @meter_sprite.x = 220 @meter_sprite.y = 159 update_flow end #-------------------------------------------------------------------------- # ● Create Text #-------------------------------------------------------------------------- def create_text @text = Sprite.new @text.bitmap = Bitmap.new(200,32) @text.z = 2 + CHAIN_HUD_Z @text.bitmap.font.name = "Georgia" @text.bitmap.font.size = 25 @text.bitmap.font.bold = true @text.bitmap.font.italic = true @text.bitmap.font.color.set(255, 255, 255,220) @text.x = 230 @text.y = 100 end #-------------------------------------------------------------------------- # ● Create Number #-------------------------------------------------------------------------- def create_number @combo = 0 @number = Sprite.new @number.bitmap = Bitmap.new(200,64) @number.z = 2 + CHAIN_HUD_Z @number.bitmap.font.name = "Arial" @number.bitmap.font.size = 24 @number.bitmap.font.bold = true @number.bitmap.font.color.set(0, 255, 255,200) @number.bitmap.draw_text(0, 0, 200, 32, "准备",1) @number.x = 30 @number.y = 100 end #-------------------------------------------------------------------------- # ● Pre Dispose #-------------------------------------------------------------------------- def exit loop do Graphics.update @sprite.x += 5 @layout.x -= 5 @meter_sprite.x -= 5 @text.x -= 2 @text.opacity -= 5 @sprite.opacity -= 5 @layout.opacity -= 5 @meter_sprite.opacity -= 5 @number.opacity -= 5 @back.opacity -= 5 @cursor.visible = false break if @sprite.opacity == 0 end SceneManager.call(Scene_Map) end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- def dispose return if @layout == nil Graphics.freeze @background_sprite.bitmap.dispose @background_sprite.dispose @bitmap.dispose @sprite.bitmap.dispose @sprite.dispose @cursor.bitmap.dispose @cursor.dispose @meter_image.dispose @meter_bitmap.dispose @meter_sprite.bitmap.dispose @meter_sprite.dispose @layout.bitmap.dispose @layout.dispose @layout = nil @back.bitmap.dispose @back.dispose @text.bitmap.dispose @text.dispose @number.bitmap.dispose @number.dispose @image.dispose end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- def update update_command update_cursor_slide update_flow update_change_time end #-------------------------------------------------------------------------- # ● Change_Time #-------------------------------------------------------------------------- def update_change_time return unless @auto @change_time += 1 check_command(-1) if @change_time >= CHAIN_INPUT_DURATION - 1 end #-------------------------------------------------------------------------- # ● Update Flow #-------------------------------------------------------------------------- def update_flow @timer -= 1 @meter_sprite.bitmap.clear @meter_width = @meter_range * @timer / @timer_max @meter_src_rect = Rect.new(@meter_flow, 0, @meter_width, @meter_height) @meter_bitmap.blt(0,0, @meter_image, @meter_src_rect) @meter_flow += 20 @meter_flow = 0 if @meter_flow >= @meter_image.width - @meter_range wrong_command if @timer == 0 and @auto == false end #-------------------------------------------------------------------------- # ● Update Command #-------------------------------------------------------------------------- def update_command return if @auto if Input.trigger?(Input::X) check_command(0) elsif Input.trigger?(Input::Z) check_command(1) elsif Input.trigger?(Input::Y) check_command(2) elsif Input.trigger?(Input::A) check_command(3) elsif Input.trigger?(Input::C) check_command(4) elsif Input.trigger?(Input::B) check_command(5) elsif Input.trigger?(Input::L) check_command(6) elsif Input.trigger?(Input::R) check_command(7) elsif Input.trigger?(Input::RIGHT) check_command(8) elsif Input.trigger?(Input::LEFT) check_command(9) elsif Input.trigger?(Input::DOWN) check_command(10) elsif Input.trigger?(Input::UP) check_command(11) end end #-------------------------------------------------------------------------- # ● command_list_check #-------------------------------------------------------------------------- def command_list_check(command) case command when "A" @com = 0 when "D" @com = 1 when "S" @com = 2 when "Shift" @com = 3 when "Z" @com = 4 when "X" @com = 5 when "Q" @com = 6 when "W" @com = 7 when "Right" @com = 8 when "Left" @com = 9 when "Down" @com = 10 when "Up" @com = 11 else @com = 12 end end #-------------------------------------------------------------------------- # ● check_command #-------------------------------------------------------------------------- def check_command(com) index = 0 if com != -1 right_input = false for i in @chain_command if index == @com_index command_list_check(i) right_input = true if @com == com end index += 1 end else command_list_check(@com_index) @change_time = 0 right_input = true end if right_input refresh_number next_command else wrong_command end end #-------------------------------------------------------------------------- # ● Next Command #-------------------------------------------------------------------------- def next_command @com_index += 1 Audio.se_play("Audio/SE/" + CHAIN_RIGHT_SE, 100, 100) if @com_index == @chain_command.size $game_switches[@action_id] = true exit $game_map.need_refresh = true end refresh_command refresh_text(0) end #-------------------------------------------------------------------------- # ● wrong_command #-------------------------------------------------------------------------- def wrong_command Audio.se_play("Audio/SE/" + CHAIN_WRONG_SE, 100, 100) refresh_text(1) exit $game_player.jump(0,0) end #-------------------------------------------------------------------------- # ● Refresh Command #-------------------------------------------------------------------------- def refresh_command @sprite.bitmap.clear index = 0 for i in @chain_command command_list_check(i) bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch) if @com_index == index @bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect) else @bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect) end index += 1 end if @chain_command.size > 15 @new_x = (544 / 2) - ((@bitmap_cw + 5) * @com_index) else @cursor.x = (544 / 2) - @cursor_space + ((@bitmap_cw + 5) * @com_index) end end #-------------------------------------------------------------------------- # ● Refresh Text #-------------------------------------------------------------------------- def refresh_text(type) @text.bitmap.clear if type == 0 if @com_index == @chain_command.size @text.bitmap.font.color.set(55, 255, 55,220) @text.bitmap.draw_text(0, 0, 200, 32, "完美!",1) else @text.bitmap.font.color.set(55, 155, 255,220) @text.bitmap.draw_text(0, 0, 200, 32, "成功!",1) end else @text.bitmap.font.color.set(255, 155, 55,220) if @timer == 0 @text.bitmap.draw_text(0, 0, 200, 32, "时间到!",1) else @text.bitmap.draw_text(0, 0, 200, 32, "失败!",1) end end @text.x = 230 @text.opacity = 255 end #-------------------------------------------------------------------------- # ● Refresh Number #-------------------------------------------------------------------------- def refresh_number @combo += 1 @number.bitmap.clear @number.bitmap.font.size = 34 @number.bitmap.draw_text(0, 0, 200, 32, @combo.to_s,1) @number.opacity = 255 @number.zoom_x = 2 @number.zoom_y = 2 end #-------------------------------------------------------------------------- # ● Update Cursor Slide #-------------------------------------------------------------------------- def update_cursor_slide @sprite.zoom_x -= 0.1 if @sprite.zoom_x > 1 @sprite.zoom_y -= 0.1 if @sprite.zoom_y > 1 @text.x -= 2 if @text.x > 210 @text.opacity -= 5 if @text.opacity > 0 @sprite.x -= @slide_time if @sprite.x > @new_x and @chain_command.size > 15 if @number.zoom_x > 1 @number.zoom_x -= 0.1 @number.zoom_y -= 0.1 end if @fy_time > 15 @fy += 1 elsif @fy_time > 0 @fy -= 1 else @fy = 0 @fy_time = 30 end @fy_time -= 1 @cursor.oy = @fy end end #============================================================================== # ■ Game Temp #============================================================================== class Game_Temp attr_accessor :chain_switch_id #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_chain_commands_initialize initialize def initialize @chain_switch_id = 0 mog_chain_commands_initialize end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● Chain Commands #-------------------------------------------------------------------------- def chain_commands(switch_id = 0) return if switch_id <= 0 $game_temp.chain_switch_id = switch_id SceneManager.call(Chain_Commands) wait(1) end end #=============================================================================== # ■ SceneManager #=============================================================================== class << SceneManager @background_bitmap2 = nil #-------------------------------------------------------------------------- # ● Snapshot For Background2 #-------------------------------------------------------------------------- def snapshot_for_background2 @background_bitmap2.dispose if @background_bitmap2 @background_bitmap2 = Graphics.snap_to_bitmap end #-------------------------------------------------------------------------- # ● Background Bitmap2 #-------------------------------------------------------------------------- def background_bitmap2 @background_bitmap2 end end #=============================================================================== # ■ Scene Map #=============================================================================== class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● Terminate #-------------------------------------------------------------------------- alias mog_chain_commands_terminate terminate def terminate SceneManager.snapshot_for_background2 mog_chain_commands_terminate end end $mog_rgss3_chain_commands = true
#===============================================================================
# +++ MOG - 输入挑战 (v1.4) +++
#===============================================================================
# By Moghunter
# [url]https://atelierrgss.wordpress.com/[/url]
#===============================================================================
# 输入挑战成功时开启开关
#
# 需要以下图片. (Graphics/System)
#
# Chain_Cursor.png
# Chain_Command.png
# Chain_Layout.png
# Chain_Timer_Layout.png
# Chain_Timer_Meter.png
#
#===============================================================================
#
# 使用脚本来显示输入挑战画面.
#
# chain_commands(挑战ID)
#
#===============================================================================
#==============================================================================
# ● Histórico (Version History)
#==============================================================================
# v 1.4 - Correção do crash aleatório.
# v 1.3 - Melhoria no sistema de dispose
# v 1.2 - Melhoria na codificação e correção de alguns glitches.
# v 1.1 - Animação de fade ao sair da cena de chain.
# - Opção de definir a prioridade da hud na tela.
#==============================================================================
module MOG_CHAIN_COMMANDS
#==============================================================================
# CHAIN_COMMAND = { 挑战ID => [指令] }
#
# 挑战ID = 挑战的ID,同时也是开启开关的ID,当挑战成功时,该ID的开关也会被开启。
# 指令 = 按键顺序.
# (下面是全部可用的指令)
#
# "Down" ,"Up" ,"Left" ,"Right" ,"Shift" ,"D" ,"S" ,"A" ,"Z" ,"X" ,"Q" ,"W"
#
# 例子:
#
# CHAIN_SWITCH_COMMAND = {
# 25=>["Down","D","S","Right"],
# 59=>["Down","Up","Left","Right","Shift","D","S","A","Z","X","Q","W"],
# 80=>["Shift","D"]
# }
#==============================================================================
CHAIN_SWITCH_COMMAND = {
5=>["X","Right","Left","Z","Z"],
6=>["Left","Right","Left","Right","Left","Right","Q","Z","Up","A","S",
"Down","D","Z","Right","Up","Up","Z","W","Left","Down","D","A","W"],
8=>["Up","Down","Left","Right","Z"]
}
#输入时间. (单位为帧) *60帧 = 1秒
CHAIN_INPUT_DURATION = 30
#输入正确时播放的音效.
CHAIN_RIGHT_SE = "Chime1"
#输入错误时播放的音效.
CHAIN_WRONG_SE = "Buzzer1"
#全部自动正确输入的开关
CHAIN_AUTOMATIC_MODE_SWITCH_ID = 19
#输入挑战图片的Z坐标
CHAIN_HUD_Z = 300
end
#===============================================================================
# ■ Chain Commands
#===============================================================================
class Chain_Commands
include MOG_CHAIN_COMMANDS
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
@action_id = $game_temp.chain_switch_id
@chain_command = CHAIN_SWITCH_COMMAND[@action_id]
@chain_command = ["?"] if @chain_command == nil
duration = [[CHAIN_INPUT_DURATION, 1].max, 9999].min
@timer_max = duration * @chain_command.size
@timer = @timer_max
@slide_time = [[60 / duration, 10].max, 60].min
@change_time = 0
if $game_switches[CHAIN_AUTOMATIC_MODE_SWITCH_ID]
@auto = true
else
@auto = false
end
@com = 0
end
#--------------------------------------------------------------------------
# ● Main
#--------------------------------------------------------------------------
def main
dispose
@background_sprite = Sprite.new
@background_sprite.bitmap = SceneManager.background_bitmap2
create_chain_command
create_cusrsor
create_layout
create_meter
create_text
create_number
Graphics.transition
loop do
Graphics.update
Input.update
update
break if SceneManager.scene != self
end
dispose
end
#--------------------------------------------------------------------------
# ● Create Cursor
#--------------------------------------------------------------------------
def create_cusrsor
@fy_time = 0
@fy = 0
@com_index = 0
@cursor = Sprite.new
@cursor.bitmap = Cache.system("Chain_Cursor")
@cursor.z = 4 + CHAIN_HUD_Z
@cursor_space = ((@bitmap_cw + 5) * @chain_command.size) / 2
if @chain_command.size <= 20
@cursor.x = (544 / 2) - @cursor_space + @cursor_space * @com_index
else
@cursor.x = (544 / 2)
end
@cursor.y = (416 / 2) + 30
end
#--------------------------------------------------------------------------
# ● Create Chain Command
#--------------------------------------------------------------------------
def create_chain_command
@image = Cache.system("Chain_Command")
width_max = ((@image.width / 13) + 5) * @chain_command.size
@bitmap = Bitmap.new(width_max,@image.height * 2)
@bitmap_cw = @image.width / 13
@bitmap_ch = @image.height
index = 0
for i in @chain_command
command_list_check(i)
bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch)
if index == 0
@bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect)
else
@bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect)
end
index += 1
end
@sprite = Sprite.new
@sprite.bitmap = @bitmap
if @chain_command.size <= 15
@sprite.x = (544 / 2) - ((@bitmap_cw + 5) * @chain_command.size) / 2
@new_x = 0
else
@sprite.x = (544 / 2)
@new_x = @sprite.x
end
@sprite.y = (416 / 2) + 30 - @bitmap_ch - 15
@sprite.z = 3 + CHAIN_HUD_Z
@sprite.zoom_x = 1.5
@sprite.zoom_y = 1.5
end
#--------------------------------------------------------------------------
# * create_layout
#--------------------------------------------------------------------------
def create_layout
@back = Plane.new
@back.bitmap = Cache.system("Chain_Layout")
@back.z = 0
@layout = Sprite.new
@layout.bitmap = Cache.system("Chain_Timer_Layout")
@layout.z = 1 + CHAIN_HUD_Z
@layout.x = 160
@layout.y = 150
end
#--------------------------------------------------------------------------
# * create_meter
#--------------------------------------------------------------------------
def create_meter
@meter_flow = 0
@meter_image = Cache.system("Chain_Timer_Meter")
@meter_bitmap = Bitmap.new(@meter_image.width,@meter_image.height)
@meter_range = @meter_image.width / 3
@meter_width = @meter_range * @timer / @timer_max
@meter_height = @meter_image.height
@meter_src_rect = Rect.new(@meter_range, 0, @meter_width, @meter_height)
@meter_bitmap.blt(0,0, @meter_image, @meter_src_rect)
@meter_sprite = Sprite.new
@meter_sprite.bitmap = @meter_bitmap
@meter_sprite.z = 2 + CHAIN_HUD_Z
@meter_sprite.x = 220
@meter_sprite.y = 159
update_flow
end
#--------------------------------------------------------------------------
# ● Create Text
#--------------------------------------------------------------------------
def create_text
@text = Sprite.new
@text.bitmap = Bitmap.new(200,32)
@text.z = 2 + CHAIN_HUD_Z
@text.bitmap.font.name = "Georgia"
@text.bitmap.font.size = 25
@text.bitmap.font.bold = true
@text.bitmap.font.italic = true
@text.bitmap.font.color.set(255, 255, 255,220)
@text.x = 230
@text.y = 100
end
#--------------------------------------------------------------------------
# ● Create Number
#--------------------------------------------------------------------------
def create_number
@combo = 0
@number = Sprite.new
@number.bitmap = Bitmap.new(200,64)
@number.z = 2 + CHAIN_HUD_Z
@number.bitmap.font.name = "Arial"
@number.bitmap.font.size = 24
@number.bitmap.font.bold = true
@number.bitmap.font.color.set(0, 255, 255,200)
@number.bitmap.draw_text(0, 0, 200, 32, "准备",1)
@number.x = 30
@number.y = 100
end
#--------------------------------------------------------------------------
# ● Pre Dispose
#--------------------------------------------------------------------------
def exit
loop do
Graphics.update
@sprite.x += 5
@layout.x -= 5
@meter_sprite.x -= 5
@text.x -= 2
@text.opacity -= 5
@sprite.opacity -= 5
@layout.opacity -= 5
@meter_sprite.opacity -= 5
@number.opacity -= 5
@back.opacity -= 5
@cursor.visible = false
break if @sprite.opacity == 0
end
SceneManager.call(Scene_Map)
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
return if @layout == nil
Graphics.freeze
@background_sprite.bitmap.dispose
@background_sprite.dispose
@bitmap.dispose
@sprite.bitmap.dispose
@sprite.dispose
@cursor.bitmap.dispose
@cursor.dispose
@meter_image.dispose
@meter_bitmap.dispose
@meter_sprite.bitmap.dispose
@meter_sprite.dispose
@layout.bitmap.dispose
@layout.dispose
@layout = nil
@back.bitmap.dispose
@back.dispose
@text.bitmap.dispose
@text.dispose
@number.bitmap.dispose
@number.dispose
@image.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
update_command
update_cursor_slide
update_flow
update_change_time
end
#--------------------------------------------------------------------------
# ● Change_Time
#--------------------------------------------------------------------------
def update_change_time
return unless @auto
@change_time += 1
check_command(-1) if @change_time >= CHAIN_INPUT_DURATION - 1
end
#--------------------------------------------------------------------------
# ● Update Flow
#--------------------------------------------------------------------------
def update_flow
@timer -= 1
@meter_sprite.bitmap.clear
@meter_width = @meter_range * @timer / @timer_max
@meter_src_rect = Rect.new(@meter_flow, 0, @meter_width, @meter_height)
@meter_bitmap.blt(0,0, @meter_image, @meter_src_rect)
@meter_flow += 20
@meter_flow = 0 if @meter_flow >= @meter_image.width - @meter_range
wrong_command if @timer == 0 and @auto == false
end
#--------------------------------------------------------------------------
# ● Update Command
#--------------------------------------------------------------------------
def update_command
return if @auto
if Input.trigger?(Input::X)
check_command(0)
elsif Input.trigger?(Input::Z)
check_command(1)
elsif Input.trigger?(Input::Y)
check_command(2)
elsif Input.trigger?(Input::A)
check_command(3)
elsif Input.trigger?(Input::C)
check_command(4)
elsif Input.trigger?(Input::B)
check_command(5)
elsif Input.trigger?(Input::L)
check_command(6)
elsif Input.trigger?(Input::R)
check_command(7)
elsif Input.trigger?(Input::RIGHT)
check_command(8)
elsif Input.trigger?(Input::LEFT)
check_command(9)
elsif Input.trigger?(Input::DOWN)
check_command(10)
elsif Input.trigger?(Input::UP)
check_command(11)
end
end
#--------------------------------------------------------------------------
# ● command_list_check
#--------------------------------------------------------------------------
def command_list_check(command)
case command
when "A"
@com = 0
when "D"
@com = 1
when "S"
@com = 2
when "Shift"
@com = 3
when "Z"
@com = 4
when "X"
@com = 5
when "Q"
@com = 6
when "W"
@com = 7
when "Right"
@com = 8
when "Left"
@com = 9
when "Down"
@com = 10
when "Up"
@com = 11
else
@com = 12
end
end
#--------------------------------------------------------------------------
# ● check_command
#--------------------------------------------------------------------------
def check_command(com)
index = 0
if com != -1
right_input = false
for i in @chain_command
if index == @com_index
command_list_check(i)
right_input = true if @com == com
end
index += 1
end
else
command_list_check(@com_index)
@change_time = 0
right_input = true
end
if right_input
refresh_number
next_command
else
wrong_command
end
end
#--------------------------------------------------------------------------
# ● Next Command
#--------------------------------------------------------------------------
def next_command
@com_index += 1
Audio.se_play("Audio/SE/" + CHAIN_RIGHT_SE, 100, 100)
if @com_index == @chain_command.size
$game_switches[@action_id] = true
exit
$game_map.need_refresh = true
end
refresh_command
refresh_text(0)
end
#--------------------------------------------------------------------------
# ● wrong_command
#--------------------------------------------------------------------------
def wrong_command
Audio.se_play("Audio/SE/" + CHAIN_WRONG_SE, 100, 100)
refresh_text(1)
exit
$game_player.jump(0,0)
end
#--------------------------------------------------------------------------
# ● Refresh Command
#--------------------------------------------------------------------------
def refresh_command
@sprite.bitmap.clear
index = 0
for i in @chain_command
command_list_check(i)
bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch)
if @com_index == index
@bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect)
else
@bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect)
end
index += 1
end
if @chain_command.size > 15
@new_x = (544 / 2) - ((@bitmap_cw + 5) * @com_index)
else
@cursor.x = (544 / 2) - @cursor_space + ((@bitmap_cw + 5) * @com_index)
end
end
#--------------------------------------------------------------------------
# ● Refresh Text
#--------------------------------------------------------------------------
def refresh_text(type)
@text.bitmap.clear
if type == 0
if @com_index == @chain_command.size
@text.bitmap.font.color.set(55, 255, 55,220)
@text.bitmap.draw_text(0, 0, 200, 32, "完美!",1)
else
@text.bitmap.font.color.set(55, 155, 255,220)
@text.bitmap.draw_text(0, 0, 200, 32, "成功!",1)
end
else
@text.bitmap.font.color.set(255, 155, 55,220)
if @timer == 0
@text.bitmap.draw_text(0, 0, 200, 32, "时间到!",1)
else
@text.bitmap.draw_text(0, 0, 200, 32, "失败!",1)
end
end
@text.x = 230
@text.opacity = 255
end
#--------------------------------------------------------------------------
# ● Refresh Number
#--------------------------------------------------------------------------
def refresh_number
@combo += 1
@number.bitmap.clear
@number.bitmap.font.size = 34
@number.bitmap.draw_text(0, 0, 200, 32, @combo.to_s,1)
@number.opacity = 255
@number.zoom_x = 2
@number.zoom_y = 2
end
#--------------------------------------------------------------------------
# ● Update Cursor Slide
#--------------------------------------------------------------------------
def update_cursor_slide
@sprite.zoom_x -= 0.1 if @sprite.zoom_x > 1
@sprite.zoom_y -= 0.1 if @sprite.zoom_y > 1
@text.x -= 2 if @text.x > 210
@text.opacity -= 5 if @text.opacity > 0
@sprite.x -= @slide_time if @sprite.x > @new_x and @chain_command.size > 15
if @number.zoom_x > 1
@number.zoom_x -= 0.1
@number.zoom_y -= 0.1
end
if @fy_time > 15
@fy += 1
elsif @fy_time > 0
@fy -= 1
else
@fy = 0
@fy_time = 30
end
@fy_time -= 1
@cursor.oy = @fy
end
end
#==============================================================================
# ■ Game Temp
#==============================================================================
class Game_Temp
attr_accessor :chain_switch_id
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_chain_commands_initialize initialize
def initialize
@chain_switch_id = 0
mog_chain_commands_initialize
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● Chain Commands
#--------------------------------------------------------------------------
def chain_commands(switch_id = 0)
return if switch_id <= 0
$game_temp.chain_switch_id = switch_id
SceneManager.call(Chain_Commands)
wait(1)
end
end
#===============================================================================
# ■ SceneManager
#===============================================================================
class << SceneManager
@background_bitmap2 = nil
#--------------------------------------------------------------------------
# ● Snapshot For Background2
#--------------------------------------------------------------------------
def snapshot_for_background2
@background_bitmap2.dispose if @background_bitmap2
@background_bitmap2 = Graphics.snap_to_bitmap
end
#--------------------------------------------------------------------------
# ● Background Bitmap2
#--------------------------------------------------------------------------
def background_bitmap2
@background_bitmap2
end
end
#===============================================================================
# ■ Scene Map
#===============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● Terminate
#--------------------------------------------------------------------------
alias mog_chain_commands_terminate terminate
def terminate
SceneManager.snapshot_for_background2
mog_chain_commands_terminate
end
end
$mog_rgss3_chain_commands = true
#============================================================================== # +++ MOG - 战斗输入挑战 (v3.3) +++ #============================================================================== # By Moghunter # [url]https://atelierrgss.wordpress.com/[/url] #============================================================================== # 在技能发动之前可以设定一个输入挑战,全部输入正确后才能施放技能. #============================================================================== # 需要以下图片,放在 Graphics/System/ # # Chain_Command.png # Chain_Battle_Layout.png # Chain_Battle_Meter.png # #============================================================================== # 使用方法 #============================================================================== # 技能备注: # # <Chain Action = X> # # X - 技能ID #============================================================================== #============================================================================== # ● Histórico (Version History) #============================================================================== # v3.3 - Melhoria na compatibilidade com MOG Battle Camera # v3.2 - Compatibilidade com MOG Sprite Actor. # v3.1 - Compatibilidade com MOG Battle Camera. # v3.0 - Adição de comandos aleatórios. # v2.9 - Correção do bug de não ocultar a janela com MOG ATB. # v2.8 - Melhoria na codificação. #============================================================================== $imported = {} if $imported.nil? $imported[:mog_active_chain] = true module MOG_CHAIN_ACTIONS #============================================================================= # CHAIN_ACTIONS = { 技能ID => [按键顺序] } # # 技能ID = 数据库中的技能ID. # 按键顺序 = 设定按键顺序 # (以下为全部可用按键) # # "Down" ,"Up" ,"Left" ,"Right" ,"Shift" ,"D" ,"S" ,"A" ,"Z" ,"X" ,"Q" ,"W", # "Random" # # 例子: # # CHAIN_ACTIONS = { # 25=>["Down","D","S","Right"], # 59=>["Down","Up","Left","Right","Shift","D","S","A","Z","X","Q","W"], # 80=>["Shift","D"] # } #============================================================================== CHAIN_ACTIONS = { 29=>["Random","Random","Random","Random"], 52=>["Up","Down","Left","Right","Z"], 70=>["X","Right","Left","Z","Z"], 138=>["Random"], 139=>["Random","Random"], 140=>["Random","Random","Random"], #138=>["X"], #139=>["A","S"], #140=>["Z","D","X"], 141=>["Up","Down"], 142=>["Left","Right","Z"], 999=>["Left","Right","Left","Right","Left","Right","Q","Z","Up","A","S", "Down","D","Z","Right","Up","Up","Z","W","Left","Down","D","A","W"] } #设置随机指令. RANDOM_KEYS = ["Left","Right","Up","Down","D","S","A","Z","X"] #默认按键的等待时间(玩家需要正确按下的时间). CHAIN_DEFAULT_INPUT_DURATION = 60 #60帧 = 1s #指定按键的等待时间 CHAIN_INPUT_DURATION = { 138=>60, 139=>40, 140=>30 #141=>160, #240=>2000 } #正确点击时的音效. CHAIN_RIGHT_SE = "Chime1" #错误点击时的音效. CHAIN_WRONG_SE = "Buzzer1" #输入挑战开始时播放的音效. CHAIN_START_SE = "Open1" #输入挑战精灵的位置. CHAIN_SPRITE_POSITION = [0,-15] #输入挑战图片的位置 CHAIN_LAYOUT_POSITION = [1,-7] #进度条图片的位置 CHAIN_METER_POSITION = [0,-6] #图标的位置 CHAIN_ICON_POSITION = [0,-32] #输入挑战开始时显示的文字. CHAIN_COMMAND_WORD = "输入挑战!" #未命中和时间结束的文字 CHAIN_MISSED_WORDS = ["未命中!", "时间结束"] #文字位置 CHAIN_COMMAND_WORD_POSITION = [0,0] #文字大小 CHAIN_WORD_FONT_SIZE = 20 #文字颜色 CHAIN_WORD_FONT_COLOR = Color.new(255,255,255) #文字Z坐标 CHAIN_SPRITE_Z = 150 end #============================================================================== # ■ Game Temp #============================================================================== class Game_Temp attr_accessor :chain_actions attr_accessor :active_chain attr_accessor :chain_ot attr_accessor :chain_action_phase #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_chain_actions_initialize initialize def initialize @chain_actions = [0,0,0,false] ; @active_chain = false @chain_action_phase = false mog_chain_actions_initialize end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● Use Item #-------------------------------------------------------------------------- alias mog_chain_actions_use_item use_item def use_item prepare_chain_command if can_use_chain_commands? mog_chain_actions_use_item execute_chain_actions if can_use_chain_commands? end #-------------------------------------------------------------------------- # ● Can Use Chain Commands #-------------------------------------------------------------------------- def can_use_chain_commands? return false if @subject == nil return false if !@subject.is_a?(Game_Actor) return false if @subject.restriction != 0 return true end #-------------------------------------------------------------------------- # ● Prepare Chain Commands #-------------------------------------------------------------------------- def prepare_chain_command @chain_skill_original = @subject.current_action.item rescue nil if $game_temp.chain_ot == nil and @subject.is_a?(Game_Actor) targets = @subject.current_action.make_targets.compact $game_temp.chain_ot = targets[0] end check_chain_targets end #-------------------------------------------------------------------------- # ● Check Chain Command Position #-------------------------------------------------------------------------- def check_chain_command_position scx = $game_temp.chain_ot.screen_x rescue nil return if scx == nil if $game_temp.chain_ot != nil and !$game_temp.chain_ot.dead? $game_temp.chain_actions = [$game_temp.chain_ot.screen_x,$game_temp.chain_ot.screen_y,true] end end #-------------------------------------------------------------------------- # ● Check Chain Targets #-------------------------------------------------------------------------- def check_chain_targets return if @subject == nil or $game_temp.chain_ot == nil if [1,7,9,10,11].include?(@subject.current_action.item.scope) @pre_target = $game_temp.chain_ot ; @pre_target_hp = $game_temp.chain_ot.hp else @pre_target = nil ; @pre_target_hp = nil end end #-------------------------------------------------------------------------- # ● Execute Chain Actions #-------------------------------------------------------------------------- def execute_chain_actions $game_temp.active_chain = false return if !can_execute_chain_actions_base? check_chain_command_position skill = @subject.current_action.item rescue nil skill = @chain_skill_original rescue nil action_id = skill.note =~ /<Chain Action = (\d+)>/i ? $1.to_i : nil rescue nil return if action_id == nil or action_id < 1 chain_command_sequence = MOG_CHAIN_ACTIONS::CHAIN_ACTIONS[action_id].dup rescue nil $game_temp.chain_actions[2] = action_id if can_execute_chain_sequence?(chain_command_sequence,action_id) chain_act_before_action if @chain_command == nil chain_sq = Chain_Actions.new(chain_command_sequence,$game_temp.chain_actions) loop do $game_temp.chain_action_phase = true (chain_sq.update($game_temp.chain_ot) ; Input.update) unless @spriteset.animation? $game_temp.active_chain = true ; chain_sq.update_skill_name @spriteset.update ; Graphics.update ; update_info_viewport break if chain_sq.phase == 9 end @subject.wp_animation = [true,chain_sq.success] if $imported[:mog_sprite_actor] action_id = nil if !chain_sq.success or $game_temp.chain_ot.dead? chain_sq.dispose ; set_chain_skill(action_id) if action_id != nil end $game_temp.active_chain = false ; $game_temp.chain_ot = nil $game_temp.chain_action_phase = false end #-------------------------------------------------------------------------- # ● Chain Act Before Action #-------------------------------------------------------------------------- def chain_act_before_action @chain_command = true ; @bb_cursor if $imported[:mog_battle_cursor] @bb_cursor = $game_temp.battle_cursor[2] $game_temp.battle_cursor[2] = false end if $imported[:mog_menu_cursor] @chain_curor_x = $game_temp.menu_cursor[2] $game_temp.menu_cursor[2] = -999 force_cursor_visible(false) end if $imported[:mog_atb_system] record_window_data if @wd_rec.nil? hide_base_window @wd_rec = true end end #-------------------------------------------------------------------------- # ● Turn End #-------------------------------------------------------------------------- alias mog_chain_command_process_action_end process_action_end def process_action_end mog_chain_command_process_action_end chain_act_after_action end #-------------------------------------------------------------------------- # ● Chain Act After ACtion #-------------------------------------------------------------------------- def chain_act_after_action @chain_skill_original = nil $game_temp.chain_ot = nil return if @chain_command == nil restore_window_data if $imported[:mog_atb_system] $game_temp.menu_cursor[2] = @chain_curor_x if $imported[:mog_menu_cursor] $game_temp.battle_cursor[2] = @bb_cursor if @bb_cursor != nil @chain_command = nil end #-------------------------------------------------------------------------- # ● Set Chain Skill #-------------------------------------------------------------------------- def set_chain_skill(action_id) return if action_id == nil @subject.input.set_skill(action_id) $game_temp.chain_actions = [0,0,0,false] ; execute_action end #-------------------------------------------------------------------------- # ● Can Execute Chain Sequence? #-------------------------------------------------------------------------- def can_execute_chain_sequence?(chain_command_sequence = nil,action_id = nil) return false if chain_command_sequence == nil skill = $data_skills[action_id] rescue nil return false if skill == nil return false if $game_temp.chain_ot == nil or $game_temp.chain_ot.dead? if [9,10].include?(skill.scope) $game_party.battle_members.each do |i| return true if i.dead? end return false end return true end #-------------------------------------------------------------------------- # ● Can Execute Chain Actions Base #-------------------------------------------------------------------------- def can_execute_chain_actions_base? return false if @subject == nil or @subject.dead? return false if $game_temp.chain_ot == nil or $game_temp.chain_ot.dead? return false if @subject.is_a?(Game_Enemy) return false if @subject.current_action == nil @subject.states.each do |i| return false if i.restriction > 0 end return false if $game_party.members.empty? return false if $game_party.all_dead? return false if $game_troop.all_dead? if @pre_target != nil and $game_temp.chain_ot.hp == @pre_target_hp return false if $game_temp.chain_ot.result.missed return false if $game_temp.chain_ot.result.evaded end return true end #-------------------------------------------------------------------------- # ● Turn End #-------------------------------------------------------------------------- alias mog_chain_command_turn_end turn_end def turn_end mog_chain_command_turn_end @wd_rec = nil end end #============================================================================== # ■ Game Temp #============================================================================== class Game_Temp attr_accessor :cache_active_chain #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_active_chain_initialize initialize def initialize mog_active_chain_initialize cache_act_chain end #-------------------------------------------------------------------------- # ● Cache Act Chain #-------------------------------------------------------------------------- def cache_act_chain @cache_active_chain = [] @cache_active_chain.push(Cache.system("IconSet")) @cache_active_chain.push(Cache.system("Chain_Battle_Layout")) @cache_active_chain.push(Cache.system("Chain_Battle_Meter")) @cache_active_chain.push(Cache.system("Chain_Battle_Command")) end end #============================================================================== # ■ Spriteset Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_active_chain_commands_initialize initialize def initialize $game_temp.cache_act_chain ; $game_temp.active_chain = false $game_temp.chain_ot = nil mog_active_chain_commands_initialize end end #============================================================================== # ■ Chain Actions #============================================================================== class Chain_Actions include MOG_CHAIN_ACTIONS attr_accessor :phase attr_accessor :success #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize(sequence,chain_temp) $game_temp.chain_actions[3] = true @chain_command_original = sequence.dup @chain_command = sequence random_sequence @x = chain_temp[0] + CHAIN_SPRITE_POSITION[0] @y = chain_temp[1] + CHAIN_SPRITE_POSITION[1] @y = (Graphics.height - 36) if @y > (Graphics.height - 36) @y = 0 if @y < 0 @skill = $data_skills[chain_temp[2]] @skillname = @skill.name if CHAIN_INPUT_DURATION[chain_temp[2]] != nil @duration = [CHAIN_INPUT_DURATION[chain_temp[2]],CHAIN_INPUT_DURATION[chain_temp[2]]] else @duration = [CHAIN_DEFAULT_INPUT_DURATION, CHAIN_DEFAULT_INPUT_DURATION] end @phase = 0 ; @success = false ; @com = 0 ; @com_index = 0 @initial_wait = 1 ; @wrong_commnad = [false,0,0] Audio.se_play("Audio/SE/" + CHAIN_START_SE, 100, 100) rescue nil create_button_sprite ; create_skill_name ; create_icon ; create_meter set_opacity(0) end #-------------------------------------------------------------------------- # ● Random Sequence #-------------------------------------------------------------------------- def random_sequence @chain_command_original.each_with_index do |c, i| next if c != "Random" k = rand(RANDOM_KEYS.size) ; @chain_command[i] = RANDOM_KEYS[k] end end #-------------------------------------------------------------------------- # ● Create Icon #-------------------------------------------------------------------------- def create_icon @icon_image = $game_temp.cache_active_chain[0] @icon_sprite = Sprite.new ; @icon_sprite.bitmap = Bitmap.new(24,24) @icon_sprite.z = CHAIN_SPRITE_Z + 1 @org_x2 = @x - 12 + CHAIN_ICON_POSITION[0] - @center @icon_sprite.x = @org_x2 - 50 @icon_sprite.y = @y + CHAIN_ICON_POSITION[1] icon_rect = Rect.new(@skill.icon_index % 16 * 24, @skill.icon_index / 16 * 24, 24, 24) @icon_sprite.bitmap.blt(0,0, @icon_image, icon_rect) end #-------------------------------------------------------------------------- # ● Create Meter #-------------------------------------------------------------------------- def create_meter @meter_layout = Sprite.new @meter_layout.bitmap = $game_temp.cache_active_chain[1] @meter_layout.z = CHAIN_SPRITE_Z @meter_layout.x = @x - (@meter_layout.width / 2) + CHAIN_LAYOUT_POSITION[0] @meter_layout.y = @y + CHAIN_LAYOUT_POSITION[1] @meter_image = $game_temp.cache_active_chain[2] @meter_cw = @meter_image.width ; @meter_ch = @meter_image.height @meter = Sprite.new @meter.bitmap = Bitmap.new(@meter_image.width, @meter_image.height) @meter.z = CHAIN_SPRITE_Z + 1 @meter.x = @x - (@meter_image.width / 2) + CHAIN_METER_POSITION[0] @meter.y = @y + CHAIN_METER_POSITION[1] @meter.visible = false ; @meter_layout.visible = false ; update_meter end #-------------------------------------------------------------------------- # ● Update Meter #-------------------------------------------------------------------------- def update_meter return if @meter == nil @meter.bitmap.clear ; range = @meter_cw * @duration[0] / @duration[1] m_scr = Rect.new(0,0,range,@meter_ch ) @meter.bitmap.blt(0,0, @meter_image ,m_scr) end #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def create_skill_name @skill_name = Sprite.new ; @skill_name.bitmap = Bitmap.new(200,32) @skill_name.bitmap.font.size = CHAIN_WORD_FONT_SIZE @skill_name.bitmap.font.color = CHAIN_WORD_FONT_COLOR @skill_name.z = CHAIN_SPRITE_Z @skill_name.y = @y - 32 + CHAIN_COMMAND_WORD_POSITION[1] refresh_skill_name end #-------------------------------------------------------------------------- # ● Refresh Skill Name #-------------------------------------------------------------------------- def refresh_skill_name cm = @skillname.to_s.split(//).size @center = ((200 / @skill_name.bitmap.font.size) * cm / 2) + 5 @org_x = @x - (@button_cw / 2) - 85 + CHAIN_COMMAND_WORD_POSITION[0] @skill_name.x = @org_x - 50 @skill_name.bitmap.draw_text(0,0,200,32,@skillname.to_s,1) end #-------------------------------------------------------------------------- # ● Create Button Sprite #-------------------------------------------------------------------------- def create_button_sprite @button_image = $game_temp.cache_active_chain[3] @button_cw = @button_image.width / 13 ; @button_ch = @button_image.height @button_sprite = Sprite.new @button_sprite.bitmap = Bitmap.new(@button_cw,@button_ch) @button_sprite.z = CHAIN_SPRITE_Z + 1 @button_sprite.ox = @button_cw / 2 ; @button_sprite.oy = @button_ch / 2 @button_sprite_oxy = [@button_sprite.ox,@button_sprite.oy] @button_sprite.x = @x + @button_sprite.ox - (@button_cw / 2) @button_sprite.y = @y + @button_sprite.oy end #-------------------------------------------------------------------------- # ● Refresh Button Command #-------------------------------------------------------------------------- def refresh_button_command return if @button_sprite == nil @duration[0] = @duration[1] command_list_check(@chain_command[@com_index]) @button_sprite.bitmap.clear button_scr = Rect.new(@com * @button_cw , 0,@button_cw,@button_ch) @button_sprite.bitmap.blt(0,0,@button_image,button_scr) @button_sprite.zoom_x = 1.3 ; @button_sprite.zoom_y = 1.3 @button_sprite.opacity = 255 end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- def dispose dispose_button ; dispose_meter ; dispose_name ; dispose_icon_sprite $game_temp.chain_actions[3] = false ; $game_temp.active_chain = false end #-------------------------------------------------------------------------- # ● Dispose Icon Sprite #-------------------------------------------------------------------------- def dispose_icon_sprite return if @icon_sprite == nil @icon_sprite.bitmap.dispose ; @icon_sprite.dispose ; @icon_sprite = nil end #-------------------------------------------------------------------------- # ● Dispose Name #-------------------------------------------------------------------------- def dispose_name return if @skill_name == nil @skill_name.bitmap.dispose ; @skill_name.dispose ; @skill_name = nil end #-------------------------------------------------------------------------- # ● Dispose Button #-------------------------------------------------------------------------- def dispose_button return if @button_sprite == nil @button_sprite.bitmap.dispose ; @button_sprite.dispose ; @button_sprite = nil end #-------------------------------------------------------------------------- # ● Dispose Meter #-------------------------------------------------------------------------- def dispose_meter return if @meter_layout == nil @meter_layout.dispose ; @meter_layout = nil @meter.bitmap.dispose ; @meter.dispose end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- def update(battler) if @initial_wait > 0 @initial_wait -= 1 if @initial_wait == 0 refresh_button_command ; @meter.visible = true @meter_layout.visible = true set_opacity(0) end return end if @wrong_commnad[0] update_fade_command return else update_opacity end update_command ; update_sprite_button ; update_time ; update_meter update_battle_camera if oxy_camera?(battler) end #-------------------------------------------------------------------------- # ● OXY_CAMERA #-------------------------------------------------------------------------- def oxy_camera?(battler) return false if battler == nil return false if $imported[:mog_battle_camera] == nil if battler.is_a?(Game_Actor) return false if $imported[:mog_battle_hud_ex] and SceneManager.face_battler? end return true end #-------------------------------------------------------------------------- # ● Update Battle Camera #-------------------------------------------------------------------------- def update_battle_camera @meter_layout.ox = $game_temp.viewport_oxy[0] @meter_layout.oy = $game_temp.viewport_oxy[1] @meter.ox = $game_temp.viewport_oxy[0] @meter.oy = $game_temp.viewport_oxy[1] @skill_name.ox = $game_temp.viewport_oxy[0] @skill_name.oy = $game_temp.viewport_oxy[1] @button_sprite.ox = $game_temp.viewport_oxy[0] + @button_sprite_oxy[0] @button_sprite.oy = $game_temp.viewport_oxy[1] + @button_sprite_oxy[1] @icon_sprite.ox = $game_temp.viewport_oxy[0] @icon_sprite.oy = $game_temp.viewport_oxy[1] end #-------------------------------------------------------------------------- # ● Set Opacity #-------------------------------------------------------------------------- def set_opacity(opc) @meter_layout.opacity = opc @meter.opacity = opc @skill_name.opacity = opc @button_sprite.opacity = opc @icon_sprite.opacity = opc end #-------------------------------------------------------------------------- # ● Update Opacity #-------------------------------------------------------------------------- def update_opacity @meter_layout.opacity += 75 @meter.opacity += 75 @skill_name.opacity += 75 @button_sprite.opacity += 75 @icon_sprite.opacity += 75 end #-------------------------------------------------------------------------- # ● Update Skill Name #-------------------------------------------------------------------------- def update_fade_command fade_speed = 6 @skill_name.opacity -= fade_speed ; @meter.opacity -= fade_speed @meter_layout.opacity -= fade_speed ; @icon_sprite.opacity -= fade_speed @button_sprite.opacity -= fade_speed * 2 ; missed if @meter.opacity == 0 end #-------------------------------------------------------------------------- # ● Update Skill Name #-------------------------------------------------------------------------- def update_skill_name return if @skill_name == nil if @skill_name.x < @org_x @skill_name.x += 3 ; @icon_sprite.x += 3 if @skill_name.x > @org_x @skill_name.x = @org_x ; @icon_sprite.x = @org_x2 end end end #-------------------------------------------------------------------------- # ● Update Time #-------------------------------------------------------------------------- def update_time return if @button_sprite == nil @duration[0] -= 1 if @duration[0] > 0 wrong_command(1) if @duration[0] == 0 end #-------------------------------------------------------------------------- # ● Update Sprite Button #-------------------------------------------------------------------------- def update_sprite_button return if @button_sprite == nil if @button_sprite.zoom_x > 1.00 @button_sprite.zoom_x -= 0.05 @button_sprite.zoom_x = 1.00 if @button_sprite.zoom_x < 1.00 end @button_sprite.zoom_y = @button_sprite.zoom_x end #-------------------------------------------------------------------------- # ● Update Command #-------------------------------------------------------------------------- def update_command if Input.trigger?(:X) ; check_command(0) elsif Input.trigger?(:Z) ; check_command(1) elsif Input.trigger?(:Y) ; check_command(2) elsif Input.trigger?(:A) ; check_command(3) elsif Input.trigger?(:C) ; check_command(4) elsif Input.trigger?(:B) ; check_command(5) elsif Input.trigger?(:L) ; check_command(6) elsif Input.trigger?(:R) ; check_command(7) elsif Input.trigger?(:RIGHT) ; check_command(8) elsif Input.trigger?(:LEFT) ; check_command(9) elsif Input.trigger?(:DOWN) ; check_command(10) elsif Input.trigger?(:UP) ; check_command(11) end end #-------------------------------------------------------------------------- # ● command_list_check #-------------------------------------------------------------------------- def command_list_check(command) case command when "A" ; @com = 0 when "D" ; @com = 1 when "S" ; @com = 2 when "Shift" ; @com = 3 when "Z" ; @com = 4 when "X" ; @com = 5 when "Q" ; @com = 6 when "W" ; @com = 7 when "Right" ; @com = 8 when "Left" ; @com = 9 when "Down" ; @com = 10 when "Up" ; @com = 11 else ; @com = 12 end end #-------------------------------------------------------------------------- # ● check_command #-------------------------------------------------------------------------- def check_command(com) if com != -1 right_input = false @chain_command.each_with_index do |i, index| if index == @com_index command_list_check(i) ; right_input = true if @com == com end end else command_list_check(@com_index) ; right_input = true end if right_input next_command else wrong_command(0) end end #-------------------------------------------------------------------------- # ● Next Command #-------------------------------------------------------------------------- def next_command @com_index += 1 Audio.se_play("Audio/SE/" + CHAIN_RIGHT_SE, 100, 100) if @com_index == @chain_command.size @phase = 9 ; @success = true return end refresh_button_command end #-------------------------------------------------------------------------- # ● wrong_command #-------------------------------------------------------------------------- def wrong_command(type = 0) @wrong_commnad[0] = true ; @wrong_commnad[1] = type @skill_name.bitmap.clear Audio.se_play("Audio/SE/" + CHAIN_WRONG_SE, 100, 100) wname = type == 0 ? CHAIN_MISSED_WORDS[0] : CHAIN_MISSED_WORDS[1] @skill_name.bitmap.draw_text(0,0,200,32,wname.to_s,1) end #-------------------------------------------------------------------------- # ● missed #-------------------------------------------------------------------------- def missed @success = false ; @phase = 9 end end
#==============================================================================
# +++ MOG - 战斗输入挑战 (v3.3) +++
#==============================================================================
# By Moghunter
# [url]https://atelierrgss.wordpress.com/[/url]
#==============================================================================
# 在技能发动之前可以设定一个输入挑战,全部输入正确后才能施放技能.
#==============================================================================
# 需要以下图片,放在 Graphics/System/
#
# Chain_Command.png
# Chain_Battle_Layout.png
# Chain_Battle_Meter.png
#
#==============================================================================
# 使用方法
#==============================================================================
# 技能备注:
#
# <Chain Action = X>
#
# X - 技能ID
#==============================================================================
#==============================================================================
# ● Histórico (Version History)
#==============================================================================
# v3.3 - Melhoria na compatibilidade com MOG Battle Camera
# v3.2 - Compatibilidade com MOG Sprite Actor.
# v3.1 - Compatibilidade com MOG Battle Camera.
# v3.0 - Adição de comandos aleatórios.
# v2.9 - Correção do bug de não ocultar a janela com MOG ATB.
# v2.8 - Melhoria na codificação.
#==============================================================================
$imported = {} if $imported.nil?
$imported[:mog_active_chain] = true
module MOG_CHAIN_ACTIONS
#=============================================================================
# CHAIN_ACTIONS = { 技能ID => [按键顺序] }
#
# 技能ID = 数据库中的技能ID.
# 按键顺序 = 设定按键顺序
# (以下为全部可用按键)
#
# "Down" ,"Up" ,"Left" ,"Right" ,"Shift" ,"D" ,"S" ,"A" ,"Z" ,"X" ,"Q" ,"W",
# "Random"
#
# 例子:
#
# CHAIN_ACTIONS = {
# 25=>["Down","D","S","Right"],
# 59=>["Down","Up","Left","Right","Shift","D","S","A","Z","X","Q","W"],
# 80=>["Shift","D"]
# }
#==============================================================================
CHAIN_ACTIONS = {
29=>["Random","Random","Random","Random"],
52=>["Up","Down","Left","Right","Z"],
70=>["X","Right","Left","Z","Z"],
138=>["Random"],
139=>["Random","Random"],
140=>["Random","Random","Random"],
#138=>["X"],
#139=>["A","S"],
#140=>["Z","D","X"],
141=>["Up","Down"],
142=>["Left","Right","Z"],
999=>["Left","Right","Left","Right","Left","Right","Q","Z","Up","A","S",
"Down","D","Z","Right","Up","Up","Z","W","Left","Down","D","A","W"]
}
#设置随机指令.
RANDOM_KEYS = ["Left","Right","Up","Down","D","S","A","Z","X"]
#默认按键的等待时间(玩家需要正确按下的时间).
CHAIN_DEFAULT_INPUT_DURATION = 60 #60帧 = 1s
#指定按键的等待时间
CHAIN_INPUT_DURATION = {
138=>60,
139=>40,
140=>30
#141=>160,
#240=>2000
}
#正确点击时的音效.
CHAIN_RIGHT_SE = "Chime1"
#错误点击时的音效.
CHAIN_WRONG_SE = "Buzzer1"
#输入挑战开始时播放的音效.
CHAIN_START_SE = "Open1"
#输入挑战精灵的位置.
CHAIN_SPRITE_POSITION = [0,-15]
#输入挑战图片的位置
CHAIN_LAYOUT_POSITION = [1,-7]
#进度条图片的位置
CHAIN_METER_POSITION = [0,-6]
#图标的位置
CHAIN_ICON_POSITION = [0,-32]
#输入挑战开始时显示的文字.
CHAIN_COMMAND_WORD = "输入挑战!"
#未命中和时间结束的文字
CHAIN_MISSED_WORDS = ["未命中!", "时间结束"]
#文字位置
CHAIN_COMMAND_WORD_POSITION = [0,0]
#文字大小
CHAIN_WORD_FONT_SIZE = 20
#文字颜色
CHAIN_WORD_FONT_COLOR = Color.new(255,255,255)
#文字Z坐标
CHAIN_SPRITE_Z = 150
end
#==============================================================================
# ■ Game Temp
#==============================================================================
class Game_Temp
attr_accessor :chain_actions
attr_accessor :active_chain
attr_accessor :chain_ot
attr_accessor :chain_action_phase
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_chain_actions_initialize initialize
def initialize
@chain_actions = [0,0,0,false] ; @active_chain = false
@chain_action_phase = false
mog_chain_actions_initialize
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Use Item
#--------------------------------------------------------------------------
alias mog_chain_actions_use_item use_item
def use_item
prepare_chain_command if can_use_chain_commands?
mog_chain_actions_use_item
execute_chain_actions if can_use_chain_commands?
end
#--------------------------------------------------------------------------
# ● Can Use Chain Commands
#--------------------------------------------------------------------------
def can_use_chain_commands?
return false if @subject == nil
return false if !@subject.is_a?(Game_Actor)
return false if @subject.restriction != 0
return true
end
#--------------------------------------------------------------------------
# ● Prepare Chain Commands
#--------------------------------------------------------------------------
def prepare_chain_command
@chain_skill_original = @subject.current_action.item rescue nil
if $game_temp.chain_ot == nil and @subject.is_a?(Game_Actor)
targets = @subject.current_action.make_targets.compact
$game_temp.chain_ot = targets[0]
end
check_chain_targets
end
#--------------------------------------------------------------------------
# ● Check Chain Command Position
#--------------------------------------------------------------------------
def check_chain_command_position
scx = $game_temp.chain_ot.screen_x rescue nil
return if scx == nil
if $game_temp.chain_ot != nil and !$game_temp.chain_ot.dead?
$game_temp.chain_actions = [$game_temp.chain_ot.screen_x,$game_temp.chain_ot.screen_y,true]
end
end
#--------------------------------------------------------------------------
# ● Check Chain Targets
#--------------------------------------------------------------------------
def check_chain_targets
return if @subject == nil or $game_temp.chain_ot == nil
if [1,7,9,10,11].include?(@subject.current_action.item.scope)
@pre_target = $game_temp.chain_ot ; @pre_target_hp = $game_temp.chain_ot.hp
else
@pre_target = nil ; @pre_target_hp = nil
end
end
#--------------------------------------------------------------------------
# ● Execute Chain Actions
#--------------------------------------------------------------------------
def execute_chain_actions
$game_temp.active_chain = false
return if !can_execute_chain_actions_base?
check_chain_command_position
skill = @subject.current_action.item rescue nil
skill = @chain_skill_original rescue nil
action_id = skill.note =~ /<Chain Action = (\d+)>/i ? $1.to_i : nil rescue nil
return if action_id == nil or action_id < 1
chain_command_sequence = MOG_CHAIN_ACTIONS::CHAIN_ACTIONS[action_id].dup rescue nil
$game_temp.chain_actions[2] = action_id
if can_execute_chain_sequence?(chain_command_sequence,action_id)
chain_act_before_action if @chain_command == nil
chain_sq = Chain_Actions.new(chain_command_sequence,$game_temp.chain_actions)
loop do
$game_temp.chain_action_phase = true
(chain_sq.update($game_temp.chain_ot) ; Input.update) unless @spriteset.animation?
$game_temp.active_chain = true ; chain_sq.update_skill_name
@spriteset.update ; Graphics.update ; update_info_viewport
break if chain_sq.phase == 9
end
@subject.wp_animation = [true,chain_sq.success] if $imported[:mog_sprite_actor]
action_id = nil if !chain_sq.success or $game_temp.chain_ot.dead?
chain_sq.dispose ; set_chain_skill(action_id) if action_id != nil
end
$game_temp.active_chain = false ; $game_temp.chain_ot = nil
$game_temp.chain_action_phase = false
end
#--------------------------------------------------------------------------
# ● Chain Act Before Action
#--------------------------------------------------------------------------
def chain_act_before_action
@chain_command = true ; @bb_cursor
if $imported[:mog_battle_cursor]
@bb_cursor = $game_temp.battle_cursor[2]
$game_temp.battle_cursor[2] = false
end
if $imported[:mog_menu_cursor]
@chain_curor_x = $game_temp.menu_cursor[2]
$game_temp.menu_cursor[2] = -999
force_cursor_visible(false)
end
if $imported[:mog_atb_system]
record_window_data if @wd_rec.nil?
hide_base_window
@wd_rec = true
end
end
#--------------------------------------------------------------------------
# ● Turn End
#--------------------------------------------------------------------------
alias mog_chain_command_process_action_end process_action_end
def process_action_end
mog_chain_command_process_action_end
chain_act_after_action
end
#--------------------------------------------------------------------------
# ● Chain Act After ACtion
#--------------------------------------------------------------------------
def chain_act_after_action
@chain_skill_original = nil
$game_temp.chain_ot = nil
return if @chain_command == nil
restore_window_data if $imported[:mog_atb_system]
$game_temp.menu_cursor[2] = @chain_curor_x if $imported[:mog_menu_cursor]
$game_temp.battle_cursor[2] = @bb_cursor if @bb_cursor != nil
@chain_command = nil
end
#--------------------------------------------------------------------------
# ● Set Chain Skill
#--------------------------------------------------------------------------
def set_chain_skill(action_id)
return if action_id == nil
@subject.input.set_skill(action_id)
$game_temp.chain_actions = [0,0,0,false] ; execute_action
end
#--------------------------------------------------------------------------
# ● Can Execute Chain Sequence?
#--------------------------------------------------------------------------
def can_execute_chain_sequence?(chain_command_sequence = nil,action_id = nil)
return false if chain_command_sequence == nil
skill = $data_skills[action_id] rescue nil
return false if skill == nil
return false if $game_temp.chain_ot == nil or $game_temp.chain_ot.dead?
if [9,10].include?(skill.scope)
$game_party.battle_members.each do |i| return true if i.dead? end
return false
end
return true
end
#--------------------------------------------------------------------------
# ● Can Execute Chain Actions Base
#--------------------------------------------------------------------------
def can_execute_chain_actions_base?
return false if @subject == nil or @subject.dead?
return false if $game_temp.chain_ot == nil or $game_temp.chain_ot.dead?
return false if @subject.is_a?(Game_Enemy)
return false if @subject.current_action == nil
@subject.states.each do |i| return false if i.restriction > 0 end
return false if $game_party.members.empty?
return false if $game_party.all_dead?
return false if $game_troop.all_dead?
if @pre_target != nil and $game_temp.chain_ot.hp == @pre_target_hp
return false if $game_temp.chain_ot.result.missed
return false if $game_temp.chain_ot.result.evaded
end
return true
end
#--------------------------------------------------------------------------
# ● Turn End
#--------------------------------------------------------------------------
alias mog_chain_command_turn_end turn_end
def turn_end
mog_chain_command_turn_end
@wd_rec = nil
end
end
#==============================================================================
# ■ Game Temp
#==============================================================================
class Game_Temp
attr_accessor :cache_active_chain
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_active_chain_initialize initialize
def initialize
mog_active_chain_initialize
cache_act_chain
end
#--------------------------------------------------------------------------
# ● Cache Act Chain
#--------------------------------------------------------------------------
def cache_act_chain
@cache_active_chain = []
@cache_active_chain.push(Cache.system("IconSet"))
@cache_active_chain.push(Cache.system("Chain_Battle_Layout"))
@cache_active_chain.push(Cache.system("Chain_Battle_Meter"))
@cache_active_chain.push(Cache.system("Chain_Battle_Command"))
end
end
#==============================================================================
# ■ Spriteset Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_active_chain_commands_initialize initialize
def initialize
$game_temp.cache_act_chain ; $game_temp.active_chain = false
$game_temp.chain_ot = nil
mog_active_chain_commands_initialize
end
end
#==============================================================================
# ■ Chain Actions
#==============================================================================
class Chain_Actions
include MOG_CHAIN_ACTIONS
attr_accessor :phase
attr_accessor :success
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(sequence,chain_temp)
$game_temp.chain_actions[3] = true
@chain_command_original = sequence.dup
@chain_command = sequence
random_sequence
@x = chain_temp[0] + CHAIN_SPRITE_POSITION[0]
@y = chain_temp[1] + CHAIN_SPRITE_POSITION[1]
@y = (Graphics.height - 36) if @y > (Graphics.height - 36)
@y = 0 if @y < 0
@skill = $data_skills[chain_temp[2]]
@skillname = @skill.name
if CHAIN_INPUT_DURATION[chain_temp[2]] != nil
@duration = [CHAIN_INPUT_DURATION[chain_temp[2]],CHAIN_INPUT_DURATION[chain_temp[2]]]
else
@duration = [CHAIN_DEFAULT_INPUT_DURATION, CHAIN_DEFAULT_INPUT_DURATION]
end
@phase = 0 ; @success = false ; @com = 0 ; @com_index = 0
@initial_wait = 1 ; @wrong_commnad = [false,0,0]
Audio.se_play("Audio/SE/" + CHAIN_START_SE, 100, 100) rescue nil
create_button_sprite ; create_skill_name ; create_icon ; create_meter
set_opacity(0)
end
#--------------------------------------------------------------------------
# ● Random Sequence
#--------------------------------------------------------------------------
def random_sequence
@chain_command_original.each_with_index do |c, i|
next if c != "Random"
k = rand(RANDOM_KEYS.size) ; @chain_command[i] = RANDOM_KEYS[k]
end
end
#--------------------------------------------------------------------------
# ● Create Icon
#--------------------------------------------------------------------------
def create_icon
@icon_image = $game_temp.cache_active_chain[0]
@icon_sprite = Sprite.new ; @icon_sprite.bitmap = Bitmap.new(24,24)
@icon_sprite.z = CHAIN_SPRITE_Z + 1
@org_x2 = @x - 12 + CHAIN_ICON_POSITION[0] - @center
@icon_sprite.x = @org_x2 - 50
@icon_sprite.y = @y + CHAIN_ICON_POSITION[1]
icon_rect = Rect.new(@skill.icon_index % 16 * 24, @skill.icon_index / 16 * 24, 24, 24)
@icon_sprite.bitmap.blt(0,0, @icon_image, icon_rect)
end
#--------------------------------------------------------------------------
# ● Create Meter
#--------------------------------------------------------------------------
def create_meter
@meter_layout = Sprite.new
@meter_layout.bitmap = $game_temp.cache_active_chain[1]
@meter_layout.z = CHAIN_SPRITE_Z
@meter_layout.x = @x - (@meter_layout.width / 2) + CHAIN_LAYOUT_POSITION[0]
@meter_layout.y = @y + CHAIN_LAYOUT_POSITION[1]
@meter_image = $game_temp.cache_active_chain[2]
@meter_cw = @meter_image.width ; @meter_ch = @meter_image.height
@meter = Sprite.new
@meter.bitmap = Bitmap.new(@meter_image.width, @meter_image.height)
@meter.z = CHAIN_SPRITE_Z + 1
@meter.x = @x - (@meter_image.width / 2) + CHAIN_METER_POSITION[0]
@meter.y = @y + CHAIN_METER_POSITION[1]
@meter.visible = false ; @meter_layout.visible = false ; update_meter
end
#--------------------------------------------------------------------------
# ● Update Meter
#--------------------------------------------------------------------------
def update_meter
return if @meter == nil
@meter.bitmap.clear ; range = @meter_cw * @duration[0] / @duration[1]
m_scr = Rect.new(0,0,range,@meter_ch )
@meter.bitmap.blt(0,0, @meter_image ,m_scr)
end
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def create_skill_name
@skill_name = Sprite.new ; @skill_name.bitmap = Bitmap.new(200,32)
@skill_name.bitmap.font.size = CHAIN_WORD_FONT_SIZE
@skill_name.bitmap.font.color = CHAIN_WORD_FONT_COLOR
@skill_name.z = CHAIN_SPRITE_Z
@skill_name.y = @y - 32 + CHAIN_COMMAND_WORD_POSITION[1]
refresh_skill_name
end
#--------------------------------------------------------------------------
# ● Refresh Skill Name
#--------------------------------------------------------------------------
def refresh_skill_name
cm = @skillname.to_s.split(//).size
@center = ((200 / @skill_name.bitmap.font.size) * cm / 2) + 5
@org_x = @x - (@button_cw / 2) - 85 + CHAIN_COMMAND_WORD_POSITION[0]
@skill_name.x = @org_x - 50
@skill_name.bitmap.draw_text(0,0,200,32,@skillname.to_s,1)
end
#--------------------------------------------------------------------------
# ● Create Button Sprite
#--------------------------------------------------------------------------
def create_button_sprite
@button_image = $game_temp.cache_active_chain[3]
@button_cw = @button_image.width / 13 ; @button_ch = @button_image.height
@button_sprite = Sprite.new
@button_sprite.bitmap = Bitmap.new(@button_cw,@button_ch)
@button_sprite.z = CHAIN_SPRITE_Z + 1
@button_sprite.ox = @button_cw / 2 ; @button_sprite.oy = @button_ch / 2
@button_sprite_oxy = [@button_sprite.ox,@button_sprite.oy]
@button_sprite.x = @x + @button_sprite.ox - (@button_cw / 2)
@button_sprite.y = @y + @button_sprite.oy
end
#--------------------------------------------------------------------------
# ● Refresh Button Command
#--------------------------------------------------------------------------
def refresh_button_command
return if @button_sprite == nil
@duration[0] = @duration[1]
command_list_check(@chain_command[@com_index])
@button_sprite.bitmap.clear
button_scr = Rect.new(@com * @button_cw , 0,@button_cw,@button_ch)
@button_sprite.bitmap.blt(0,0,@button_image,button_scr)
@button_sprite.zoom_x = 1.3 ; @button_sprite.zoom_y = 1.3
@button_sprite.opacity = 255
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
dispose_button ; dispose_meter ; dispose_name ; dispose_icon_sprite
$game_temp.chain_actions[3] = false ; $game_temp.active_chain = false
end
#--------------------------------------------------------------------------
# ● Dispose Icon Sprite
#--------------------------------------------------------------------------
def dispose_icon_sprite
return if @icon_sprite == nil
@icon_sprite.bitmap.dispose ; @icon_sprite.dispose ; @icon_sprite = nil
end
#--------------------------------------------------------------------------
# ● Dispose Name
#--------------------------------------------------------------------------
def dispose_name
return if @skill_name == nil
@skill_name.bitmap.dispose ; @skill_name.dispose ; @skill_name = nil
end
#--------------------------------------------------------------------------
# ● Dispose Button
#--------------------------------------------------------------------------
def dispose_button
return if @button_sprite == nil
@button_sprite.bitmap.dispose ; @button_sprite.dispose ; @button_sprite = nil
end
#--------------------------------------------------------------------------
# ● Dispose Meter
#--------------------------------------------------------------------------
def dispose_meter
return if @meter_layout == nil
@meter_layout.dispose ; @meter_layout = nil
@meter.bitmap.dispose ; @meter.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update(battler)
if @initial_wait > 0
@initial_wait -= 1
if @initial_wait == 0
refresh_button_command ; @meter.visible = true
@meter_layout.visible = true
set_opacity(0)
end
return
end
if @wrong_commnad[0]
update_fade_command
return
else
update_opacity
end
update_command ; update_sprite_button ; update_time ; update_meter
update_battle_camera if oxy_camera?(battler)
end
#--------------------------------------------------------------------------
# ● OXY_CAMERA
#--------------------------------------------------------------------------
def oxy_camera?(battler)
return false if battler == nil
return false if $imported[:mog_battle_camera] == nil
if battler.is_a?(Game_Actor)
return false if $imported[:mog_battle_hud_ex] and SceneManager.face_battler?
end
return true
end
#--------------------------------------------------------------------------
# ● Update Battle Camera
#--------------------------------------------------------------------------
def update_battle_camera
@meter_layout.ox = $game_temp.viewport_oxy[0]
@meter_layout.oy = $game_temp.viewport_oxy[1]
@meter.ox = $game_temp.viewport_oxy[0]
@meter.oy = $game_temp.viewport_oxy[1]
@skill_name.ox = $game_temp.viewport_oxy[0]
@skill_name.oy = $game_temp.viewport_oxy[1]
@button_sprite.ox = $game_temp.viewport_oxy[0] + @button_sprite_oxy[0]
@button_sprite.oy = $game_temp.viewport_oxy[1] + @button_sprite_oxy[1]
@icon_sprite.ox = $game_temp.viewport_oxy[0]
@icon_sprite.oy = $game_temp.viewport_oxy[1]
end
#--------------------------------------------------------------------------
# ● Set Opacity
#--------------------------------------------------------------------------
def set_opacity(opc)
@meter_layout.opacity = opc
@meter.opacity = opc
@skill_name.opacity = opc
@button_sprite.opacity = opc
@icon_sprite.opacity = opc
end
#--------------------------------------------------------------------------
# ● Update Opacity
#--------------------------------------------------------------------------
def update_opacity
@meter_layout.opacity += 75
@meter.opacity += 75
@skill_name.opacity += 75
@button_sprite.opacity += 75
@icon_sprite.opacity += 75
end
#--------------------------------------------------------------------------
# ● Update Skill Name
#--------------------------------------------------------------------------
def update_fade_command
fade_speed = 6
@skill_name.opacity -= fade_speed ; @meter.opacity -= fade_speed
@meter_layout.opacity -= fade_speed ; @icon_sprite.opacity -= fade_speed
@button_sprite.opacity -= fade_speed * 2 ; missed if @meter.opacity == 0
end
#--------------------------------------------------------------------------
# ● Update Skill Name
#--------------------------------------------------------------------------
def update_skill_name
return if @skill_name == nil
if @skill_name.x < @org_x
@skill_name.x += 3 ; @icon_sprite.x += 3
if @skill_name.x > @org_x
@skill_name.x = @org_x ; @icon_sprite.x = @org_x2
end
end
end
#--------------------------------------------------------------------------
# ● Update Time
#--------------------------------------------------------------------------
def update_time
return if @button_sprite == nil
@duration[0] -= 1 if @duration[0] > 0
wrong_command(1) if @duration[0] == 0
end
#--------------------------------------------------------------------------
# ● Update Sprite Button
#--------------------------------------------------------------------------
def update_sprite_button
return if @button_sprite == nil
if @button_sprite.zoom_x > 1.00
@button_sprite.zoom_x -= 0.05
@button_sprite.zoom_x = 1.00 if @button_sprite.zoom_x < 1.00
end
@button_sprite.zoom_y = @button_sprite.zoom_x
end
#--------------------------------------------------------------------------
# ● Update Command
#--------------------------------------------------------------------------
def update_command
if Input.trigger?(:X) ; check_command(0)
elsif Input.trigger?(:Z) ; check_command(1)
elsif Input.trigger?(:Y) ; check_command(2)
elsif Input.trigger?(:A) ; check_command(3)
elsif Input.trigger?(:C) ; check_command(4)
elsif Input.trigger?(:B) ; check_command(5)
elsif Input.trigger?(:L) ; check_command(6)
elsif Input.trigger?(:R) ; check_command(7)
elsif Input.trigger?(:RIGHT) ; check_command(8)
elsif Input.trigger?(:LEFT) ; check_command(9)
elsif Input.trigger?(:DOWN) ; check_command(10)
elsif Input.trigger?(:UP) ; check_command(11)
end
end
#--------------------------------------------------------------------------
# ● command_list_check
#--------------------------------------------------------------------------
def command_list_check(command)
case command
when "A" ; @com = 0
when "D" ; @com = 1
when "S" ; @com = 2
when "Shift" ; @com = 3
when "Z" ; @com = 4
when "X" ; @com = 5
when "Q" ; @com = 6
when "W" ; @com = 7
when "Right" ; @com = 8
when "Left" ; @com = 9
when "Down" ; @com = 10
when "Up" ; @com = 11
else ; @com = 12
end
end
#--------------------------------------------------------------------------
# ● check_command
#--------------------------------------------------------------------------
def check_command(com)
if com != -1
right_input = false
@chain_command.each_with_index do |i, index|
if index == @com_index
command_list_check(i) ; right_input = true if @com == com
end
end
else
command_list_check(@com_index) ; right_input = true
end
if right_input
next_command
else
wrong_command(0)
end
end
#--------------------------------------------------------------------------
# ● Next Command
#--------------------------------------------------------------------------
def next_command
@com_index += 1
Audio.se_play("Audio/SE/" + CHAIN_RIGHT_SE, 100, 100)
if @com_index == @chain_command.size
@phase = 9 ; @success = true
return
end
refresh_button_command
end
#--------------------------------------------------------------------------
# ● wrong_command
#--------------------------------------------------------------------------
def wrong_command(type = 0)
@wrong_commnad[0] = true ; @wrong_commnad[1] = type
@skill_name.bitmap.clear
Audio.se_play("Audio/SE/" + CHAIN_WRONG_SE, 100, 100)
wname = type == 0 ? CHAIN_MISSED_WORDS[0] : CHAIN_MISSED_WORDS[1]
@skill_name.bitmap.draw_text(0,0,200,32,wname.to_s,1)
end
#--------------------------------------------------------------------------
# ● missed
#--------------------------------------------------------------------------
def missed
@success = false ; @phase = 9
end
end
|
|