(info) Other great resources: Official JS API docs, Scripting Forum

propulsionCanReach()

Find out if a specific propulsion can travel between two points on the map...

 

Syntax

var returnValue = propulsionCanReach(propulsion, x1, y1, x2, y2);

Parameters

ParameterTypeMandatoryNotesGame version
propulsionString(tick)A string defining the propulsion id (see propulsion.txt or propulsion.ini)3.2
x1Number(tick)The x co-ordinate of the start position3.2
y1Number(tick)The y co-ordinate of the start position3.2
x2Number(tick)The x co-ordinate of the destination3.2
y2Number(tick)The y co-ordinate of the destination3.2

Return value

ValueTypeNotesGame version
trueBooleanThe propulsion can travel between the two points (ignores player-build blockades)3.1 Beta 1
falseBooleanThe propulsion is not capable of travelling between the two points.3.1 Beta 1
<error>ErrorInvalid parameters or droid not found.3.1 Beta 1

Notes

The function ignores player built structures (tank traps, walls, etc) and features (trees, skyscrapers, etc). The assumption is that you'll blow them up on the way to your destination.

If you plan to scan all tiles on the map for both land and hover access, that would be as much as 131,072 iterations on a 256x256 map! And each check is doing path finding to determine the route that propulsion would take from A to B. And you could have up to 9 AIs (and even 10 if scavengers join the fun) doing the same thing at the same time.

So, if you plan to scan the whole map, do it incrementally using a timer and only process a few tiles at a time. Note: You don't need to change the start position (your base), you'd just be changing the destination.

Example

// get my start position
var myPos = startPositions(playerData[me].position);
 
// get player 2's start position
var theirPos = startPositions(playerData[1].position);
 
if ( propulsionCanReach("wheeled01", myPos.x, myPos.y, theirPos.x, theirPos.y) ) {
  // I can reach them with wheels, half-track, hover, track and vtol
} else if ( propulsionCanReach("hover01", myPos.x, myPos.y, theirPos.x, theirPos.y) ) {
  // I can only reach them with hover and VTOL
} else {
  // I can only reach them with VTOL (assuming VTOLs can get anywhere on the map)
}
Availability 3.2+

Requires:

  • Warzone 3.1 Beta 1 and above.
Contents

Jump to:

See also

Related articles:

  • droidCanReach() – check if a specific droid can reach some destination from it's current position
  • distBetweenTwoPoints() – calculate straight-line distance between two points on the map

Â