VoidExpanse/scope-generator

From AtomicTorchWiki
Revision as of 03:44, 5 July 2014 by Damonwall (talk | contribs) (→‎List of functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Scope generator

Used for generation items, objects, systems in game, and also for getting some specific info about them.

Visibility: Global.

List of functions

AddAsteroid
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: type - xml id of asteroid
  • double: scale
  • double: resQ - resouces modifier
  • object: rotation
  • object: rotationSpeed

int: identifier of created object

var id = generator.AddAsteroid(1,100,100,"Asteroid01",1, 0, {x:0,y:0,z:0}, {x:0,y:0,z:0});
Description

Adds asteroid with specified parameters into game world. Asteroid contents (extractable resources), asteroid's look and other parameters can be modified only in .xml file, which is specified in this function by parameter "type".


AddBase
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: type - xml id of base
  • string: name
  • (optional) object: tags

int: identifier of created object

var id = generator.AddBase(1, 100, 100, "Base01", "Station Horizon", {class: "order"});
Description

Adds space station to game world.


AddItem
Arguments Returns Example
  • int: object_id
  • string: item_xml_id
  • int: quantity

object:

  • quantity - quantity was actually added
  • type - can be "item" or "resource"
var obj = generator.AddItem(1, "SomeItem", 5);
Description

Adds item to some object's inventory. In VoidExpanse not all objects do have inventory, so this function must be applied only to those, which have it, such as ships, space stations, containers.


AddItemToSpecifiedContainer
Arguments Returns Example
  • int: container_id
  • string: item_xml_id
  • int: quantity

object:

  • quantity - quantity was actually added
  • type - can be "item" or "resource"
var obj = generator.AddItemToSpecifiedContainer(1525, "SomeItem", 5);
Description

Important notice: container_id - is a special, unique in-game identifier for containers, which cannot be obtained by any way through API. Container id can only be obtained as a function parameter in events. Currently used in OnInstancedContainerGeneration event.


GenerateItemsWithItemlist
Arguments Returns Example
  • int: item_list_xml_id

array of objects:

  • quantity - quantity was actually added
  • id - xml-id of item
var items = generator.GenerateItemsWithItemlist(1, "SomeItem", 5);
for(var i = 0; i < items.length; i++)
{
	generator.AddItemToSpecifiedContainer(
		args.container_id,
		items[i].id,
		items[i].quantity );
}
Description

Generates set of items with itemlist. After generation, items can be added to any container.



AddContainer
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: xml_type
  • string: droplist
  • (optional) object: tags

int: identifier of object created

var id = generator.AddContainer(1, 0, 0, "Container01", "DropList01");
Description

Adds a floating container to game world. By default container is empty. Also containers, which has no contents, are unstable (self-destroyed as soon as someone will look at it's contents), so it's better not to create empty containers. Content can be added with generator.AddItem function.


AddDecoration
Arguments Returns Example
  • int: system_id
  • string: item_xml_id
  • vector2: position
  • double: depth
  • vector2: rotation
  • vector2: rotation_speed,
  • double: scale

int: ID of created object

var id = generator.AddDecoration(1, "Decoration01", {x:0,y:0}, 100, {x:5, y:5}, {x:5, y:5}, 2);
Description

Adds a decoration to game world. Decoration is a non-interactive object, which is used as a... decoration.


AddJumpgate
Arguments Returns Example
  • int: system_id
  • int: system_to
  • double: coord_x
  • double: coord_y
  • double: angle
  • string: xml_type
  • (optional) object: tags

int: ID of created object

var id = generator.AddJumpgate(1, 2, 100, 100, 20, "Jumpgate01", {sometag: "sometag"});
Description

Adds a jumpgate - an object, which allows ships to travel between systems. Every jumpgate must be paired with another one, for example, if in system A theres a jumpgate, that leads to system B, then in system B must be a jumpgate, that leads to system A.


AddNPCShipToSystem
Arguments Returns Example
  • string: npc_name
  • string: behavior - AI-script ("brains")
  • int: level
  • string: xml_type - npc xml type
  • int: system_id
  • double: coord_x
  • double: coord_y
  • (optional) object: tags

int: ID of created object

var id = generator.AddNPCShipToSystem("Pirate",
	"PirateAI", 100, "PirateNpc01",
	1, 105, 223, 
	{class: "pirate", uniq_id: "boss"});
Description

Adds an npc ship into game. NPC's avatar and faction are set through another functions - generator.SetNPCAvatar and relations.SetShipFaction


OverrideDropList
Arguments Returns Example
  • int: ship_id
  • array: droplists - strings array of droplists

void

generator.OverrideDropList(23303, ["DropList01", "DropList02"]);
Description

Adds specified droplists to npc's droplists list.


AddPlanet
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: name
  • int: seed

int: ID of created object

var id = generator.AddPlanet(1, 0, 0, "Earth", 123);
Description

Adds planet to game world. Planet's look is driven by seed, based on which planet's look will be defined by random generator. If you want a particular planet, you should either use seed with defined results (by our tool - SeedGenerator), or use another function - AddPlanetWithType.


AddPlanetWithType
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: name
  • int: seed
  • string: planet_config_type

int: ID of created object

var id = generator.AddPlanetWithType(1, 0, 0, "Earth", 123, "EarthTypePlanet");
Description

Adds planet to game world. Planet's look is driven partially be seed, but mostly by the specified type.


AddSpaceObject
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: xml_type_id
  • object: tags

int: ID of created object

var id = generator.AddSpaceObject(1, 0, 0, "Debris01", {class: "mine"})
Description

Adds a space object to game world. Space objects are interactive object. They cannot be destroyed, but they are interactive and collision-enabled. For example, spacemines are created with space objects.


AddLever
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • string: xml_type_id
  • int: visible_to
  • object: tags

int: ID of created object

var id = generator.AddLever(1, 0, 0, "Debris01", 0, {class: "mine"})
Description

Adds a lever object to world. Lever - is a special object, which can be activated. Parameter "visible_to" specifies, to whom lever is visible. If 0, it's visible to all, else - only to specified ship. Useful when you need to create a special object only to a man, who took the quest.


AddStar
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y
  • int: seed
  • int: heat - how much damage star deals, when ship approaches
  • (optional) string: typeID

int: ID of created object

var id = generator.AddStar(1, 0, 0, 234, 0)
Description

Adds a star. Conventionally, you shouldn't add more then 1 star to a system. If typeID is not specified, type will be picked by random, based on seed parameter.


AddSystem
Arguments Returns Example
  • double: coord_x
  • double: coord_y
  • string: name
  • int: seed

int: ID of created system

var id = generator.AddSystem(0, 0, "Hawkins Eta", 123)
Description

Adds a star system. Star system can be added anywhere, and by default it won't be connected to any other systems. See tutorial to see, how systems generation works.


SetSystemTags
Arguments Returns Example
  • int: system_id
  • object: tags

void

generator.SetSystemTags(1, {"show_clouds": "yes"})
Description

Sets tags of specified star system. Can be expanded with generator.AddSystemTag and retrieved by generator.GetSystemTags.


AddSystemTag
Arguments Returns Example
  • int: system_id
  • string: name
  • object: value

void

generator.AddSystemTag(1, "show_clouds", "yes")
Description

Adds tag to star system tags (or overwrites existing one with the same name).


GetSystemTags
Arguments Returns Example
  • int: system_id

object: tags set by methods above

var tags = generator.GetSystemTags(1);
if(tags != null && tags["show_clouds"] == "yes")
{
	console.Print("System 1 was told to show clouds");
}
Description

Retrieves tags of star system, which were set by SetSystemTags and AddSystemTag.


AddAnomaly
Arguments Returns Example
  • int: system_id
  • string: anomaly_id
  • object: args

void

generator.AddAnomaly(args.sys_id, "radar_disable", {});
Description

Adds anomaly to star system. There are few predefined anomalies (see more in the article Anomalies), but you can specify and implement your own anomalies.


SystemClose
Arguments Returns Example
  • int: system_id

void

generator.SystemClose(20);
Description

Sets system status to closed. Can be used anywhere, has no hardcoded implementation. For example, now it's being used to prevent player to travel to alien systems. System can be opened with generator.SystemOpen. All systems are opened by default.


SystemOpen
Arguments Returns Example
  • int: system_id

void

generator.SystemOpen(20);
Description

Sets system status to opened. Can be used anywhere, has no hardcoded implementation. For example, now it's being used to prevent player to travel to alien systems. System can be closed with generator.SystemClose. All systems are opened by default.


IsSystemClosed
Arguments Returns Example
  • int: system_id

bool

var closed = generator.IsSystemClosed(20);
Description

Check whether system is closed or not.


CountNpcInSystemByTags
Arguments Returns Example
  • int: system_id
  • object: tags

int

var numOfPirates= generator.CountNpcInSystemByTags(20, {class: "pirate"});
Description

Counts npcs with specified tags in specified system.


ClearDropList
Arguments Returns Example
  • int: ship_id

void

generator.ClearDropList(20025);
Description

Clears droplist of a specified NPC.


SetSystemPlaylists
Arguments Returns Example
  • int: system_id
  • object: key->value object

void

generator.SetSystemPlaylists(args.sys_id,
				{
					"explore": "playlist_generic_explore",
					"combat": "playlist_generic_combat"
				}
			);
Description

Sets system music playlists. There are few possible keys, see more in MusicPlaylists.


AddSystemsLink
Arguments Returns Example
  • int: system_id
  • int: system_2_id

void

generator.AddSystemsLink(1,2);
Description

This function creates a link between two systems. This links are simply logical, but there are few hardcoded rules about them. There are some specific rules, that are applied to every link:

  • Duplication - cannot create a link between already linked systems
  • Future Linking - cannot create a link between systems, that aren't exist yet
  • Proximity - link cannot pass closer then 2 units to a star
  • Intersections - link cannot intersect any other link

Links created this way are displayed on galaxy map. By this links jumpgates are created (though, there is no hard rule about that - you can create jumpgate without link between two star systems, but this connection won't be displayed on galaxy map).


FixConnectivity
Arguments Returns Example

void

void

generator.FixConnectivity();
Description

Should be called after all stars and links were created. It checks, if all stars are reachable from one another, and, if not, it creates missing star systems links.


DockShipToBase
Arguments Returns Example
  • int: ship_id
  • int: base_id

void

generator.DockShipToBase(12253,2);
Description

Immediately, without any animations, checkups and routines, docks ship to a space station. It's better not to use it on players, because it'll have unpredictable behavior.


ExpandArea
Arguments Returns Example
  • array: array of stars IDs

void

var stars = [3];
while(true)
{
	stars = generator.ExpandArea(stars);
	if(newstars.length >= 10) break;
}
console.Print("Now we have an area of 10 or more stars around star with id 3");
Description

Function, which returns the same array, as input + all stars, which are linked to input ones by 1 link. In other words, it returns an area, expanded by 1 link. Very useful during generation of zones in galaxy, such as faction territories.


GetAllSystems
Arguments Returns Example

void

array: IDs of all systems

var arr = generator.GetAllSystems();
Description


GetAsteroidTypes
Arguments Returns Example

void

array: xml_ids (strings) of all asteroids

var arr = generator.GetAsteroidTypes();
Description


GetClosestSystemToPoint
Arguments Returns Example
  • double: coord_x
  • double: coord_y

int: ID of picked system of 0, if none

var sys_id = generator.GetClosestSystemToPoint(0,0);
Description

Useful during generation process.


GetDebrisTypes
Arguments Returns Example

void

array: xml_ids (strings) of all space objects

var arr = generator.GetDebrisTypes();
Description

Useful during generation process. Alias of generator.GetSpaceObjectsTypes.


GetSpaceObjectsTypes
Arguments Returns Example

void

array: xml_ids (strings) of all space objects

var arr = generator.GetSpaceObjectsTypes();
Description

Useful during generation process. The same as generator.GetDebrisTypes.


GetIntersection
Arguments Returns Example
  • int: system_id
  • double: coord_x
  • double: coord_y

string: intersection in format "coord_x;coord_y" or empty string

var intersection = generator.GetIntersection(0, 15, 15);
if(intersection.length > 0)
{
	var arr = intersection.split(';');
	console.Print("Intersection was found: point X:" + arr[0] +", Y:" + arr[1]);
}
Description

The function answers the question: if a put a link between system with specified id and point with coordinates coord_x;coord_y, will it intersect any other links? Useful during galaxy generation process.


GetJumpsBetweenSystems
Arguments Returns Example
  • int: system_id
  • int: system_2_id

int: number of jumps

var jumps = generator.GetJumpsBetweenSystems(1,1000);
Description

Returns length (number of links) of the minimal way between two systems.


GetLinkedSystems
Arguments Returns Example
  • int: sys_id

array: IDs of systems

var arr = generator.GetLinkedSystems(1);
Description

Returns an array with IDs of all systems linked to the specified one.


GetRoute
Arguments Returns Example
  • int: sys_id_from
  • int: sys_id_to

array: IDs of systems

var route = generator.GetRoute(1,5);
Description

Returns an array with IDs of all systems, which makes the shortes route between two points.


GetItemPrice
Arguments Returns Example
  • string: item

int: price

var price = generator.GetItemPrice("object_alien_relic_01");
Description

Returns a price of item by it's xml id.


GetItemTitle
Arguments Returns Example
  • string: item

string: title

var title = generator.GetItemTitle("object_alien_relic_01");
Description

Returns a name of item by it's xml id.


GetMinDistanceToSystem
Arguments Returns Example
  • double: coord_x
  • double: coord_y

double: distance to the closest system (or maximum double value if none)

var dist = generator.GetLinkedSystems(1);
Description

Return distance to the closest system to a specified point.


GetNumberOfLinks
Arguments Returns Example
  • int: system_id

int: number of links to specified system

var links = generator.GetNumberOfLinks(1);
Description


GetPlanetCoordinates
Arguments Returns Example
  • int: planet_id

vector2: coordinates of a planet

var coords = generator.GetPlanetCoordinates(242);
console.Print("Planet coordinates: X:" + coords.x + ", Y:" + coords.y);
Description

Returns coordinates of specified planet.


GetRandomPlanetInSystem
Arguments Returns Example
  • int: system_id

int: ID of a planet

var id = generator.GetRandomPlanetInSystem(1);
Description

Returns ID of random planet in system (or 0 if there are no planets).


GetSystemPlanets
Arguments Returns Example
  • int: system_id

array: IDs of planets

var arr = generator.GetSystemPlanets(1);
Description

Returns an array with IDs of all planets in system.


GetSystemByID
Arguments Returns Example
  • int: system_id

object:

  • double: coord_x
  • double: coord_y
  • int: seed
  • string: faction
  • int: danger_level
  • int: tech_level
  • string: name
var obj = generator.GetSystemByID(1);
Description

Returns basic info about specified system. Tags of star system can be gained with generator.GetSystemTags.


GetBaseByID
Arguments Returns Example
  • int: base_id

object:

  • string: faction
  • int: tech_level
  • string: name
  • double: coord_x
  • double: coord_y
var obj = generator.GetBaseByID(1);
Description

Returns space station basic description. Tags cannot be retrieved with this function - use game.GetTags instead.


GetSystemsByDistanceTo
Arguments Returns Example
  • int: system_id

array: IDs of systems

var arr = generator.GetSystemsByDistanceTo(1);
Description

Returns an array with IDs of systems, which are sorted by distance to specified system. Specified system is included into resulting array.


GetPopulatedSystems
Arguments Returns Example

void

array: IDs of systems

var arr = generator.GetPopulatedSystems();
Description

Returns an array with IDs of systems in which there are currently players.


GetAllResources
Arguments Returns Example

void

array: xml_ids (strings) of resources

var arr = generator.GetAllResources();
Description

Returns an array of all resources of VoidExpanse.


GetResourcesWithFlags
Arguments Returns Example
  • array of strings: flags

array: xml_ids (strings) of resources

var arr = generator.GetResourcesWithFlags(["mineable", "highlevel"]);
Description

Returns an array of resources of VoidExpanse, contains all specified flags in it's XML description.


GetResourceByID
Arguments Returns Example
  • string: xml_id

object:

  • double: price - standard price of this item
  • int: shops_level - level of shops in which this resource should be sold
  • string: name - name of resource
  • string: id - xml id of resource
var obj = generator.GetResourceByID("Resource01");
Description

Returns a description of a resource by it's xml_id.


GetItemByXmlID
Arguments Returns Example
  • string: xml_id

object:

  • double: price - standard price of this item
  • int: shops_level - level of shops in which this resource should be sold
  • string: name - name of resource
  • string: id - xml id of resource
var obj = generator.GetItemByXmlID("Item01");
Description

Returns a description of an item by it's xml_id.


RemoveAsteroid
Arguments Returns Example
  • int: asteroid_id

void

generator.RemoveAsteroid(123);
Description

Removes asteroid from a game world.


RemoveBase
Arguments Returns Example
  • int: base_id

void

generator.RemoveBase(123);
Description

Removes base (space station) from a game world.


RemoveDecoration
Arguments Returns Example
  • int: decoration_id

void

generator.RemoveDecoration(123);
Description

Removes decoration from a game world.


RemoveJumpgate
Arguments Returns Example
  • int: jumpgate_id

void

generator.RemoveJumpgate(123);
Description

Removes a jumpgate from a game world.


RemovePlanet
Arguments Returns Example
  • int: planet_id

void

generator.RemovePlanet(123);
Description

Removes a planet from a game world.


RemoveSpaceObject
Arguments Returns Example
  • int: space_object_id

void

generator.RemoveSpaceObject(123);
Description

Removes a space object from a game world.


RemoveLever
Arguments Returns Example
  • int: lever_id

void

generator.RemoveLever(123);
Description

Removes specified lever from a game world.


RemoveStar
Arguments Returns Example
  • int: star_id

void

generator.RemoveStar(123);
Description

Removes a star from a game world.


RemoveSystemsLink
Arguments Returns Example
  • int: system_id
  • int: system_2_id

void

generator.RemoveSystemsLink(1,2);
Description

Removes a link between two systems.


ReportLoadingPhase
Arguments Returns Example
  • string: phase

void

generator.ReportLoadingPhase("Loading galaxy");
Description

Adds message to singleplayer client with loader (then to alter loader use generator.ReportLoadingProgress).


ReportLoadingPhaseNoLoader
Arguments Returns Example
  • string: phase

void

generator.ReportLoadingPhaseNoLoader("Loading galaxy");
Description

Adds message to singleplayer client.


ReportLoadingProgress
Arguments Returns Example
  • double: percent - a value from 0 to 1

void

generator.ReportLoadingProgress(0.5);
Description

Adds message to singleplayer client.


SetNPCAvatar
Arguments Returns Example
  • int: npc_ship_id
  • object: avatar parameters

void

generator.SetNPCAvatar(12553, [1,2,3,4,5,6]);
Description

Sets npc avatar.


SetNPCAvatarImg
Arguments Returns Example
  • int: npc_ship_id
  • string: path_to_image

void

generator.SetNPCAvatarImg(id, "avatars/unique/terminal_01.png");
Description

Sets npc avatar image instead of standart avatar system.


SetSystemDangerLevel
Arguments Returns Example
  • int: system_id
  • int: danger_level - from 0 to 100

void

generator.SetSystemDangerLevel(1, 99);
Description

Set star system danger level. Danger level usually affects a level of system's npc and many other parameters.


SetSystemTechLevel
Arguments Returns Example
  • int: system_id
  • int: tech_level - from 0 to 100

void

generator.SetSystemTechLevel(1, 99);
Description

Set star system tech level. Tech level usually affects shops store items.


ShipExists
Arguments Returns Example
  • int: ship_id

bool: whether ship exists or not

generator.ShipExists(12552);
Description