VoidExpanse/scope-ship

From AtomicTorchWiki


Scope ship

Used to get info and manipulate objects if type "ship".

Visibility: Global.

List of functions

AddItem
Arguments Returns Example
  • int: ship_id
  • string: xml_item_type
  • int: quantity

object:

  • int: quantity - amount added
  • string: type - "item" or "resource"
var obj = ship.Add(24556, "SomeItem2", 5);
Description

Adds item to ship's inventory.


AddItemToStorage
Arguments Returns Example
  • int: ship_id
  • string: xml_item_type
  • int: quantity

object:

  • int: quantity - amount added
  • string: type - "item" or "resource"
var obj = ship.AddItemToStorage(24556, "BFG", 0);
Description

Adds item to ship's storage, not inventory (only works on a base). Useful when you need to add new hull through scripts, but it cannot be added to inventory, only to storage.


RemoveItem
Arguments Returns Example
  • int: ship_id
  • int: item_id

void

ship.RemoveItem(24556, 5562);
Description

Removes item from ship's inventory.


RemoveItemByType
Arguments Returns Example
  • int: ship_id
  • string: item_xml_type

void

ship.RemoveItemByType(24556, "SomeItem2");
Description

Removes item from PLAYER's inventory by type. If there's no item of specified type in ship's inventory, nothing will happen.


RemoveItemByTypeCount
Arguments Returns Example
  • int: ship_id
  • string: item_xml_type
  • int: quantity

void

ship.RemoveItemByTypeCount(24556, "SomeItem2", 5);
Description

Removes item from PLAYER's inventory by type. If there's no item of specified type in ship's inventory, nothing will happen.


RemoveCargoByType
Arguments Returns Example
  • int: ship_id
  • string: cargo_type
  • (optional) int: cargo_quantity

void

ship.RemoveCargoByType(24556, "SomeCargo");
Description

Removes cargo from PLAYER's inventory by type. If there's no cargo of specified type in ship's inventory, nothing will happen.


AddSkillPointsToPlayer
Arguments Returns Example
  • string: player_name
  • int: skillpoints

void

ship.AddSkillPointsToPlayer("DLirry", 20);
Description

Adds skill points to specified player.


AddSkillPointsToShip
Arguments Returns Example
  • int: ship_id
  • int: skillpoints

void

ship.AddSkillPointsToShip(12335, 20);
Description

