Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Automatic Boat Call, Calls the boat automatically when stepping 'into' a river
BigEd781
post Dec 13 2008, 06:14 PM
Post #1


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




Automatic Boat Call
By BigEd781


Introduction
This script makes your game act like Final Fantasy I or Zelda I. In those games, when you had the "raft" or "boat" item in inventory and you attempted to walk 'into' a river, the boat would automatically appear and you would seamlessly board it. Same thing here; when you attempt to walk 'into' a river with a user defined item in inventory, an animation will play, the boat will be called, and you will automatically board it. An animation will also play when you get off of the boat and it will disappear. These options are configurable and can be turned off.

I think that I will add the same functionality for the boat as soon as I get some time.

Configuration / Use
I tried to be very clear in the configuration section of the script, so I will post that here:

CODE
# The item that must be in inventory for the boat to be called
  ITEM_ID = 1
  # If this is set to "true", a map name must include this text:
  #
  # <boat>
  #
  # in order for the boat to be called automatically.
  USE_BOAT_REQ = true
  # If this is set to "true", an animation will play
  # when the player gets on or off the boat.
  USE_ANIMATION = true
  # The animation displayed when the player gets on the
  # boat if USE_ANIMATION is set to "true".
  ON_ANIMATION_ID = 75
  # The animation displayed when the player gets off of the
  # boat if USE_ANIMATION is set to "true".
  OFF_ANIMATION_ID = 75
  # If this is set to "true", the boat will
  # disappear when the player gets off of it.
  REMOVE_VEHICLE = true


The reason that you are forced to enter "<boat>" into the map name by default (can be turned off) is because the boat can travel on any shallow water, including the tiles that would be normally used for rivers and streams in towns. By omitting the "<boat>" tag from the map name the boat will not be called automatically in these maps.


Script
Just place it in the "Materials" section.
CODE
module CallBoatConfig
    
  # The item that must be in inventory for the boat to be called
  ITEM_ID = 1
  # If this is set to "true", a map name must include this text:
  #
  # <boat>
  #
  # in order for the boat to be called automatically.
  USE_BOAT_REQ = true
  # If this is set to "true", an animation will play
  # when the player gets on or off the boat.
  USE_ANIMATION = true
  # The animation displayed when the player gets on the
  # boat if USE_ANIMATION is set to "true".
  ON_ANIMATION_ID = 75
  # The animation displayed when the player gets off of the
  # boat if USE_ANIMATION is set to "true".
  OFF_ANIMATION_ID = 75
  # If this is set to "true", the boat will
  # disappear when the player gets off of it.
  REMOVE_VEHICLE = true
end

class Game_Vehicle
  attr_accessor :direction  
end

class Game_Map
  
  alias :eds_pre_call_setup :setup
  def setup(map_id)
    eds_pre_call_setup(map_id)
    @info = load_data("Data/MapInfos.rvdata")    
  end
  
  def can_use_boat?
    return true unless CallBoatConfig::USE_BOAT_REQ
    return @info[@map_id].name.downcase.include?("<boat>")
  end
  
end

class Game_Player < Game_Character
include CallBoatConfig

  def should_call_boat?(x, y)
    return $game_map.can_use_boat? &&
           $game_party.items.include?($data_items[ITEM_ID]) &&
           $game_map.boat_passable?(x, y) &&
           !@vehicle_getting_on &&
           !in_vehicle?
  end
        
  def auto_call_boat(x, y, direction)      
    $game_map.vehicles[0].direction = direction
    $game_map.vehicles[0].set_location($game_map.map_id, x, y)
    $game_map.vehicles[0].animation_id = ON_ANIMATION_ID if USE_ANIMATION
    get_on_boat
  end
  #--------------------------------------------------------------------------
  # * Move Up
  #--------------------------------------------------------------------------
  alias :eds_pre_call_move_up :move_up
  def move_up(turn_ok = true)    
    if should_call_boat?(@x, @y - 1)      
      @direction = 0 unless @direction == 0
      auto_call_boat(@x, @y - 1, 0)
    else
      eds_pre_call_move_up(turn_ok)
    end
  end
  #--------------------------------------------------------------------------
  # * Move Right
  #--------------------------------------------------------------------------
  alias :eds_pre_call_move_right :move_right
  def move_right(turn_ok = true)
    if should_call_boat?(@x + 1, @y)
      @direction = 1 unless @direction == 1
      auto_call_boat(@x + 1, @y, 1)
    else
      eds_pre_call_move_right(turn_ok)
    end
  end
  #--------------------------------------------------------------------------
  # * Move Down  
  #--------------------------------------------------------------------------
  alias :eds_pre_call_move_down :move_down
  def move_down(turn_ok = true)
    if should_call_boat?(@x, @y + 1)
      @direction = 2 unless @direction == 2
      auto_call_boat(@x, @y + 1, 2)
    else
      eds_pre_call_move_down(turn_ok)    
    end
  end
  #--------------------------------------------------------------------------
  # * Move Left
  #--------------------------------------------------------------------------
  alias :eds_pre_call_move_left :move_left
  def move_left(turn_ok = true)
    if should_call_boat?(@x - 1, @y)
      @direction = 3 unless @direction == 3
      auto_call_boat(@x - 1, @y, 3)
    else
      eds_pre_call_move_left(turn_ok)
    end
  end  
  #--------------------------------------------------------------------------
  # * Get Off Vehicle  
  #--------------------------------------------------------------------------
  alias :eds_pre_call_get_off_vehicle :get_off_vehicle
  def get_off_vehicle
    in_boat = ( @vehicle_type == 0 )
    eds_pre_call_get_off_vehicle
    if REMOVE_VEHICLE && in_boat
      $game_map.vehicles[0].set_location(-1, 0, 0)
      $game_map.vehicles[0].animation_id = OFF_ANIMATION_ID if USE_ANIMATION
    end      
  end
  
