Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX]Vehicle modification

I have been fooling around with the VX a while and got to the conclution that what I want, cant be done with events. In the case it CAN be done with events, sorry to have posted this X P
Actually I have two request:

The vehicle system on the VX is very simple, there is a boat/ship/aircraft on the map and you "climb" on board and travel wherever you want... the classic vehicle system

1)I was wondering if it was possible to change the vehicles graphic at the time you get on board it, for example change the graphic of the boat, for a boat but with the hero onboard... or a horse and the change the charaset, for a graphic with the hero riding the horse

basically "Change the graphic of the vehicle on boarding it"

2)This one I`m guessing could be more complicated... instead of having a vehicle FOR the airship... you could BE the airship... imagine "Superman the rpg", superman shoudnt need to walk to the airship or a certain spot to fly... He whould to it whenever he wanted, walk around then press an unused button (C for instance) and fly up in the air to the generic dungeon and then land to get in.

basically "That the hero could fly, on his own"

I hope the request is clear, if something is lacking I`ll edit ir right away

Thanks in advance
 
This doesn't need a script. It needs an edit to the vehicle graphic.

When the hero gets on board the vehicle, change the graphic of the vehicle to the new graphic using an event. easy. At work at the moment, so I could be wrong. I'll check later. If it needs a script i'll make one, i'll post a demo in the next 24 hours (scripted or unscripted)
 
at work at the mo, but honestly.. both of those are doable!
rest assured, it will be looked at over the next 24 hours, and if its as simple as i think it is, expect a demo by then, if not give it another day and i'm sure i can get something up!  :wink:
Edit: I'm a scriper not a spriter, so i will do a simple graphics change using the rtp, you may need a graphics request for the new airship/flying hero sprite
 
Here, it was harder to code than I though but it works!
Code:
#==============================================================================
# ** Advanced Vehicle System
#------------------------------------------------------------------------------
#  © Dargor, 2008
#  27/03/08
#  Version 1.0
#------------------------------------------------------------------------------
#  VERSION HISTORY:
#   - 1.0 (27/03/08), Initial release
#------------------------------------------------------------------------------
#  INSTRUCTIONS:
#     1)  Edit the variables in the Vehicle Module
#     2)  Edit the new variables in Game_System
#==============================================================================

#==============================================================================
# ** Vehicle Module
#==============================================================================
module Vehicle
  Key = Input::SHIFT
  Switch = 1
  Fly_BGM = RPG::BGM.new('Airship')
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :boat_character
  attr_accessor :ship_character
  attr_accessor :airship_character
  attr_accessor :fly_character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_system_vehicle_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @boat_character = ['Vehicle',4]
    @ship_character = ['Vehicle',5]
    @airship_character = ['Vehicle',6]
    @fly_character = ['Actor1',0]
    dargor_vx_system_vehicle_initialize
  end
end

#==============================================================================
# ** Game_Vehicle
#------------------------------------------------------------------------------
#  This class handles vehicles. It's used within the Game_Map class. If there
# are no vehicles on the current map, the coordinates is set to (-1,-1).
#==============================================================================

