Player Hosted
Based on game build 714014 | Last updated: 2026-03-06
Overview
player_hosted is a prefab function that constructs a hostile, player-shaped entity (typically used for shadow thralls/parasites). It extends the base character infrastructure with components for combat, health, sanity aura, and locomotion. The entity is networked, pristined, and configured to track and attack non-hosted entities while respecting its owner (identified via hosted_userid). It uses the SGplayer_hosted state graph and hostedbrain AI. The prefab integrates with inspectable, skinner, health, combat, and sanityaura components to deliver consistent gameplay behavior and visual representation.
Usage example
local inst = Prefab("player_hosted", fn, assets)
-- Typically instantiated via TheWorld:SpawnPrefab("player_hosted")
-- Internally, this creates an entity with combat, health, and brain components preconfigured
Dependencies & tags
Components used: skinner, inspectable, sanityaura, locomotor, inventory, health, combat, network, transform, animstate, soundemitter, dynamicshadow, physics (via MakeCharacterPhysics)
Tags: monster, hostile, scarytoprey, shadowthrall, shadow_aligned
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
skeleton_prefab | string | "skeleton_player" | The prefab name used for skeleton-based rendering. |
hosted_userid | net_string | (GUID-linked string) | Identifies the owning player; used to determine if this entity belongs to the local viewer. |
displaynamefn | function | DisplayNameFn | Callback to return localized name (e.g., "ME" if owned by ThePlayer). |
OnSave / OnLoad | function | OnSave, OnLoad | Save/load hooks for persisting skeleton_prefab and hosted_userid. |
Main functions
RetargetFn(inst)
- Description: Finds the closest valid target within range for combat. Uses
FindEntitywith a custom filter to exclude hosted/masked entities and respects tag restrictions. - Parameters:
inst(Entity) — the entity instance invoking retargeting. - Returns: Entity or
nil— the nearest valid target ornilif none found. - Error states: May return
nilif no suitable entity exists withinTUNING.SHADOWTHRALL_PARASITE_TARGET_DIST.
KeepTarget(inst, target)
- Description: Determines whether the current target should be retained during combat. Ensures the target remains valid and is not the hosted entity itself.
- Parameters:
inst(Entity),target(Entity). - Returns: boolean —
trueif the target is valid and not hosted;falseotherwise.
DisplayNameFn(inst)
- Description: Returns a special name if the local player owns this entity; otherwise returns
nil. - Parameters:
inst(Entity). - Returns: string or
nil—"PLAYER_HOSTED_ME"ifThePlayer.userid == inst.hosted_userid, elsenil.
GetStatus(inst, viewer)
- Description: Returns
"ME"to the viewer if they own this entity; otherwise returnsnil. Used for UI/inspection context. - Parameters:
inst(Entity),viewer(Entity ornil). - Returns: string or
nil—"ME"if viewer owns this entity;nilotherwise.
OnSave(inst, data)
- Description: Serializes key state (
skeleton_prefab,hosted_userid) for world save. - Parameters:
inst(Entity),data(table) — table to populate. - Returns: Nothing.
OnLoad(inst, data)
- Description: Restores
skeleton_prefaband setshosted_useridfrom saved data. - Parameters:
inst(Entity),data(table ornil) — saved state. - Returns: Nothing.
Events & listeners
None identified.