VoidExpanse/scope-npc

From AtomicTorchWiki


Scope npc

Manages NPC bahavior, interactions and parameters.

Visibility: Global.

List of functions

Objectives

CountObjectives
Arguments Returns Example
  • int: npc_ship_id

int: current number of objectives

var obj = npc.CountObjectives(25334);
Description


AddObjective
Arguments Returns Example
  • int: npc_ship_id
  • string: name
  • (optional) object: parameters

void

npc.AddObjective(25334, "go_to_jumpgate", {jumpgate_id: 15});
Description

Adds new objective to npc. All objectives must be implemented in npc's behavior script. NOTE: in object parameters there shouldn't be parameters "name" - it will be overriden by name of objective.


CleanObjectives
Arguments Returns Example
  • int: npc_ship_id

void

npc.CleanObjectives(25334);
Description

Removes all objectives from npc ship.


NextObjective
Arguments Returns Example
  • int: npc_ship_id

void

npc.NextObjective(25334);
Description

Moves current objective pointer to next position, removes previous objective.


GetCurrentObjective
Arguments Returns Example
  • int: npc_ship_id

object:

  • string: name - name of objective, specified in AddObjective
  • string: key - value - other parameters, specified in AddObjective
var objective = npc.GetCurrentObjective(25334);
Description

Gets current npc's objective (or null if none)


GetCurrentObjectiveTimer
Arguments Returns Example
  • int: npc_ship_id

double: time - how long npc is doing his current objective

var time = npc.GetCurrentObjectiveTimer(25334);
Description


NODES

AddNode
Arguments Returns Example
  • int: npc_ship_id
  • double: coord_x
  • double: coord_y

void

npc.AddNode(25334, 100, 100);
Description

Adds a node to npc. NPC can use nodes for patrolling, or for any other reason.


ClearNodes
Arguments Returns Example
  • int: npc_ship_id

void

npc.ClearNodes(25334);
Description

Removes all nodes from npc.


GetDistanceToNode
Arguments Returns Example
  • int: npc_ship_id
  • int: node_id - number of node

double: distance_to_node

var dist = npc.GetDistanceToNode(25334, 1);
Description


GetNodes
Arguments Returns Example
  • int: npc_ship_id

array of objects:

  • double: CoordX
  • double: CoordY
var nodes = npc.GetNodes(25334);
Description


RemoveNode
Arguments Returns Example
  • int: npc_ship_id
  • int: node_id

void

npc.RemoveNode(25334, 1);
Description

Removes node from npc nodes.


FollowRouteToObject
Arguments Returns Example
  • int: npc_ship_id
  • int: object_id

void

npc.FollowRouteToObject(25334, 2535);
Description

Creates route to object and follow it.


FollowRouteToBase
Arguments Returns Example
  • int: npc_ship_id
  • int: base_id

void

npc.FollowRouteToBase(25334, 2535);
Description

Creates route to base and follow it.


StopFollowingRoute
Arguments Returns Example
  • int: npc_ship_id

void

npc.StopFollowingRoute(25334);
Description

Stops following current route.


IsNodeReached
Arguments Returns Example
  • int: npc_ship_id
  • int: is_node_reached

void

var res = npc.IsNodeReached(25334, 0);
Description

Checks if node is reached.


Battle

Fire
Arguments Returns Example
  • int: npc_ship_id
  • int: slot

void

npc.Fire(25334, 0);
Description

Fires from specified slot.


SetWeaponUsage
Arguments Returns Example
  • int: npc_ship_id
  • string: projectile_type - "Ray","DirectHit","BulletOrMissile"
  • double: min_dist
  • double: max_dist
  • double: delay

void

npc.SetWeaponUsage(25334, "Ray", 2,10, 200);
Description

Sets weapon usage. It means npc will try to shoot with it's weapons of specified type only on specified distance and will make specified delays between shots.


Movement

CapSpeed
Arguments Returns Example
  • int: npc_ship_id
  • double: value

void

npc.CapSpeed(25334, 2);
Description

Caps npc's ship speed.


FaceFromObj
Arguments Returns Example
  • int: npc_ship_id
  • int: object_id

void

npc.FaceFromObj(25334, 235);
Description

NPC faces from object.


FaceObj
Arguments Returns Example
  • int: npc_ship_id
  • int: object_id

void

npc.FaceObj(25334, 235);
Description

NPC faces to object.


FaceStickPoint
Arguments Returns Example
  • int: npc_ship_id

void

npc.FaceStickPoint(25334, 235);
Description

NPC faces current stick point.


FaceCoord
Arguments Returns Example
  • int: npc_ship_id
  • double: coord_x
  • double: coord_y

void

npc.v(25334, 100, 105);
Description

NPC faces specified coordinates.


GoBackward
Arguments Returns Example
  • int: npc_ship_id

void

npc.GoBackward(25334);
Description


GoForward
Arguments Returns Example
  • int: npc_ship_id