class Game_Vehicle < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_vehicle_graphic_load_system_settings load_system_settings
  alias dargor_vx_vehicle_graphic_get_on get_on
  alias dargor_vx_vehicle_graphic_get_off get_off
  alias dargor_vx_vehicle_graphic_refresh refresh
  alias dargor_vx_vehicle_graphic_upddate update
  alias dargor_vx_vehicle_graphic_movable? movable?
  #--------------------------------------------------------------------------
  # * Load System Settings
  #--------------------------------------------------------------------------
  def load_system_settings
    dargor_vx_vehicle_graphic_load_system_settings
    case @type
    when 3
      $game_player = Game_Player.new if $game_player.nil?
      @character_name = $game_system.fly_character[0]
      @character_index = $game_system.fly_character[1]
      @bgm = Vehicle::Fly_BGM
      if $game_map.nil?
        @map_id = $data_system.start_map_id
      else
        @map_id = $game_map.map_id
      end
      if $game_player.nil?
        @x = $data_system.start_x
        @y = $data_system.start_y
      else
        @x = $game_player.x
        @y = $game_player.y
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    dargor_vx_vehicle_graphic_refresh
    case @type
    when 3
      @priority_type = @driving ? 2 : 0
      @move_speed = 6
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    dargor_vx_vehicle_graphic_upddate
    if @type == 3               # If flying
      if $game_player.pos?(@x, @y) and (@driving or $game_player.vehicle_getting_off)
        @character_name = $game_system.fly_character[0]
        @character_index = $game_system.fly_character[1]
      else
        @character_name = ''
        @character_index = 0
      end
      if @driving
        if @altitude < MAX_ALTITUDE
          @altitude += 1        # Increase altitude
        end
      elsif @altitude > 0
        @altitude -= 1          # Decrease altitude
        if @altitude == 0
          @priority_type = 0    # Return priority to "Below Characters"
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if Movement is Possible
  #--------------------------------------------------------------------------
  def movable?
    return false if (@type == 3 and @altitude < MAX_ALTITUDE)
    dargor_vx_vehicle_graphic_movable?
  end
  #--------------------------------------------------------------------------
  # * Board Vehicle
  #--------------------------------------------------------------------------
  def get_on
    dargor_vx_vehicle_graphic_get_on
    if @type == 3               # If flying
      @priority_type = 2        # Change priority to "Above Characters"
    end
    change_graphic
  end
  #--------------------------------------------------------------------------
  # * Get Off Vehicle
  #--------------------------------------------------------------------------
  def get_off
    dargor_vx_vehicle_graphic_get_off
    @direction = $game_player.direction if @type == 3
    change_graphic
  end
  #--------------------------------------------------------------------------
  # * Change Graphic
  #--------------------------------------------------------------------------
  def change_graphic
    if @driving
      case @type
      when 0
        @character_name = $game_system.boat_character[0]
        @character_index = $game_system.boat_character[1]
      when 1
        @character_name = $game_system.ship_character[0]
        @character_index = $game_system.ship_character[1]
      when 2
        @character_name = $game_system.airship_character[0]
        @character_index = $game_system.airship_character[1]
      when 3
        @character_name = $game_system.fly_character[0]
        @character_index = $game_system.fly_character[1]
      end
    else
      load_system_settings
    end
    refresh
  end
end

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :vehicle_getting_off
  attr_accessor :direction
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_player_vehicle_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    dargor_vx_player_vehicle_update
    if Input.trigger?(Vehicle::Key) and $game_switches[Vehicle::Switch]
      get_on_fly
    end
  end
  #--------------------------------------------------------------------------
  # * Board Airship
  #--------------------------------------------------------------------------
  def get_on_fly
    @vehicle_getting_on = true        # Start boarding operation
    @vehicle_type = 3                 # Set vehicle type
    @through = true                   # Passage ON
    @walking_bgm = RPG::BGM::last     # Memorize walking BGM
    $game_map.fly.get_on          # Boarding processing
  end
  #--------------------------------------------------------------------------
  # * Get Off Vehicle
  #    Assumes that the player is currently riding in a vehicle.
  #--------------------------------------------------------------------------
  def get_off_vehicle
    if in_airship? or @vehicle_type == 3          # Airship
      return unless airship_land_ok?(@x, @y)      # Can't land?
    else                                          # Boat/ship
      front_x = $game_map.x_with_direction(@x, @direction)
      front_y = $game_map.y_with_direction(@y, @direction)
      return unless can_walk?(front_x, front_y)   # Can't touch land?
    end
    $game_map.vehicles[@vehicle_type].get_off     # Get off processing
    if in_airship? or @vehicle_type == 3          # Airship or Flying
      @direction = 2                              # Face down
    else                                          # Boat/ship
      force_move_forward                          # Move one step forward
      @transparent = false                        # Remove transparency
    end
    @vehicle_getting_off = true                   # Start getting off operation
    @move_speed = 4                               # Return move speed
    @through = false                              # Passage OFF
    @walking_bgm.play                             # Restore walking BGM
    make_encounter_count                          # Initialize encounter
  end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_vehicle_map_create_vehicles create_vehicles
  #--------------------------------------------------------------------------
  # * Create Vehicles
  #--------------------------------------------------------------------------
  def create_vehicles
    dargor_vx_vehicle_map_create_vehicles
    @vehicles[3] = Game_Vehicle.new(3)    # Fly
  end
  #--------------------------------------------------------------------------
  # * Get Airship
  #--------------------------------------------------------------------------
  def fly
    return @vehicles[3]
  end
