+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: Super Simple Vehicle System - Enhanced - Vehicle Placement (/thread-5147.html)
Super Simple Vehicle System - Enhanced - Vehicle Placement - DerVVulfman - 05-19-2014
Super Simple Vehicle System - Enhanced 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
end
Credits and Thanks
Hey, thanks to habs11 for noting this and asking for this system.
Terms and Conditions
Free for use, even in commercial games.
RE: Super Simple Vehicle System - Enhanced - Vehicle Placement - DerVVulfman - 05-21-2014
BUMP
to version 1.1
Well, it wasn't FULLY compatible.
I totally forgot how the vehicle system stored the x/y location of the vehicles in the event you left the map and then returned. This storage feature allowed you to park your car wherever you wished and it wouldn't reset back to where the event first spawned.
So I went and tapped into that storage array and supply the newer data for when this new command is used.... And now, the new version is borne.
RE: Super Simple Vehicle System - Enhanced - Vehicle Placement - DerVVulfman - 05-22-2014
BUMP to version 1.2
Aaaarrrrhhh!!! *Headdesks*
When you board a vehicle, you erase the original event. When you exit the vehicle, a new event is created. So I used the feature that stored vehicle location for the placement for the 'new' event created thus. But when you exit a map and return, the original event returns and in the place you actually exit the vehicle.
*DOH!*
So I had to include a system that ensured that the returned 'original' event also moved according to the placement system.