Super Simple Vehicle System - Enhanced
#35
Sorry I disappeared for a little while, I kinda had a master's thesis to defend. Thanks a bunch! This is perfect. Once again, you never fail to get things done. Much appreciated!

Hey man,

Sorry about the double post, but I have a new question for you, go figure. With the last system, you made a patch for the following map looping script:

Code:
#============================================================================
# Map Looping
# Extracted from Neo Mode 7 script
# MGC
#
# Add [L] in the maps names to define looping maps
#============================================================================

# To access maps names
$data_maps = load_data("Data/MapInfos.rxdata")

#============================================================================
# ** RPG::MapInfo
#============================================================================

class RPG::MapInfo
  # defines the map's name as the name without anything within brackets,
  # including brackets
  def name
    return @name.gsub(/\[.*\]/) {""}
  end
  #--------------------------------------------------------------------------
  # the original name with the codes
  def fullname
    return @name
  end
end


#============================================================================
# ** Game_System
#----------------------------------------------------------------------------
# Add attributes to this class
#============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Aliased methods (F12 compatibility)
  #--------------------------------------------------------------------------
  unless @already_aliased
    alias initialize_mapLooping_game_system initialize
    @already_aliased = true
  end
  #--------------------------------------------------------------------------
  # * Attributes
  #--------------------------------------------------------------------------
  attr_accessor :mapLooping # true : map looping mode
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    initialize_mapLooping_game_system
    self.mapLooping = false
  end
end


#============================================================================
# ** Game_Map
#----------------------------------------------------------------------------
# Methods modifications to handle map looping
#============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Aliased methods (F12 compatibility)
  #--------------------------------------------------------------------------
  unless @already_aliased
    alias scroll_down_mapLooping_game_map scroll_down
    alias scroll_left_mapLooping_game_map scroll_left
    alias scroll_right_mapLooping_game_map scroll_right
    alias scroll_up_mapLooping_game_map scroll_up
    alias valid_mapLooping_game_map? valid?
    alias passable_mapLooping_game_map? passable?
    alias old_setup_mapLooping setup
    @already_aliased = true
  end
  #--------------------------------------------------------------------------
  # * Scroll Down
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    unless $game_system.mapLooping
      scroll_down_mapLooping_game_map(distance)
      return
    end
    @display_y = @display_y + distance
  end
  #--------------------------------------------------------------------------
  # * Scroll Left
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_left(distance)
    unless $game_system.mapLooping
      scroll_left_mapLooping_game_map(distance)
      return
    end
    @display_x = @display_x - distance
  end
  #--------------------------------------------------------------------------
  # * Scroll Right
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    unless $game_system.mapLooping
      scroll_right_mapLooping_game_map(distance)
      return
    end
    @display_x = @display_x + distance
  end
  #--------------------------------------------------------------------------
  # * Scroll Up
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_up(distance)
    unless $game_system.mapLooping
      scroll_up_mapLooping_game_map(distance)
      return
    end
    @display_y = @display_y - distance
  end
  #--------------------------------------------------------------------------
  # * Determine Valid Coordinates
  #     x          : x-coordinate
  #     y          : y-coordinate
  #   Allow the hero to go out of the map when map looping
  #--------------------------------------------------------------------------
  def valid?(x, y)
    unless $game_system.mapLooping
      return valid_mapLooping_game_map?(x, y)
    end
    if $game_system.mapLooping then return true end
    return (x >= 0 && x < width && y >= 0&& y < height)
  end
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     x          : x-coordinate
  #     y          : y-coordinate
  #     d          : direction (0,2,4,6,8,10)
  #                  *  0,10 = determine if all directions are impassable
  #     self_event : Self (If event is determined passable)
  #--------------------------------------------------------------------------
  def passable?(x, y, d, self_event = nil)
    unless $game_system.mapLooping
      return passable_mapLooping_game_map?(x, y, d, self_event)
    end
    unless valid?(x, y)
      return false
    end
    bit = (1 << (d / 2 - 1)) & 0x0f
    for event in events.values
      if event.tile_id >= 0 and event != self_event and
         event.x == x and event.y == y and not event.through
        if @passages[event.tile_id] & bit != 0
          return false
        elsif @passages[event.tile_id] & 0x0f == 0x0f
          return false
        elsif @priorities[event.tile_id] == 0
          return true
        end
      end
    end
    for i in [2, 1, 0]
      tile_id = data[x % width, y % height, i] # handle map looping
      if tile_id == nil
        return false
      elsif @passages[tile_id] & bit != 0
        return false
      elsif @passages[tile_id] & 0x0f == 0x0f
        return false
      elsif @priorities[tile_id] == 0
        return true
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Setup
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def setup(map_id)
    old_setup_mapLooping(map_id)
    map_data = $data_maps[$game_map.map_id]
    $game_system.mapLooping = map_data.fullname.include?("[L]")
  end
