Quantcast
Channel: RGSS3 Scripts (RMVX Ace) Latest Topics
Viewing all articles
Browse latest Browse all 416

GE Game Adapter

$
0
0

This script works with Gamepad Extender by Lone Wolf to make the default scripts work well with a controller. It does not break things for keyboard users, so players using whatever they desire should be able to play with optimal controls.

 

To use this script, copy and paste it into your game under materials and above main, but Gamepad Extender must also be in the game under materials and above GE Game Adapter. You can get it here: http://forums.rpgmakerweb.com/index.php?/topic/1284-gamepad-extender-v11-2202015

 

Spoiler

#==============================================================================
# Gamepad Extender Game Adapter
# by Jono99
#------------------------------------------------------------------------------
# This allows the game commands to be handled in a way more friendly to controller
# input. Based off Gamepad Extender by Lone Wolf and requires Gamepad Extender
# in order to function.
# Link to download Gamepad Extender: http://forums.rpgmakerweb.com/index.php?/topic/1284-gamepad-extender-v11-2202015/
# Please give me credit when using this script in your game (and Lone Wolf, too, but that's becuse he made Gamepad Extender and is awesome).
#==============================================================================
module GEGAOptions
  # Use the Start button instead of the B button to pause the game
  StartForPause = true
  
  # Determine what input device is used for the menus.
  # 0 for just the dpad
  # 1 for just the left analogue stick
  # 2 for both
  MenuInput = 2
  
  # Determine what input device is used for moving around the map.
  # 0 for just the dpad
  # 1 for just the left analogue stick
  # 2 for both
  MoveInput = 2
end






#==============================================================================
# DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!
#==============================================================================
if defined?(WolfPad) == nil
  msgbox("WARNING: GamePad Extender is either missing or executes sometime after this. To avoid issues, GE Game Adapter will not execute!")
elsif GEGAOptions::StartForPause.class != TrueClass
  msgbox("WARNING: StartForPause doesn't have a valid value. It must be true or false. To avoid issues, GE Game Adapter will not execute!")
elsif GEGAOptions::MenuInput.class != Fixnum || GEGAOptions::MenuInput > 2
  msgbox("WARNING: MenuInput doesn't have a valid value. It must be 0, 1, or 2. To avoid issues, GE Game Adapter will not execute!")
elsif GEGAOptions::MoveInput.class != Fixnum || GEGAOptions::MoveInput > 2
  msgbox("WARNING: MoveInput doesn't have a valid value. It must be 0, 1, or 2. To avoid issues, GE Game Adapter will not execute!")