end

Follow the instructions in the script header.

Hope you like it!
-Dargor
 
I think there is  a small bug... when you board any vehicle... move a bit and get of the that vehicle... it desapears and "lands" on the spot where you boarded it in the first place  @_@
... or I`m doing something wrong... XP

The flying is awsome... is there a way to add the shadow that the airship projects to it?

Thx for this!
 
I believe the second request is doable with events, though I am in no way a scripter, so I don't know if it would be easier with scripts:

1) In system, make the airship the graphic of the character flying.
2) Make an "Input Key" thing.
3) When "C" (or whatever you want) is pressed, move the airship to the player's location.
4) Use the "Get On/Off" vehicle event thing.
5) Use a parallel process that checks if the player is in the airship.
6) In the "else" thing, move the airship to somewhere where they cant see it.

Not really sure how well this would work, but I think it would. I don't have time to make a demo and try it.
 
I have added the shadow sprite but I'm still trying to figure out how to fix the other problem.
Here's the updated version. The next one should come soon :smile:
Code:
#==============================================================================
# ** Advanced Vehicle System
#------------------------------------------------------------------------------
#  © Dargor, 2008
#  31/03/08
#  Version 1.1
#------------------------------------------------------------------------------
#  VERSION HISTORY:
#   - 1.0 (27/03/08), Initial release
#   - 1.1 (31/03/08), Flying shadow added
#------------------------------------------------------------------------------
#  INSTRUCTIONS:
#     1)  Edit the variables in the Vehicle Module
#     2)  Edit the new variables in Game_System
#==============================================================================

#==============================================================================
# ** Vehicle Module
#==============================================================================
module Vehicle
  Key = Input::SHIFT
  Switch = 1
  Fly_BGM = RPG::BGM.new('Airship')
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :boat_character
  attr_accessor :ship_character
  attr_accessor :airship_character
  attr_accessor :fly_character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_system_vehicle_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @boat_character = ['Vehicle',4]
    @ship_character = ['Vehicle',5]
    @airship_character = ['Vehicle',6]
    @fly_character = ['Actor1',0]
    dargor_vx_system_vehicle_initialize
  end
end

#==============================================================================
# ** Game_Vehicle
#------------------------------------------------------------------------------
#  This class handles vehicles. It's used within the Game_Map class. If there
# are no vehicles on the current map, the coordinates is set to (-1,-1).
#==============================================================================

class Game_Vehicle < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_vehicle_graphic_load_system_settings load_system_settings
  alias dargor_vx_vehicle_graphic_get_on get_on
  alias dargor_vx_vehicle_graphic_get_off get_off
  alias dargor_vx_vehicle_graphic_refresh refresh
  alias dargor_vx_vehicle_graphic_upddate update
  alias dargor_vx_vehicle_graphic_movable? movable?
  #--------------------------------------------------------------------------
  # * Load System Settings
  #--------------------------------------------------------------------------
  def load_system_settings
    dargor_vx_vehicle_graphic_load_system_settings
    case @type
    when 3
      $game_player = Game_Player.new if $game_player.nil?
      @character_name = $game_system.fly_character[0]
      @character_index = $game_system.fly_character[1]
      @bgm = Vehicle::Fly_BGM
      if $game_map.nil?
        @map_id = $data_system.start_map_id
      else
        @map_id = $game_map.map_id
      end
      if $game_player.nil?
        @x = $data_system.start_x
        @y = $data_system.start_y
      else
        @x = $game_player.x
        @y = $game_player.y
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    dargor_vx_vehicle_graphic_refresh
    case @type
    when 3
      @priority_type = @driving ? 2 : 0
      @move_speed = 6
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    dargor_vx_vehicle_graphic_upddate
    if @type == 3               # If flying
      if $game_player.pos?(@x, @y) and (@driving or $game_player.vehicle_getting_off)
        @character_name = $game_system.fly_character[0]
        @character_index = $game_system.fly_character[1]
      else
        @character_name = ''
        @character_index = 0
      end
      if @driving
        if @altitude < MAX_ALTITUDE
          @altitude += 1        # Increase altitude
        end
      elsif @altitude > 0
        @altitude -= 1          # Decrease altitude
        if @altitude == 0
          @priority_type = 0    # Return priority to "Below Characters"
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if Movement is Possible
  #--------------------------------------------------------------------------
  def movable?
    return false if (@type == 3 and @altitude < MAX_ALTITUDE)
    dargor_vx_vehicle_graphic_movable?
  end
  #--------------------------------------------------------------------------
  # * Board Vehicle
  #--------------------------------------------------------------------------
  def get_on
    dargor_vx_vehicle_graphic_get_on
    if @type == 3               # If flying
      @priority_type = 2        # Change priority to "Above Characters"
    end
    change_graphic
  end
  #--------------------------------------------------------------------------
  # * Get Off Vehicle
  #--------------------------------------------------------------------------
  def get_off
    dargor_vx_vehicle_graphic_get_off
    @direction = $game_player.direction if @type == 3
    change_graphic
  end
  #--------------------------------------------------------------------------
  # * Change Graphic
  #--------------------------------------------------------------------------
  def change_graphic
    if @driving
      case @type
      when 0
        @character_name = $game_system.boat_character[0]
        @character_index = $game_system.boat_character[1]
      when 1
        @character_name = $game_system.ship_character[0]
        @character_index = $game_system.ship_character[1]
      when 2
        @character_name = $game_system.airship_character[0]
        @character_index = $game_system.airship_character[1]
      when 3
        @character_name = $game_system.fly_character[0]
        @character_index = $game_system.fly_character[1]
      end
    else
      load_system_settings
    end
    refresh
  end
end

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :vehicle_getting_off
  attr_accessor :direction
  attr_accessor :vehicle_type
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_player_vehicle_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    dargor_vx_player_vehicle_update
    if Input.trigger?(Vehicle::Key) and $game_switches[Vehicle::Switch]
      get_on_fly
    end
  end
  #--------------------------------------------------------------------------
  # * Board Airship
  #--------------------------------------------------------------------------
  def get_on_fly
    @vehicle_getting_on = true        # Start boarding operation
    @vehicle_type = 3                 # Set vehicle type
    @through = true                   # Passage ON
    @walking_bgm = RPG::BGM::last     # Memorize walking BGM
    $game_map.fly.get_on          # Boarding processing
  end
  #--------------------------------------------------------------------------
  # * Get Off Vehicle
  #    Assumes that the player is currently riding in a vehicle.
  #--------------------------------------------------------------------------
  def get_off_vehicle
    if in_airship? or @vehicle_type == 3          # Airship
      return unless airship_land_ok?(@x, @y)      # Can't land?
    else                                          # Boat/ship
      front_x = $game_map.x_with_direction(@x, @direction)
      front_y = $game_map.y_with_direction(@y, @direction)
      return unless can_walk?(front_x, front_y)   # Can't touch land?
    end
    $game_map.vehicles[@vehicle_type].get_off     # Get off processing
    if in_airship? or @vehicle_type == 3          # Airship or Flying
      @direction = 2                              # Face down
    else                                          # Boat/ship
      force_move_forward                          # Move one step forward
      @transparent = false                        # Remove transparency
    end
    @vehicle_getting_off = true                   # Start getting off operation
    @move_speed = 4                               # Return move speed
    @through = false                              # Passage OFF
    @walking_bgm.play                             # Restore walking BGM
    make_encounter_count                          # Initialize encounter
  end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_vehicle_map_create_vehicles create_vehicles
  #--------------------------------------------------------------------------
  # * Create Vehicles
  #--------------------------------------------------------------------------
  def create_vehicles
    dargor_vx_vehicle_map_create_vehicles
    @vehicles[3] = Game_Vehicle.new(3)    # Fly
  end
  #--------------------------------------------------------------------------
  # * Get Airship
  #--------------------------------------------------------------------------
  def fly
    return @vehicles[3]
  end
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Update Airship Shadow Sprite
  #--------------------------------------------------------------------------
  def update_shadow
    if $game_player.vehicle_type == 3
      airship = $game_map.fly
    else
      airship = $game_map.airship
    end
    @shadow_sprite.x = airship.screen_x
    @shadow_sprite.y = airship.screen_y + airship.altitude
    @shadow_sprite.opacity = airship.altitude * 8
    @shadow_sprite.update
  end
end
 
wow this is the script I was looking for the airship changes whenever your character rides it. but how do you use this ? are there any demos or screen shots? is the shadow sprites also animated?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top