Moose
Based on game build 714014 | Last updated: 2026-03-06
Overview
The moose prefab implements the moose boss entity, a large, aggressive creature that patrols and attacks players and other creatures. It integrates with the game's ECS to manage health, combat, locomotion, loot dropping, and seasonal behavior. The moose is only active during spring (unless in the caves) and will remove itself when the season changes. It has unique mechanics including egg-laying via a timer, a disarm cooldown, and a named identity system.
Usage example
local moose = Prefab("moose", fn, assets, prefabs)
local inst = moose()
inst.components.health:SetMaxHealth(500)
inst.components.combat:SetDefaultDamage(35)
Dependencies & tags
Components used: playerprox, health, combat, explosiveresist, sleeper, lootdropper, inspectable, named, knownlocations, inventory, entitytracker, timer, eater, drownable, locomotor, dynamicshadow, transform, animstate, soundemitter, network
Tags: moose, epic, animal, scarytoprey, largecreature, structure
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
WantsToLayEgg | boolean | false | Whether the moose is ready to lay an egg. Set to true by the "WantsToLayEgg" timer. |
CanDisarm | boolean | false | Whether the moose can be disarmed. Set to true by the "DisarmCooldown" timer. |
shouldGoAway | boolean | false | Indicates whether the moose should be removed due to seasonal change or cave environment. |
Main functions
RetargetFn(inst)
- Description: Finds a new target for the moose. Prioritizes entities near its egg, then any valid target within range. Skips re-targeting if the moose is in a "busy" state.
- Parameters:
inst(Entity) - the moose instance. - Returns: Entity or
nil— the closest valid target withinTARGET_DIST, ornilif none found. - Error states: Returns
nilif no valid target exists or if the moose is currently in thebusystate tag.
KeepTargetFn(inst, target)
- Description: Determines whether the moose should continue pursuing a current target. Ensures both the moose and the target remain near the landing point (or current position).
- Parameters:
inst(Entity) — the moose instance.target(Entity) — the currently targeted entity.
- Returns: boolean —
trueif target remains valid (combat checks pass and distance constraints hold). - Error states: Returns
falseif the target is out of range or too far from the landing point.
OnSpringChange(inst, isspring)
- Description: Responds to seasonal changes. Sets
shouldGoAwaytotrueif not spring or if the world is a cave, and removes the moose if it is asleep. - Parameters:
isspring(boolean) — whether the current season is spring.inst(Entity) — the moose instance.
- Returns: Nothing.
OnAttacked(inst, data)
- Description: Automatically sets the attacker as the moose's combat target upon being attacked.
- Parameters:
inst(Entity) — the moose instance.data(table) — event data containingattacker.
- Returns: Nothing.
OnSave(inst, data)
- Description: Serializes key state values for world save compatibility.
- Parameters:
inst(Entity) — the moose instance.data(table) — table to populate with save data.
- Returns: Nothing.
OnLoad(inst, data)
- Description: Restores serialized state values on load.
- Parameters:
inst(Entity) — the moose instance.data(table) — loaded data from save.
- Returns: Nothing.
ontimerdone(inst, data)
- Description: Handles timer completions for laying eggs and disarm cooldown.
- Parameters:
inst(Entity) — the moose instance.data(table) — timer event data containingnamefield.
- Returns: Nothing.
OnEntitySleep(inst)
- Description: If
shouldGoAwayis true and the moose is asleep, removes the entity from the world. - Parameters:
inst(Entity) — the moose instance. - Returns: Nothing.
OnPreLoad(inst, data)
- Description: Ensures the moose spawns at ground level (
y = 0) by correcting its world position if airborne. - Parameters:
inst(Entity) — the moose instance.data(table) — pre-load data (unused).
- Returns: Nothing.
OnDead(inst)
- Description: Awards the "moosegoose_killed" achievement upon the moose's death.
- Parameters:
inst(Entity) — the moose instance. - Returns: Nothing.
Events & listeners
- Listens to:
attacked— triggersOnAttackedto engage the attacker as target.entitysleep— triggersOnEntitySleepto remove the moose if needed.timerdone— triggersontimerdonefor egg-laying and disarm timers.EggHatch— triggersontimerdone(same handler as above).death— triggersOnDeadto award achievement.isspringworld state — triggersOnSpringChangeon seasonal update.
- Pushes: None identified.