RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Vehicle Maps

0 Members and 1 Guest are viewing this topic.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Vehicle Maps
Version: 1.0
Author: TDS
Date: May 6, 2011

Version History


  • <Version 1.0> 05.06.2011 - Public release

Description


This script allows you to assign a map that can be used as the interior of a vehicle, and can be accessed by pressing the "Shift" key while riding the vehicle.

Features

  • Gives vehicles a map.
  • Vehicle maps can be changed at any time.
  • Allows you to return directly to the vehicle from a map.

Instructions

To set a Vehicle map use this in a script call from an event:
Code: [Select]
set_vehicle_map(vehicle, map_id, x, y, direction = 2)

vehicle   =  Vehicle type (0: boat, 1: ship, 2: airship)
map_id    = map id
x         = x-coordinate
y         = y-coordinate
direction = direction  (2,4,6,8) 

Example:
Code: [Select]
set_vehicle_map(1, 9, 8, 5, 2)


To return to a vehicle use this in a script call from an event.
Code: [Select]
 
return_to_vehicle(vehicle)

vehicle   =  Vehicle type (0: boat, 1: ship, 2: airship)

Example:
Code: [Select]
return_to_vehicle(2)


To remove a vehicle map information, use this in a script call from an event:
Code: [Select]
clear_vehicle_map(vehicle)
 
vehicle   : Vehicle type (-1: all 0: boat, 1: ship, 2: airship)

Example:
Code: [Select]
clear_vehicle_map(1)

Script


Code: [Select]
#==============================================================================
# ** TDS Vehicle Maps
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  This script gives vehicles a map that can be accessed while on the vehicle.
#------------------------------------------------------------------------------
#  * Features:
#  Gives vehicles a map.
#  Vehicle maps can be changed at any time.
#  Allows you to return directly to the vehicle from a map.
#------------------------------------------------------------------------------
#  * Instructions:
#  To set a Vehicle map use this in a script call from an event:
#
#  set_vehicle_map(vehicle, map_id, x, y, direction = 2)
#
#  vehicle   =  Vehicle type (0: boat, 1: ship, 2: airship)
#  map_id    = map id
#  x         = x-coordinate
#  y         = y-coordinate
#  direction = direction  (2,4,6,8) 
#
#  Example:
#
#  set_vehicle_map(1, 9, 8, 5, 2)
#
#
#  To return to a vehicle use this in a script call from an event.

#  return_to_vehicle(vehicle)
#
#  vehicle   =  Vehicle type (0: boat, 1: ship, 2: airship)
#
#  Example:
#
#  return_to_vehicle(2)
#
#
#  To remove a vehicle map information, use this in a script call from an event:
#
#  clear_vehicle_map(vehicle)
#
#  vehicle   : Vehicle type (-1: all 0: boat, 1: ship, 2: airship)
#
#  Example:
#
#  clear_vehicle_map(1)
#------------------------------------------------------------------------------
#  * Notes:
#  To access a Vehicle Map press the "Shift" key.
#------------------------------------------------------------------------------
#  * New Methods:
#  Game_Vehicle:
#  - current_location
#    ^ Method used to get a vehicles current location.
#
#  Game_Player:
#  - can_transfer_to_vehicle_map?
#    ^ Method used to determine if it's possible to go to a vehicle map.
#  - setup_vehicle_map_transfer
#    ^ Method used to setup a transfer from the vehicle to it's map.
#  - return_to_vehicle_transfer(vehicle)
#    ^ Method used to return the player to a vehicle from a map.
#
#  Game_Interpreter:
#  - set_vehicle_map(vehicle, map_id, x, y, direction = 2)
#    ^ Method used to set a vehicles map and placing information.
#  - clear_vehicle_map(vehicle)
#    ^ Method used to remove vehicle map information.
#  - return_to_vehicle(vehicle)
#    ^ Method used to return the player to a vehicle from a map.
#
#  Scene_Map:
#  - update_vehicle_map_transfer
#    ^ Method that waits for input to transfer player to a vehicle map.
#  - update_transfer_to_vehicle
#    ^ Method to smoothly transfer into a vehicle from a map.
#------------------------------------------------------------------------------
#  * Aliased Methods:
#  Game_Player:
#  - initialize
#    ^ Aliased to initialize vehicle map values hash
#
#  Scene_Map:
#  - update
#    ^ Aliased to wait for input to transfer into a Vehicle map.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================

#==============================================================================
# ** 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
 #--------------------------------------------------------------------------
  # * Get Vehicle Current Position Values
  #--------------------------------------------------------------------------
  def current_location
    # Return Vehicle Map ID, X and Y Values
    return @map_id, @x, @y, @direction
  end 
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor   :vehicle_maps               # Vehicle Maps Properties Hash
  #--------------------------------------------------------------------------
  # * Alias Listings
  #-------------------------------------------------------------------------- 
  alias tds_vehicle_map_game_player_initialize      initialize      unless $@ 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Run Original Method
    tds_vehicle_map_game_player_initialize
    # Vehicle Maps Properties Hash
    @vehicle_maps = {}
  end
  #--------------------------------------------------------------------------
  # * Determine if it's possible to transfer into a vehicle map
  #--------------------------------------------------------------------------
  def can_transfer_to_vehicle_map?
    # Return False if moving
    return false if moving?
    # Return false if not in vehicle
    return false if !in_vehicle?
    # Return false if Vehicle Map Information is nil
    return false if @vehicle_maps[@vehicle_type] == nil
    # Return true
    return true
  end
  #--------------------------------------------------------------------------
  # * Setup Vehicle Map Transfer
  #--------------------------------------------------------------------------
  def setup_vehicle_map_transfer
    # Get off Vehicle processing
    $game_map.vehicles[@vehicle_type].get_off
    # Transfer information
    t_inf = @vehicle_maps[@vehicle_type]   
    # Erase vehicle type
    @vehicle_type = -1
    # Reserve Player Map Transfter
    reserve_transfer(t_inf[0], t_inf[1], t_inf[2], t_inf[3])
    # Remove transparency
    @transparent = false                     
    # Passage OFF       
    @through = false
    # Reset Move Speed to normal walking
    @move_speed = 4   
  end 
  #--------------------------------------------------------------------------
  # * Return to Vehicle Transfer
  #     vehicle   : Vehicle type (0: boat, 1: ship, 2: airship) 
  #--------------------------------------------------------------------------
  def return_to_vehicle_transfer(vehicle)   
    # Map Transfer Information
    t_inf = $game_map.vehicles[vehicle].current_location   
    # Reserve Player Map Transfter
    reserve_transfer(t_inf[0], t_inf[1], t_inf[2], t_inf[3])   
    # Vehicle Case
    case vehicle
    when 0 ; get_on_boat
    when 1 ; get_on_ship
    when 2 ; get_on_airship
    end   
    # Set Walking BGM to map BGM   
    @walking_bgm = load_data(sprintf("Data/Map%03d.rvdata", t_inf[0])).bgm
  end 
end


#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Set a Map for a Vehicle
  #     vehicle   : Vehicle type (0: boat, 1: ship, 2: airship)
  #     map_id    : map id
  #     x         : x-coordinate
  #     y         : y-coordinate
  #     direction : direction  (2,4,6,8) 
  #--------------------------------------------------------------------------
  def set_vehicle_map(vehicle, map_id, x, y, direction = 2)
    # Set Vehicle Map Information
    $game_player.vehicle_maps[vehicle] = [map_id, x, y, direction]
  end
  #--------------------------------------------------------------------------
  # * Removes Vehicle Map Information
  #     vehicle   : Vehicle type (-1: all 0: boat, 1: ship, 2: airship)
  #--------------------------------------------------------------------------
  def clear_vehicle_map(vehicle)
    # If Vehicle type is less than 0 (Remove All)
    if vehicle < 0
      # Remove all Vehicle Map Information
      $game_player.vehicle_maps.clear
    else
      # Remove Vehicle Information From Hash
      $game_player.vehicle_maps.delete(vehicle)     
    end     
  end 
  #--------------------------------------------------------------------------
  # * Return to a Vehicle
  #     vehicle   : Vehicle type (0: boat, 1: ship, 2: airship)
  #--------------------------------------------------------------------------
  def return_to_vehicle(vehicle)
    # If on Scene Map
    if $scene.is_a?(Scene_Map)     
      # Fadeout Screen
      $scene.fadeout(30)
      # Return Player to Vehicle Process
      $game_player.return_to_vehicle_transfer(vehicle)
      # Loop 25 times(Frames)
      (25).times do
        # Update Basic
        $scene.update_basic
        # Update Game Player
        $game_player.update
        # Update Transfer to Vehicle
        $scene.update_transfer_to_vehicle       
      end
      # Fade In Screen
      $scene.fadein(30)
    end
  end
end


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

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_vehicle_map_scene_map_update          update            unless $@ 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Run Original Method
    tds_vehicle_map_scene_map_update
    # Update Vehnicle Map Transfer
    update_vehicle_map_transfer   
  end
  #--------------------------------------------------------------------------
  # * Update Vehicle Map Transfer
  #--------------------------------------------------------------------------
  def update_vehicle_map_transfer   
    # Return if displaying a message
    return if $game_message.visible
    # Return if Game Map Interpreter is running
    return if $game_map.interpreter.running?
    # Return if Game Player cannot transfer into a vehicle map
    return if !$game_player.can_transfer_to_vehicle_map?
    # If Input Trigger Shift
    if Input.trigger?(Input::A)     
      # Fadeout Screen
      fadeout(30)
      # Transfer Player to Vehicle Map
      $game_player.setup_vehicle_map_transfer
      # Loop 20 times(Frames)
      (20).times do
        # Update Basic
        update_basic
        # Update Player Map Transfer
        update_transfer_player
      end
      # Fade In Screen
      fadein(30)
    end   
  end
  #--------------------------------------------------------------------------
  # * Player Transfer to Vehicle Processing
  #--------------------------------------------------------------------------
  def update_transfer_to_vehicle
    return unless $game_player.transfer?
    @spriteset.dispose              # Dispose of sprite set
    $game_player.perform_transfer   # Execute player transfer
    $game_map.update
    Graphics.wait(15)
    @spriteset = Spriteset_Map.new  # Recreate sprite set
    Input.update
  end 
end

Credit


  • TDS

Support


On this topic.

Known Compatibility Issues

There may be a slight incompatibility issue with BGM of maps under certain circumstances.


Author's Notes


To go into a Vehicle map press the "Shift" key while on the vehicle.

Restrictions

Only for use in non-commercial games".
« Last Edit: May 08, 2011, 03:07:44 AM by TDS »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
This seems like a great idea. I was a little confused with the description, but I take it that the purpose of the script is that when you are in a vehicle, you can press shift and it will bring you to a new map (which you can design to be the inside of the ship or boat or what have you). That is something I have seen quite a few requests for - good work TDS.

I think you should probably modify the description a little bit to better reflect that though.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Yeah, script descriptions are the main reason I don't release some of the more complex scripts I've made...

No matter how hard I try, most of the time I end up drawing a blank when trying to describes my scripts.

Thank you for you Input and I'll try to see if I can come up with better descriptions.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Yeah, it's pretty tough :) It usually takes me more time to write out descriptions and instructions for my scripts than it does to actually write the scripts, and it's a thousand times more boring.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
That's why my script descriptions are so wacky. I often unintentionally insult the maker in the description.
At first, I had next to no idea what this script did, the I tried it and it's actually really cool. Another original and innovative function by TDS.
it's like a metaphor or something i don't know