Adds skill points to specified ship (works only on player's ships, non-npc).


GetCargoAmount
Arguments Returns Example
  • int: ship_id
  • string: cargo_type

int: amount

var left = ship.GetCargoAmount(24556, "SomeCargo");
Description

Returns amount of specified cargo in player's inventory.


GetCoordinates
Arguments Returns Example
  • int: ship_id

vector2: coordinates

var coords = ship.GetCoordinates(24556);
Description

Returns current coordinates of specified ship. Alias of GetPosition.


GetShipsInScope
Arguments Returns Example
  • int: ship_id

array of int: ids

var ships = ship.GetShipsInScope(24556);
Description

Returns IDs of all ships, that are currently in specified ship's scope.


GetProjectilesInScope
Arguments Returns Example
  • int: ship_id

array of int: ids

var bullets = ship.GetProjectilesInScope(24556);
Description

Returns IDs of all projectiles, that are currently in specified ship's scope.


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

double: distance

var dist = ship.GetDistanceToObj(24556, 25225);
Description

Returns distance from specified ship to specified object.


GetFreeInventorySlots
Arguments Returns Example
  • int: ship_id

int: number of free slots

var slotsNum= ship.GetFreeInventorySlots(24556);
Description

Returns number of empty inventory slots in ship's inventory.


HasCargoAmount
Arguments Returns Example
  • int: ship_id
  • string: cargo_type
  • int: amount

bool

var hasCargo = ship.HasCargoAmount(24556, "SomeCargo", 14);
Description

Checks if player has specified amount of cargo.


HasItemOfType
Arguments Returns Example
  • int: ship_id
  • string: item_id

bool: if player's ship has item of specified type

var hasItem = ship.HasItemOfType(24556, "SomeItem1");
Description

Useful in quests.


CountItemOfType
Arguments Returns Example
  • int: ship_id
  • string: item_id

int: count

var quantity = ship.CountItemOfType(24556, "SomeItem1");
Description

Useful in quests.


CountItemOfType
Arguments Returns Example
  • int: ship_id
  • string: item_id

int: count

var quantity = ship.CountItemOfType(24556, "SomeItem1");
Description

Useful in quests.



GetBuffs
Arguments Returns Example
  • int: ship_id

array of objects:

  • int: caster - id of ship casted this active effect
  • double: time_left - time left
  • double: effect_base
  • double: effect_cap
  • double: effect_per_level
  • string: effect_type
var effects = ship.GetBuffs(24556);
Description

Returns all specified ship's active effects. Active effects are temporary effects, which are usually effects of consumables or devices.


GetBuffsCache
Arguments Returns Example
  • int: ship_id

array: key - value

var cache = ship.GetBuffsCache(24556);
Description

Returns current buffs cache. Used in FinalCacheCalculations.


GetCurrentValue
Arguments Returns Example
  • int: ship_id
  • string: name

double: current value with specified key

var val = ship.GetCurrentValue(24556, "structure");
Description

Returns current value of ship.


GetCurrentValuesList
Arguments Returns Example
  • int: ship_id

array: key -> value

var values = ship.GetCurrentValuesList(24556);
Description

Returns all current values of ship.



GetEquipment
Arguments Returns Example
  • int: ship_id

array: unique IDs (int) of equipped items

var equipment = ship.GetEquipment(24556);
Description

Returns current equipment of player's ship. Npc ship has no equipment, so it cannot be retreieved this way.


GetWeapons
Arguments Returns Example
  • int: ship_id

array: unique IDs (int) of equipped weapons

var weapons = ship.GetWeapons(24556);
Description

Returns currently equipped weapons of a ship. Npc ship has no equipment, so it cannot be retireved this way.


GetWeaponsOfType
Arguments Returns Example
  • int: ship_id
  • int: weapon_type (1 for energy, 2 for ballistic, 3 for missile)

array: unique IDs (int) of equipped weapons

var weapons = ship.GetWeapons(24556);
Description

Returns currently equipped weapons of a ship of a specified type. Npc ship has no equipment, so it cannot be retireved this way.


RefillAmmoForWeapon
Arguments Returns Example
  • int: ship_id
  • int: weapon_id

void

ship.RefillAmmoForWeapon(24556, 15252);
Description

Refills ammo for weapon with specified unique in-game id (GID).


GetHullXmlID
Arguments Returns Example
  • int: ship_id

string: current ship's hull's xml type

var hull = ship.GetHullXmlID(24556);
Description

Returns currently equipped hull's xml_id.


GetEquipmentCache
Arguments Returns Example
  • int: ship_id

array: key-value

var cache = ship.GetEquipmentCache(24556);
Description

Returns current equipment cache of ship.


GetFinalCache
Arguments Returns Example
  • int: ship_id

array: key-value

var cache = ship.GetFinalCache(24556);
Description

Returns current final cache of ship.


GetFinalCacheValue
Arguments Returns Example
  • int: ship_id
  • string: name

double: specified cache value

var val = ship.GetFinalCacheValue(24556, "structure");
Description

Returns final cache value.


GetSkills
Arguments Returns Example
  • int: ship_id

array of objects:

  • string: id
  • int: level
  • string: skill_id
var skills = ship.GetSkills(24556);
Description

Returns all current skills of ship.


GetSkillsCache
Arguments Returns Example
  • int: ship_id

array: key-value

var cache = ship.GetSkillsCache(24556);
Description

Returns current skills cache.


GetLevel
Arguments Returns Example
  • int: ship_id

int: current level of ship

var level = ship.GetLevel(24556);
Description


GetTags
Arguments Returns Example
  • int: ship_id

object: tags of a ship

var tags = ship.GetTags(24556);
Description


GetSystemID
Arguments Returns Example
  • int: ship_id

int: ID of ship's current system

var sys_id = ship.GetSystemID(24556);
Description


IsDocked
Arguments Returns Example
  • int: ship_id

bool: returns whether ship is currently docked

var docked = ship.IsDocked(24556);
Description


EnteringJumpgate
Arguments Returns Example
  • int: ship_id

int: returns ID of jumpgate ship is entering (or 0 if none)

var current_jumpgate = ship.EnteringJumpgate(24556);
Description


GetCurrentBase
Arguments Returns Example
  • int: ship_id

int: returns ID of base to which ship is docked (or -1 if none)

var current_base = ship.GetCurrentBase(24556);
Description


GetTimeSinceLastHit
Arguments Returns Example
  • int: ship_id

double: time since ship last time dealt damage to someone

var time = ship.GetTimeSinceLastHit(24556);
Description

Used in AI


GetTimeSinceLastHitted
Arguments Returns Example
  • int: ship_id

double: time since ship last time took damage from someone

var time = ship.GetTimeSinceLastHitted(24556);
Description

Used in ship's shield reestablishment calculations.


IsShieldUp
Arguments Returns Example
  • int: ship_id

bool: returns whether ship's shield is up

var shield_up = ship.IsShieldUp(24556);
Description


IsNpc
Arguments Returns Example
  • int: ship_id

bool: returns whether ship is npc-controlled

var is_npc = ship.IsNpc(24556);
Description


IsEngineOn
Arguments Returns Example
  • int: ship_id

bool: returns whether ship's engine is working

var is_engine_on = ship.IsEngineOn(24556);
Description


RegenerateWeapons
Arguments Returns Example
  • int: ship_id
  • double: energy
  • double: mult

double: amount of energy spent on weapons regeneration

var energy_spent = ship.RegenerateWeapons(24556);
Description

Hardcoded part - trying to regenerate weapons with energy. Only usable on PLAYER's ships. Returns amount of energy spent on weapons regeneration.


ReleaseGrappler
Arguments Returns Example
  • int: ship_id

void

ship.ReleaseGrappler(24556);
Description

Release all current grappled objects.


GetGrappledCount
Arguments Returns Example
  • int: ship_id

int: number of grappled objects

var grappled = ship.GetGrappledCount(24556);
Description

Get number of grappled objects. Useful in caluclation of grappler energy consumption.


SetBuffsCacheValue
Arguments Returns Example
  • int: ship_id
  • string: field_name
  • double: value

void

ship.SetBuffsCacheValue(24556, "structure", 2);
Description

Sets buff cache value.


ClearBuffsCache
Arguments Returns Example
  • int: ship_id

void

ship.ClearBuffsCache(24556);
Description

Clears all current buffs cache values.


SetCurrentValue
Arguments Returns Example
  • int: ship_id
  • string: field_name
  • double: val

void

ship.SetCurrentValue(24556, "structure", 59);
Description

Sets current value of ship


SetCurrentValueDelta
Arguments Returns Example
  • int: ship_id
  • string: field_name
  • double: val

void

ship.SetCurrentValueDelta(24556, "structure", -10);
Description

Alters current value to specified value. Value will be clamped automatically between 0 and it's max value (which is governed by ship params.)


SetCurrentArea
Arguments Returns Example
  • int: ship_id
  • string: area_id

void

ship.SetCurrentArea(24556, "command_deck");
Description

Sets current area of a player to specified one. Area determines in which section on a station NPC or player is.


GetCurrentArea
Arguments Returns Example
  • int: ship_id

string: area_id

var area = ship.GetCurrentArea(24556);
Description

Gets current area of the ship.



SetDrift
Arguments Returns Example
  • int: ship_id
  • double: time

void

ship.SetDrift(24556, 5000);
Description

Enables driftmode of ship - in this mode ship cannot be controlled and can gain torque (which is always 0 when driftmode is off). Useful in explosion effects.


SetEquipmentCacheValue
Arguments Returns Example
  • int: ship_id
  • string: field_name
  • double: value

void

ship.SetEquipmentCacheValue(24556, "structure", 5000);
Description

Sets equipment cache value.


ClearEquipmentCache
Arguments Returns Example
  • int: ship_id

void

ship.ClearEquipmentCache(24556);
Description

Clears equipment cache.


SetFinalCacheValue
Arguments Returns Example
  • int: ship_id
  • string: field_name
  • double: value

void

ship.SetFinalCacheValue(24556, "structure", 5000);
Description

Sets final cache value. Final cache is the one used in all in-game caluclations.


SetShieldUp
Arguments Returns Example
  • int: ship_id
  • bool: status - true or false

void

ship.SetShieldUp(24556, true);
Description

Sets shield up/down status. Affects collision and damage models. Does not applies visual effects (see more in VisualScope).


SetSkillsCacheValue
Arguments Returns Example
  • int: ship_id
  • string: field_name
  • double: value

void

ship.SetSkillsCacheValue(24556, "structure", 5000);
Description

Sets skill cache value.


ClearSkillsCache
Arguments Returns Example
  • int: ship_id

void

ship.ClearSkillsCache(24556);
Description

Clear skills cache.


SetShipAsArrivedFromJumpgate
Arguments Returns Example
  • int: ship_id
  • int: jumpgate_id

void

ship.SetShipAsArrivedFromJumpgate(24556, 15);
Description

Set visual and physical effects, that looks like ship just arrived from specified jumpgate.


SetDamageByShip
Arguments Returns Example
  • int: ship_id
  • double: damage
  • int: caster_id

void

ship.SetDamageByShip(24556, 15, 44535);
Description

Sets damage from ship. Useful in AI - you can count damage from player ship and decide, whether to attack or not.


SetDamageByShip
Arguments Returns Example
  • int: ship_id
  • int: caster_id

void

var dmg = ship.SetDamageByShip(24556, 44535);
Description

Gets damage by ship, which was set by ship.SetDamageByShip method.