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.
[VXA] Vehicle Ports

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Vehicle Ports
Version: 1.0.0
Author: modern algebra
Date: 29 December 2012

Version History


  • <Version 1.0.0> 2012.12.29 - Original Release

Description


This script allows you to set it so that boats, ships, and airships, can only land in particular regions that you designate as ports for that type of vehicle. This allows you to, for instance, prevent ships from landing anywhere except at a dock, or boats from landing anywhere but on beaches or docks. It also works for airships, if you want to restrict the places that they can land.

Features

  • Prevents vehicles from landing anywhere except in regions that you prescribe
  • Easy region-based port creation
  • Each vehicle can have a different set of port regions
  • Port regions can overlap, so you can make some ports that only accept ships, some that only accept boats, and some that accept both, etc...

Instructions

Paste the script into its own slot in the Script Editor, above Main but below Materials.

This script works by regions, which means that each vehicle will only be able to land on a square if it is painted in a port region. You set which regions are ports for which vehicles in the script itself. Please read the header of the script for more detailed instructions on use.

Script


Code: [Select]
#==============================================================================
#    Vehicle Ports
#    Version: 1.0.0
#    Author: modern algebra (rmrk.net)
#    Date: 29 December 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    This script allows you to set it so that boats, ships, and airships, can
#   only land in particular regions that you designate as ports for that type
#   of vehicle. This allows you to, for instance, prevent ships from landing
#   anywhere except at a dock, or boats from landing anywhere but on beaches or
#   docks. It also works for airships, if you want to restrict the places that
#   they can land.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#   
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    Beyond that, the only thing you need to do is go to the editable region at
#   line 36 and input the IDs of any port regions into the array for each
#   vehicle. By default, boats can land in regions 32 and 40, while ships can
#   only land in region 40. Airship landing is unrestricted by default. You can
#   change those values in the editable region.
#
#    Once that is done, all you need to do to make a port is paint that tile
#   with the port region for that vehicle.
#==============================================================================

$imported = {} unless $imported
$imported[:MA_VehiclePorts] = true

MAVP_PORT_REGIONS = {
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#    BEGIN Editable Region
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  For each array, input the IDs of the regions in which the vehicle can land,
# separated by commas. If left empty, then that vehicle's landing locations are
# unrestricted and they can land no matter what the region.
  boat:    [32, 40], # IDs of regions in which a boat can land
  ship:    [40],     # IDs of regions in which a ship can land
  airship: [],       # IDs of regions in which an airship can land
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#    END Editable Region
#//////////////////////////////////////////////////////////////////////////////
}
MAVP_PORT_REGIONS.default = []

#==============================================================================
# ** Game_Vehicle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - land_ok?
#==============================================================================

class Game_Vehicle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Determine if Docking/Landing Is Possible
  #     d:  Direction (2,4,6,8)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mavp_landok_1up3 land_ok?
  def land_ok?(x, y, d, *args)
    unless MAVP_PORT_REGIONS[@type].empty? # Unless no port required
      if @type == :airship
        return false unless MAVP_PORT_REGIONS[@type].include?( $game_map.region_id(x, y) )
      else
        x2 = $game_map.round_x_with_direction(x, d)
        y2 = $game_map.round_y_with_direction(y, d)
        return false unless MAVP_PORT_REGIONS[@type].include?( $game_map.region_id(x2, y2) )
      end
    end
    mavp_landok_1up3(x, y, d, *args) # Call original method
  end
end

Credit


  • modern algebra

Thanks

  • Maliki79, for the request

Support


Please post in this topic at RMRK.net if you have any questions, suggestions, error reports, or comments about this script. It is perfectly fine to post here even if this topic has not been posted in for a very long time.

Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am occasionally absent, and posting publically will allow other members to assist you when I am unable to do so quickly.

Known Compatibility Issues

I am currently unaware of any compatibility issues.

Author's Notes


Maliki79 actually requested this script nearly a year ago, but I totally forgot about it. I stumbled across his post recently and decided to make it, since I figured it would help others even if Maliki79 should have given up on it long ago. Sorry Maliki! You learned the hard way that they don't call me "Unreliable Dorrybo" for nothing!

Terms of Use


I adopt RMRK's default Terms of Use.