MinchinWeb's MetaLibrary v.11
Library functions for OpenTTD AI (and GS) writers.
Loading...
Searching...
No Matches
_MinchinWeb_Marine_ Class Reference

Water and Ship related functions. More...

Static Public Member Functions

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

Private Attributes

 main = null

Detailed Description

Water and Ship related functions.

Version
v.4 (2025-09-30)
Author
W. Minchin (MinchinWeb)
Since
MetaLibrary v.2
See also
_MinchinWeb_ShipPathfinder_

Definition at line 84 of file Marine.nut.

Member Function Documentation

◆ BuildBuoy()

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 332 of file Marine.nut.

◆ BuildDepot()

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 384 of file Marine.nut.

◆ DistanceShip()

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 229 of file Marine.nut.

◆ GetDockFrontTiles()

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 268 of file Marine.nut.

◆ GetPossibleDockTiles()

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 235 of file Marine.nut.

◆ NearestDepot()

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 537 of file Marine.nut.

◆ RateShips()

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

Ship Scoring. Deprecated in favour of RateShips2().

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
Implement ship capacity in given cargo.
See also
RateShips2()

Definition at line 492 of file Marine.nut.

◆ RateShips2()

function _MinchinWeb_Marine_::RateShips2 ( EngineID ,
Cargo ,
TargetCapacity ,
MaxSpend = 0 )
static

Ship Scoring v2. Deprecated in favour of RateShips3().

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

Parameters
CargoCargo you want to carry. Ensure that the ship can retrofit to the desired cargo.
TargetCapacity(Approximate) amount of cargo you want to carry. Often the industry's monthly production.
MaxSpendHard upper limit on (upfront) Engine cost. Set to zero (the default) to ignore. Does not include retrofit costs.
Note
Designed to run as a valuator on a AIList of EngineID's.
Capacity is measured in the default cargo.
Assumes this vehicle will be continuously replaced, rather than over a pre-defined "lifetime".
Todo

Add example of validator code.

Implement ship capacity in given cargo.

Since
MetaLibrary v10.1
See also
_MinchinWeb_Engine_.Rate2()
RateShips3()

Definition at line 517 of file Marine.nut.

◆ RateShips3()

function _MinchinWeb_Marine_::RateShips3 ( EngineID ,
Cargo ,
MonthlyProduction ,
Distance ,
MaxSpend = 0 )
static

Ship Scoring v3.

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

Parameters
CargoCargo you want to carry. Ensure that the ship can retrofit to the desired cargo.
MonthlyProduction(Approximate) amount of cargo you want to carry. Often the industry's monthly production.
DistanceThe distance (in map tiles) that the engine is expected to travel between pickup and drop off. Assumes that the return distance is the same.
MaxSpendHard upper limit on (upfront) Engine cost. Set to zero (the default) to ignore. Does not include retrofit costs.
Note
Designed to run as a valuator on a AIList of EngineID's.
Capacity is measured in the default cargo.
Assumes this vehicle will be continuously replaced, rather than over a pre-defined "lifetime".
Todo

Add example of validator code.

Implement ship capacity in given cargo.

Since
MetaLibrary v10.1
See also
_MinchinWeb_Engine_.Rate3()

Definition at line 527 of file Marine.nut.

Member Data Documentation

◆ main

_MinchinWeb_Marine_::main = null
private

Definition at line 85 of file Marine.nut.


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