Pigelite
Based on game build 714014 | Last updated: 2026-03-06
Overview
pigelite.lua defines a factory function that generates four distinct elite pig variants (pigelite1 through pigelite4) used as boss minions in DST. It initializes a complete entity with visual, audio, physics, and gameplay components—including combat, inventory, sleeper, and squad membership—tailored for boss arena encounters. The prefabs are heavily integrated with the SGpigelite stategraph and rely on the pigelitebrain for high-level AI behavior.
Usage example
-- The prefabs are automatically registered and accessible by name
local elite_pig = SpawnPrefab("pigelite2")
elite_pig.Transform:SetPosition(x, y, z)
Dependencies & tags
Components used: talker, locomotor, health, combat, minigame_participator, squadmember, burnable, hauntable, inspectable, inventory, knownlocations, entitytracker, sleeper, freezable
Tags added: character, pig, pigelite, scarytoprey, noepicmusic, minigame_participator
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
cheatflag | Task or nil | nil | Timer handle used to detect cheat triggers (ignition, teleport, root). |
SetCheatFlag | function | — | Helper to start a 5-second cheat-detection timer. |
WasCheated | function | — | Returns true if cheat-detection conditions are active. |
IsSquadAlreadyTargeting | function | — | Checks if another squad member is already targeting a given entity within range. |
Main functions
MakePigElite(variation)
- Description: Factory function that constructs and returns a Prefab for one of the four elite pig variants based on the
variationstring ("1"–"4"). - Parameters:
variation(string) — One of"1","2","3", or"4", selecting the visual build variation. - Returns:
Prefab— A pre-configured prefab definition forpigelite<variation>. - Error states: None. Invalid variation strings produce no prefabs silently (only "1"–"4" are handled).
RetargetFn(inst)
- Description: Combat retargeting logic that selects the nearest valid player within range, respecting king proximity constraints and squad targeting rules.
- Parameters:
inst(Entity) — The elite pig instance requesting a new target. - Returns:
{player, force}— The chosen target entity and atrueflag, ornilif no suitable target exists. - Error states: Returns
nilwhen no eligible players are within range or when the king constraint fails.
KeepTargetFn(inst, target)
- Description: Decision function determining whether the elite pig should maintain its current target.
- Parameters:
inst(Entity) — The elite pig instance.target(Entity) — The candidate target to retain.
- Returns:
boolean—trueif the target should be kept;falseotherwise. - Error states: Returns
falseif the pig is weaponless, the target is out of range, the king constraint fails, or another squad member is targeting the same entity.
OnEquip(inst, data)
- Description: Event handler triggered on hand-slot equipment changes; re-evaluates combat target when a weapon is equipped.
- Parameters:
inst(Entity) — The elite pig instance.data(table) — Containseslot = EQUIPSLOTS.HANDS.
- Returns: Nothing.
- Error states: No effect if
data.eslotis notEQUIPSLOTS.HANDS.
OnUnequip(inst, data)
- Description: Event handler triggered on hand-slot unequipment; clears the combat target when the weapon is removed.
- Parameters: Same as
OnEquip. - Returns: Nothing.
RefreshSleeperExtraResist(inst)
- Description: Periodic task ensuring sleeper resistance remains at least
5seconds. - Parameters:
inst(Entity) — The elite pig instance. - Returns: Nothing.
SetCheatFlag(inst)
- Description: Sets a 5-second timer to mark the elite pig as "cheated" (e.g., after being ignited or teleported).
- Parameters:
inst(Entity) — The elite pig instance. - Returns: Nothing.
WasCheated(inst)
- Description: Checks whether the elite pig is currently in a "cheated" state.
- Parameters:
inst(Entity) — The elite pig instance. - Returns:
boolean—trueif the pig was recently cheated, asleep, frozen, on fire, or panicking.
Events & listeners
- Listens to:
equip— TriggersOnEquipto update combat targeting.unequip— TriggersOnUnequipto clear combat targeting.onignite— CallsSetCheatFlagto record cheat state.teleported— CallsSetCheatFlagto record cheat state.rooted— CallsSetCheatFlagto record cheat state.
- Pushes: None (no events are directly fired by this component/prefab).