Penguin
Based on game build 714014 | Last updated: 2026-03-06
Overview
The penguin prefab defines two entities: the standard penguin and its mutated variant. It manages core animal behaviors including combat retargeting, team formation via teamattacker and teamleader, hunger management, egg storage in an inventory, and seasonal lifecycle (auto-removal in late winter). It integrates with the penguinspawner system for colony tracking, supports moon mutation via halloweenmoonmutable, and persists colony membership across saves. The component functions as a game entity definition, not a reusable component, initializing many core systems in its constructor.
Usage example
While this file defines prefabs (not reusable components), a modder would typically instantiate one via:
-- Spawn a standard penguin
local penguin = SpawnPrefab("penguin")
-- Spawn a mutated penguin
local mutated = SpawnPrefab("mutated_penguin")
-- Access properties set during initialization
penguin.colonyNum = 5
penguin.eggsLayed = 0
penguin.eggprefab = "bird_egg"
Dependencies & tags
Components used: combat, health, hunger, lootdropper, homeseeker, knownlocations, herdmember, teamattacker, eater, sleeper, inspectable, inventory, halloweenmoonmutable, locomotor.
Tags: penguin, animal, smallcreature, herdmember, scarytoprey (mutated only), lunar_aligned (mutated only), mutated_penguin (mutated only), soulless (mutated only).
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
colonyNum | number? | nil | The colony ID this penguin belongs to; restored on load via penguinspawner. |
eggsLayed | number | 0 | Counter of eggs laid by this penguin. |
eggprefab | string | "bird_egg" or "rottenegg" | Prefab name for eggs laid; defaults to standard egg, changed to rotten egg in mutated form. |
nesting | boolean | false | Set by OnEnterMood/OnLeaveMood; indicates if the penguin is in nesting mood. |
spawn_lunar_mutated_tuning | string | "SPAWN_MOON_PENGULLS" | Key used for lunar mutation event configuration. |
Main functions
Retarget(inst)
- Description: Attempts to find a new valid target when the penguin is starving; may trigger team formation if no team exists. Only used in the pristine penguin's combat component.
- Parameters:
inst(Entity) - the penguin instance. - Returns:
nilif not starving, otherwise potentially returns the new target. May triggerMakeTeam. - Error states: Returns early with
nilifhunger:IsStarving()is false.
MutatedRetarget(inst)
- Description: Similar to
Retargetbut used by the mutated penguin; has a wider scan radius (4 vs. 3) and different target tags. Also triggers team formation. - Parameters:
inst(Entity) - the mutated penguin instance. - Returns:
nilor the new target; may triggerMakeTeam. - Error states: None beyond target-finding failure.
MakeTeam(inst, attacker)
- Description: Spawns a
teamleaderprefab and configures it with the penguin as the first teammate, setting team properties like attack interval, size, and type. - Parameters:
inst(Entity) - the penguin initiating the team;attacker(Entity) - the threat being responded to. - Returns: Nothing (side effects only).
- Error states: None; always spawns and configures the team leader.
OnAttacked(inst, data)
- Description: Event handler called when the penguin is attacked; attempts to form a team if needed and shares the attacker with nearby penguins if the team is active.
- Parameters:
inst(Entity) - the penguin;data(table) - combat event data containingattacker. - Returns: Nothing.
- Error states: Returns early if no
teamattackercomponent exists.
GetStatus(inst)
- Description: Human-readable status string for
inspectablecomponent; reportsSTARVINGorHUNGRYbased on hunger percentage. - Parameters:
inst(Entity) - the penguin instance. - Returns:
"STARVING"or"HUNGRY"ornil. - Error states: Returns
nilif hunger is normal (>=50% full).
SaveCorpseData(inst, corpse)
- Description: Returns colony membership data to serialize on corpse creation; used to preserve colony assignment.
- Parameters:
inst(Entity) - the penguin;corpse(Entity) - the corpse being saved. - Returns:
{ colonyNum = number }ornil. - Error states: Returns
nilifcolonyNumis not set.
LoadCorpseData(inst, corpse)
- Description: Loads colony membership from corpse data and registers with the
penguinspawner. - Parameters:
inst(Entity) - the penguin (usually the spawned corpse);corpse(Entity) - the source corpse. - Returns: Nothing (side effects only).
- Error states: Does nothing if no
colonyNumis present incorpse.corpsedata.
Events & listeners
- Listens to:
entermood- callsOnEnterMood, setsnesting = true. - Listens to:
leavemood- callsOnLeaveMood, setsnesting = false. - Listens to:
onignite- callsOnIgnite, cooks eggs in inventory. - Listens to:
attacked- callsOnAttacked, initiates team formation and target sharing. - Pushes: None directly (events are handled by other components, not fired by this file's logic).