Skip to main content

Teams

Alliance flags

Alliance flags represent the alliance status between two players. Functions like Query use alliance flags for filtering. You can use the Alliance function to determine the alliance status between two entities.

Alliance:Self = 0b0001

A player is considered Alliance:Self only with itself.

Alliance:Ally = 0b0010

A player is considered Alliance:Ally if it has the same Team as the other player, and the other player is not itself.

Alliance:Enemy = 0b0100

A player is considered Alliance:Enemy if it is on a different Team as the other player.

Alliance:Neutral = 0b1000

A player is considered Alliance:Neutral if the other player is null. The most commonly happens with Entities who have no Owner.

Alliance:Friendly = 0b0011

A compound flag that represents both Alliance:Self and Alliance:Ally.

Alliance:NotFriendly = 0b1100

A compound flag that represents both Alliance:Enemy and Alliance:Neutral.

Alliance:All = 0b1111

A compound flag that includes all possible alliance statuses.

Alliance:None = 0b0000

A compound flag that represents no alliance status.

Alliance

Alliance(a, b) -> flags

Alliance can be used to determine the alliance status between two entities. It first looks up who owns the entity according to what its Owner property is set to, and then determines the alliance status of the two owners by looking at their Team properties.

It can return one of four flags:

  • Alliance:Self if the two entities have the same owner
  • Alliance:Neutral if at least one of the entities has no owner
  • Alliance:Ally if the owners have the same team
  • Alliance:Enemy if the owners are on different teams

If any parameter is nullish, returns Alliance:Neutral.

Owner

this.Owner -> player

Returns the owner of an entity. Returns undefined if the entity has no owner or this is nullish.

this.Owner = player

Sets the owner of an entity. The owner must be a player or team entity. Player entities are received from SpawnEachPlayer or from QueryPlayers. If you assign an entity that is not a player, it will be treated as a team entity, and anything which is owned by that same team entity will be considered to be on the same team. Any entity can be used as a team - you can simply Spawn one when needed.

Does nothing if this is nullish.

await this.Owner -> player

Waits until the owner of an entity changes, then returns its new value. If this is nullish, the owner can never change, so this function will wait forever.

delete this.Owner

Removes the owner of an entity. Does nothing if this is nullish.

Team

owner.Team -> team

Gets the team Entity of the given owner player Entity.

If the player has not been assigned to a team, the player is considered to be on an individual team of one, and so this will return the original owner Entity.

If owner is not a player entity, looks up the Owner and returns its team. If owner is nullish, returns undefined.

owner.Team = team

Sets the team for a given owner player Entity. The team must be an Entity, and the entity cannot be a player Entity. The best thing to do is to Spawn a new entity to represent each team in your game.

Throws an error if owner is an Entity but is not a player Entity.

Does nothing is owner is nullish.

delete owner.Team

Removes the team assignment from the given owner player Entity. If the player is not assigned to a team, does nothing.

Throws an error if owner is an Entity but is not a player Entity. Does nothing if owner is nullish.

await owner.Team -> team

Waits until the team of the given owner player Entity changes, then returns its new value. If owner is nullish or not a player Entity, then the team can never change, so this function will wait forever.