Skip to content

ufo_util

Source: base/tealdef/game_mechanics/fun_elements/ufo_util.d.tl

Notes

UFO that flies in, abducts a cow from a livestock farm and leaves.

UfoUtil

record global base/tealdef/game_mechanics/fun_elements/ufo_util.d.tl:3

global record UfoUtil

Notes

UFO that flies in from the map edge, lifts a cow from a livestock farm field and flies off again.

Details

The fun elements game script spawns one every 2 to 4 game years while no other UFO is in flight.

Functions

spawnNew(callback : function(UfoData)) : boolean base/tealdef/game_mechanics/fun_elements/ufo_util.d.tl:21

Notes

Spawns a cow on a random cow field of a livestock farm and a UFO at the nearest map edge.

Parameter Type Description
callback function(UfoData) Receives the UFO's data once both entities exist.

Returns boolean: False if no livestock farm with cows exists.

update(data : UfoData, dt : number) : boolean base/tealdef/game_mechanics/fun_elements/ufo_util.d.tl:22

Notes

Moves the UFO (or the cow during the abduction) one step and advances the flight stage.

Parameter Type Description
data UfoData UFO to update; changed in place.
dt number Time step in seconds.

Returns boolean: True when the UFO was removed and its data can be dropped.

UfoUtil.UfoState

enum base/tealdef/game_mechanics/fun_elements/ufo_util.d.tl:4

enum UfoState

Notes

Flight stage of a UFO.

Value Description
"Approach" Flying from the map edge towards the farm.
"Target" Slowing down to hover 25 metres above the cow.
"Abduct" Lifting the cow.In game Abducting · Abducted
"Leave" Flying to the nearest map edge after the cow is gone.In game Leaving
"Despawn" Shrunk at the map edge; removed on the next update.

UfoUtil.UfoData

record base/tealdef/game_mechanics/fun_elements/ufo_util.d.tl:12

record UfoData

Notes

Saved state of one UFO.

Used in the base game: 4 times in 2 files

base/content/game_mechanics/game_mechanics/fun_elements/fun_elements.script.tl:45

ufo_util.spawnNew(function(ufoData : UfoUtil.UfoData)
base/content/game_mechanics/game_mechanics/fun_elements/ufo_util.tl:65
ufoUtil.spawnNew = function(callback:function(UfoUtil.UfoData)) : boolean

Fields

Name Type Description
ufoEntity EntityUtil.EntityAndRevision UFO entity.
cowEntity EntityUtil.EntityAndRevision Cow entity; empty after the abduction.
state UfoState Current flight stage.
velocity {number} Velocity as {x, y, z} in metres per second.
target {number} Current target position as {x, y, z}.
abductSpeed number Speed at which the cow is pulled up to the UFO in the Abduct stage, per dt unit of the game script update. It starts at 0 and rises to at most 6.