The space_objects module
Overview
API: Space Objects
broad_test(x1, z1, x2, z2, broad_type=65520)
Returns a set of ids that are in the target rect. Args: x1 (float): x location (left) z1 (float): z location (top) x2 (float): x location (right) z2 (float): z location (bottom) broad_type (int, optional): The type of objects for which to search. * TERRAIN = 0x01, * NPC = 0x10, * PLAYER = 0x20, * ALL = 0xffff, * NPC_AND_PLAYER = 0x30, * DEFAULT is 0xfff0 Returns: set[int]: A set of ids
broad_test_around(id_or_obj, width, depth, broad_type=65520)
Returns a set of ids that are around the specified object in the target rect. Args: id_obj (Agent | int): The ID or object of an agent w (float): width d (float): depth broad_type (int, optional): The type of objects for which to search. * TERRAIN = 0x01, * NPC = 0x10, * PLAYER = 0x20, * ALL = 0xffff, * NPC_AND_PLAYER = 0x30, * DEFAULT is 0xfff0 Returns: set[int]: A set of ids
clear_target(chasers, throttle=0)
Clear the target on an agent or set of agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chasers
|
set[Agent | int] | int | Agent | CloseData | SpawnData
|
an agent or set of agents |
required |
closest(the_ship, the_set, max_dist=None, filter_func=None)
Get the CloseData that matches the test set, max_dist, and optional filter function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
the_ship
|
Agent | int
|
The agent ID or object |
required |
the_set
|
Agent | int | set[Agent | int]
|
The agent or id or set of objects or ids to test against |
required |
max_dist
|
float
|
The maximum distance to check. Defaults to None. |
None
|
filter_func
|
Callable
|
An additional function to test with. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CloseData |
CloseData
|
The closest object's CloseData to get the distance. |
closest_list(source, the_set, max_dist=None, filter_func=None)
Get the list of close data that matches the test set, max_dist, and optional filter function. Args: source (Agent | int | CloseData | SpawnData): The agent object or id of the agent. the_set (set[int]): A set of ids to check against. max_dist (float, optional): The maximum distance to include. Defaults to None. filter_func (Callable, optional): An additional function to check against. Defaults to None.
Returns:
| Type | Description |
|---|---|
list[CloseData]
|
list[CloseData]: The list of CloseData representing the close objects to get the distance. |
closest_object(the_ship, the_set, max_dist=None, filter_func=None)
Get the CloseData that matches the test set, max_dist, and optional filter function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
the_ship
|
Agent | int
|
The agent ID or object. |
required |
the_set
|
Agent | int | set[Agent | int]
|
The id or object or set of objects or ids to test against. |
required |
max_dist
|
float
|
The maximum distance to check. Defaults to None. |
None
|
filter_func
|
func
|
An additional function to test with. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
agent |
Agent
|
Return the closest agents or None |
delete_object(id_or_objs)
Delete the specified object or set of objects. Args: id_or_objs (Agent | int | set[Agent | int]): The object or set of objects.
delete_objects_box(x, y, z, w, h, d, broad_type=15, roles=None)
Removes items from an area
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x,y,z
|
(float, float, float)
|
the start point/origin |
required |
radius
|
float
|
the radius |
required |
broad_type
|
int
|
The engine level bit test for broadtest * TERRAIN = 0x01, * NPC = 0x10, * PLAYER = 0x20, * ALL = 0xffff, * NPC_AND_PLAYER = 0x30, * DEFAULT is 0x0F |
15
|
roles
|
str
|
A comma-separated list of roles that the objects must have to be deleted. |
None
|
delete_objects_sphere(x, y, z, radius, broad_type=15, roles=None)
Removes items from an area if they meet the broadtype and role filter requirements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x,y,z
|
(float, float, float)
|
The start point/origin of the sphere. |
required |
radius
|
float
|
The radius of the sphere. |
required |
roles
|
str
|
A comma-separated list of roles that the objects must have to be deleted. |
None
|
get_engineering_value(id_or_obj, name, default=None)
Gets an engineering value by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_obj
|
Agent | int
|
An agent id or object. |
required |
name
|
str
|
The engineering value to get. |
required |
default
|
float
|
What to return if not found. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
A value or the default |
get_pos(id_or_obj)
Get the position of an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_obj
|
Agent | int
|
The agent for which to get the position. |
required |
Returns:
| Type | Description |
|---|---|
|
Vec3 | None: The position of the agent or None if it doesn't exist. |
set_engineering_value(id_or_obj, name, value)
Sets an engineering value by name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_obj
|
Agent | int
|
An agent id or object. |
required |
name
|
str
|
The engineering value to set. |
required |
value
|
float
|
The value. |
required |
set_pos(id_or_obj, x, y=None, z=None)
Set the position of an agent or set of agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_obj
|
Agent | int | set[Agent | int]
|
An agent or set of agent IDs or objects. |
required |
x
|
float | Vec3
|
The x location or a vector. |
required |
y
|
float
|
y location. If None, |
None
|
z
|
float
|
z location. Defaults to None. |
None
|
target(set_or_object, target_id, shoot=True, throttle=1.0, stop_dist=None)
Set the target for an agent or set of agents. Args: set_or_object (Agent | int | set[Agent | int]): The agent or set of agents for which to set the target. target_id (Agent | int): The agent id or object to target. shoot (bool, optional): Whether to also lock weapons on target. Defaults to True. throttle (float, optional): The speed at which to travel. Defaults to 1.0. stop_dist (int, optional): If the target is within this distance, then the throttle will be set to 0. Default is None.
target_pos(chasers, x, y, z, throttle=1.0, target_id=None, stop_dist=None)
Set the target position of an agent or set of agents
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chasers
|
Agent | int | set[Agent | int]
|
The agents which should go to the target position. |
required |
x
|
float
|
x location |
required |
y
|
float
|
y location |
required |
z
|
float
|
z location |
required |
throttle
|
float
|
The speed at which to travel. Defaults to 1.0. |
1.0
|
target_id
|
id
|
What to shoot |
None
|
stop_dist
|
float
|
If the target position is within this distance, then the throttle will be set to 0. Default is None. |
None
|
target_shoot(chasers, target_id=None)
Set the target id only Args: chasers (agent id | agent set): the agents to set target_id (id, optional): What to shoot