05-19-2014, 04:08 AM 
	
	
	Super Simple Vehicle System - Enhanced
Add-On: Vehicle Placement
Version: 1.2
Add-On: Vehicle Placement
Version: 1.2
Introduction
This add-on to the 'Super Simple Vehicles System - Enhanced', allows you to move your vehicle events from one x/y location to another, even after having used the vehicle.
Script
 The Script
  			Code:
#==============================================================================
# ** Super Simple Vehicle System - Enhanced
# ** Add-On:  Vehicle Placement
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 1.2
#    05-21-2014
#    RGSS / RPGMaker XP
#==============================================================================
#
#
#                                INTRODUCTION:
#                                =============
#
#  This add-on to the 'Super Simple Vehicles System - Enhanced',  allows you to 
#  move your vehicle events from one x/y location to another, even after having
#  used the vehicle.
#
#  This script add-on would be a must for anyone  wishing to move the position
#  of a vehicle as the system erases the old event  and replaces it with a new
#  event with a new ID number.  In these cases, the classic SET EVENT LOCATION
#  map call would prove useless.
#
#  To make a call, you need to use the 'key' name  for your vehicle as defined
#  in the VEHICLES array.   Along with that,  you need to supply  both X and Y
#  values to point out where the event is to move, and optionally  a direction
#  based on the 2/4/6/8 directional values.
#
#  That's pretty much it. :)  
#
#
#  NOTE:  Likely compatible with scripts that support diagonal movement.
#
#  
#
#==============================================================================
#
#                             CREDITS AND THANKS:
#                             ===================
#
#  Credit to habs11 for noting that vehicle events could not be moved by the
#  default SET EVENT LOCATION command and requesting the feature.
#
#
#==============================================================================
#
#                                TERMS OF USE:
#                                =============
#
#  Free for use, even in commercial games.  Only due credit is required.
#
#
#==============================================================================
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Setup
  #     map_id : map ID
  #--------------------------------------------------------------------------
  alias game_map_vehicle_placement_setup setup
  def setup(id)
    game_map_vehicle_placement_setup(id)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias game_map_vehicle_placement_refresh refresh
  def refresh
    # Alias Listings
    game_map_vehicle_placement_refresh
    # If map ID is effective
    if @map_id > 0
      # Refresh all map events
      for event in @events.values
        # Get the event's name for checking
        name = event.name
        # If the name meets the vehicle formula's need
        if name =~ Vehicles::VEHICLE_FORMULA
          #  Obtain key
          veh_key = $1
          # For valid vehicle keys only
          if Vehicles::VEHICLE.has_key?(veh_key)        
            # Only if a vehicle object array exists
            unless $game_system.vehicle_object.nil?  
              # Only if that vehicle object exists for that vehicle
              unless $game_system.vehicle_object[veh_key].nil?  
                # Get position and direction
                x = $game_system.vehicle_object.vehicle[veh_key][1]
                y = $game_system.vehicle_object.vehicle[veh_key][2]
                d = $game_system.vehicle_object.vehicle[veh_key][3]
                # Move vehicle
                event.moveto(x,y)
                # Turn vehicle
                event.direction = d
              end
            end
          end
        end
      end
    end
    # Clear refresh request flag
    @need_refresh = false
  end  
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :direction                # direction
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
  #--------------------------------------------------------------------------
  # * Place the Vehicle
  #     name   : Vehicle ID Name
  #     x      : map x-coordinate
  #     y      : map y-coordinate
  #     d      : direction (2,4,6,8) ... or more if more directions allowed.
  #--------------------------------------------------------------------------
  def place_vehicle(name=nil, x=0, y=0,d=nil)
    # Cycle through all map events
    for event in $game_map.events.values
      # Skip if non-existant
      next if event.nil?
      # Perform only if a vehicle ID detected
      if event.name =~ Vehicles::VEHICLE_FORMULA
        #  Obtain key for that vehicle (which vehicle)
        veh_key = $1
        # If the vehicle is the one being searched
        if name == veh_key
          # Set event position
          direction = (d == nil) ? event.direction : d
          event.moveto(x,y)
          event.direction = direction
          # And update the vehicle array
          vehicle_array = [$game_map.map_id, x, y, direction]
          $game_system.vehicle_object.vehicle[veh_key] = vehicle_array
        end
      end
    end    
  end
endCredits and Thanks
Hey, thanks to habs11 for noting this and asking for this system.
Terms and Conditions
Free for use, even in commercial games.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
	  Above are clickable links

 
 
 Super Simple Vehicle System - Enhanced - Vehicle Placement
 Super Simple Vehicle System - Enhanced - Vehicle Placement
 
 
![[Image: QrnbKlx.jpg]](https://i.imgur.com/QrnbKlx.jpg)
![[Image: sGz1ErF.png]](https://i.imgur.com/sGz1ErF.png)
![[Image: liM4ikn.png]](https://i.imgur.com/liM4ikn.png)
![[Image: fdzKgZA.png]](https://i.imgur.com/fdzKgZA.png)
![[Image: sj0H81z.png]](https://i.imgur.com/sj0H81z.png)
![[Image: QL7oRau.png]](https://i.imgur.com/QL7oRau.png)
![[Image: uSqjY09.png]](https://i.imgur.com/uSqjY09.png)
![[Image: GAA3qE9.png]](https://i.imgur.com/GAA3qE9.png)
![[Image: 2Hmnx1G.png]](https://i.imgur.com/2Hmnx1G.png)
![[Image: BwtNdKw.png%5B]](https://i.imgur.com/BwtNdKw.png%5B)