MinchinWeb's MetaLibrary  v.9
Library functions of OpenTTD AI writers.
_MinchinWeb_Marine_ Class Reference

Water and Ship related functions. More...

Static Public Member Functions

function DistanceShip (TileA, TileB)
 Distance, as measured by a ship. More...
 
function GetPossibleDockTiles (IndustryID)
 Tiles where a dock can be built near an industry. More...
 
function GetDockFrontTiles (Tile)
 The tiles a ship can access a dock from. More...
 
function BuildBuoy (Tile)
 Builds a buoy. More...
 
function BuildDepot (DockTile, Front, NotNextToDock=true)
 Build a (ship) depot next to a dock. More...
 
function RateShips (EngineID, Life, Cargo)
 Ship Scoring. More...
 
function NearestDepot (TileID)
 Nearest ship depot. More...
 

Private Attributes

 main = null
 

Detailed Description

Water and Ship related functions.

Version
v.3 (2012-06-23)
Author
W. Minchin (MinchinWeb)
Since
MetaLibrary v.2
See also
_MinchinWeb_ShipPathfinder_

Definition at line 77 of file Marine.nut.

Member Function Documentation

function _MinchinWeb_Marine_::BuildBuoy ( Tile  )
static

Builds a buoy.

Attempts to build a buoy, but first checks the box within _MinchinWeb_C_.BuoyOffset() for an existing buoy, and makes sure there's nothing but water between the two. If no existing buoy is found, one is built.

Returns
The location of the existing or built buoy.

Definition at line 276 of file Marine.nut.

function _MinchinWeb_Marine_::BuildDepot ( DockTile  ,
Front  ,
NotNextToDock  = true 
)
static

Build a (ship) depot next to a dock.

Attempts to build a (water) depot, but first checks the box within _MinchinWeb_C_.WaterDepotOffset() for an existing depot, and makes sure there's nothing but water between the depot and dock. If no existing depot is found, one is built.

Parameters
DockTileMust be a water tile.
NotNextToDockWhen True, will keep the dock from being built next to an existing dock.
Note
This will fail if the DockTile given is a dock (or any tile that is not a water tile).
Returns
The location of the existing or built depot.
Todo:
Check documentation of parameters.

Definition at line 328 of file Marine.nut.

function _MinchinWeb_Marine_::DistanceShip ( TileA  ,
TileB   
)
static

Distance, as measured by a ship.

Assuming open ocean, ship in OpenTTD will travel 45° angle where possible, and then finish up the trip by going along a cardinal direction.

Definition at line 173 of file Marine.nut.

function _MinchinWeb_Marine_::GetDockFrontTiles ( Tile  )
static

The tiles a ship can access a dock from.

Given a tile, returns an array of possible 'front' tiles that a ship could access the dock from.

Parameters
TileCan be either the land tile of a dock, or the water tile.
Note
Does not test if there is currently a dock at the tile.
Might do funny things if the tile given is next to a river (i.e. a flat tile next to a water tile).

Definition at line 212 of file Marine.nut.

function _MinchinWeb_Marine_::GetPossibleDockTiles ( IndustryID  )
static

Tiles where a dock can be built near an industry.

Given an industry (by IndustryID), searches for possible tiles to build a dock and returns the list as an array of TileIndexs.

Note
Tiles returned should be checked to ensure that the desired cargo is still accepted.
Assumes that the industry location returned is the NE corner of the industry, and that industries fit within a 4x4 block.
Parameters
IndustryIDThe IndustryID you wanted checked.
Returns
An array of tiles that a dock could be built on near the industry.
If the industry has a built-in dock, that tile will be included in the tiles returned.

Definition at line 179 of file Marine.nut.

function _MinchinWeb_Marine_::NearestDepot ( TileID  )
static

Nearest ship depot.

Returns
The tile of the Ship Depot nearest to the given TileID
Todo:

Add check that depot is connected to the given TileID.

Check that there is a depot to return.

Definition at line 461 of file Marine.nut.

function _MinchinWeb_Marine_::RateShips ( EngineID  ,
Life  ,
Cargo   
)
static

Ship Scoring.

Given an EngineID, the function will score them; higher is better.

Parameters
LifeDesired lifespan of route, assumed to be in years.
CargoDoesn't work yet. Capacity is measured in the default cargo.
Note
Designed to run as a valuator on a AIList of EngineID's.
Todo:

Add example of validator code.

Implement ship capacity in given cargo.

Definition at line 436 of file Marine.nut.

Member Data Documentation

_MinchinWeb_Marine_::main = null
private

Definition at line 78 of file Marine.nut.


The documentation for this class was generated from the following file: