Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

data/smart_objects/

A smart object definition: an entity that advertises activities and owns slots agents claim, so a mod adds a forge, a bench or a shrine without touching any brain. A brain’s activity finds objects with targets: SmartObjects(..), claims a slot with ClaimSlot and runs the slot’s behaviour with UseSlot. An entity becomes one through the manifold-ai:smart-object component, (def: "<key>"). Loaded by the server only.

Registrymanifold-ai:smart-object
Filesdata/smart_objects/*.ron, *.update.ron, *.final.ron
Sidesserver: only the server loads it
Readsmanifold-ai:state-tree
ContractPopulation, data stage

Entry

A record, written SmartObject(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe definition’s key, <mod-id>:<name>.
tagslist of stringnononeThe object’s tags, dotted; a query’s tag matches itself and its descendants.
slotslist of SlotnononeIts slots, at most 16 with the engagement ring’s.
engagementEngagement or NonenononeA ring of engagement slots around the object (a large enemy), so melee attackers spread around it.
advertisementslist of AdvertisementnononeThe activities it offers, at most 8.
player_usablebytesnononeSlot ids players may occupy.
query_radiusu16no48The distance, in blocks, at which an advertisement’s score halves.

Example

No bundled file declares one yet. From the reference’s test fixture, crates/manifold-server-state/tests/data-reference-fixture/data/smart_objects/workshop.ron, which the data stage loads in its tests:

SmartObjectDef(id: "dataref-fixture:so/marker")

Types

Slot

A claimable slot.

A record: Slot(..) or (..).

FieldTypeRequiredDefaultDescription
idu8yesThe slot’s id, unique within the object.
offset(f32, f32, f32)no(0.0, 0.0, 0.0)Where the occupant stands, from the object’s position, turned by the object’s yaw.
yawf32no0.0The way the occupant faces, in degrees, added to the object’s yaw.
tagslist of stringnononeThe slot’s tags, which advertisements and jobs name.
acceptscondition or NonenoanyoneA condition in the smart_object context (This the agent, Target the object) an occupant must meet.
behaviourSlotBehaviouryesWhat the occupant does there.
timeoutdurationno"60s"How long a claim lasts unless renewed.

SlotBehaviour

What a slot’s occupant does.

VariantWrittenDescription
StateTreeStateTree(string)A state tree by key (manifold-ai:state-tree), which must be declared.
TasksTasks([Task])Tasks run in order, at least one: Tasks([Face(target: Slot), PlayAnimation(play: "sit"), Wait(seconds: 8.0)]).

Task

A task a state runs.

VariantWrittenDescription
MoveToMoveTo(target: .., stop_within: .., speed: .., fail_on: ..)Walks to a target.
FollowFollow(target: .., band: .., speed: .., teleport_beyond: .., fail_on: .., background: ..)Keeps within a distance band of a target.
FaceFace(target: .., background: ..)Turns to face a target.
WaitWait(seconds: ..)Waits.
WanderWander(radius: .., around: ..)Wanders.
UseAbilityUseAbility(ability: .., target: .., max_range: ..)Requests an ability.
ClaimClaim(target: ..)Claims a target, so no other agent takes it (released when the state’s scope ends).
ReleaseRelease(target: ..)Releases a claim.
AcquireTokenAcquireToken(pool: .., wait: ..)Asks for a token from a pool for the activity’s target, each tick until it is granted; held until the state’s scope ends, like a claim.
RequestRoleRequestRole(role: .., score: ..)Asks the agent’s squad for a role; succeeds at once. The squad grants roles within its style’s limits.
ClaimSlotClaimSlot(object: ..)Claims a slot of a smart object for the running activity: the first free slot its advertisement names whose accepts holds. Scoped like Claim.
UseSlotUseSlotRuns the held slot’s behaviour as a nested tree; ends with it. Not allowed inside a slot’s own behaviour.
PullJobPullJob(wait: ..)Asks the chore board for a job: at the activity’s target station when it has one, else the best job the worker may take. The job and its slot belong to the state’s scope, like a claim.
WorkWork(cycles: ..)Works the held job at its station; the station completes cycles from its work numbers.
PickUpPickUp(item: ..)Picks up a dropped item.
PutDownPutDownPuts the carried item down at the agent’s feet.
PlayAnimationPlayAnimation(play: ..)Plays an animation by its play name.
EmitEmit(Emit)Emits a cue, an ally call or a noise.
SetMemorySetMemory(kind: .., value: .., ttl: ..)Writes a memory.
ClearMemoryClearMemory(kind: ..)Clears a memory.

MoveTo fields:

FieldTypeRequiredDefaultDescription
targetBindyesWhere.
stop_withinf32no1.0Succeeds within this many blocks.
speedf32no1.0A fraction of walking speed; above 1 sprints.
fail_onlist of FailOnnononeConditions that fail it.

Follow fields:

FieldTypeRequiredDefaultDescription
targetBindyesWhom.
band(f32, f32)yesThe band, (near, far) in blocks.
speedf32no1.0A fraction of walking speed.
teleport_beyondf32 or NonenoneverTeleports to the target beyond this many blocks.
fail_onlist of FailOnnononeConditions that fail it.
backgroundboolnofalseWhether it runs alongside the state’s other tasks without deciding its completion.

Face fields:

FieldTypeRequiredDefaultDescription
targetBindyesWhat.
backgroundboolnofalseWhether it runs in the background.

Wait fields:

FieldTypeRequiredDefaultDescription
secondssecondsyesHow long.

Wander fields:

FieldTypeRequiredDefaultDescription
radiusfloat-or-paramno8.0How far, in blocks.
aroundAroundnoHomeAround what.

UseAbility fields:

FieldTypeRequiredDefaultDescription
abilitystringyesThe ability (manifold:ability key), or "$param". An unknown key fails the data stage (DATA010).
targetBindnoTargetAt whom.
max_rangef32no16.0Fails beyond this many blocks.

Claim fields:

FieldTypeRequiredDefaultDescription
targetBindyesWhat.

Release fields:

FieldTypeRequiredDefaultDescription
targetBindyesWhat.

AcquireToken fields:

FieldTypeRequiredDefaultDescription
poolstringyesThe pool (manifold-ai:token-pool key).
waitf32no2.0Fails Denied after this many seconds without a grant.

RequestRole fields:

FieldTypeRequiredDefaultDescription
rolestringyesThe role (manifold-ai:role key).
scorei32no0The request’s score; higher requests win the role.

ClaimSlot fields:

FieldTypeRequiredDefaultDescription
objectBindnoTargetThe smart object.

PullJob fields:

FieldTypeRequiredDefaultDescription
waitf32no2.0Fails Denied after this many seconds without a job.

Work fields:

FieldTypeRequiredDefaultDescription
cyclesu32 or Nonenoruns until the job endsSucceeds after this many cycles.

PickUp fields:

FieldTypeRequiredDefaultDescription
itemBindyesWhich.

PlayAnimation fields:

FieldTypeRequiredDefaultDescription
playstringyesThe play.

SetMemory fields:

FieldTypeRequiredDefaultDescription
kindstringyesThe memory (manifold-ai:memory-kind key).
valueBindyesThe value.
ttlf32 or Nonenothe memory kind’sSeconds until it expires.

ClearMemory fields:

FieldTypeRequiredDefaultDescription
kindstringyesThe memory.

Bind

Who or what a task acts on.

VariantWrittenDescription
TargetTargetThe activity’s target.
OwnerOwnerThe agent’s owner.
SelfSelfThe agent itself.
HomeHomeThe agent’s home.
MemoryMemory(string)A memory’s entity or position.
ClaimedClaimedWhat the current scope claimed.
CarriedCarriedThe item the agent carries.
SlotSlotThe slot the agent holds on the smart object it claimed: the slot’s position; Face(Slot) turns to the slot’s facing.
PointPoint(f32, f32, f32)A fixed point: Point(x, y, z).

FailOn

A condition that fails a task.

VariantWrittenDescription
TargetGoneTargetGoneThe target is gone.
TargetLostTargetLostThe target is lost.
ReservationLostReservationLostThe claim was lost.
OwnerGoneOwnerGoneThe owner is gone.
OwnerFartherOwnerFarther(f32)The owner is farther than this many blocks.
TimeoutTimeout(f32)The task ran longer than this many seconds.

Around

Where wandering centres.

VariantWrittenDescription
HomeHomeThe agent’s home, else where it first stood.
SelfSelfWhere the agent is.
OwnerOwnerThe agent’s owner.

Emit

An emission.

VariantWrittenDescription
CueCue(string)A gameplay cue by key.
CallCall(tag: .., radius: ..)An ally call about the activity’s target: its last-known position and confidence, heard by allies whose Hearing sensor listens for the tag.
NoiseNoise(tag: .., loudness: ..)A noise other agents hear.

Call fields:

FieldTypeRequiredDefaultDescription
tagstringyesThe call’s tag (call.help).
radiusf32yesAllies within this many blocks hear it, 1 to 255.

Noise fields:

FieldTypeRequiredDefaultDescription
tagstringyesThe noise’s tag (noise.growl).
loudnessf32yesHeard within this many blocks (times the listener’s sensitivity), 1 to 255.

Engagement

An engagement ring: count slots evenly on a circle around the object, the first in front of it, each facing its centre, with ids after the object’s own.

A record: Engagement(..) or (..).

FieldTypeRequiredDefaultDescription
countu8yesThe slots, 1 to 16.
radiusf32yesThe circle’s radius, in blocks, above 0 and at most 16.
tagslist of stringno["slot.engage"]The slots’ tags.
offset(f32, f32, f32)no(0.0, 0.0, 0.0)Only the height, the middle value, is used: the ring’s height above the object.
acceptscondition or NonenoanyoneA condition an occupant must meet, as a slot’s.
behaviourSlotBehaviouryesWhat an occupant does there.
timeoutdurationno"60s"How long a claim lasts unless renewed.

An activity the object offers in slots with matching tags.

A record: Advertisement(..) or (..).

FieldTypeRequiredDefaultDescription
activitystringyesThe activity’s id in the agents’ brains.
slot_tagslist of stringnonone (any slot)The tags a slot needs; some slot must have them.
scorenumberyesThe score, a number in the smart_object context, lowered by distance (score × r / (r + d) with r the query_radius).
requirescondition or NonenoalwaysA condition in the same context that must hold.

Value forms used here: condition, duration, float-or-param, number, seconds.