void

npc.GoForward(25334);
Description


RotLeft
Arguments Returns Example
  • int: npc_ship_id

void

npc.RotLeft(25334);
Description


RotRight
Arguments Returns Example
  • int: npc_ship_id

void

npc.RotRight(25334);
Description


Stop
Arguments Returns Example
  • int: npc_ship_id

void

npc.Stop(25334);
Description


InstantStop
Arguments Returns Example
  • int: npc_ship_id

void

npc.InstantStop(25334);
Description


StrafeLeft
Arguments Returns Example
  • int: npc_ship_id

void

npc.StrafeLeft(25334);
Description


StrafeRight
Arguments Returns Example
  • int: npc_ship_id

void

npc.StrafeRight(25334);
Description


StopEvasion
Arguments Returns Example
  • int: npc_ship_id

void

npc.StopEvasion(25334);
Description

Turns evasion mode off. Evasion mode is the mode, when npc can avoid attacks with rockets and ballistics by strafing.


StartEvasion
Arguments Returns Example
  • int: npc_ship_id

void

npc.StartEvasion(25334);
Description

Turns evasion mode on. Evasion mode is the mode, when npc can avoid attacks with rockets and ballistics by strafing.

Locks

FriendlyLockOnTarget
Arguments Returns Example
  • int: npc_ship_id
  • int: target_id
  • double: get_away_dist

void

npc.FriendlyLockOnTarget(25334, 16);
Description

Friendly lock is a type of lock, when npc facing it's target, but do not attack.


GetLockTarget
Arguments Returns Example
  • int: npc_ship_id

int: lock target object ID

var lockTarget = npc.GetLockTarget(25334);
Description

Gets current target, on which npc is locked.


GetStickObject
Arguments Returns Example
  • int: npc_ship_id

int: object_id - current stick object id

var stickObject = npc.GetStickObject(25334);
Description

Get current stick object.


GetFriendlyLockTarget
Arguments Returns Example
  • int: npc_ship_id

int: object_id - current friendly lock target

var lockTarget = npc.GetFriendlyLockTarget(25334);
Description

Get current lock target


IsFriendlyLocked
Arguments Returns Example
  • int: npc_ship_id

bool: is npc friendly locked

var is_locked = npc.IsFriendlyLocked(25334);
Description

Returns whether npc is friendly locked.


IsLocked
Arguments Returns Example
  • int: npc_ship_id

bool: is npc locked on target

var is_locked = npc.IsLocked(25334);
Description

Returns whether npc is locked on target.


Unlock
Arguments Returns Example
  • int: npc_ship_id

void

npc.Unlock(25334);
Description

Unlocks from target or frienly lock target.


IsStickToPoint
Arguments Returns Example
  • int: npc_ship_id

bool: is_sticked - whether npc is sticked to point

var res = npc.IsStickToPoint(25334);
Description


IsStickToObject
Arguments Returns Example
  • int: npc_ship_id

bool: is_sticked - whether npc is sticked to point

var res = npc.IsStickToObject(25334);
Description


GetDistanceToStickPoint
Arguments Returns Example
  • int: npc_ship_id

double: distance

var distance = npc.GetDistanceToStickPoint(25334);
Description

Returns distance to current stick point.


GetDistanceToStickObject
Arguments Returns Example
  • int: npc_ship_id

double: distance

var distance = npc.GetDistanceToStickObject(25334);
Description

Returns distance to current stick object.


LockOnTarget
Arguments Returns Example
  • int: npc_ship_id
  • int: target_id
  • double: get_away_dist

void

npc.LockOnTarget(25334, 25343, 20);
Description

Locks on target. Npc will automatically unlock, when distance to target object will be more then get_away_dist.


StickToObject
Arguments Returns Example
  • int: npc_ship_id
  • int: target_object
  • (optional) double: get_away_dist

void

npc.StickToObject(25334, 24000, 20);
Description

Sticks NPC to object. Npc will try to approach sticked object. Will automatically unstick, when distance to object will exceed get_away_dist parameter.


StickToPoint
Arguments Returns Example
  • int: npc_ship_id
  • double: coord_x
  • double: coord_y
  • double: get_back_distance

void

npc.StickToPoint(25334, 100, 100, 20);
Description

NPC sticks to specified point. If NPC goes further then get_back_distance, npc will try to get back to stick point.


Unstick
Arguments Returns Example
  • int: npc_ship_id

void

npc.Unstick(25334);
Description

Unsticks NPC from point or object.


GetLockedTime
Arguments Returns Example
  • int: npc_ship_id

double: locked_time

var time = npc.GetLockedTime(25334);
Description

Returns time, during which NPC is locked on it's current target.


Interaction

DeviceActivateOnObject
Arguments Returns Example
  • int: npc_ship_id
  • string: id
  • int: target

void

npc.DeviceActivateOnObject(25334, "device", 1541);
Description

NPC tries to activate device on specified target.