end


#============================================================================
# ** Game_Character
#----------------------------------------------------------------------------
# "update" method modifications to handle map looping
#============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Aliased methods (F12 compatibility)
  #--------------------------------------------------------------------------
  unless @already_aliased
    alias initialize_mapLooping_game_character initialize
    alias update_mapLooping_game_character update
    @already_aliased = true
  end
  #--------------------------------------------------------------------------
  # * Attributes
  #--------------------------------------------------------------------------
  attr_accessor :x
  attr_accessor :y
  attr_accessor :real_x
  attr_accessor :real_y
  attr_accessor :map_number_x # map's number with X-looping
  attr_accessor :map_number_y # map's number with Y-looping
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    initialize_mapLooping_game_character
    self.map_number_x = 0
    self.map_number_y = 0
  end
  #--------------------------------------------------------------------------
  # * Update : handle map looping
  #--------------------------------------------------------------------------
  def update
    unless $game_system.mapLooping
      update_mapLooping_game_character
      return
    end
    # if x-coordinate is out of the map
    unless (x.between?(0, $game_map.width - 1))
      difference = 128 * x - real_x
      if self.is_a?(Game_Player)
        # increase or decrease map's number
        self.map_number_x += difference / (difference.abs)
      end
      # x-coordinate is equal to its equivalent in the map
      self.x %= $game_map.width
      self.real_x = 128 * x - difference
    end
    # if y-coordinate is out of the map
    unless (y.between?(0, $game_map.height - 1))
      difference = 128 * y - real_y
      if self.is_a?(Game_Player)
        # increase or decrease map's number
        self.map_number_y += difference / (difference.abs)
      end
      # y-coordinate is equal to its equivalent in the map
      self.y %= $game_map.height
      self.real_y = 128 * y - difference
    end
    update_mapLooping_game_character
  end
end


#============================================================================
# ** Game_Player
#============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Aliased methods (F12 compatibility)
  #--------------------------------------------------------------------------
  unless @already_aliased
    alias center_mapLooping_game_player center
    @already_aliased = true
  end
  #--------------------------------------------------------------------------
  # * Always center around the hero if map looping
  #--------------------------------------------------------------------------
  def center(x, y)
    unless $game_system.mapLooping
      center_mapLooping_game_player(x, y)
      return
    end
    $game_map.display_x = x * 128 - CENTER_X
    $game_map.display_y = y * 128 - CENTER_Y
  end
end


#============================================================================
# ** Sprite_Character
#============================================================================

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Aliased methods (F12 compatibility)
  #--------------------------------------------------------------------------
  unless @already_aliased
    alias update_mapLooping_sprite_character update
    @already_aliased = true
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    update_mapLooping_sprite_character
    if $game_system.mapLooping
      unless x + computed_right_width >= 0 && x - computed_left_width < 640
        self.x %= $game_map.width << 5
      end
      while y + computed_lower_height < 0
        self.y += $game_map.height << 5
        self.z += $game_map.height << 5
      end
      while y - computed_upper_height >= 480
        self.y -= $game_map.height << 5
        self.z -= $game_map.height << 5
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Sprite's upper height (doesn't handle rotation)
  #--------------------------------------------------------------------------
  def computed_upper_height
    return (oy * zoom_y).to_i
  end
  #--------------------------------------------------------------------------
  # * Sprite's lower height
  #--------------------------------------------------------------------------
  def computed_lower_height
    return ((src_rect.height - oy) * zoom_y).to_i
  end
  #--------------------------------------------------------------------------
  # * Sprite's left width
  #--------------------------------------------------------------------------
  def computed_left_width
    return (ox * zoom_x).to_i
  end
  #--------------------------------------------------------------------------
  # * Sprite's right width
  #--------------------------------------------------------------------------
  def computed_right_width
    return ((src_rect.width - ox) * zoom_x).to_i
  end
end

You used the following patch:

