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
> [Vehicle Call Script] By BigEd781, Call any vehicle dynamically and show an animation
BigEd781
post Aug 21 2008, 12:12 AM
Post #1


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

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




Vehicle Call Script 2.0

Provided by BigEd781


Updated

- Now call any vehicle


Introduction

This is a simple script that will allow you to call any vehicle from the map with an animation.
This is most useful for something like an item that can call a vehicle from anywhere.
Anyone can use this script, I don't care about credit in your game, but if you do post it on another forum please attribute the script to me.

Features

-> Easy to use, two line script call.
-> Reliable, will only call the vehicle if it is appropriate. Otherwise, an error message is displayed.
-> Shows an animation when the vehicle is called.
-> Easily configurable.

How To Use

Place the script in the materials section. To call the vehicle, use the "Script..." event command and use this code:

CODE
vehicle_caller = Vehicle_Caller.new


Depending on which vehicle you would like to call, place one of the following lines after "vehicle_caller = Vehicle_Caller.new".

Boat:
CODE
vehicle_caller.call_boat


Ship:
CODE
vehicle_caller.call_ship


Airship:
CODE
vehicle_caller.call_airship


Configuration

There are really only three things to configure currently. These can be found in the beginning of the script, in the CONFIGURE module.

CODE
module CONFIG
  #----------------------------------------------------------------------------
  #    Configuration Settings
  #----------------------------------------------------------------------------
  #World Map map id to control when the airship can be called
  WORLD_MAP_IDs         = [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


WORLD_MAP_ID - This is an array of map ids from which the airship can be called. This is used so that the player cannot call the airship from any map but those designated by you as ok.
To add to this array, just use a comma and the new map id, like so:
CODE
WORLD_MAP_IDs         = [1, 2, 3]

Now you can call the airship from map 1, 2, or 3.

BOAT_ANIMATION_ID - This is the animation that is displayed when the boat is called. Uses the database id.
SHIP_ANIMATION_ID - This is the animation that is displayed when the ship is called. Uses the database id.
AIRSHIP_ANIMATION_ID - This is the animation that is displayed when the airship is called. Uses the database id.

B_ERROR_TEXT - The text displayed when the user attempts to call the boat from an invalid location.
S_ERROR_TEXT - The text displayed when the user attempts to call the ship from an invalid location.
A_ERROR_TEXT - The text displayed when the user attempts to call the airship from an invalid location.

The error text is a string array. The first entry (the \'\') is just a line break.
Change the text after that, between the two apostrophes (\') to change what is displayed.
The extra spaces are just padding so that the text is centered. I am sure there is a function for this, but I couldn't find one (quickly), so meh.

Demo and Screenshots

Not really necessary.

Script


CODE
module CONFIG
  #----------------------------------------------------------------------------
  #    Configuration Settings
  #----------------------------------------------------------------------------
  #World Map map id to control when the airship can be called
  WORLD_MAP_IDs         = [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 a world map...
    if  CONFIG::WORLD_MAP_IDs.include?($game_map.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




Future Plans

Well...there are none. I am pretty busy, but I will take feature requests if there are any.

There is one behavior that could be considered a glitch. The tile that is chosen for the vehicle location is simply the first valid one.
So, this means that if you were surrounded by valid tiles, the boat would always appear above the player (the script checks surrounding tiles in a counter clockwise fashion).
If this really needed to be fixed, I could check which way the player is facing, but I don't think it is necessary.
Attached File(s)
Attached File  vehicle_Caller.txt ( 4.99K ) Number of downloads: 78
 


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Netto
post Aug 21 2008, 12:36 AM
Post #2


芸術家
Group Icon

Group: Revolutionary
Posts: 708
Type: None
RM Skill: Skilled




Useful, I can see how this would come in handy, but I'm not sure if I'm going to have a world map tongue.gif , it does work on any ocean tile, right?
Thanks for the share.


__________________________
Current Project[RC]: Twilight Realm 3DMMORPG w/dx9, and char creation through mysql after I get a server, now C++ scripting
Current Project[VX]: Obsidian Trilogy just started 08/12/2008
Current Project[XP&RM2K3]: none
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 21 2008, 12:40 AM
Post #3


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

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




Yup. It will work on any tile that the boat can normally travel on.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Netto
post Aug 21 2008, 12:47 AM
Post #4


芸術家
Group Icon

Group: Revolutionary
Posts: 708
Type: None
RM Skill: Skilled




QUOTE (BigEd781 @ Aug 21 2008, 01:02 AM) *
Yup. It will work on any tile that the boat can normally travel on.

That increases the likelihood that I would use it tongue.gif
OT: Did you receive my PM?


__________________________
Current Project[RC]: Twilight Realm 3DMMORPG w/dx9, and char creation through mysql after I get a server, now C++ scripting
Current Project[VX]: Obsidian Trilogy just started 08/12/2008
Current Project[XP&RM2K3]: none
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 21 2008, 12:53 AM
Post #5


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

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




Hmmm...I didn't get a prompt. I'll check it tomorrow. Must...sleep. Goodnight.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
PhantomH
post Aug 21 2008, 03:45 AM
Post #6


Ushiromiya Battler
Group Icon

Group: Revolutionary
Posts: 758
Type: Writer
RM Skill: Skilled




It's also a good idea to do a similar script for the other 2 vehicles as well. It's always a pain to travel so far from where you left your vehicle at a certain point in the game.


__________________________
Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 21 2008, 06:28 AM
Post #7


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




QUOTE (PhantomH @ Aug 21 2008, 04:07 AM) *
It's also a good idea to do a similar script for the other 2 vehicles as well. It's always a pain to travel so far from where you left your vehicle at a certain point in the game.


For airships, it should be quite easy since they can pass any tile

and btw nice work Ed, seems you finnally got this to work! thumbsup.gif


__________________________
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 21 2008, 09:42 AM
Post #8


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

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




Yes, ver is correct. This would be very easy for airships (it would actually be the opposite). I already tell you how to use this with the ship in the configure section. I could pass the vehicle id as a parameter to the call_boat function if you guys want.

lol, the airship is the trickiest one precisely because it can pass over anything. You would not, however, want it to be placed anywhere, so it needs some extra conditions.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 22 2008, 02:34 AM
Post #9


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

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




I've updated this so that it now calls any vehicle.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Netto
post Aug 22 2008, 02:43 AM
Post #10


芸術家
Group Icon

Group: Revolutionary
Posts: 708
Type: None
RM Skill: Skilled




QUOTE (BigEd781 @ Aug 22 2008, 02:56 AM) *
I've updated this so that it now calls any vehicle.

Can you make it so you can only call at certain marked areas? Like call script on a certain event.
OT: I had a problem with arrow thing, please check topic in RMVX.


__________________________
Current Project[RC]: Twilight Realm 3DMMORPG w/dx9, and char creation through mysql after I get a server, now C++ scripting
Current Project[VX]: Obsidian Trilogy just started 08/12/2008
Current Project[XP&RM2K3]: none
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 22 2008, 02:45 AM
Post #11


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

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




Sure. Wherever you place the call, that is where it will call from. You can completely control when the player can call the vehicle.

BTW, I'll check that soon.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
lahandi
post Aug 25 2008, 10:40 AM
Post #12


Level 8
Group Icon

Group: Revolutionary
Posts: 111
Type: Artist
RM Skill: Skilled





QUOTE
WORLD_MAP_ID - This is the map id of the world map. This is used so that the player cannot call the airship from any map but the world map.


This for one map only or it can handle several map? like WORLD_MAP_ID = 1, 2, 3


__________________________
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 27 2008, 10:44 PM
Post #13


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

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




It can now wink.gif Good idea, get the latest script.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
kccarmea
post Dec 30 2008, 07:55 AM
Post #14


Level 5
Group Icon

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




im trying to call the airship on map 44 but it says it cant call the airship from this location.
Go to the top of the page
 
+Quote Post
   
kccarmea
post Dec 30 2008, 08:01 AM
Post #15


Level 5
Group Icon

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




QUOTE (kccarmea @ Dec 30 2008, 08:55 AM) *
im trying to call the airship on map 44 but it says it cant call the airship from this location.

nevermind i figured it out but is there a way to have the airship not pass through certain areas?

This post has been edited by kccarmea: Dec 30 2008, 08:02 AM
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: 23rd May 2013 - 04:29 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker