查看: 1157|回复: 4

[已经过期] 箭头输入挑战脚本,不知道怎么触发。。。

[复制链接]
梦石
0
星屑
433
在线时间
50 小时
注册时间
2017-1-10
回帖
16
发表于 2018-6-28 12:05:54 | 显示全部楼层 |阅读模式

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

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

×
看到一个不错的东西,输入箭头挑战,但是不知道怎么在大地图中触发


这是原地址貌似
https://atelierrgss.wordpress.com/rgss3-chain-commands-m/

大地图版,下面是战斗中的,技能备注了没用。。。求大神帮忙


[pre lang="ruby"]#===============================================================================
# +++ MOG - 输入挑战 (v1.4) +++
#===============================================================================
# By Moghunter                                                               
# https://atelierrgss.wordpress.com/                  
#===============================================================================
# 输入挑战成功时开启开关
#
# 需要以下图片. (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[/pre]

[pre lang="ruby"]#==============================================================================
# +++ MOG - 战斗输入挑战 (v3.3) +++
#==============================================================================
# By Moghunter
# https://atelierrgss.wordpress.com/
#==============================================================================
# 在技能发动之前可以设定一个输入挑战,全部输入正确后才能施放技能.
#==============================================================================
# 需要以下图片,放在 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 = 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[/pre]
梦石
1
星屑
14374
在线时间
2109 小时
注册时间
2017-9-28
回帖
607
发表于 2018-6-28 13:06:45 | 显示全部楼层
本帖最后由 Nil2018 于 2018-6-28 13:08 编辑

仔细一看,好像战斗输入挑战的我翻错了,技能id那里
VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复

使用道具 举报

梦石
0
星屑
2870
在线时间
1074 小时
注册时间
2015-11-1
回帖
261
发表于 2018-6-28 20:38:42 | 显示全部楼层
印象中,mog是有几个工程范例大整合的,其中也包括这个,很久以前论坛下过的,不知道现在还有没有。

-
顺带一提,mog的这个外加一个按键连招我就没有完整输入过。。。我觉得RPG游戏里面加入这个玩法对我这类玩家太不友好了。
回复

使用道具 举报

梦石
0
星屑
433
在线时间
50 小时
注册时间
2017-1-10
回帖
16
 楼主| 发表于 2018-6-28 20:51:14 | 显示全部楼层
QQ图片20180628204832.png

找到范例了,但是在范例能用,搁我的里提示这个,不懂
回复

使用道具 举报

梦石
0
星屑
433
在线时间
50 小时
注册时间
2017-1-10
回帖
16
 楼主| 发表于 2018-6-29 10:57:52 | 显示全部楼层
