Kain Nobel
Member
I'm having a problem with a script I wrote awhile ago not working like it used to anymore. For some reason, when I enter a vehicle, then exit and try to enter again, I can't get on the vehicle again. I'm curious if it might be the current version of the Event_Spawner I have, or if there's something I'm forgetting to do when creating the event (I've tried creating other generic test events, and they don't work either.)
I even tested the event's command list in game with p/print, and it prints the same exact setup as the real event that does work.
I'm going to go ahead and post both the Vehicle script, and Seph's Event_Spawner, maybe somebody knows whats wrong with it because everything seems as it should work fine even though it doesn't (anymore).
Please note, you can test any real or spawned event's command list like so with this call script.
You'll see the spawn events have commands, just the same as the real ones do, so I'm not sure what's wrong, why none of them do anything. I tried a couple generic test events with show message commands and they didn't do anything either. I don't know why, I never changed the origional Event_Spawner and it worked fine before.
I even tested the event's command list in game with p/print, and it prints the same exact setup as the real event that does work.
I'm going to go ahead and post both the Vehicle script, and Seph's Event_Spawner, maybe somebody knows whats wrong with it because everything seems as it should work fine even though it doesn't (anymore).
Code:
#===============================================================================
# ~** XP Vehicles Script **~
#-------------------------------------------------------------------------------
# Written by : Kain Nobel
# Version : 2.0
# Last Update : 09.02.2008
# Created On : 07.24.2008
#-------------------------------------------------------------------------------
# ** Requirements
# This script requires MACL 2.3, specifically these scripts...
# o RGSS.Map Section
# o Event_Spawner
#-------------------------------------------------------------------------------
# ** Script Plug-Ins
# o 'Run' : Kain Nobel's Run Script (Version 1.5 or Higher)
# o 'Jump' : Kain Nobel's Jump Script (Version 1.5 or Higher)
# o 'StepSFX' : Kain Nobel's Player/Event Steps (Version 1.0 or Higher)
#-------------------------------------------------------------------------------
# ** Special Thanks to SephirothSpawn for clearing up MACL methods used within.
# ** Special Thanks to Amanda a.k.a. Lambchop for origional concept.
# ** Special Thanks to RMXP community altogether for their work within the MACL!
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK.log
#-------------------------------------------------------------------------------
SDK.log('System.VehicleXP', 'Kain Nobel', 2.0, '09.02.2008')
#-------------------------------------------------------------------------------
# * SDK Enabled Test - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('System.VehicleXP')
#===============================================================================
# ** Vehicle
#-------------------------------------------------------------------------------
# This module is the data structure and control center for XP Vehicle System.
#===============================================================================
module Vehicle
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~** CUSTOMIZABLE CONSTANTS - BEGIN **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
#-----------------------------------------------------------------------------
# * List (This is the master list of all vehicles in your game, needed for
# the Vehicle.disable_all command
#-----------------------------------------------------------------------------
List = ["Car", "Buggy", "Canoe", "Boat", "Ship", "Dragon"]
#-----------------------------------------------------------------------------
# * Vehicle Terrain
#-----------------------------------------------------------------------------
# * Syntax: "Graphic" => [0, 1, 2, 3, 4, 5, 6, 7]
#-----------------------------------------------------------------------------
# * DEFAULT TERRAIN GUIDE (Please update list description for self reference.)
#-----------------------------------------------------------------------------
# 0) Land : Area the player can always walk on.
# 1) Forest : Area filled with trees, can't land airship here.
# 2) Mountains : Rocky mountain ranges, can't land airship here either.
# 3) Snow : Only specialty equiped vehicles can cross the snow.
# 4) Delta : A shallow part of a river/lakebed, special vehicles can pass.
# 5) River : A flowing body of water, airship can't land here.
# 6) Sea : The body of water near the land, airship can't land here.
# 7) Ocean : A deep body of water, only ships can pass here.
#-----------------------------------------------------------------------------
Terrain = {
# A vehicle that can cross land
"Car" => [0, 1],
# A vehicle that can cross land and deltas
"Buggy" => [0, 1, 5],
# A vehicle that can travel along rivers
"Canoe" => [5],
# A vehicle that can travel along rivers and seas
"Boat" => [5, 6],
# A vehicle that can travel along seas and oceans
"Ship" => [7, 8],
# A vehicle that can fly over anything
"Dragon" => [0, 1, 2, 3, 4, 5, 6, 7]
}
#-----------------------------------------------------------------------------
# * Speed (*Use array with 2 integers if using Kain Nobel Run*)
#-----------------------------------------------------------------------------
Speed = {
"Canoe" => [3, 4],
"Dragon" => [4, 6]
}
#-----------------------------------------------------------------------------
# * Freq (*Use array with 2 integers if using Kain Nobel Run*)
#-----------------------------------------------------------------------------
Freq = {
"Canoe" => [3, 4],
"Dragon" => [4, 6]
}
#-----------------------------------------------------------------------------
# * Background Music (played when in vehicle)
#-----------------------------------------------------------------------------
BGM = {
"Canoe" => "045-Positive03",
"Ship" => "046-Positive04",
"Dragon" => "047-Positive05"
}
#-----------------------------------------------------------------------------
# * Move SE (*Feature requires Kain Nobel's Player/Event Step SFX Script*)
#-----------------------------------------------------------------------------
Move_SFX = {
"Canoe" => ["Steps-04-Water", 50, 100]
}
#-----------------------------------------------------------------------------
# * Vehicles that remain animated while standing idle
#-----------------------------------------------------------------------------
Idle_Animated = ["Dragon"]
#-----------------------------------------------------------------------------
# * Vehicles that are animated while nobody is inside of them.
#-----------------------------------------------------------------------------
Empty_Animated = ["Dragon"]
#-----------------------------------------------------------------------------
# * Flying Vehicles
#-----------------------------------------------------------------------------
Flying = ["Dragon"]
#-----------------------------------------------------------------------------
# * Max Altitude for vehicle (by tiles, not pixels)
#-----------------------------------------------------------------------------
Max_Altitude = {
"Dragon" => 2
}
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~** CUSTOMIZABLE CONSTANTS - END **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
#-----------------------------------------------------------------------------
# * Vehicle.enter(vehicle)
#-----------------------------------------------------------------------------
def self.enter(vehicle)
if $game_player.vehicle.nil?
# If Jump Plug-In included
if SDK.enabled?('Player.Jump') || PlugIns.include?('Jump') && !Jump.nil?
@jump_enabled = SDK.enabled?('Player.Jump')
SDK.disable('Player.Jump')
end
# Disable Menu and Save
$game_system.menu_disabled, $game_system.save_disabled = true, true
# Save party leader's graphic info, speed and frequency
actor = $game_party.actors[0]
@c_name, @c_hue = actor.character_name, actor.character_hue
@b_name, @b_hue = actor.battler_name, actor.battler_hue
@save_speed = $game_player.move_speed
@save_freq = $game_player.move_frequency
# Change party leader's graphic into vehicle
actor.set_graphic(vehicle, @c_hue, @b_name, @b_hue)
$game_player.move_speed = Vehicle.speed(vehicle)
$game_player.move_frequency = Vehicle.freq(vehicle)
$game_player.step_anime = idle_animated?(vehicle)
$game_player.always_on_top = flight_animated?(vehicle)
$game_player.vehicle = vehicle
$game_player.refresh
# Play Vehicle's BGM theme (unless not set)
play_theme(vehicle)
# Delete vehicle from map
$game_map.delete_event($game_map.this_event)
# Vehicle Raises from Ground (if Flying)
#Vehicle.flight_begin(vehicle) if Flying.include?(vehicle)
end
end
#-----------------------------------------------------------------------------
# * Vehicle.exit
#-----------------------------------------------------------------------------
def self.exit
unless $game_player.vehicle.nil?
# Vehicle Lowers To Ground (if Flying)
#if Flying.include?($game_player.vehicle)
#Vehicle.flight_end($game_player.vehicle)
#end
# If Jump Plug-In included
if @jump_enabled == true
SDK.enable('Player.Jump')
end
# Re-enable Menu and Save
$game_system.menu_disabled, $game_system.save_disabled = false, false
# Reset party leader's graphic info
$game_party.actors[0].set_graphic(@c_name, @c_hue, @b_name, @b_hue)
$game_player.move_speed = Vehicle.speed(nil)
$game_player.move_frequency = Vehicle.freq(nil)
$game_player.step_anime = false
$game_player.always_on_top = false
# Autoplay map BGM/BGS then refresh player
$game_player.refresh
# Create new vehicle on map, set player's vehicle to nil
Event_Spawner.create_vehicle($game_player.vehicle)
$game_player.vehicle = nil
# Play Map's BGM theme
$game_map.autoplay
end
end
#-----------------------------------------------------------------------------
# * Vehicle.enable(vehicle)
#-----------------------------------------------------------------------------
def self.enable(vehicle)
@disabled = [] if @disabled.nil?
@disabled.delete(vehicle) if vehicle.is_a?(String) && !vehicle.nil?
end
#-----------------------------------------------------------------------------
# * Vehicle.enable_all
#-----------------------------------------------------------------------------
def self.enable_all
@disabled = []
end
#-----------------------------------------------------------------------------
# * Vehicle.disable(vehicle)
#-----------------------------------------------------------------------------
def self.disable(vehicle)
@disabled = [] if @disabled.nil?
@disabled.push(vehicle) if vehicle.is_a?(String) && !vehicle.nil?
end
#-----------------------------------------------------------------------------
# * Vehicle.disable_all
#-----------------------------------------------------------------------------
def self.disable_all
@disabled = List.dup
end
#-----------------------------------------------------------------------------
# * Vehicle.disabled?(vehicle)
#-----------------------------------------------------------------------------
def self.disabled?(vehicle)
@disabled = [] if @disabled.nil?
unless vehicle.nil? ; return @disabled.include?(vehicle)
else ; return false
end
end
#-----------------------------------------------------------------------------
# * Vehicle.delete_disabled
#-----------------------------------------------------------------------------
def self.delete_disabled
for event in $game_map.events.values
$game_map.delete_event(event.id) if disabled?(event.character_name)
end
end
#-----------------------------------------------------------------------------
# * Vehicle.passable?(x, y)
#-----------------------------------------------------------------------------
def self.passable?(x, y)
return false if !$game_map.valid?(x, y)
return $DEBUG if Input.press?(Input::CTRL)
unless $game_player.vehicle.nil?
return Terrain[$game_player.vehicle].include?($game_map.terrain_tag(x,y))
end
end
#-----------------------------------------------------------------------------
# * Vehicle.landable?(x, y, d)
#-----------------------------------------------------------------------------
def self.landable?(x, y, d)
vehicle = $game_player.vehicle
$game_player.vehicle = nil
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
if $game_player.passable?(new_x, new_y, d) ; boolean = true
else ; boolean = false
end
$game_player.vehicle = vehicle
return boolean
end
#-----------------------------------------------------------------------------
# * Vehicle.speed(vehicle)
#-----------------------------------------------------------------------------
def self.speed(vehicle)
unless vehicle.nil? or Speed[vehicle].nil? or @save_speed.nil?
return Speed[vehicle][0] if Speed[vehicle].is_a?(Array)
return Speed[vehicle] unless Speed[vehicle].is_a?(Array)
else ; return @save_speed.nil? ? 4 : @save_speed
end
end
#-----------------------------------------------------------------------------
# * Vehicle.freq(vehicle)
#-----------------------------------------------------------------------------
def self.freq(vehicle)
unless vehicle.nil? or Freq[vehicle].nil? or @save_freq.nil?
return Freq[vehicle][0] if Freq[vehicle].is_a?(Array)
return Freq[vehicle] unless Freq[vehicle].is_a?(Array)
else ; return @save_freq.nil? ? 4 : @save_freq
end
end
#-----------------------------------------------------------------------------
# * Vehicle.play_theme(vehicle)
#-----------------------------------------------------------------------------
def self.play_theme(vehicle)
unless vehicle.nil?
bgm = BGM[vehicle]
if bgm.is_a?(String) ; Audio.bgm_play("Audio/BGM/"+bgm, 100, 100)
elsif bgm.is_a?(Array) ; Audio.bgm_play("Audio/BGM/"+bgm[0],bgm[1],bgm[2])
end
end
end
#-----------------------------------------------------------------------------
# * Vehicle.move_se(vehicle)
#-----------------------------------------------------------------------------
def self.move_se(vehicle)
return if vehicle.nil? or Move_SFX.nil? or Move_SFX[vehicle].nil?
se = Move_SFX[vehicle]
begin
if se.is_a?(String) ; Audio.se_play("Audio/SEx/"+se, 100, 100)
elsif se.is_a?(Array) ; Audio.se_play("Audio/SEx/"+se[0], se[1], se[2])
end
rescue
end
end
#-----------------------------------------------------------------------------
# * Vehicle.idle_animated?(vehicle)
#-----------------------------------------------------------------------------
def self.idle_animated?(vehicle)
return false if vehicle.nil? or Idle_Animated.nil?
return Idle_Animated.include?(vehicle)
end
#-----------------------------------------------------------------------------
# * Vehicle.empty_animated?(vehicle)
#-----------------------------------------------------------------------------
def self.empty_animated?(vehicle)
return false if vehicle.nil? or Empty_Animated.nil?
return Empty_Animated.include?(vehicle)
end
#-----------------------------------------------------------------------------
# * Vehicle.flight_animated?(vehicle)
#-----------------------------------------------------------------------------
def self.flight_animated?(vehicle)
return Flying.include?(vehicle) if !Flying.nil? or !vehicle.nil?
end
#-----------------------------------------------------------------------------
# * Vehicle.adjusting_altitude?
#-----------------------------------------------------------------------------
def self.adjusting_altitude?
return @adjusting_altitude.nil? ? false : @adjusting_altitude
end
#-----------------------------------------------------------------------------
# * Vehicle.flight_begin(vehicle)
#-----------------------------------------------------------------------------
def self.flight_begin(vehicle)
@altitude, shadow = 0, $scene.vehicle_shadow
shadow.x = $game_player.screen_x - ($scene.vehicle_shadow.bitmap.width / 2)
shadow.y = $game_player.screen_y - ($scene.vehicle_shadow.bitmap.height / 2)
shadow.visible = true
unless @altitude == Max_Altitude[vehicle] or Max_Altitude[vehicle].nil?
@adjusting_altitude = true
Max_Altitude[vehicle].times do $game_player.move_up(false) end
@adjusting_altitude = false
end
end
#-----------------------------------------------------------------------------
# * Vehicle.flight_end(vehicle)
#-----------------------------------------------------------------------------
def self.flight_end(vehicle)
@altitude = Max_Altitude[vehicle] if @altitude.nil?
$scene.vehicle_shadow.visible = true
unless @altitude == Max_Altitude[vehicle] or Max_Altitude[vehicle].nil?
@adjusting_altitude = true
Max_Altitude[vehicle].times do $game_player.move_down(false) end
@adjusting_altitude = false
end
end
end
#===============================================================================
# ** Event_Spawner
#-------------------------------------------------------------------------------
# Added a quick method to spawn a vehicle event when you exit the vehicle.
#===============================================================================
module Event_Spawner
#-----------------------------------------------------------------------------
# * Event_Spawner.print_list(event_id)
#-----------------------------------------------------------------------------
def self.print_list(event_id)
for commands in $game_map.events[event_id].list
p [commands.code, commands.parameters, commands.indent]
end
end
#-----------------------------------------------------------------------------
# * Event_Spawner.call_script([''], 0)
#-----------------------------------------------------------------------------
def self.call_script(parameters = [], indent = 0)
# Its basically add_event_command minus one argument.
add_event_command(355, parameters, indent)
end
#-----------------------------------------------------------------------------
# * Event_Spawner.create_vehicle(name, x, y)
#-----------------------------------------------------------------------------
def self.create_vehicle(name, x = $game_player.x, y = $game_player.y)
unless name.nil?
create_event(x, y, name)
@event.name = name
set_page_graphic({'c_name' => name})
set_page_options({'step_anime' => Vehicle.empty_animated?(name)})
call_script(['$game_player.enter_vehicle("'+name+'")'])
end_event
end
end
end
#===============================================================================
# ** Game_Character
#-------------------------------------------------------------------------------
# Simply added attribute accessors for 'character_name' and 'character_hue'
# that weren't writtable, just readable in default scripts.
#===============================================================================
class Game_Character
#-----------------------------------------------------------------------------
# * Attribute Accessors
#-----------------------------------------------------------------------------
attr_accessor :character_name
attr_accessor :character_hue
attr_accessor :step_anime
attr_accessor :always_on_top
attr_accessor :move_speed
attr_accessor :move_frequency
end
#===============================================================================
# ** Game_Player
#-------------------------------------------------------------------------------
# This class has been enhanced to mimic the player in the form of a vehicle,
# and so the player will inherit a vehicle's passability traits.
#===============================================================================
class Game_Player < Game_Character
#-----------------------------------------------------------------------------
# * Attributes
#-----------------------------------------------------------------------------
attr_accessor :vehicle
#-----------------------------------------------------------------------------
# * Alias Methods
#-----------------------------------------------------------------------------
alias_method :vehicle_system_game_player_update, :update
alias_method :vehicle_system_game_player_passable?, :passable?
#-----------------------------------------------------------------------------
# * Update (*Aliased*)
#-----------------------------------------------------------------------------
def update
exit_vehicle if Input.trigger?(Input::C) and !@vehicle.nil? and !moving?
vehicle_system_game_player_update
end
#-----------------------------------------------------------------------------
# * Passable? (*Aliased*)
#-----------------------------------------------------------------------------
def passable?(x, y, d)
unless @vehicle.nil?
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return Vehicle.passable?(new_x, new_y)
super
else ; vehicle_system_game_player_passable?(x, y, d)
end
end
#-----------------------------------------------------------------------------
# * Enter Vehicle
#-----------------------------------------------------------------------------
def enter_vehicle(vehicle)
return if vehicle.nil? or vehicle == "" or !@vehicle.nil?
@through = true
move_forward
@through = false
Vehicle.enter(vehicle)
end
#-----------------------------------------------------------------------------
# * Exit Vehicle
#-----------------------------------------------------------------------------
def exit_vehicle
if Vehicle.landable?(self.x, self.y, self.direction)
Vehicle.exit
@through = true
move_forward
@through = false
end
end
end
#===============================================================================
# ** Game_Map
#-------------------------------------------------------------------------------
# The autoplay function has been aliased so it doesn't go into effect while
# in a vehicle.
#===============================================================================
class Game_Map
#-----------------------------------------------------------------------------
# * Alias Methods
#-----------------------------------------------------------------------------
alias_method :vehicle_system_game_map_setup, :setup
alias_method :vehicle_system_game_map_autoplay, :autoplay
#-----------------------------------------------------------------------------
# * Setup (*Aliased*)
#-----------------------------------------------------------------------------
def setup(map_id)
vehicle_system_game_map_setup(map_id)
Vehicle.delete_disabled
end
#-----------------------------------------------------------------------------
# * Autoplay
#-----------------------------------------------------------------------------
def autoplay
vehicle_system_game_map_autoplay if $game_player.vehicle.nil?
end
#-----------------------------------------------------------------------------
# * Name : This Event
# Info : Simply returns event on, or event directly in front of you
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def this_event
x, y, d = $game_player.x, $game_player.y, $game_player.direction
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
for event in @events.values
return event.id if event.x == x && event.y == y
return event.id if event.x == new_x && event.y == new_y
end
end
#-----------------------------------------------------------------------------
# * Name : Event Count
# Info : Simply counts how many events are on the $game_map
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def event_count
return @events.empty? ? 0 : @events.size
end
end
#===============================================================================
# ** Scene_Map
#-------------------------------------------------------------------------------
# This scene has been aliased to handle the vehicle shadow creation and
# disposal
#===============================================================================
class Scene_Map
#-----------------------------------------------------------------------------
# * Attribute Accessor
#-----------------------------------------------------------------------------
attr_accessor :vehicle_shadow
#-----------------------------------------------------------------------------
# * Alias Methods
#-----------------------------------------------------------------------------
alias_method :vehicle_system_scene_map_main, :main
alias_method :vehicle_system_scene_map_update, :update
#-----------------------------------------------------------------------------
# * Main (*Aliased*)
#-----------------------------------------------------------------------------
def main
@vehicle_shadow = Sprite.new
@vehicle_shadow.bitmap = RPG::Cache.picture("Shadow")
@vehicle_shadow.x = $game_player.screen_x-(@vehicle_shadow.bitmap.width / 2)
@vehicle_shadow.y = $game_player.screen_y+(@vehicle_shadow.bitmap.height / 2)
@vehicle_shadow.z = $game_player.screen_z
@vehicle_shadow.visible = false
vehicle_system_scene_map_main
@vehicle_shadow.dispose unless @vehicle_shadow.nil?
end
#-----------------------------------------------------------------------------
# * Update (*Aliased*)
#-----------------------------------------------------------------------------
def update
vehicle_system_scene_map_update
@vehicle_shadow.visible = Vehicle.flight_animated?($game_player.vehicle)
unless $game_player.vehicle.nil?
unless Vehicle.adjusting_altitude?
@vehicle_shadow.x = $game_player.screen_x-(@vehicle_shadow.bitmap.width / 2)
@vehicle_shadow.y = $game_player.screen_y+(@vehicle_shadow.bitmap.height / 2)
@vehicle_shadow.z = $game_player.screen_z
end
else ; @vehicle_shadow.visible = false unless @vehicle_shadow.nil?
end
end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end
Too big to fit on the page, just go here.
Please note, you can test any real or spawned event's command list like so with this call script.
Code:
Event_Spawner.print_list($game_map.this_event) #<--Or any event ID.
You'll see the spawn events have commands, just the same as the real ones do, so I'm not sure what's wrong, why none of them do anything. I tried a couple generic test events with show message commands and they didn't do anything either. I don't know why, I never changed the origional Event_Spawner and it worked fine before.