SCRIPT HELP PLEASE!! :)

Posts

Pages: 1
Puddor
if squallbutts was a misao category i'd win every damn year
5702
So, I'm using DerVVulfman/Lambchop's Vehicle system. It works great, I've gotten everything figured out about the script and how to use the calls and etc...however the script has one major issue and I'm not sure if it's even fixable, but I thought I'd try just to get everyone off my back.

The actual airship is an event that appears on the map. Now, in normal circumstances and in RPGs saving is permitted on the World Map, but as of right now I can't enable saving because if I do, the airship returns to where the original event is rather than staying in the place it was when the game was saved (essentially stranding the player and rendering the save completely useless- not cool)
Events not retaining their present state through save games seems to be an issue RMXP has (I've noticed it elsewhere) but unlike those events which I can fix through switch creation instead of just changing graphics, this one I cannot.

I'm thinking this may be solvable through common event, but I'm not sure how to go about grabbing the X/Y coordinates of the event before saving and restoring them when the player reloads...

Anyway, here's the script:
#==============================================================================
# ** Super Simple Vehicle System - Enhanced
#------------------------------------------------------------------------------
# by DerVVulfman (Original code by Lambchop)
# version 8.0
# 10-13-2007
# Notable SDK Compatability (Rewrites Game_Character's passable? method)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# INTRODUCTION:
# =============
#
# This system allows you to create and manage 'vehicles' in your RMXP project.
# You can have simple vehicles that travel in rivers or oceans, or can fly
# through the air over all the mountains on the map. You can even create
# mobile headquarters such as those in the Final Fantasy™ games.
#
# The only thing you can't do is go into the default menus when riding, unless
# you're IN a mobile headquarters.
#
# That's pretty much it. :)
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# THE BASICS:
# ===========
#
# Normally I would delve into the actual configuration system of a script, but
# this system uses map events to create the vehicles and default RMXP switches
# to manage them.
#
# Still... it's the best one I've seen so far.
#
# There are at least three things to touch on with this system... the config
# array in this script, the map event you're using for a vehicle, and an RMXP
# switch. These three things are key when making a vehicle.
#
# Oh, and some graphics for the vehicle would be good too. :)
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# CONFIGURATION ARRAY:
# --------------------
#
# The configuration array in this script (called VEHICLES) is where you set up
# the information on your vehicle... the name, graphics, music played... even
# the speed the vehicle travels. However, the important ones to consider are:
#
# NAME * GRAPHIC * TERRAIN * SWITCH ID
#
# The NAME of the vehicle must be in the map event's name (which I'll get to
# later). Likewise, the GRAPHIC and TERRAIN will be discussed later. As far
# the SWITCH ID... that too is crutial.
#
# The NAME of the vehicle in the array actually identifies the event on the
# map and allows the system to track its location. So as you can tell, this
# is very important. Also, no two vehicles may share the same name.
#
# The SWITCH ID for the vehicle corresponds to the RMXP switches you would
# turn on or off in a map or common event, even with the
# command in the Event Editors. What makes this so important is that you use
# this to hide the map event you've created for a vehicle. When your actor
# uses a vehicle, this pre-defined 'switch' is turned on. And since it is a
# specifically 'chosen' switch, we know which one it is so the map event can
# be hidden.
#
# Now to cover the other two: GRAPHIC and TERRAIN:
#
# The GRAPHIC in the array points to a characterset graphic that the vehicle
# uses. Typically, this is the same one that shows up on the map before the
# actor boards the vessel.
#
# As your RMXP uses terrain tags from 0 to 7, the values you can enter into
# the TERRAIN array for your vehicle are from 0 to 7, like the ones in your
# map's tileset. This small array can indicate one or more terrains that a
# vehicle can move along. The only exception to this is by replacing the array
# with a setting of 'nil'. If the value is set to 'nil', then the vehicle can
# move along any and all terrain as if it was flying.
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# SWITCHES:
# ---------
#
# Only one switch is needed for any one vehicle. These are the same ones you
# find in things like the common event editor's command, or
# in the map event's list of conditions in the top right:
# ______
# | |-----
# | 1 | 2 |
# | |_____|___________________________________
# | List of Event
# | ______________
# | -Conditions------------------- |
# | | ||
# | | Switch ____________ <----------------------- Like this
# | |
#
# Being able to assign a specific switch to a vehicle is a GOOD thing. You
# may want to have certain plot points occur if a vehicle is boarded, turn off
# some objects like teleport events, or what ever floats your boat.
#
# Still, it would be a good thing to go and name them in the RMXP editor like
# most people would, so you can keep track of them. And there's the debugger
# built into the system so you can see when it's turned on.
#
# For the unknowing, running a project in the editor allows you to press
# to bring up a debug window. You can see the variables and switches being
# used by the project.
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# MAP EVENTS:
# -----------
#
# Here's all you need to do to configure a map event to generate your vehicle.
# But first, let's look at the event page:
#
# Name:
# -------------------
# | boat-MAP001 |
# -------------------
# ______
# | |-----
# | 1 | 2 |
# | |_____|___________________________________
# | List of Event
# | ______________
# | -Conditions------------------- |
# | | ||
# | | Switch ____________ ||
# | |
#
# Regardless of the data on each page in your event, the name of the event is
# based on the 'NAME' of the vehicle (just like I described above) and on the
# Current Map Name. As such, the above example shows that a vehicle called
# "boat" will be using this event and that this event is on MAP001.
#
# NOTE: Other than including the map's name in the event, there was no clear
# cut way to prevent equal numbered events from different maps from
# changing positions accidentally. As such, event #3 from one map and
# event #3 from another may BOTH change position if one of the two hap-
# pened to be a vehicle.
#
#
# PAGE 1: The Graphic: Change/insert the graphic image of your vehicle
# as you would see it before the actor boards the
# vessel.
#
# Stop Animation: An option. When this switch is left OFF, the
# characterset graphic is left unanimated. But
# when this switch is ON, then the graphic becomes
# ______ animated. The description for the switch seems
# -----| | a little reversed.
# | 1 | 2 |
# |_____| |___________________________________
# | List of Event
# | ______________
# | -Conditions------------------- |
# | | ||
# | | Switch 0001:Dragon is ON ||
# | |
#
#
# PAGE 2: The Graphic: Erase the graphic. This page is used to hide your
# vehicle event when the actor has boarded it.
#
# A Switch: One of the Switch Conditions. When a vehicle is
# boarded, it turns on a switch that is defined in
# the VEHICLE array. This Switch Condition looks
# for that switch and turns on the second page if
# and when it finds that switch turned on.
#
# NOTE: In the above example, page #2 would be
# activated when Switch '0001:Dragon' was
# turned on.
#
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# And, that's really about it for configuring the events. So in general, there
# may be really only four to five things to configure per each event, with the
# actual name of the event included.
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# CONFIGURATION:
# ==============
#
#
# CONFIGURING THE VEHICLE ARRAY:
# ------------------------------
#
# Here's a small breakdown of all the values that you are to include in the
# vehicle array:
#
# Name * Graphic * Music * Sound Effects * Terrain * Undockable Terrain
# Speed * Event Block * Encounters * Stepping * HQ Settings * Switch ID
# -----------------------------------------------------------------------
#
#
# NAME: (String) This is a 'Unique' ID used by the system to identify
# a single vehicle in your project. You may have two boats in
# your game, but neither one may share this name. This value is
# key in that it helps to identify the map event using it, the
# switches that the vehicle uses, and other niceties.
#
# GRAPHIC: (Array) This is the characterset that the actor changes into
# when the system makes it look like he's boarded a vehicle. It's
# a simple array that includes both the filename and the hue of
# the characterset.
#
# NOTE: The basic entry is two-parter like which
# can set a 'canoe' graphic in your Graphics\Characters
# folder with a hue of 40. But using is just
# as legal as the hue would be defaulted to '0' which is
# the normal setting.
#
#
# MUSIC: (Array) This is the music that plays when the vehicle is cur-
# rently active. You may choose any music in the Audio\BGM fol-
# der, or 'nil' if you do not wish to change the music.
#
# NOTE: To create a music selection, you must set it up as an
# array. This array consists of three parts: file, volume
# and pitch. The volume and pitch settings are optional,
# but the array must at least have a file (again in the
# BGM folder). As an example, you could use an entry of
# to play the 6th default piece in
# the RTP at half volume and sped up a little.
#
# You may also use arrays such as or
# . The first sets the file to play
# at half volume but regular pitch while the second plays
# at regular volume (by default) and a slower pitch speed.
#
# SOUND (Array) This is the background sound effect that plays when the
# EFFECTS: vehicle is active. It replaces the map's background sound ef-
# fect with its own until the vehicle is exited. You may choose
# any sound file within the Audio\BGS folder, or 'nil' if you do
# not wish to change the background sound effect.
#
# NOTE: This follows the exact same rules as the MUSIC array.
#
# TERRAIN: (Array) This is a small array that holds the terrain tags which
# your vehicle is limited to moving across. If the array contains
# a single digit (let's say... '4'), then the vehicle will only
# be able to move across tiles with that terrain tag. If it's set
# to 'nil', then it will move along any and all terrain tags.
#
# NOTE: If a vehicle is set to nil, it will also bypass special
# directional tiles such as ones used for cliffs and holes.
#
# UNDOCK* (Array) This is a small array that holds terrain tags that your
# TERRAIN: vehicle cannot land upon. Whether a ship cannot land at a rocky
# shore or an airship cannot land in a swampy region or two, this
# array informs the system what type of terrain a vehicle cannot
# land. Or... it too can be set to 'nil' so it can land on any
# terrain.
#
# NOTE: Conditions such as 'blocked by events' and impassable
# tiles still hold true however.
#
# SPEED: (Numeric) This controls how fast the vehicle moves. You can
# enter a range of 0 (being the slowest) to 8 (being pretty fast.
# Values can be accepted in the array that are outside this range
# (like -1 or 12), but it generally won't move the vehicle any
# slower or faster than the system allows.
#
# EVENT (Boolean, or true/false) This switch (typically defaulted to
# BLOCK: 'true') informs the system that the vehicle can't move through
# events. About the only time that this switch would be set to
# 'false' would be for vehicles that would fly overhead of these
# events.
#
# NOTE: This is an all-or-nothing deal. Either you block all of
# the events, or none at all. You can't select some events
# for blocking and leave the others.
#
# ENC: (Boolean, or true/false) This switch (typically defaulted to
# 'true') informs the system whether or not random encounters may
# occur when in or on a vehicle. This is a simple true/false
# value... good for things like airborne vehicles.
#
# STEPPING: (Boolean, or true/false) When this is set to 'true' (typically,
# the default), then the actor will step forward when boarding
# and/or exiting a vehicle. This switch can be set to 'false' so
# boarding can appear instantaneous.
#
# HQ (Array) This array holds information so you can switch from the
# SETTINGS: vehicle to your mobile headquarters, or just 'nil' if the vehi-
# cle doesn't have a mobile HQ. Small and simple, this array
# consists of six values: Map, X, Y, Direction, Fading & Sounds:
#
# NOTE: Unlike the previously described arrays (for Music and
# so forth), this array does not have default values. It
# must contain all settings like so: .
#
# The first value in the array contains the actual ID no.
# of the mobile HQ's map.. the map you will be teleporting
# into. The 'name' of your map is typically based on this
# ID number, but for those unaware, the ID number is also
# visible in the Map Properties window, or in the bottom-
# right corner of the map editor (like ID:004). Just re-
# member to trim off any excess zeros.
#
# The second and third values are the X and Y coordinates
# where your character will appear on the map. Rather sim-
# ple, these are the tile coordinates, just like the ones
# you set with the map event.
#
# The fourth value (direction) sets the direction that the
# actor will face after teleporting to the map array. The
# value is currently usable with even values of 2 to 8:
#
# ( 2 = Down, 4 = Left , 6 = Right, 8 = Down )
#
# Though other values may be accepted, the results may be
# a little off.
#
# The fifth switch (transitional fading) is a true/false
# value. Set it to true if you want to 'fade to' the HQ,
# or set it to false to just 'pop in'.
#
# The sixth and final switch (background sounds) is a true
# or false value. Set it to true if you want the background
# sound effect of your vehicle to continue to sound within
# the mobile headquarters, or set it to false to disable it
# if you don't plan to use the 'vehicle' sound effect. In
# either case, the mobile HQ's own sound effect overrides
# this effect.
#
# SWITCH ID: (Numeric) Finally, this is ID number of a single switch that is
# turned on when you have boarded a vehicle. This is important,
# as the switch being used allows you to 'hide' the map event you
# have used to generate the vehicle.
#
# NOTE: This switch would also be important to prevent one from
# accidentally teleporting from map to map while still in
# a vehicle.
#
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# The actual 'ORDER' of the vehicles listed in the array does not matter as
# the system compares the name of a map event and finds the exact match in
# this array.
#
# What does matter is that you must be careful about the brackets sur-
# rounding the data and the data itself. The main array does hold smaller
# arrays that describe each vehicle. And each of these smaller arrays hold
# seven types of data as already described above. Missing quotes, missing
# commas, missing end brackets... these can cause errors.
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# MISCELLANEOUS SETTINGS:
# -----------------------
#
# PASSABLE_TERRAIN: This is an array that holds the ID values of terrain
# tags your character can move along without a vehicle.
# Typically, this array doesn't hold the IDS used in
# the VEHICLES array, but there isn't anything stopping
# the user from making a game where the character can
# walk along multiple terrain types and a vehicle that
# can only move along one of those types.
#
# LANDING_SFX This is the sound effect file that plays if you try
# to land or dock on a terrain that prevents movement.
# This may sound if you try to land on a terrain whose
# tag is not 'walkable', if the terrain itself may not
# permit movement due to directional/blocking flags, or
# if the vehicle attempts to land on or next to another
# map event.
#
# NOTE: To create a landing sound effect, you must set
# it up as an array. This array can consist of
# three parts: file, volume and pitch. The vol-
# ume and pitch settings are optional, but the
# array must at least have a file (which is
# stored in the SE folder).
#
#
# V_BOARD_KEY: These values hold the keystroke CONSTANT used to get
# V_EXIT_KEY: onboard or exit a vehicle, or to go from a HQ vehicle
# and V_HQ_KEY: to the Headquarters itself. This is the same type of
# keystroke used in general Input commands. Currently,
# set to a setting of Input::A (or the Shift Key).
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# VEHICLE MAPS:
# =============
#
# Call them what you will... world maps, city maps with cars, whatever. These
# maps are the ones that contain vehicle events. But... there is one slight
# visual glitch that as of yet has not been resolved.
#
# Teleporting to these maps will (for a small time... 1/2 second?) have the
# vehicles in their 'starting' position. As such, if you drove a Ferrari
# across the map and went into a building (teleporting into another map), once
# you left the building... the Ferrari won't be there. Well... for a split
# second anyway.
#
# As a cheat, the best way around this is to use common events to fade out the
# screen before you teleport to any Vehicle Map and fade in right after:
#
# @> Call Common Event: Fade Out
# @> Transfer Player:, (12, 13), Down, No Fade
# @> Call Common Event: Fade In
#
#
# The above example is from a map event. It shows two common events on either
# side of a teleport event. The first one is merely a used to fade out the
# screen while the second one fades it back in.
#
# Oh, and for best results, set the teleport event to 'No Fade'.
#
# Here's the coding for the two common events:
#
# Fade Out:
# @> Change Screen Color Tone (-255,-255,-255,0), @10
# @> Wait: 10 frame(s)
#
# Fade In:
# @> Change Screen Color Tone (0,0,0,0), @10
# @> Wait: 10 frame(s)
#
#
# That's it. Very simple.
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# MOBILE HEADQUARTERS:
# ====================
#
# This system allows you to turn a vehicle into a mobile headquarters such as
# the Highwind from Final Fantasy 7 or Balamb Garden from Final Fantasy 8.
# These HQs are nothing more than an additional 'map' that your character can
# teleport into when riding a vehicle, with the noted exception that he/she
# returns to normal and can once again use the menu & save/load features.
#
# Obviously, this is a three-step process...
#
# First, MAKE A NEW MAP! It could be anything, but reasonably closed off from
# the rest of the world. Well... you can have smaller maps inside, like having
# a bridge, an engineering section, a ship's galley, or whatever.
#
# The second step is to edit your configuration for that vehicle to point to
# that map. This is done by creating a smaller array that contains the MapID
# for the HQ map, the x and y position where your character appears, the di-
# rection he'll be facing, a true/false value related to how he teleports to
# the HQ, and another true/false value if it uses the same background effect
# that the vehicle itself does.
#
# WAIT!!! HOW DO I GET OFF THIS CRAZY THING!
#
# That... is the third step. Somewhere in your HQ, you have to make a map
# event that returns you to the vehicle. This can be basically ANYTHING like
# a doorway, floor button, lever... whatever you wanna draw. The only thing
# is that this specific map event must include is a scripted call:
#
# $game_player.hq_exit
#
# Nothing more is required, though I do recommend calling some common events
# to fade out and into the vehicle again (like I mentioned above). When you
# leave the HQ itself, you are returned to the vehicle. The data regarding
# the map, vehicle, x & y position and etc. is automatically saved and ready
# for transport.
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
# NOTE ON AUDIO:
# ==============
#
# Audio effects, whether they be music or sound effects are now entered as an
# array so each audio clip may contain their own pre-set volume and/or pitch
# settings. As such, a battle music piece may be entered like the following
# example:
#
#
#
# While the volume and pitch settings are optional (and can be set to 'nil'),
# the actual file must be entered.
#
# Safeguard routines have been entered into this system to check on the exis-
# tance of the audio files. Prior to this, cases where 'listed' audio files
# were not present in the project caused the system to crash. As of now, the
# system will detect whether or not the actual file exists in your project or
# RTP and play it through the Game_System class, or 'not' if it doesn't exist.
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# COMPATABILITY:
# ==============
#
# Currently, this system is designed only for the default RMXP system and may
# conflict with other map/movement systems. As it is, it will not be compat-
# ible with any script that redefines the 'passable?' method in Game_Character
# as this one likewise does so.
#
# As far as modifications to this system, it is not recommended. But stand-
# alone patches that allow this system and other scripts to work together are
# welcomed.
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# CREDITS AND THANKS:
# ===================
#
# To Lambchop... DUH! And to SephirothSpawn who inspired and showed her how
# to make the first version of this script. Thanks to Regimos and Monk for
# detecting a minor (yet stubborn) bug that occurs when landing next to a map
# n event (now fixed). Another thank to Regimos for detecting a glitch where
# the main menu was accidentally re-enabled in a regular vehicle. To Alistor
# and mephisto for supplying the code for animating vehicles in motion, and
# again to Alistor for discovering the ability to accidentally debark a vehi-
# cle when exiting a mobile HQ. And to shannon who suggested terrain tags
# that may not be 'landable', even if they are passable. Also, thanks goes
# to Regimos for noting that 'landed' vehicles permitted other vehicles to
# pass across/into impassable terrains. Finally, thanks to
#
#==============================================================================



#======================================================================
# ** CONFIGURATION ** #
#======================================================================


# Name Graphic Music SE Ter. Undock Spd Ev-Blk Enc Step HQ Coords. Sw
VEHICLES = [ ["s_canoe", , , nil, , nil, 3, true, true, true, nil, 4],
["boat", , , , , nil, 4, true, false, true, , 2],
["RAGNAROK", , , , nil, , 6, false, false, false, , 125],
["canoe", , , nil, , nil, 3, true, true, true, nil, 1] ]


# Terrain ID(s_ for on-foot travel
PASSABLE_TERRAIN =


# Landing Error SFX
LAND_SFT =


# Keys used to board or exit a vehicle
V_BOARD_KEY = Input::A
V_EXIT_KEY = Input::A
V_HQ_KEY = Input::B



#======================================================================
# ** END OF CONFIGURATION ** #
#======================================================================

# Do not touch... used for map system.
$d_v_maps = load_data("Data/MapInfos.rxdata")



#==============================================================================
# ** Visual Basic
#------------------------------------------------------------------------------
# This module includes routine(s) that mimic Basic/Visual basic statements.
#==============================================================================

module V_Basic
#--------------------------------------------------------------------------
# * In String (recreation of 'basic' string function)
# Returns position of tested string, or nil if doesn't exist
# text : string being checked
# check : string searched for
# start :(optional) characters to skip before search
#--------------------------------------------------------------------------
def instr(text, check, start = 0)
textstart = (text.length) - start # Get start position of text
temp = text.slice(start, textstart) # Get text from calculated start
return nil if temp == nil # Return nil if empty
chklength = check.length # Get size of check string
testpos = 0 # Reset position counter
for txt in 0...temp.length # Perform loop through text
testpos += 1 # Increase counter by 1
char1 = temp.slice(txt, chklength) # Get portion of text
return testpos if char1 == check # Return counter if found
end # End of loop
return nil # Return nil if not fount
end
end



#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :orig_move_speed # Original character movement speed
attr_accessor :vehicle_number # vehicle ID number (or 0 if none)
attr_accessor :vehicle_name # vehicle event name
attr_accessor :vehicle_movex # vehicle position save array (x)
attr_accessor :vehicle_movey # vehicle position save array (y)
attr_accessor :prehq_map # Map ID number before HQ transition
attr_accessor :prehq_x # X position before HQ transition
attr_accessor :prehq_y # Y position before HQ transition
attr_accessor :prehq_d # Direction before HQ transition
attr_accessor :prehq_v # Vehicle before HQ transition
attr_accessor :prehq_l # Leaving the HQ (back to map)
attr_accessor :v_transfer_f # Transfer finished flag
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias vehicle_init initialize
def initialize
vehicle_init
@vehicle_number = 0
@vehicle_name = ""
@vehicle_movex = {}
@vehicle_movey = {}
@prehq_map = 0
@prehq_x = 0
@prehq_y = 0
@prehq_d = 0
@prehq_v = 0
@prehq_l = false
@v_transfer_f = true
end
end



#==============================================================================
# ** 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
#--------------------------------------------------------------------------
# * Automatically Change Background Music and Backround Sound
#--------------------------------------------------------------------------
alias vehicle_autoplay autoplay
def autoplay
# Exit if HQ (transfer back) flag is true
return if $game_system.prehq_l == true
vehicle_autoplay
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
include V_Basic
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :move_speed # Character Movement Speed
attr_accessor :step_anime # Character Stop Animation
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Obtain map name for comparison
map_name = $d_v_maps.name
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# If coordinates are outside of map
unless $game_map.valid?(new_x, new_y)
return false
end
# If through is ON
if @through
return true
end
# Flyover flag
flyover_tag = false
v_flyover = $game_system.vehicle_number
unless v_flyover == 0
flyover_tag = true if VEHICLES == nil
end
# Only block direction if they can't fly over it
unless flyover_tag
# If unable to leave first move tile in designated direction
unless $game_map.passable?(x, y, d, self)
# impassable
return false
end
# If unable to enter move tile in designated direction
unless $game_map.passable?(new_x, new_y, 10 - d)
# impassable
return false
end
end
# Check terrain for vehicle
check_terrain(new_x, new_y)
# Event block flag
event_block = true
unless $game_system.vehicle_number == 0
event_block = false unless VEHICLES
end
# Set block-bypass
block_bypass = false
# Block event if blocks true
if event_block
# Loop all events
for event in $game_map.events.values
# If event coordinates are consistent with move destination
if event.x == new_x and event.y == new_y
@state = true
# Test for vehicle event
v_test = instr(event.name, map_name)
block_bypass = true if $game_system.vehicle_number != 0 && event.name != v_test
# If through is OFF
unless event.through && !block_bypass
# If self is event
if self != $game_player
# impassable
return false
end
# With self as the player and partner graphic as character
if event.character_name != ""
# impassable
return false
end
end
end
end
end
# Return false if event/terrain state is false/blocked
if @state == false
return false
end
# If player coordinates are consistent with move destination
if $game_player.x == new_x and $game_player.y == new_y
# If through is OFF
unless $game_player.through
# If your own graphic is the character
if @character_name != ""
# impassable
return false
end
end
end
# passable
return true
end
#--------------------------------------------------------------------------
# * Determine if Landing is Possible
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def land_possible?(x, y)
# If unable to leave first move tile in designated direction
unless $game_map.passable?(x, y, 0, self)
# impassable
return false
end
end
#--------------------------------------------------------------------------
# * Determine if Landing on specific terrain is Possible
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def land_terrain_possible?(x, y)
@terrain = $game_map.terrain_tag(x, y)
unless VEHICLES == nil
return false if VEHICLES.include?(@terrain)
end
end
#--------------------------------------------------------------------------
# * Determine if Landing on or next to event is Possible
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def land_event_possible?(x, y)
# Loop all events
for event in $game_map.events.values
# Loop all directions
for dir in 1..4
d = dir * 2
# Cycle outwards
for tiles in 0..1
# Get new coordinates
new_x = x + (d == 6 ? tiles : d == 4 ? -1*tiles : 0)
new_y = y + (d == 2 ? tiles : d == 8 ? -1*tiles : 0)
# If event coordinates are consistent with move destination
if event.x == new_x and event.y == new_y
# Skip if the event being tested is the take-off event
unless event.name == $game_system.vehicle_name
# impassable
return false
end
end
end
end
end
end
#--------------------------------------------------------------------------
# * Check the terrain for the vehicle
# new_x : future x position
# new_y : future y position
#--------------------------------------------------------------------------
def check_terrain(new_x, new_y)
@state = false
@terrain = $game_map.terrain_tag(new_x, new_y)
vehicle = $game_system.vehicle_number
# Normal passable state
@state = true if vehicle == 0 && PASSABLE_TERRAIN.include?(@terrain)
# Vehicle passable states
if vehicle != 0
# Passable if terrain is nil
@state = true if VEHICLES == nil
# Passable for matching terrain
if VEHICLES!= nil
@state = true if VEHICLES.include?(@terrain)
end
end
end
end



#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================

class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Obtain name
#--------------------------------------------------------------------------
def name
return @event.nil? ? '' : @event.name
end
end



#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================

class Game_Player < Game_Character
include V_Basic
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :encounter_count # Encounter count
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias vehicle_update update
def update
# Original Call
vehicle_update
# If waiting (added for vehicle speed transition)
if @wait_count > 0
# Reduce wait count
@wait_count -= 1
return
end
# if not in vehicle, check for boat exit
if $game_system.vehicle_number == 0
if Input.trigger?(V_BOARD_KEY)
vehicle_enter
end
else
if Input.trigger?(V_EXIT_KEY)
vehicle_exit if $game_system.v_transfer_f == true
elsif Input.trigger?(V_HQ_KEY)
unless VEHICLES == nil
hq_enter
end
end
end
# Change to Vehicle speed
if $game_system.vehicle_number != 0
@move_speed = VEHICLES
end
end
#--------------------------------------------------------------------------
# * Change Actor Graphic & Vehicle
#--------------------------------------------------------------------------
def actor_change
# Change actor appearance
actor_memorize
v_graphic = VEHICLES
# Cycle through Vehicle Array
for v_counter in 0..VEHICLES.size-1
# Set game switch off
$game_switches[VEHICLES] = false
end
$game_switches[VEHICLES] = true
return v_graphic
end
#--------------------------------------------------------------------------
# * Actor disembarks Vehicle
#--------------------------------------------------------------------------
def actor_disembark(map_name)
# Set Current Vehicle
v_counter = $game_system.vehicle_number - 1
# If the listed vehicle is used
if $game_switches[VEHICLES] == true
for vehicle in $game_map.events.values
if vehicle.name == VEHICLES + '-' + map_name
vehicle.moveto(x, y)
$game_switches[VEHICLES] = false
$game_system.vehicle_movex = x
$game_system.vehicle_movey = y
# Perform movement if Step is true
if VEHICLES
@through = true
move_forward
@through = false
end
end
end
end
# Get off vehicle
actor_restore
# Reset Vehicle to none
$game_system.vehicle_number = 0
return v_counter
end
#--------------------------------------------------------------------------
# * Memorize actor graphic
#--------------------------------------------------------------------------
def actor_memorize
@actor_speed = @move_speed
tmp_id = $game_party.actors.id
@actor_name = $game_actors.character_name
@actor_hue = $game_actors.character_hue
@battler_name = $game_actors.battler_name
@battler_hue = $game_actors.battler_hue
return true
end
#--------------------------------------------------------------------------
# * Restore actor graphic
#--------------------------------------------------------------------------
def actor_restore
tmp_id = $game_party.actors.id
actor = $game_actors
actor.set_graphic(@actor_name.to_s, @actor_hue, @battler_name.to_s, @battler_hue)
@move_speed = @actor_speed
$game_player.refresh
return true
end
#--------------------------------------------------------------------------
# * HQ Enter
#--------------------------------------------------------------------------
def hq_enter
# Obtain map name for comparison
map_name = $d_v_maps.name
# Enable save and menu
$game_system.menu_disabled = false
$game_system.save_disabled = false
# Store Vehicle location
$game_system.prehq_map = $game_map.map_id
$game_system.prehq_x = @x
$game_system.prehq_y = @y
$game_system.prehq_d = @direction
$game_system.prehq_v = $game_system.vehicle_number
# Get Off Current Vehicle
v_counter = actor_disembark(map_name)
# Vehicle Animation is turned off
@step_anime = false
# Set transferring player flag
$game_temp.player_transferring = true
# Grab the data
hq_map = VEHICLES
# Set player move destination
$game_temp.player_new_map_id = hq_map # MapID
$game_temp.player_new_x = hq_map # X
$game_temp.player_new_y = hq_map # Y
$game_temp.player_new_direction = hq_map # Direction
if hq_map == true # Fade
# Prepare for transition
Graphics.freeze
# Set transition processing flag
$game_temp.transition_processing = true
$game_temp.transition_name = ""
end
# Restore old sound
$game_system.bgs_restore if VEHICLES == false
# Advance index
$game_player.refresh
$game_map.refresh
end
#--------------------------------------------------------------------------
# * HQ Exit
#--------------------------------------------------------------------------
def hq_exit
# Set the HQ (transfer back) flag to true
$game_system.prehq_l = true
# Disable save and menu
$game_system.menu_disabled = true
$game_system.save_disabled = true
# Obtain original Vehicle Number
$game_system.vehicle_number = $game_system.prehq_v
# Change Actor Appearance
v_graphic = actor_change
# Set transferring player flag
$game_temp.player_transferring = true
# Set player move destination
$game_temp.player_new_map_id = $game_system.prehq_map
$game_temp.player_new_x = $game_system.prehq_x
$game_temp.player_new_y = $game_system.prehq_y
$game_temp.player_new_direction = $game_system.prehq_d
# Set Vehicle Graphic
tmp_id = $game_party.actors.id
actor = $game_actors
v_file = v_graphic
v_hue = v_graphic
v_hue = 0 if v_hue == nil
actor.set_graphic(v_file, v_hue, @battler_name.to_s, @battler_hue)
# Vehicle Animation is turned on
@step_anime = true
# Required Refreshes
$game_player.refresh
$game_map.refresh
# Change Vehicle Music
vehicle_music
# Change Vehicle Background SE
vehicle_sound
end
#--------------------------------------------------------------------------
# * Enter a vehicle (Check Condition)
#--------------------------------------------------------------------------
def vehicle_enter
# Only function if outside of vehicle
if $game_system.vehicle_number == 0
# Obtain map name for comparison
map_name = $d_v_maps.name
# Calculate front event coordinates
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y
# Obtain event name
event_name = event.name
end
end
# Test if standing on event
if event_name == nil
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == @x and event.y == @y
# Obtain event name
event_name = event.name
end
end
end
# Only perform for legal condition
unless event_name == nil
# Test for separation string
separation_string = instr(event_name, '-')
if separation_string != nil
event_name_length = event_name.length - separation_string
type = event_name.slice(0, separation_string-1)
v_map_name = event_name.slice(separation_string, event_name_length)
# Only for properly named Vehicles w/ map name
if v_map_name = map_name
vehicle_enter_step2(type)
end
end
end
end
end
#--------------------------------------------------------------------------
# * Enter Vehicle (Actual Transfer)
#--------------------------------------------------------------------------
def vehicle_enter_step2(type)
# Disable save and menu
$game_system.menu_disabled = true
$game_system.save_disabled = true
map_name = $d_v_maps.name
# Obtain vehicle number & event
for v_counter in 0..VEHICLES.size-1
v_array = VEHICLES
if type == v_array
$game_system.vehicle_number = v_counter + 1
$game_system.vehicle_name = v_array + '-' + map_name
if v_array
@through = true
move_forward
@through = false
@wait_count = 40
end
end
end
# Memorize old BMG
$game_system.bgm_memorize
# Memorize old BMS
$game_system.bgs_memorize
# Change Vehicle Music
vehicle_music
# Change Vehicle Background SE
vehicle_sound
# Change Actor Appearance
v_graphic = actor_change
# Set Vehicle Graphic
tmp_id = $game_party.actors.id
actor = $game_actors
v_file = v_graphic
v_hue = v_graphic
v_hue = 0 if v_hue == nil
actor.set_graphic(v_file, v_hue, @battler_name.to_s, @battler_hue)
# Vehicle Animation is turned on
@step_anime = true
# Required Refreshes
$game_player.refresh
$game_map.refresh
return true
end
#--------------------------------------------------------------------------
# * Exit a vehicle
#--------------------------------------------------------------------------
def vehicle_exit
# Obtain map name for comparison
map_name = $d_v_maps.name
# If on a passable terrain
unless PASSABLE_TERRAIN.include?(@terrain)
# Play buzzer SE
vehicle_sound_buzzer
else
# If airborne vehicle tries to land on impassable terrain
if land_possible?(x, y) == false
# Play buzzer SE
vehicle_sound_buzzer
elsif land_event_possible?(x, y) == false
# Play buzzer SE
vehicle_sound_buzzer
elsif land_terrain_possible?(x, y) == false
# Play buzzer SE
vehicle_sound_buzzer
else
# Enable save and menu
$game_system.menu_disabled = false
$game_system.save_disabled = false
# Vehicle Animation is turned off
@step_anime = false
# Get Off Current Vehicle
actor_disembark(map_name)
# Restore old music
$game_system.bgm_restore
# Restore old sound
$game_system.bgs_restore
# Required Refreshes
$game_player.refresh
$game_map.refresh
end
end
end
#--------------------------------------------------------------------------
# * Change Vehicle Music
#--------------------------------------------------------------------------
def vehicle_music
# Play vehicle BMG
unless VEHICLES == nil
music_set = VEHICLES
# If the music set isn't nil
if music_set != nil
# Extract from array
music_f = music_set # File
music_v = music_set # Volume
music_p = music_set # Pitch
# For default values
music_v = 100 if music_v == nil
music_p = 100 if music_p == nil
# Ensure valid Music File
begin
@trd = RPG::AudioFile.new(music_f)
Audio.bgm_play("Audio/BGM/" + @trd.name, 0, 100)
rescue Errno::ENOENT
# Music file is invalid (restore default)
music_f = nil
end
# Play the Music File
if music_f != nil
# Recombine into audio format
music = RPG::AudioFile.new
music.name = music_f
music.volume = music_v
music.pitch = music_p
# Pass to master system
$game_system.bgm_play(music)
end
end
end
end
#--------------------------------------------------------------------------
# * Change Vehicle Background Sound
#--------------------------------------------------------------------------
def vehicle_sound
# Play vehicle BGS
unless VEHICLES == nil
se_set = VEHICLES
# If the se set isn't nil
if se_set != nil
# Extract from array
se_f = se_set # File
se_v = se_set # Volume
se_p = se_set # Pitch
# For default values
se_v = 80 if se_v == nil
se_p = 100 if se_p == nil
# Ensure valid BGS File
begin
@trd = RPG::AudioFile.new(se_f)
Audio.bgs_play("Audio/BGS/" + @trd.name, 0, 100)
rescue Errno::ENOENT
# BGS file is invalid (restore default)
se_f = nil
end
# Play the BGS File
if se_f != nil
# Recombine into audio format
se = RPG::AudioFile.new
se.name = se_f
se.volume = se_v
se.pitch = se_p
# Pass to master system
$game_system.bgs_play(se)
end
end
end
end
#--------------------------------------------------------------------------
# * Play Vehicle Buzzer FX
#--------------------------------------------------------------------------
def vehicle_sound_buzzer
# If the error se set isn't nil
if LAND_SFT != nil
# Extract from array
se_f = LAND_SFT # File
se_v = LAND_SFT # Volume
se_p = LAND_SFT # Pitch
# For default values
se_v = 100 if se_v == nil
se_p = 100 if se_p == nil
# Ensure valid SE File
begin
@trd = RPG::AudioFile.new(se_f)
Audio.se_play("Audio/SE/" + @trd.name, 0, 100)
rescue Errno::ENOENT
# BGS file is invalid (restore default)
se_f = nil
end
# Play the BGS File
if se_f != nil
# Recombine into audio format
se = RPG::AudioFile.new
se.name = se_f
se.volume = se_v
se.pitch = se_p
# Pass to master system
$game_system.se_play(se)
end
end
end
end



#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================

class Scene_Map
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias vehicle_update update
def update
# Set No Encounter flag to true (No encounters)
no_enc_tag = true
# If in vehicle
if $game_system.vehicle_number == 0
# Turn encounters back on
no_enc_tag = nil
else
# Turn Encounters back on if vehicle has encounters
no_enc_tag = nil if VEHICLES
end
# Reset 'count' to start (prevent encounters) if flag is true
$game_player.encounter_count = $game_map.encounter_step if no_enc_tag
# Perform the original call
vehicle_update
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias vehicle_transfer_player transfer_player
def transfer_player
# Transfer start flag
$game_system.v_transfer_f = nil
# Original transfer
vehicle_transfer_player
# Reset HQ (transfer back) flag
$game_system.prehq_l = nil
# Obtain map name for comparison
map_name = $d_v_maps.name
# Cycle through vehicle list
for v_counter in 0..VEHICLES.size-1
# cycle through vehicle events
for vehicle in $game_map.events.values
# Prevent nil vehicles
unless vehicle == nil
# If vehicles share the map name (same map)
if vehicle.name == VEHICLES + '-' + map_name
x = $game_system.vehicle_movex
y = $game_system.vehicle_movey
unless x == nil
unless y == nil
vehicle.moveto(x, y)
end
end
end
end
end
end
# Transfer finished flag
$game_system.v_transfer_f = true
end
end


Anyway you can help me out with this would be great and save my players a lot of grief. Thanks in advance! ^^
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Question. If you enter a town and then leave and return to the world map, does the airship revert to its original location?

Also, do you care if saving is enabled while flying or not? Or do you just need saving to be allowed on the ground, and don't care one way or the other about saving mid-flight?
Puddor
if squallbutts was a misao category i'd win every damn year
5702
The menu is disabled while flying, so no, I don't care. Only on the ground, like in most FF's.

And when you come out onto the world map, there's a brief moment where the script grabs the airship and moves it to its parked coordinates.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
In the default script Scene_Load that comes with RPG Maker XP, you'll find the following method "on_decision":

def on_decision(filename)
    # If file doesn't exist
    unless FileTest.exist?(filename)
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # Play load SE
    $game_system.se_play($data_system.load_se)
    # Read save data
    file = File.open(filename, "rb")
    read_save_data(file)
    file.close
    # Restore BGM and BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
  end


Try changing it to this. I added one line, which calls the "transfer_player" method in your script that moves the airship when the player enters the map. So upon loading the game, it should do the same thing it does upon entering the map.

def on_decision(filename)
    # If file doesn't exist
    unless FileTest.exist?(filename)
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # Play load SE
    $game_system.se_play($data_system.load_se)
    # Read save data
    file = File.open(filename, "rb")
    read_save_data(file)
    file.close
    # Restore BGM and BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
    $scene.transfer_player
  end


If this doesn't work let me know.
Puddor
if squallbutts was a misao category i'd win every damn year
5702
It does not :<. Once you save your game and reload the game crashes, the engine saying it can't find Map000.rxdata (which doesn't exist!)
Pages: 1