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:

    TypeNameDescription
    UnitunitThe unit.
    Vec3positionThe target position.

    Returns:

    TypeDescription
    booleanReturns 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:

    TypeNameDescription
    CharacterselfThe firing character.
    HarvestabletargetThe target harvestable.
    numberrangeThe maximum firing distance.
    numberwidthThe width of the fire lane.

    Returns:

    TypeDescription
    boolean,Vec3The 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:

    TypeNameDescription
    CharacterselfThe firing character.
    CharactertargetThe target character.
    numberrangeThe maximum firing distance.
    numberwidthThe width of the fire lane.

    Returns:

    TypeDescription
    boolean,Vec3The result.

    sm.ai.getBreachablePosition(unit, position, range, attack)

    Check if there's an attackable object between the unit and a position.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.
    Vec3positionThe target position.
    numberrangeThe distance.
    integerattackThe possible attack level from the breacher.

    Returns:

    TypeDescription
    boolean,Vec3,ShapeReturns true if a breachable object is found, an attackable position, and an attackable shape.
    boolean,Vec3,HarvestableReturns true if a breachable object is found, an attackable position, and an attackable harvestable.
    boolean,Vec3,LiftReturns true if a breachable object is found, an attackable position, and an attackable lift.
    boolean,Vec3Returns false if the object is unbreachable and an attackable position.
    booleanReturns true when nothing is found.

    sm.ai.getClosestTree(position, world=nil)

    Find the closest harvestable of 'tree' type in a world.

    Parameters:

    TypeNameDescription
    Vec3positionThe world position to search around.
    Worldworld=nilThe world to search in. (Defaults to the world of the script that is calling the function)

    Returns:

    TypeDescription
    HarvestableThe closest tree harvestable.

    sm.ai.getClosestVisibleCharacterType(unit, uuid)

    Returns the character of a given uuid type that is closest to the unit.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.
    UuiduuidThe character uuid.

    Returns:

    TypeDescription
    CharacterThe character.

    sm.ai.getClosestVisibleCrop(unit)

    Returns the farming harvestable that is closest to the unit.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.

    Returns:

    TypeDescription
    HarvestableThe harvestable.

    sm.ai.getClosestVisiblePlayerCharacter(unit)

    Returns the character closest to the unit.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.

    Returns:

    TypeDescription
    CharacterThe character.

    sm.ai.getClosestVisibleTeamOpponent(unit, color)

    Returns the character, with an opposing color, closest to the unit.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.
    ColorcolorThe color.

    Returns:

    TypeDescription
    CharacterThe character.

    sm.ai.getRandomCreationPosition(body)

    eturns a random position on a given body.

    Parameters:

    TypeNameDescription
    BodybodyThe body.

    Returns:

    TypeDescription
    Vec3The position.

    sm.ai.isReachable(unit, position)

    Check if the unit can reach the target position by moving along a path.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.
    Vec3positionThe target position.

    Returns:

    TypeDescription
    booleanReturns true if the position is reachable.