Code:
#==============================================================================
# ** Super Simple Vehicle System / Mode7 Patch
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 2
#    10-26-2007
#    
#------------------------------------------------------------------------------
#
#  This script appends the check_terrain routine in the Vehicle System to permit
#  looping vehicles.   Also, it calls on the valid? routine in the Mode7 system.
#
#  The only  'drawback'  to this system was the routine that prevents the player
#  from exiting vehicles  along map borders.   A strange nuance  about the Mode7
#  system  (or possibly  about any loop script)  is that  tiles detected  on map
#  borders read as terrain tag 1. To prevent landing/disembarking in water, this
#  patch prevents landing on map borders.
#
#  To use this system, merely paste it BELOW both the Vehicle and Mode7 systems.
#  This script handles the rest.
#
#==============================================================================



#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Check the terrain for the vehicle
  #   new_x     : future x position
  #   new_y     : future y position
  #--------------------------------------------------------------------------
  alias m7_check_terrain check_terrain
  def check_terrain(new_x, new_y)  
    m7_check_terrain(new_x, new_y)
    vehicle = $game_system.vehicle_number
    if vehicle != 0
      # Passable for matching terrain
      if VEHICLES[vehicle-1][4]!= nil
        # If loopable game map
        if $game_map.valid?(new_x, new_y)
          # Set the looping switch off
          ssvs_m7_looping = false
          # Branch on direction
          case @direction
          when 2; ssvs_m7_looping = true if new_y == $game_map.height and @y == ($game_map.height - 1)
          when 4; ssvs_m7_looping = true if new_x == -1 and @x == 0
          when 6; ssvs_m7_looping = true if new_x == $game_map.width and @x == ($game_map.width - 1)
          when 8; ssvs_m7_looping = true if new_y == -1 and @y == 0
          end
          # If looping noted...
          @state = true if ssvs_m7_looping
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if Landing is Possible
  #     x : x-coordinate
  #     y : y-coordinate
  #--------------------------------------------------------------------------  
  alias m7_land_possible? land_possible?
  def land_possible?(x, y)
    # Original result
    result = m7_land_possible?(x, y)
    # Ensure false result if on map edges
    result = false if x == 0
    result = false if y == 0
    result = false if x == $game_map.width-1
    result = false if y == $game_map.height-1
    # Return result
    return result
  end
end

Would it be possible to update the patch for the new system? Thanks!
Habs11
Reply }


Messages In This Thread
RE: Super Simple Vehicle System - Enhanced - by habs11 - 08-19-2013, 12:50 AM
Super Simple Vehicle System - Enhanced - by Jeea - 12-20-2009, 04:03 PM
Super Simple Vehicle System - Enhanced - by Jeea - 12-21-2009, 02:44 AM
Super Simple Vehicle System - Enhanced - by Ace - 02-01-2010, 11:06 PM
Super Simple Vehicle System - Enhanced - by Ace - 02-01-2010, 11:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Wachunga's Fog of War - Enhanced Edition DerVVulfman 0 55 11-17-2024, 04:14 AM
Last Post: DerVVulfman
   The Wanderers: The Customizable Encounters System DerVVulfman 0 263 08-24-2024, 07:12 PM
Last Post: DerVVulfman
   Enhanced Squad Movement DerVVulfman 5 6,604 02-24-2023, 04:40 PM
Last Post: DerVVulfman
   Zenith Tactical Battle System Plus (ZTBS+) DerVVulfman 0 2,848 05-10-2022, 10:42 PM
Last Post: DerVVulfman
   Text Scroll Script - Enhanced DerVVulfman 23 34,304 02-18-2021, 04:16 AM
Last Post: DerVVulfman
   Commercial System Package DerVVulfman 11 14,312 01-04-2020, 12:37 AM
Last Post: Pelip
   ACBS - Atoa Custom Battle System 3.2 Victor Sant 150 255,728 03-02-2019, 04:47 AM
Last Post: dragonprincess44
   DerVV's Simple Popup System DerVVulfman 4 12,234 10-08-2017, 04:53 PM
Last Post: DerVVulfman
   Super Simple MCISendString DerVVulfman 0 4,890 03-09-2017, 04:52 AM
Last Post: DerVVulfman
   Melly-Mel's Calendar System DerVVulfman 23 43,620 12-02-2016, 04:31 AM
Last Post: DerVVulfman



Users browsing this thread: 9 Guest(s)