原来和大窗口脚本冲突了,求帮忙


  1. #=============================================================================
  2. # Σ Fullscreen
  3. #-----------------------------------------------------------------------------
  4. # @author  : Gabriel "Gab!" Teles
  5. # @date    : 2014-09-27
  6. # @version : 0.9.2
  7. #-----------------------------------------------------------------------------
  8. # TODO:
  9. #   - Transições por imagens
  10. #-----------------------------------------------------------------------------
  11. # Créditos:
  12. #   Scripter Desconhecido no Pastebin (http://pastebin.com/sM2MNJZj)
  13. #   Esrever : Map viewport/scroll fix
  14. #   Zeus81  : FPS Display
  15. #-----------------------------------------------------------------------------
  16. # Permite utilizar fullscreen real (sem redimensionamento de tela), e alterar
  17. # o limite da função Graphics.resize_screen para a resolução máxima do monitor
  18. # ou um valor próximo.
  19. #=============================================================================

  20. # Módulo Graphics
  21. class << Graphics
  22.   # API
  23.   User32   = DL.dlopen('user32')
  24.   Kernel32 = DL.dlopen('kernel32')
  25.   GetActiveWindow  = DL::CFunc.new(  User32['GetActiveWindow' ], DL::TYPE_LONG)
  26.   GetSystemMetrics = DL::CFunc.new(  User32['GetSystemMetrics'], DL::TYPE_LONG)
  27.   GetWindowRect    = DL::CFunc.new(  User32['GetWindowRect'   ], DL::TYPE_LONG)
  28.   SetWindowLong    = DL::CFunc.new(  User32['SetWindowLong'   ], DL::TYPE_LONG)
  29.   SetWindowPos     = DL::CFunc.new(  User32['SetWindowPos'    ], DL::TYPE_LONG)
  30.   GetModuleHandle  = DL::CFunc.new(Kernel32['GetModuleHandle' ], DL::TYPE_LONG)  

  31.   # DLL sendo utilizada
  32.   _DLLName = DL::CPtr.malloc(140)
  33.   s = DL::CFunc.new(Kernel32['GetPrivateProfileString'], DL::TYPE_LONG).call([
  34.     DL::CPtr["Game"].to_i,
  35.     DL::CPtr["Library"].to_i,
  36.     0,
  37.     _DLLName.to_i,
  38.     140,
  39.     DL::CPtr["./Game.ini"].to_i
  40.   ])

  41.   @@DLLName = File.basename(_DLLName.to_s(s))

  42.   # Verifica se é uma RGSS3xx.dll
  43.   if @@DLLName.match(/^RGSS3(\d{2})\.dll$/)
  44.     @@DLLVersion = $1.to_i
  45.    
  46.     # Verifica se a versão é 0 ou 1.
  47.     if @@DLLVersion.between?(0, 1)
  48.       # Flag de fullscreen
  49.       @@inFullscreen = false
  50.      
  51.       # Instância da DLL. *Necessariamente* a RGSS300.dll ou RGSS301.dll, visto
  52.       # que o trabalho com memória a seguir é específico.
  53.      
  54.       @@DLLHandle   = GetModuleHandle.call([DL::CPtr[@@DLLName].to_i])
  55.      
  56.       # Instância da janela de jogo
  57.       @@hWnd       = GetActiveWindow.call([])
  58.      
  59.       # Tamanho da tela
  60.       @@screenSize = [
  61.         GetSystemMetrics.call([0]),
  62.         GetSystemMetrics.call([1])
  63.       ]
  64.      
  65.       # Calcula o próximo tamanho divisível por 32 para fazer a limitação
  66.       width, height = @@screenSize
  67.       width  += (32 - (width  % 32)) unless (width  % 32).zero?
  68.       height += (32 - (height % 32)) unless (height % 32).zero?
  69.       puts "Limitando para: #{width}x#{height}" if $TEST
  70.      
  71.       #-----------------------------------------------------------------------
  72.       # Bruxaria de scripter desconhecido. Remove a limitação de tamanho para
  73.       # o método Graphics.resize_screen (640x480)
  74.       #
  75.       # Base retirada de: http://pastebin.com/sM2MNJZj
  76.       #
  77.       # Adaptações para a RGSS300.dll e início do mapeamento dos endereços
  78.       # utilizados por Gab!
  79.       #-----------------------------------------------------------------------
  80.      
  81.       # Número para string
  82.       wh = ->(w, h, off = 0){
  83.         [w + off, h + off].pack('l2').scan(/..../)
  84.       }
  85.      
  86.       # Altera um valor na memória relativa à DLL
  87.       mod = ->(adr, val){
  88.         adr += @@OFF if @@DLLVersion.zero?
  89.         DL::CPtr.new(@@DLLHandle + adr)[0, val.size] = val
  90.       }
  91.      
  92.       # Valores úteis
  93.       wt,  ht  = width.divmod(32), height.divmod(32)
  94.       w,   h   = wh.(width, height)
  95.       ww,  hh  = wh.(width, height, 32)
  96.       www, hhh = wh.(wt.first, ht.first, 1)
  97.       zero     = [0].pack('l')
  98.          
  99.       # Faz as alterações na memória
  100.      
  101.       # Graphics
  102.       @@OFF = 0
  103.       mod.(0x195F, "\x90"*5) # ???
  104.       mod.(0x19A4,   h     ) # ???
  105.       mod.(0x19A9,   w     ) # ???
  106.       mod.(0x1A56,   h     ) # ???
  107.       mod.(0x1A5B,   w     ) # ???
  108.       mod.(0x20F6,   w     ) # Max width  (?)
  109.       mod.(0x20FF,   w     ) # Max width  (?)
  110.       mod.(0x2106,   h     ) # Max height (?)
  111.       mod.(0x210F,   h     ) # Max height (?)
  112.      
  113.       # Plane (?) Class
  114.       @@OFF   = -0xC0
  115.       Graphics::PlaneSpeedUp = true
  116.         # Setando para false não é necessário reescrever classe Plane. No
  117.         # entanto, o mapa fica MUITO lento.
  118.       mod.(0x1C5E3,  Graphics::PlaneSpeedUp ? zero : h) # Max height
  119.       mod.(0x1C5E8,  Graphics::PlaneSpeedUp ? zero : w) # Max width
  120.      
  121.       # ???
  122.       @@OFF = 0x20
  123.       mod.(0x1F477,  h     ) # ???
  124.       mod.(0x1F47C,  w     ) # ???
  125.      
  126.       # Tilemap Class
  127.       @@OFF = 0x1E0
  128.       mod.(0x211FF,  hh    ) # Tilemap render height
  129.       mod.(0x21204,  ww    ) # Tilemap render width
  130.       mod.(0x21D7D,  hhh[0]) # Tilemap max tiles on screen height
  131.       mod.(0x21E01,  www[0]) # Tilemap max tiles on screen width
  132.      
  133.       # ???
  134.       @@OFF = 0x140
  135.       mod.(0x10DEA8, h     ) # ???
  136.       mod.(0x10DEAD, w     ) # ???   
  137.       mod.(0x10DEDF, h     ) # ???
  138.       mod.(0x10DEE3, w     ) # ???
  139.       mod.(0x10DF14, h     ) # ???
  140.       mod.(0x10DF18, w     ) # ???
  141.       mod.(0x10DF48, h     ) # ???
  142.       mod.(0x10DF4C, w     ) # ???
  143.       mod.(0x10E6A7, w     ) # ???
  144.       mod.(0x10E6C3, h     ) # ???
  145.       mod.(0x10EEA9, w     ) # ???
  146.       mod.(0x10EEB9, h     ) # ???
  147.      
  148.       #-------------------------------------------------------------------------
  149.       # Fim da bruxaria
  150.       #-------------------------------------------------------------------------
  151.      
  152.       # Sprite de transição de tela
  153.       @@TransitionSprite = Sprite.new
  154.       @@TransitionSprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  155.       @@TransitionSprite.bitmap.fill_rect(@@TransitionSprite.bitmap.rect, Color.new(0, 0, 0))
  156.       @@TransitionSprite.opacity = 0
  157.       @@TransitionSprite.z = 0x7FFFFFFF
  158.      
  159.       # Bitmap da tela no momento do Graphics.freeze
  160.       @@FrozenBitmap = Bitmap.new(Graphics.width, Graphics.height)
  161.       @@FrozenBitmap.fill_rect(@@FrozenBitmap.rect, Color.new(0, 0, 0))
  162.      
  163.       # Realiza a transição de tela
  164.       # Nota: Não é possível realizar transição de tela com imagens
  165.       alias oldFullscreenResTransition transition
  166.       def transition(time, image='', vague=40)
  167.         @@TransitionSprite.bitmap.dispose
  168.         @@TransitionSprite.dispose
  169.         @@TransitionSprite = Sprite.new
  170.         @@TransitionSprite.bitmap = @@FrozenBitmap
  171.         @@TransitionSprite.opacity = 255
  172.         @@TransitionSprite.z = 0x7FFFFFFF
  173.      
  174.         oldFullscreenResTransition(0)
  175.       
  176.         dec = (255.0 / time)
  177.         time.times {
  178.           @@TransitionSprite.opacity -= dec
  179.           Graphics.update
  180.         }
  181.       end
  182.      
  183.       # Fadein
  184.       def fadein(time)
  185.         @@FrozenBitmap = Bitmap.new(Graphics.width, Graphics.height)
  186.         @@FrozenBitmap.fill_rect(@@FrozenBitmap.rect, Color.new(0, 0, 0))
  187.       
  188.         transition(time)
  189.       end
  190.      
  191.       # Fadeout
  192.       def fadeout(time)
  193.         inc = (255.0 / time)
  194.         time.times {
  195.           @@TransitionSprite.opacity += inc
  196.           Graphics.update
  197.         }
  198.       end
  199.      
  200.       # Armazena a imagem da tela
  201.       alias oldFullscreenResFreeze freeze
  202.       def freeze(*a, &b)
  203.         oldFullscreenResFreeze(*a, &b)
  204.         @@FrozenBitmap = Graphics.snap_to_bitmap
  205.       end
  206.      
  207.       # Realiza o redimensionamento de tela
  208.       alias gabFullscreenOldResizeScreen resize_screen
  209.       def resize_screen(*a, &b)
  210.         # Redimensiona normalmente
  211.         gabFullscreenOldResizeScreen(*a, &b)
  212.         # Redimensiona o sprite de transição
  213.         @@TransitionSprite.bitmap.dispose
  214.         @@TransitionSprite.bitmap = Bitmap.new(*Graphics.size)
  215.         @@TransitionSprite.bitmap.fill_rect(@@TransitionSprite.bitmap.rect, Color.new(0, 0, 0))
  216.       
  217.         if Graphics::PlaneSpeedUp
  218.           # Manda o sinal de atualização para todas as instâncias da classe Plane
  219.           ObjectSpace.each_object(Plane){|plane|
  220.             plane.send(:recreateBitmap)
  221.           }
  222.         end
  223.       end
  224.      
  225.       # Altera para fullscreen
  226.       def fullscreen
  227.         # Retorna se já estiver em fullscreen
  228.         return if @@inFullscreen
  229.         # Tamanho antes do fullscreen
  230.         rect = DL::CPtr.malloc(16)
  231.         rect[0, 16] = 0.chr * 16
  232.         GetWindowRect.call([@@hWnd, rect])
  233.         @@windowSize = rect[0, 16].unpack("l*")
  234.         @@windowSize[2] -= @@windowSize[0]
  235.         @@windowSize[3] -= @@windowSize[1]
  236.         @@windowResolution = Graphics.size
  237.         # Muda o tamanho da tela
  238.         Graphics.resize_screen(*@@screenSize)
  239.         # Remover bordas da janela
  240.         SetWindowLong.call([@@hWnd, -16, 0x14000000])
  241.         # Coloca a janela acima de todas as outras
  242.         SetWindowPos.call([@@hWnd, -1, 0, 0, *@@screenSize, 0])
  243.         # Modifica a flag de fullscreen
  244.         @@inFullscreen = true
  245.         # Espera alguns frames para terminar o processamento
  246.         Graphics.wait(5)
  247.       end
  248.      
  249.       # Altera para modo janela
  250.       def windowed
  251.         # Retorna se não estiver em fullscreen
  252.         return unless @@inFullscreen
  253.         # Muda o tamanho da tela
  254.         Graphics.resize_screen(*@@windowResolution)
  255.         # Recoloca bordas da janela
  256.         SetWindowLong.call([@@hWnd, -16, 0x14CA0000])
  257.         # Coloca a janela na posição x,y,z comum e ajusta seu tamanho
  258.         SetWindowPos.call([@@hWnd, 0, *@@windowSize, 0])
  259.         # Modifica a flag de fullscreen
  260.         @@inFullscreen = false
  261.         # Espera alguns frames para terminar o processamento
  262.         Graphics.wait(5)
  263.       end
  264.      
  265.       # Tamanho da tela
  266.       def size
  267.         [self.width, self.height]
  268.       end
  269.      
  270.       # Verifica se a janela está no modo fullscreen
  271.       def fullscreen?
  272.         return @@inFullscreen
  273.       end
  274.      
  275.       # Verifica se a janela está no modo janela
  276.       def windowed?
  277.         return !@@inFullscreen
  278.       end
  279.      
  280.       # Alterna entre os modos fullscreen e janela
  281.       def toggleFullscreen
  282.         @@inFullscreen ? self.windowed : self.fullscreen
  283.       end
  284.     end
  285.   end
  286. end

  287. if Graphics::PlaneSpeedUp
  288.   # Remove a classe Plane Anterior
  289.   Object.send(:remove_const, :Plane)
  290.   # Redefinição da classe Plane
  291.   class Plane
  292.     attr_reader :viewport
  293.     attr_reader :bitmap
  294.     attr_reader :ox
  295.     attr_reader :oy
  296.     attr_reader :opacity
  297.     attr_reader :blend_type
  298.     attr_reader :color
  299.     attr_reader :tone
  300.     attr_reader :visible
  301.     attr_reader :zoom_x
  302.     attr_reader :zoom_y
  303.     attr_reader :z
  304.    
  305.     # Inicialização do objeto
  306.     def initialize(viewport = nil)
  307.       # É necessário verificar se um viewport foi enviado. Desse modo, ao mudar a
  308.       # resolução da tela, deve-se mudar também a rect do viewport para que o
  309.       # Plane que ocupava a tela toda continue
  310.       @defaultViewport = !viewport.is_a?(Viewport)
  311.       @viewport = @defaultViewport ? Viewport.new(0, 0, *Graphics.size) : viewport
  312.      
  313.       @sprite        = Sprite.new(@viewport)
  314.       @bitmap        = nil
  315.       @ox            = @sprite.ox         # 0
  316.       @oy            = @sprite.oy         # 0
  317.       @opacity       = @sprite.opacity    # 255
  318.       @blend_type    = @sprite.blend_type # 0
  319.       @color         = @sprite.color      # Color.new(0, 0, 0, 0)
  320.       @tone          = @sprite.tone       # Tone.new(0, 0, 0, 0)
  321.       @visible       = @sprite.visible    # true
  322.       @z             = @sprite.z          # 0
  323.       @zoom_x        = @sprite.zoom_x     # 1.0
  324.       @zoom_y        = @sprite.zoom_y     # 1.0
  325.     end
  326.    
  327.     def bitmap=(bitmap)
  328.       return unless bitmap.is_a?(Bitmap)
  329.       @bitmap = bitmap
  330.       self.recreateBitmap(true)
  331.     end
  332.    
  333.     def ox=(value)
  334.       @ox = value
  335.       return unless @bitmap
  336.       @sprite.ox = (value % @bitmap.width)
  337.     end
  338.    
  339.     def oy=(value)
  340.       @oy = value
  341.       return unless @bitmap
  342.       @sprite.oy = (value % @bitmap.height)
  343.     end
  344.    
  345.     def opacity=(value)
  346.       @sprite.opacity = value
  347.       @opacity = @sprite.opacity
  348.     end
  349.    
  350.     def blend_type=(value)
  351.       @sprite.blend_type = value
  352.       @blend_type = @sprite.blend_type
  353.     end
  354.    
  355.     def color=(value)
  356.       @sprite.color = value
  357.       @color = @sprite.color
  358.     end
  359.    
  360.     def tone=(value)
  361.       @sprite.tone = value
  362.       @tone = @sprite.tone
  363.     end
  364.    
  365.     def viewport=(value)
  366.       @defaultViewport &= (value == @sprite.viewport)
  367.       @sprite.viewport = value
  368.       @viewport = @sprite.viewport
  369.     end
  370.    
  371.     def visible=(value)
  372.       @sprite.visible = value
  373.       @visible = sprite.visible
  374.     end
  375.    
  376.     def z=(value)
  377.       @sprite.z = value
  378.       @z = @sprite.z
  379.     end
  380.    
  381.     def zoom_x=(value)
  382.       @sprite.zoom_x = value
  383.       @zoom_x = @sprite.zoom_x
  384.       self.recreateBitmap
  385.     end
  386.    
  387.     def zoom_y=(value)
  388.       @sprite.zoom_y = value
  389.       @zoom_y = @sprite.zoom_y
  390.       self.recreateBitmap
  391.     end
  392.    
  393.     def disposed?
  394.       return @sprite.disposed?
  395.     end
  396.    
  397.     def dispose
  398.       @sprite.dispose
  399.     end
  400.    
  401.     protected
  402.    
  403.     def recreateBitmap(forceRefresh = false)
  404.       cw, ch      = Graphics.width * (2.0/@zoom_x), Graphics.height * (2.0/@zoom_y)
  405.       needRefresh = true
  406.      
  407.       if @defaultViewport
  408.         @viewport.rect.width, @viewport.rect.height = *Graphics.size
  409.       end
  410.      
  411.       if @sprite.bitmap.nil? or @sprite.bitmap.disposed?
  412.         newBitmap = Bitmap.new(cw, ch)
  413.       else
  414.         if (cw == @sprite.bitmap.width) and (ch == @sprite.bitmap.height) and (!forceRefresh)
  415.           return
  416.         end
  417.       
  418.         newBitmap = Bitmap.new(cw, ch)
  419.         if (cw < @sprite.bitmap.width) and (ch < @sprite.bitmap.height)
  420.           newBitmap.blt(0, 0, @sprite.bitmap, @sprite.bitmap.rect)
  421.           @sprite.bitmap.dispose
  422.           needRefresh = false
  423.         end
  424.       end
  425.      
  426.       @sprite.bitmap = newBitmap
  427.       self.refreshBitmap if needRefresh or forceRefresh
  428.     end
  429.    
  430.     def refreshBitmap
  431.       # Limpa o bitmap
  432.       b = @sprite.bitmap
  433.       b.clear
  434.      
  435.       return if @bitmap.nil?
  436.      
  437.       # Quantia de espaços para blt
  438.       tx = (b.width  / @bitmap.width.to_f )
  439.       ty = (b.height / @bitmap.height.to_f)
  440.      
  441.       b.blt(0, 0, @bitmap, @bitmap.rect)
  442.      
  443.       return if tx + ty == 2
  444.      
  445.       # Preenche 1 linha
  446.       basePow = @bitmap.width
  447.       baseRct = Rect.new(0, 0, @bitmap.width, @bitmap.height)
  448.      
  449.       Math.log2(tx).floor.times{
  450.         b.blt(basePow, 0, b, baseRct)
  451.         baseRct.width += basePow
  452.         basePow *= 2
  453.       }
  454.      
  455.       # Último bitmap da linha
  456.       baseRct.width = (b.width - baseRct.width)
  457.       b.blt(basePow, 0, b, baseRct)
  458.      
  459.       # Preenche o restante das linhas
  460.       basePow = @bitmap.height
  461.       baseRct = Rect.new(0, 0, b.width, @bitmap.height)
  462.      
  463.       Math.log2(ty).floor.times{
  464.         b.blt(0, basePow, b, baseRct)
  465.         baseRct.height += basePow
  466.         basePow *= 2
  467.       }
  468.      
  469.       # Última linha
  470.       baseRct.height = b.height - baseRct.height
  471.       b.blt(basePow, 0, b, baseRct)
  472.     end
  473.   end
  474. end

  475. class Game_Map
  476.   # Número de tiles horizontais na tela
  477.   def screen_tile_x
  478.     (Graphics.width / 32.0).ceil
  479.   end

  480.   # Número de tiles verticais na tela
  481.   def screen_tile_y
  482.     (Graphics.height / 32.0).ceil
  483.   end
  484. end

  485. # Contador de FPS para o modo Fullscreen
  486. if $TEST
  487.   # FPS Display // Zeus81
  488.   # http://forums.rpgmakerweb.com/index.php?/topic/3738-fps-display-isnt-very-accurate/#entry40350
  489.   module Graphics
  490.     @fps, @fps_tmp = 0, []
  491.    
  492.     class << self
  493.       attr_reader :fps
  494.      
  495.       alias fps_update update unless method_defined?(:fps_update)
  496.       def update
  497.         t = Time.now
  498.         fps_update
  499.         @fps_tmp[frame_count % frame_rate] = Time.now != t
  500.         @fps = 0
  501.         frame_rate.times {|i| @fps += 1 if @fps_tmp[i]}
  502.         fps_sprite.src_rect.y = @fps * 16
  503.       end
  504.      
  505.       def fps_sprite
  506.         if !@fps_sprite or @fps_sprite.disposed?
  507.           @fps_sprite = Sprite.new
  508.           @fps_sprite.z = 0x7FFFFFFF
  509.           @fps_sprite.bitmap = Bitmap.new(24, 16*120)
  510.           @fps_sprite.bitmap.font.name = "Arial"
  511.           @fps_sprite.bitmap.font.size = 16
  512.           @fps_sprite.bitmap.font.color.set(255, 255, 255)
  513.           @fps_sprite.bitmap.fill_rect(@fps_sprite.bitmap.rect, Color.new(0, 0, 0, 127))
  514.           120.times {|i|
  515.             @fps_sprite.bitmap.draw_text(0, i*16, 24, 16, "% 3d"%i, 1)
  516.           }
  517.           @fps_sprite.src_rect.height = 16
  518.         end
  519.         return @fps_sprite
  520.       end      
  521.     end
  522.   end
  523. end

  524. #==============================================================================
  525. # ▼ Viewports/Map Fix for Modified RGSS300.dll File
  526. #   Origin of Code: Yanfly Engine Ace - Ace Core Engine v1.06
  527. # -- Last Updated: 2011.12.26
  528. # -- Level: Easy, Normal
  529. # -- Requires: n/a
  530. #==============================================================================

  531. #==============================================================================
  532. # ■ Game_Map
  533. #==============================================================================

  534. class Game_Map

  535.   #--------------------------------------------------------------------------
  536.   # overwrite method: scroll_down
  537.   #--------------------------------------------------------------------------
  538.   def scroll_down(distance)
  539.     if loop_vertical?
  540.       @display_y += distance
  541.       @display_y %= @map.height * 256
  542.       @parallax_y += distance
  543.     else
  544.       last_y = @display_y
  545.       dh = Graphics.height > height * 32 ? height : screen_tile_y
  546.       @display_y = [@display_y + distance, height - dh].min
  547.       @parallax_y += @display_y - last_y
  548.     end
  549.   end

  550.   #--------------------------------------------------------------------------
  551.   # overwrite method: scroll_right
  552.   #--------------------------------------------------------------------------
  553.   def scroll_right(distance)
  554.     if loop_horizontal?
  555.       @display_x += distance
  556.       @display_x %= @map.width * 256
  557.       @parallax_x += distance
  558.     else
  559.       last_x = @display_x
  560.       dw = Graphics.width > width * 32 ? width : screen_tile_x
  561.       @display_x = [@display_x + distance, width - dw].min
  562.       @parallax_x += @display_x - last_x
  563.     end
  564.   end

  565. end # Game_Map

  566. #==============================================================================
  567. # ■ Spriteset_Map
  568. #==============================================================================

  569. class Spriteset_Map

  570.   #--------------------------------------------------------------------------
  571.   # overwrite method: create_viewports
  572.   #--------------------------------------------------------------------------
  573.   def create_viewports
  574.     if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal?
  575.       dx = (Graphics.width - $game_map.width * 32) / 2
  576.     else
  577.       dx = 0
  578.     end
  579.     dw = [Graphics.width, $game_map.width * 32].min
  580.     dw = Graphics.width if $game_map.loop_horizontal?
  581.     if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical?
  582.       dy = (Graphics.height - $game_map.height * 32) / 2
  583.     else
  584.       dy = 0
  585.     end
  586.     dh = [Graphics.height, $game_map.height * 32].min
  587.     dh = Graphics.height if $game_map.loop_vertical?
  588.     @viewport1 = Viewport.new(dx, dy, dw, dh)
  589.     @viewport2 = Viewport.new(dx, dy, dw, dh)
  590.     @viewport3 = Viewport.new(dx, dy, dw, dh)
  591.     @viewport2.z = 50
  592.     @viewport3.z = 100
  593.   end

  594.   #--------------------------------------------------------------------------
  595.   # new method: update_viewport_sizes
  596.   #--------------------------------------------------------------------------
  597.   def update_viewport_sizes
  598.     if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal?
  599.       dx = (Graphics.width - $game_map.width * 32) / 2
  600.     else
  601.       dx = 0
  602.     end
  603.     dw = [Graphics.width, $game_map.width * 32].min
  604.     dw = Graphics.width if $game_map.loop_horizontal?
  605.     if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical?
  606.       dy = (Graphics.height - $game_map.height * 32) / 2
  607.     else
  608.       dy = 0
  609.     end
  610.     dh = [Graphics.height, $game_map.height * 32].min
  611.     dh = Graphics.height if $game_map.loop_vertical?
  612.     rect = Rect.new(dx, dy, dw, dh)
  613.     for viewport in [@viewport1, @viewport2, @viewport3]
  614.       viewport.rect = rect
  615.     end
  616.   end

  617. end # Spriteset_Map

  618. #==============================================================================
  619. # ■ Scene_Map
  620. #==============================================================================

  621. class Scene_Map < Scene_Base

  622.   #--------------------------------------------------------------------------
  623.   # alias method: post_transfer
  624.   #--------------------------------------------------------------------------
  625.   alias scene_map_post_transfer_ace post_transfer
  626.   def post_transfer
  627.     @spriteset.update_viewport_sizes
  628.     scene_map_post_transfer_ace
  629.   end

  630. end # Scene_Map

  631. #==============================================================================
  632. # ■ Game_Event
  633. #==============================================================================

  634. class Game_Event < Game_Character

  635.   #--------------------------------------------------------------------------
  636.   # overwrite method: near_the_screen?
  637.   #--------------------------------------------------------------------------
  638.   def near_the_screen?(dx = nil, dy = nil)
  639.     dx = [Graphics.width, $game_map.width * 256].min/32 - 5 if dx.nil?
  640.     dy = [Graphics.height, $game_map.height * 256].min/32 - 5 if dy.nil?
  641.     ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
  642.     ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
  643.     ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
  644.   end

  645. end # Game_Event

  646. # Chama o método que realiza a mudança de tamanho
  647. # Graphics.fullscreen
  648. Graphics.resize_screen(800, 600)

  649. __END__
  650. # TESTES
  651. # Graphics.windowed
  652. x = Bitmap.new(50, 50)
  653. x.gradient_fill_rect(0,  0, 50, 25, Color.new(255, 0, 0), Color.new(0, 255, 0))
  654. x.gradient_fill_rect(0, 25, 50, 25, Color.new(0, 255, 0), Color.new(0, 0, 255))
  655. y = Plane.new
  656. y.bitmap = x
  657. y.zoom_x = 3
  658. y.zoom_y = 3
  659. #Graphics.fullscreen
  660. #Graphics.windowed
  661. loop do
  662.   Graphics.update
  663.   y.ox += 1
  664.   y.oy += 1
  665. end
复制代码
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部