sm.ai
AI utility functions.
Functions:
directPathAvailable getAimPosition getAimPosition getBreachablePosition getClosestTree getClosestVisibleCharacterType getClosestVisibleCrop getClosestVisiblePlayerCharacter getClosestVisibleTeamOpponent getRandomCreationPosition isReachable
sm.ai.directPathAvailable(unit, position)
Check if the unit can reach the target position by moving straight.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Vec3 | position | The target position. |
Returns:
Type | Description |
boolean | Returns true if the position is available directly. |
sm.ai.getAimPosition(self, target, range, width)
Returns true if the character can fire at the target harvestable within a given fire lane.
Also returns the aim position that allows the character to succeed.
Parameters:
Type | Name | Description |
Character | self | The firing character. |
Harvestable | target | The target harvestable. |
number | range | The maximum firing distance. |
number | width | The width of the fire lane. |
Returns:
Type | Description |
boolean,Vec3 | The result. |
sm.ai.getAimPosition(self, target, range, width)
Returns true if the character can fire at the target character within a given fire lane.
Also returns the aim position that allows the character to succeed.
Parameters:
Type | Name | Description |
Character | self | The firing character. |
Character | target | The target character. |
number | range | The maximum firing distance. |
number | width | The width of the fire lane. |
Returns:
Type | Description |
boolean,Vec3 | The result. |
sm.ai.getBreachablePosition(unit, position, range, attack)
Check if there's an attackable object between the unit and a position.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Vec3 | position | The target position. |
number | range | The distance. |
integer | attack | The possible attack level from the breacher. |
Returns:
Type | Description |
boolean,Vec3,Shape | Returns true if a breachable object is found, an attackable position, and an attackable shape. |
boolean,Vec3,Harvestable | Returns true if a breachable object is found, an attackable position, and an attackable harvestable. |
boolean,Vec3,Lift | Returns true if a breachable object is found, an attackable position, and an attackable lift. |
boolean,Vec3 | Returns false if the object is unbreachable and an attackable position. |
boolean | Returns true when nothing is found. |
sm.ai.getClosestTree(position, world=nil)
Find the closest harvestable of 'tree' type in a world.
Parameters:
Type | Name | Description |
Vec3 | position | The world position to search around. |
World | world=nil | The world to search in. (Defaults to the world of the script that is calling the function) |
Returns:
Type | Description |
Harvestable | The closest tree harvestable. |
sm.ai.getClosestVisibleCharacterType(unit, uuid)
Returns the character of a given uuid type that is closest to the unit.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Uuid | uuid | The character uuid. |
Returns:
sm.ai.getClosestVisibleCrop(unit)
Returns the farming harvestable that is closest to the unit.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Returns:
sm.ai.getClosestVisiblePlayerCharacter(unit)
Returns the character closest to the unit.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Returns:
sm.ai.getClosestVisibleTeamOpponent(unit, color)
Returns the character, with an opposing color, closest to the unit.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Color | color | The color. |
Returns:
sm.ai.getRandomCreationPosition(body)
eturns a random position on a given body.
Parameters:
Type | Name | Description |
Body | body | The body. |
Returns:
Type | Description |
Vec3 | The position. |
sm.ai.isReachable(unit, position)
Check if the unit can reach the target position by moving along a path.
Parameters:
Type | Name | Description |
Unit | unit | The unit. |
Vec3 | position | The target position. |
Returns:
Type | Description |
boolean | Returns true if the position is reachable. |