The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on March 05, 2008, 04:08:09 PM

Title: Boat/Ship Passability for Events
Post by: modern algebra on March 05, 2008, 04:08:09 PM
Boat/Ship Passability for Events
Version: 1.1
Author: modern algebra
Date: March 5, 2008

Description



This script allows you to set events as boats or ships, and thus forces them to adhere to the passability of boats or ships. The most obvious use for it is for making a boat or ship event with random movement. Or really, any boat or ship events

Features


Instructions

Basically, all you need to do to identify any given event as being a ship or a boat, just type \boat or \ship (captialization doesn't matter) in a comment that you place as the very first line of the page of the event. If you do something like \boat\ShIp, it will identify as ship since ship has priority over boat. I would do airship as well, but it seems to me that clicking the Passage Box would be enough. With that in mind, I should clarify - if you set a boat or ship event with passage, then it will still be restricted from moving onto land or into the deep water or whatever - it will just be able to move onto other events in the water. I did it that way because I figure that if you want an event to move anywhere, why would you bother identifying it as a ship or boat?

Script




#========================================================================
#  Boat/Ship Passability for Events
#  Version: 1.1
#  Author: modern algebra
#  Date: March 5, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    Basically, identify a ship or boat event by putting \boat or \ship somewhere in the name of
#    the event.
#========================================================================
# ** Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#      aliased method - initialize
#      super methods changed - passable?
#========================================================================

class Game_Event < Game_Character
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Object Initialization
 #     map_id : map ID
 #     event  : event object (RPG::Event)
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias modalg_boat_random_movement_init initialize
 def initialize (map_id, event)
   # Initialize boat/ship variables
   @boat_object, @ship_object = false, false
   # Run Original Method
   modalg_boat_random_movement_init (map_id, event)
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Setup
 #    new_page : the active page
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias modalg_boat_random_movement_stp setup
 def setup(new_page)
   if new_page != nil
     first_command = new_page.list[0]
     # If a Comment
     if first_command.code == 108
       @boat_object = first_command.parameters[0][/\\BOAT/i] != nil
       @ship_object = first_command.parameters[0][/\\SHIP/i] != nil
     end
   end
   # Run Original Method
   modalg_boat_random_movement_stp (new_page)
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Passable?
 #       x : the x coordinate of the square being tested
 #       y : the y coordinate of the square being tested
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def passable? (x, y)
   return false if collide_with_characters? (x, y) unless (@through || debug_through?)
   if @ship_object
     return $game_map.ship_passable? (x, y)
   elsif @boat_object
     return $game_map.boat_passable? (x, y)
   end
   return super (x, y)
 end
end


Credit




Thanks


Support



Just post in this topic.



Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Boat/Ship Passability for Events
Post by: modern algebra on March 13, 2008, 09:09:26 PM
Updated to Version 1.1. It now reads the first comment of a page, rather than the name. This is better for two reasons: (a) You can retrieve the name of an event without it being corrupted by the code and (b) you can set it's special passability by page, thus if an event is a ship on one page, it doesn't need to be on another page.
Title: Re: Boat/Ship Passability for Events
Post by: ahref on March 16, 2008, 12:06:19 AM
oo cool.

hover boat here i come :D
Title: Re: Boat/Ship Passability for Events
Post by: Leventhan on March 16, 2008, 01:35:23 PM
 :lol:
This is useful!
Especially for meeee~
Title: Re: Boat/Ship Passability for Events
Post by: ahref on March 17, 2008, 04:25:35 PM
ill post the port script when i fix it so the event command "get on.off vehicle" still works even with the script in :D