end


Compatibility
Should be no problems. let me know of any bugs.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Urahara~
post Dec 13 2008, 06:39 PM
Post #2


Level 2
Group Icon

Group: Member
Posts: 26
Type: Developer
RM Skill: Skilled




This looks like an awesome script! but this is only good if you start with a boat if you don't it's pretty much useless to other players as we say in greek SKATA! Unless this script has a switch to switch it on.

This post has been edited by Urahara~: Dec 13 2008, 06:39 PM


__________________________
Im dead sexy :3
Go to the top of the page
 
+Quote Post
   
BigEd781
post Dec 13 2008, 06:42 PM
Post #3


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




I don't understand. The boat would be an item, and if that item is in the inventory it would be called. If you don't have that item, the script will not do anything. Look at this line in the config section:

CODE
# The item that must be in inventory for the boat to be called
ITEM_ID = 1


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Urahara~
post Dec 22 2008, 12:03 PM
Post #4


Level 2
Group Icon

Group: Member
Posts: 26
Type: Developer
RM Skill: Skilled




Oh sorry, great job!


__________________________
Im dead sexy :3
Go to the top of the page
 
+Quote Post
   
EvilM00s
post Dec 28 2008, 09:34 PM
Post #5



Group Icon

Group: Member
Posts: 4
Type: Writer
RM Skill: Intermediate




Hey. Being new to the scripting thing, I can't figure out how to turn off the need for <boat> to be in the map name to enable the script. Other than that, it's an answer to my EvilPrayers.


__________________________
Nothing is more offensive than the truth.





Which Final Fantasy Character Are You?
Final Fantasy 7


Go to the top of the page
 
+Quote Post
   
BigEd781
post Dec 28 2008, 09:41 PM
Post #6


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




Set his line to false instead of true:

CODE
USE_BOAT_REQ = true


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
EvilM00s
post Dec 28 2008, 09:55 PM
Post #7



Group Icon

Group: Member
Posts: 4
Type: Writer
RM Skill: Intermediate




Far out! Thank you, sir.


__________________________
Nothing is more offensive than the truth.





Which Final Fantasy Character Are You?
Final Fantasy 7


Go to the top of the page
 
+Quote Post
   
kccarmea
post Dec 28 2008, 10:28 PM
Post #8


Level 5
Group Icon

Group: Member
Posts: 64
Type: None
RM Skill: Undisclosed




Hi im using a different script you wrote a while back when I requested it and I need an airship but it always says "you cant place it here" or something. I cant get this new script to work right. Is there a common even required for the item to call it? This is the version I am using.

CODE
module CONFIG
  #----------------------------------------------------------------------------
  #    Configuration Settings
  #----------------------------------------------------------------------------
  #World Map map id to control when the airship can be called
  WORLD_MAP_ID         = 1
  #Change these to show a different animation using the database id  
  BOAT_ANIMATION_ID    = 75
  SHIP_ANIMATION_ID    = 75
  AIRSHIP_ANIMATION_ID = 75
  #Change this to alter the error message
  B_ERROR_TEXT =  ['','               You cannot call the boat from here']
  S_ERROR_TEXT =  ['','               You cannot call the ship from here']
  A_ERROR_TEXT =  ['','               You cannot call the airship from here']
end

class Vehicle_Caller
  
  def initialize
    @vehicle_loc = nil    
  end
  
  def show_error_message(message)
   unless $game_message.busy
     $game_message.position = 1
     $game_message.texts = message    
     $game_message.visible = true
   end
  end
  
  def call_boat    
    px = $game_player.x
    py = $game_player.y
    
    #Check the tiles surrounding the player.
    #and see if the boat can pass through the tile.
    #If it can, place it there.
    if $game_map.boat_passable?(px, py - 1)     #up
      @vehicle_loc = [px, py - 1]      
    elsif $game_map.boat_passable?(px + 1, py)  #right
      @vehicle_loc = [px + 1, py]      
    elsif $game_map.boat_passable?(px, py + 1)  #down
      @vehicle_loc = [px, py + 1]      
    elsif $game_map.boat_passable?(px - 1, py)  #left
      @vehicle_loc = [px - 1, py]      
    else
      @vehicle_loc = nil
    end    
    
    if @vehicle_loc != nil
      #Set the boat location
      $game_map.vehicles[0].set_location(
                            $game_map.map_id, @vehicle_loc[0], @vehicle_loc[1])      
      $game_map.vehicles[0].animation_id = CONFIG::BOAT_ANIMATION_ID
    else
      #nowhere to put the boat, show an error message
      show_error_message(CONFIG::B_ERROR_TEXT)
    end
  end  
  
  def call_ship    
    px = $game_player.x
    py = $game_player.y
    
    #Check the tiles surrounding the player.
    #and see if the ship can pass through the tile.
    #If it can, place it there.
    if $game_map.ship_passable?(px, py - 1)     #up
      @vehicle_loc = [px, py - 1]      
    elsif $game_map.ship_passable?(px + 1, py)  #right
      @vehicle_loc = [px + 1, py]      
    elsif $game_map.ship_passable?(px, py + 1)  #down
      @vehicle_loc = [px, py + 1]      
    elsif $game_map.ship_passable?(px - 1, py)  #left
      @vehicle_loc = [px - 1, py]      
    else
      @vehicle_loc = nil
    end
    
    if @vehicle_loc != nil
      #Set the ship location
      $game_map.vehicles[1].set_location(
                            $game_map.map_id, @vehicle_loc[0], @vehicle_loc[1])      
      $game_map.vehicles[1].animation_id = CONFIG::SHIP_ANIMATION_ID
    else
      #nowhere to put the ship, show an error message
      show_error_message(CONFIG::S_ERROR_TEXT)
    end
  end  
  
  def call_airship    
    px = $game_player.x
    py = $game_player.y
    
    #if this is the world map...
    if $game_map.map_id == CONFIG::WORLD_MAP_ID
      #...check the tiles surrounding the player.
      #if a tile is passable when the 0x01 flag is passed
      #to the function, the player can walk there.  If that is true,
      #we then check to see if the airship could land there.
      #After that, make sure that there is no event on that tile.
      #If these conditions are all true, place it there.
      if $game_map.passable?(px, py - 1, 0x01) and     #up
         $game_map.airship_land_ok?(px, py - 1)and     #can land
         $game_map.events_xy(px, py - 1) == []         #no event
        @vehicle_loc = [px, py - 1]      
      elsif $game_map.passable?(px + 1, py, 0x01) and  #right
            $game_map.airship_land_ok?(px + 1, py)and  #can land
            $game_map.events_xy(px + 1, py) == []      #no event
        @vehicle_loc = [px + 1, py]      
      elsif $game_map.passable?(px, py + 1, 0x01) and  #down
            $game_map.airship_land_ok?(px, py + 1)and  #can land
            $game_map.events_xy(px, py + 1) == []      #no event
        @vehicle_loc = [px, py + 1]      
      elsif $game_map.passable?(px - 1, py, 0x01) and  #left
            $game_map.airship_land_ok?(px - 1, py)and  #can land
            $game_map.events_xy(px - 1, py) == []      #no event
        @vehicle_loc = [px - 1, py]      
      else
        @vehicle_loc = nil
      end
    else
      show_error_message(CONFIG::A_ERROR_TEXT)
      return
    end
    
    if @vehicle_loc != nil
      #Set the airship location
      $game_map.vehicles[2].set_location(
                            $game_map.map_id, @vehicle_loc[0], @vehicle_loc[1])      
      $game_map.vehicles[2].animation_id = CONFIG::AIRSHIP_ANIMATION_ID
    else
      #nowhere to put the airship, show an error message
      show_error_message(CONFIG::A_ERROR_TEXT)
    end
  end  
end
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 09:25 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker