Persistent Real-Time Strategy Space Game
Hosted by SourceForge
openspace project page

All objects will consist of an object description to define its shape and features, and default functions written in a scripting language. The player is able to modify or add new strategic functions to any object to make it 'smarter'. Ships can be made to react to changes from other ships. If you have ships in a formation and one is destroyed then the remaining ships can change formation or compensate for the missing ship. If sensors pick up a ship at warp then SDF generators can activate and knock it out of warp. Ships can be dispatched to destroy detected ships. Shipyards can keep building new ships if you have the resources or they can only build each time a ship is lost.

The scripting language will be very easy to use and anyone should be able to learn it rather quickly.

Scripts can be downloaded from the internet and loaded into the client. Players can also pass scripts to each other in the game.

The following basic language commands, object functions and events are NOT complete lists. If you have ideas for more commands/functions then please email me.

Basic Language Commands

DEFINE function_name (parameters...) (statement) create function. only used in the script editor or in imported scripts. can not be used in functions or on the command line.
WHEN event (object.function p... ) when object receives event process function.
ORDER (object.function p...) set primary task for object, returns to this function after being interrupted by events.
HALT object remove an object's primary task. not sure if this is needed.
GVAR variable create a variable global to all functions. can not be used inside functions.
SET variable (statement) assign value returned from statement to variable

Function Control Commands

LVAR variable create a variable local to the function
WAITUNTIL event pause function until object receives event
IF (condition) (statement1) (statement2) if condition is true then process statement1 otherwise process statement2
DOWHILE (statement) (condition) process statement once, repeat while condition is true
WHILE (condition) (statement) process statement while condition is true
REPEAT used inside a function, processes function again
WHEN object event function when object received event process function
WAIT seconds suspend function for seconds

Math Functions

RANDOM return a random number
ADD var/num var/num ... add multiple variables or numbers and return the result
SUB var/num var2/num2 subtract var2/num2 from var/num and return result
MUL var/num var/num ... multiply multiple variables or numbers and return result
DIV var/num var2/num2 divide var/num by var2/num2 and return result
NEG num return two's complement of number
ABS num return absolute value of number

Object Functions: all objects

SELFDESTRUCT detonates the object and inflicts damage on any objects within the blast radius.
GIVE resources give resources to the ship currently docked with. destination ship will only take what it can hold, if resources exceeds this then they will remain in the source ship. if zero then it will fill the object up.
DISTRESS send a distress call to all players within range of ship. other players can have triggers to respond to distress calls and help out. helping players in distress is a good way to make allies.
MESSAGE player/group/allies "message" send a message to the player, another player, a group of players or allies.
NEAR distance object returns true if the object is less than distance away.
DISTANCE object returns the distance to object.
SCAN on/off enable/disable active sensors. gives away position when on.

Object Functions: all mobile objects

TURN relative_degrees turn the object relative to its current heading. consumes fuel while turning.
SETHEADING absolute_degrees turn the object to the absolute heading. consumes fuel while turning.
SETDEST x y set destination coordinates.
SETDISTANCE distance set distance before STOP command is issued. the object will not stop instantaneously so distance needs to account for decceleration. if zero then object will not stop until ordered.
SETVELOCITY velocity set velocity of object. object will begin moving and will consume fuel until velocity is reached.
GOTO x y velocity sets velocity and calculates distance to x,y. consumes fuel until velocity is reached.
STOP slow object to a complete stop. object will consume fuel while stopping. if object runs out of fuel it will be unable to stop.
SCOUT fly around and scan region.
FOLLOW object follow an object.
PATROL velocity point1 point2 ... patrol from current position to each point and back to current position. will attack any enemy ships if encountered and if the current object has weapons.
KAMIKAZE object move toward another object while increasing velocity and self destruct on collision.
DOCK object dock with another object.
FUELFOR velocity distance returns the amount of resources it takes to travel the distance.
FUELTO velocity returns the amount of resources it takes to go from current velocity to new velocity.
REFUEL get resources from docked object.

Object Functions: wormhole generators

ACTIVATE_WM opens wormhole and pushes docked object into it.

Object Functions: all objects with weapons

ATTACK object weapon level fires weapon at object. level is the strength of the weapon damage. If a MOVE order is given after an attack order then the ship will continue to attack while moving.
BLINDSHOT coordinates weapon level fires weapons at coordinates. same as ATTACK but useful for attacking cloaked objects.
STANDDOWN cancels an attack order.
GAURD stays at a stop unless an enemy ship is visible on short-range sensors.
HOLD will not move from current position. will return fire if attacked.
LAUNCH type coordinates must have a warp launcher, launch a probe/mine/etc to the given coordinates.

Object Functions: all objects with replicators

BUILD type build type of object. each object has a list of types it can build.
REPAIR object must have repair capabilities, begin repairs on object.

Object Functions: all mining objects

MINE object mine resources from another object.

Object Functions: all objects with tractor beam emitters

GRAB object grab object to hold in place or tow. the size of the object determines the power needed by the emitter. if the ship is not able to supply this power then the emitters will shutdown. to tow another ship there must be anough power for the engines and the emitters.

Object Functions: all objects with life support

COMMAND transfer command. if the command object is destroyed the player can no longer issue commands and the ships will carry on with current orders until destroyed. the player must start over if the command object is lost. objects must be docked.


enemy_seen enemy is within sensor range of current object
attacked current object is attacked, does not send event if attacked by owner. object ID of attacking ship is sent with this event. object can return fire, send a distress signal, order other ships to attack, etc..
arrived current object has arrived at destination point. MOVE will wait on this event so it knows when to continue processing a function.
distress received by all objects in range. object ID is sent with this event.
dock_complete current object has completed dock with the other object. DOCK waits on this event before function continues.
docked current object has been docked by another ship.
out_of_fuel current object has run out of resources. send order to tanker or a ship in the area.

~ precedes current object variables
# precedes function parameter names
. variables in other objects can be accessed by placing a . between the object name and variable

Example Code

	DEFINE tanker_run1
	(warp_factor pick_up_point warpgate1 warpgate2 drop_off_point)
		// tanker will pickup resources and take them to a
		// shipyard via a warpgate
		(DOCK #pick_up_point)
		(DOCK #warpgate1)

		// fill up warp gate
		(GIVE (FUELTO #warp_factor #warpgate1.dest))

		// activate warp gate
		(WARP #warp_factor)
		(DOCK #drop_off_point)
		(GIVE (SUB ~fuel (ADD (FUELTO 0 #warpgate2)
				      (FUELTO #warp_factor #warpgate2.dest)
				      (FUELTO 0 #pick_up_point)
		(DOCK #warpgate2)

		// fill up warp gate
		(GIVE (FUELTO #warp_factor #warpgate1.dest))

		// activate warp gate
		(WARP #warp_factor)