else
  module WolfPad
    def self.dird4(p_i = 0)
      if press?(:UP, p_i)
       8
      elsif press?(:RIGHT, p_i)
       6
      elsif press?(:LEFT, p_i)
       4
      elsif press?(:DOWN, p_i)
       2
      else
       0
      end
    end
    def self.dird8(p_i = 0)
      if press?(:UP, p_i) and press?(:LEFT, p_i)
       7
      elsif press?(:UP, p_i) and press?(:RIGHT, p_i)
       9
      elsif press?(:DOWN, p_i) and press?(:LEFT, p_i)
       1
      elsif press?(:DOWN, p_i) and press?(:RIGHT, p_i)
       3
     else
       dird4(p_i)
      end
    end
  end
  class Game_Player
    #--------------------------------------------------------------------------
    # * Determine if Dashing
    #--------------------------------------------------------------------------
    def dash?
      return false if @move_route_forcing
      return false if $game_map.disable_dash?
      return false if vehicle
      return Input.press?(PadConfig.dash)
    end
    #--------------------------------------------------------------------------
    # * Processing of Movement via Input from Directional Buttons
    #--------------------------------------------------------------------------
    def move_by_input
      return if !movable? || $game_map.interpreter.running?
      if WolfPad.plugged_in? == false
        gega_move_by_input_input(Input.dir4)
      else
        gega_move_by_input_input(WolfPad.dird4) if GEGAOptions::MoveInput == 0 || GEGAOptions::MoveInput == 2
        gega_move_by_input_input(WolfPad.lstick4) if GEGAOptions::MoveInput > 0
      end
    end
    def gega_move_by_input_input(dir4)
      move_straight(dir4) if dir4 > 0
    end
    #--------------------------------------------------------------------------
    # * Processing When Not Moving
    #     last_moving : Was it moving previously?
    #--------------------------------------------------------------------------
    def update_nonmoving(last_moving)
      return if $game_map.interpreter.running?
      if last_moving
        $game_party.on_player_walk
        return if check_touch_event
      end
      if movable? && Input.trigger?(PadConfig.confirm)
        return if get_on_off_vehicle
        return if check_action_event
      end
      update_encounter if last_moving
    end
  end
  class Window_Selectable
    #--------------------------------------------------------------------------
    # * Cursor Movement Processing
    #--------------------------------------------------------------------------
    def process_cursor_move
      return unless cursor_movable?
      last_index = @index
      if WolfPad.plugged_in?
        gega_process_cursor_move_input(:UP, :DOWN, :LEFT, :RIGHT) if GEGAOptions::MenuInput == 0 || GEGAOptions::MenuInput == 2
        gega_process_cursor_move_input(:L_UP, :L_DOWN, :L_LEFT, :L_RIGHT) if GEGAOptions::MenuInput > 0
      else
        gega_process_cursor_move_input(:UP, :DOWN, :LEFT, :RIGHT)
      end
      cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(PadConfig.page_down)
      cursor_pageup     if !handle?(:pageup)   && Input.trigger?(PadConfig.page_up)
      Sound.play_cursor if @index != last_index
    end
    def gega_process_cursor_move_input(up, down, left, right)
      cursor_down (Input.trigger?(down)) if Input.repeat?(down)
      cursor_up   (Input.trigger?(up))    if Input.repeat?(up)
      cursor_right(Input.trigger?(right)) if Input.repeat?(right)
      cursor_left (Input.trigger?(left))  if Input.repeat?(left)
    end
    #--------------------------------------------------------------------------
    # * Handling Processing for OK and Cancel Etc.
    #--------------------------------------------------------------------------
    def process_handling
      return unless open? && active
      return process_ok       if ok_enabled?        && Input.trigger?(PadConfig.confirm)
      return process_cancel   if cancel_enabled?    && Input.trigger?(PadConfig.cancel)
      return process_pagedown if handle?(:pagedown) && Input.trigger?(PadConfig.page_down)
      return process_pageup   if handle?(:pageup)   && Input.trigger?(PadConfig.page_up)
    end
  end
  class Window_ShopNumber
    #--------------------------------------------------------------------------
    # * Update Quantity
    #--------------------------------------------------------------------------
    def update_number
      if WolfPad.plugged_in?
        gega_update_number_input(:RIGHT, :LEFT, :UP, :DOWN) if GEGAOptions::MenuInput == 0 || GEGAOptions::MenuInput == 2
        gega_update_number_input(:L_RIGHT, :L_LEFT, :L_UP, :L_DOWN) if GEGAOptions::MenuInput > 0
      else
        gega_update_number_input(:RIGHT, :LEFT, :UP, :DOWN)
      end
    end
  end
  def gega_update_number_input(right, left, up, down)
    change_number(1)   if Input.repeat?(right)
    change_number(-1)  if Input.repeat?(left)
    change_number(10)  if Input.repeat?(up)
    change_number(-10) if Input.repeat?(down)
  end
  class Window_NameInput
    #--------------------------------------------------------------------------
    # * Handling Processing for OK and Cancel Etc.
    #--------------------------------------------------------------------------
    def process_handling
      return unless open? && active
      process_jump if Input.trigger?(:A) && WolfPad.plugged_in? == false
      process_back if Input.repeat?(PadConfig.cancel)
      process_ok   if Input.trigger?(PadConfig.confirm)
    end
  end
  class Window_NumberInput
    #--------------------------------------------------------------------------
    # * Cursor Movement Processing
    #--------------------------------------------------------------------------
    def process_cursor_move
      return unless active
      last_index = @index
      if WolfPad.plugged_in?
        gega_process_cursor_move_input(:LEFT, :RIGHT) if GEGAOptions::MenuInput == 0 || GEGAOptions::MenuInput == 2
        gega_process_cursor_move_input(:L_LEFT, :L_RIGHT) if GEGAOptions::MenuInput > 0
      else
        gega_process_cursor_move_input(:LEFT, :RIGHT)
      end
      Sound.play_cursor if @index != last_index
    end
    def gega_process_cursor_move_input(left, right)
      cursor_right(Input.trigger?(right)) if Input.repeat?(right)
      cursor_left (Input.trigger?(left))  if Input.repeat?(left)
    end
    #--------------------------------------------------------------------------
    # * Change Processing for Digits
    #--------------------------------------------------------------------------
    def process_digit_change
      return unless active
      if WolfPad.plugged_in?
        gega_process_digit_change_input(:UP, :DOWN) if GEGAOptions::MenuInput == 0 || GEGAOptions::MenuInput == 2
        gega_process_digit_change_input(:L_UP, :L_DOWN) if GEGAOptions::MenuInput > 0
      else
        gega_process_digit_change_input(:UP, :DOWN)
      end
    end
    def gega_process_digit_change_input(up, down)
      if Input.repeat?(up) || Input.repeat?(down)
        Sound.play_cursor
        place = 10 ** (@digits_max - 1 - @index)
        n = @number / place % 10
        @number -= n * place
        n = (n + 1) % 10 if Input.repeat?(up)
        n = (n + 9) % 10 if Input.repeat?(down)
        @number += n * place
        refresh
      end
    end
    #--------------------------------------------------------------------------
    # * Handling Processing for OK and Cancel
    #--------------------------------------------------------------------------
    def process_handling
      return unless active
      return process_ok     if Input.trigger?(PadConfig.confirm)
      return process_cancel if Input.trigger?(PadConfig.cancel)
    end
  end
  class Window_Message
    #--------------------------------------------------------------------------
    # * Update Fast Forward Flag
    #--------------------------------------------------------------------------
    def update_show_fast
      @show_fast = true if Input.trigger?(PadConfig.confirm)
    end
    #--------------------------------------------------------------------------
    # * Input Pause Processing
    #--------------------------------------------------------------------------
    def input_pause
      self.pause = true
      wait(10)
      Fiber.yield until Input.trigger?(PadConfig.cancel) || Input.trigger?(PadConfig.confirm)
      Input.update
      self.pause = false
    end
  end
  class Window_ScrollText
    #--------------------------------------------------------------------------
    # * Determine if Fast Forward
    #--------------------------------------------------------------------------
    def show_fast?
      !$game_message.scroll_no_fast && (Input.press?(PadConfig.dash) || Input.press?(PadConfig.confirm))
    end
  end
  class Scene_Map
    #--------------------------------------------------------------------------
    # * Determine if Menu is Called due to Cancel Button
    #--------------------------------------------------------------------------
    def update_call_menu
      if $game_system.menu_disabled || $game_map.interpreter.running?
        @menu_calling = false
      else
        if WolfPad.plugged_in? && GEGAOptions::StartForPause
          @menu_calling ||= Input.trigger?(:START)
        else
          @menu_calling ||= Input.trigger?(:B)
        end
        call_menu if @menu_calling && !$game_player.moving?
      end
    end
  end
  class Scene_File
    #--------------------------------------------------------------------------
    # * Update Save File Selection
    #--------------------------------------------------------------------------
    def update_savefile_selection
      return on_savefile_ok     if Input.trigger?(PadConfig.confirm)
      return on_savefile_cancel if Input.trigger?(PadConfig.cancel)
      update_cursor
    end
    #--------------------------------------------------------------------------
    # * Update Cursor
    #--------------------------------------------------------------------------
    def update_cursor
      last_index = @index
      if WolfPad.plugged_in?
        gega_update_cursor_input(:UP, :DOWN) if GEGAOptions::MenuInput == 0 || GEGAOptions::MenuInput == 2
        gega_update_cursor_input(:L_UP, :L_DOWN) if GEGAOptions::MenuInput > 0
      else
        gega_update_cursor_input(:UP, :DOWN)
      end
      cursor_pagedown   if Input.trigger?(PadConfig.page_down)
      cursor_pageup     if Input.trigger?(PadConfig.page_up)
      if @index != last_index
        Sound.play_cursor
        @savefile_windows[last_index].selected = false
        @savefile_windows[@index].selected = true
      end
    end
  end
  def gega_update_cursor_input(up, down)
    cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
    cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  end
  class Scene_Gameover
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
      super
      goto_title if Input.trigger?(PadConfig.confirm)
    end
  end
end

 

There are also scripts out there that will overwrite this script. For this reason, I am taking requests for extension scripts that will add this functionality back in when another script overwrites it (ones for Arc Engine and Sapphire Action System IV are in the works right now). If you find a script that doesn't work with the base version, post about it in this thread detailing what script that conflicts with GE Game Adapter and provide a link to the script. I will check the script myself and create an extension script if I encounter the problem or message you telling you that I could not find any conflict.


Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>