DeviceActivateOnCoords
Arguments Returns Example
  • int: npc_ship_id
  • string: id
  • double: coord_x
  • double: coord_y

void

npc.DeviceActivateOnCoords(25334, "device", 100, 100);
Description

NPC tries to activate device on specified coordinates.


DeviceActivateOnSelf
Arguments Returns Example
  • int: npc_ship_id
  • string: id

void

npc.DeviceActivateOnSelf(25334, "device");
Description

NPC tries to activate device on self.


DeviceDeactivate
Arguments Returns Example
  • int: npc_ship_id
  • string: id

void

npc.DeviceDeactivate(25334, "device");
Description

Deactivates device.


EnterBase
Arguments Returns Example
  • int: npc_ship_id
  • int: base_id

void

npc.EnterBase(25334, 15);
Description

Npc enters base (with animation, routine etc.)


EnterJumpgate
Arguments Returns Example
  • int: npc_ship_id
  • int: jumpgate_id

void

npc.EnterJumpgate(25334, 16);
Description

Npc enters jumpgate (with animation, routine etc.) After entering jumpgate, ship will be destroyed.


TravelThroughJumpgate
Arguments Returns Example
  • int: npc_ship_id
  • int: jumpgate_id

void

npc.TravelThroughJumpgate(25334, 16);
Description

Npc enters jumpgate (with animation, routine etc.). After travel, ship will actually appear in destination system.


GetDistanceToObj
Arguments Returns Example
  • int: npc_ship_id
  • int: object_id

double: distance

var distance = npc.GetDistanceToObj(25334, 165);
Description

Returns distance from npc to specified object.


GetCurrentCoordinates
Arguments Returns Example
  • int: npc_ship_id

vector2: distance

var coords = npc.GetCurrentCoordinates(25334);
Description

Returns current coordinates of NPC.


GetDockedTime
Arguments Returns Example
  • int: npc_ship_id

double: docked_time

var time = npc.GetDockedTime(25334);
Description


GetObstacleOnTheWay
Arguments Returns Example
  • int: npc_ship_id
  • double: distance

int: ID of first obstacle on the way of NPC

var obstacle_id = npc.GetObstacleOnTheWay(25334, 7);
Description


GetSystemAsteroidsByDistanceToNPC
Arguments Returns Example
  • int: npc_ship_id
  • int: limit

array: IDs of asteroids

var asteroids = npc.GetSystemAsteroidsByDistanceToNPC(25334, 8);
Description

Returns an array of asteroids, which are ordered by distance to NPC (from closest to furthest)


GetShipsInScope
Arguments Returns Example
  • int: npc_ship_id

array: IDs of all ships in scope (int)

var ships = npc.GetShipsInScope(25334);
Description

Returns an array of ships in NPC's scope.


GetCurrentSystemID
Arguments Returns Example
  • int: npc_ship_id

int: current system id

var sys_id = npc.GetCurrentSystemID(25334);
Description


IsOnBase
Arguments Returns Example
  • int: npc_ship_id

bool: whether npc is docked to base right now

var res = npc.IsOnBase(25334);
Description


IsAtBaseEntry
Arguments Returns Example
  • int: npc_ship_id
  • int: base_id

bool: whether npc is at base entry point

var res = npc.IsAtBaseEntry(25334);
Description


LeaveBase
Arguments Returns Example
  • int: npc_ship_id

void

npc.LeaveBase(25334);
Description

NPC undocks from a base.


GetTags
Arguments Returns Example
  • int: npc_ship_id

object: tags - tags of NPC's ship

var tags = npc.GetTags(25334);
Description


SetBehavior
Arguments Returns Example
  • int: npc_ship_id
  • string: behavior
  • objects: parameters

void

npc.SetBehavior(25353, "avoid_asteroids", true);
Description

Sets behavior of NPC. See more on behaviors in Behaviors section.


RemoveBehavior
Arguments Returns Example
  • int: npc_ship_id
  • string: behavior

void

npc.RemoveBehavior(25353, "avoid_asteroids");
Description

Removes behavior of NPC. See more on behaviors in Behaviors section.


ClearBehaviors
Arguments Returns Example
  • int: npc_ship_id

void

npc.ClearBehaviors(25353);
Description

Removes all behaviors from npc.


SetAIScript
Arguments Returns Example
  • int: npc_ship_id
  • string: AI_script

void

npc.SetAIScript(25353, "PirateInWaiting");
Description

Sets npc's AI script.


IsInBattleWith
Arguments Returns Example
  • int: npc_ship_id
  • int: ship_id

void

var bEngaged = npc.IsInBattleWith(25353, 52522);
Description

Returns whether specified NPC is in battle with specified ship or not.


SetDecisionsPerSecond
Arguments Returns Example
  • int: npc_ship_id
  • int: num

void

npc.SetDecisionsPerSecond(25444, 15);
Description

It affects how often function Decision on AIBehavior will be called.