Other great resources: Official JS API docs, Scripting Forum

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Overview

Find out if a specific droid can reach a specific location (from the droid's current location).

Some other functions already include this check - such as pickStructLocation() and orderDroidLoc(). However, it's still useful to do your own checks so you can choose a different target should the initial target be inaccessible.

Note: The function ignores player built structures, such as tank traps and walls/gates. The assumption is that you'll blow them up on the way to your destination. (smile)

Syntax

var returnValue = droidCanReach(droid,x,y);

Parameters

ParameterTypeMandatoryDescription
droidDroid object(tick)An object representing the droid that will be travelling to x,y
xNumber(tick)The x co-ordinate of the destination
yNumber(tick)The y co-ordinate of the destination

Return value

ValueTypeDescription
trueBooleanFrom its current location, the droid can reach x,y
falseBooleanThe droid is unable to reach x,y from its current position

Example

if (droidCanReach(droid,x,y)) {
  // do stuff
}

See also

 

  • No labels