sm.ai
AI utility functions.
Functions
directPathAvailable
sm.ai.directPathAvailable( unit, position )
Checks if the unit can reach the target position by moving straight.
Arguments:Returns:
- [ bool ]: Whether the target position is directly reachable or not.
getAimPosition
sm.ai.getAimPosition( character, target, range, width )
Returns true if the character can fire at the target within a given fire lane.
Also returns the aim position that allows the character to succeed.
Arguments:character
[ Character ]: The firing character.target
[ Harvestable /character ]: The target.range
[ number ]: The maximum firing distance.width
[ number ]: The width of the fire lane.
- [ bool ]: Whether the character can fire at the target or not.
- [ Vec3 ]: The aim position, if available.
getBreachablePosition
sm.ai.getBreachablePosition( unit, position, range, attack )
Check if there's an attackable object between the unit and a position.
Arguments:unit
[ Unit ]: The unit.position
[ Vec3 ]: The target position.range
[ number ]: The distance.attack
[ int ]: The possible attack level from the attacker.
- [ bool ]: True if a breachable object was found or no object was found. False if the found object is unbreachable.
- [ Vec3 ]: The attackable position, if found.
- [ Shape / Harvestable /lift ]: The object to attack.
getClosestTree
sm.ai.getClosestTree( position, world )
Find the closest "tree" harvestable in a world.
Arguments:Returns:
- [ Harvestable ]: The closest found tree.
getClosestVisibleCharacterType
sm.ai.getClosestVisibleCharacterType( unit, uuid )
Returns the closest visible character with matching uuid.
Arguments:Returns:
- [ Character ]: The closest visible character.
getClosestVisibleCrop
sm.ai.getClosestVisibleCrop( unit )
Returns the closest visible farming harvestable.
Arguments:unit
[ Unit ]: The unit.
- [ Harvestable ]: The closest visible farming harvestable.
getClosestVisiblePlayerCharacter
sm.ai.getClosestVisiblePlayerCharacter( unit )
Returns the closest visible player character.
Arguments:unit
[ Unit ]: The unit.
- [ Character ]: The closest visible player character.
getClosestVisibleTeamOpponent
sm.ai.getClosestVisibleTeamOpponent( unit, color )
Returns the closest visible character that does not have the given color.
Arguments:Returns:
- [ Character ]: The closest visible team opponent.
getRandomCreationPosition
sm.ai.getRandomCreationPosition( body )
Returns a random position on the given body.
Arguments:body
[ Body ]: The body.
- [ Vec3 ]: The random position.
isReachable
sm.ai.isReachable( unit, position )
Check if the unit can reach the target position by moving along a path.
Arguments:Returns:
- [ bool ]: Whether the position is reachable or not.