Lunarriftmutationsmanager
Based on game build 714014 | Last updated: 2026-03-03
Overview
LunarRiftMutationsManager tracks the defeat of specific lunar rift mutated creatures (mutatedwarg, mutatedbearger, mutateddeerclops) and orchestrates related quest logic. It handles Wagstaff NPC appearances after defeating mutations, reward conditions, and persistence across saves. This component exists only on the server (TheWorld.ismastersim) and resides on the TheWorld entity. It collaborates closely with wagboss_tracker and health components.
Usage example
-- The component is automatically added to TheWorld and should not be manually instantiated.
-- Typical interaction from mod code:
if TheWorld.components.lunarriftmutationsmanager then
TheWorld.components.lunarriftmutationsmanager:OnRewardGiven()
end
Dependencies & tags
Components used: health, wagboss_tracker
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
task_completed | boolean | false | Whether the final reward for completing the mutation quest has been given. |
_MUTATIONS_NAMES | table | { "mutatedwarg", "mutatedbearger", "mutateddeerclops" } | Copy of the mutation prefab names (for mods). |
_MUTATIONS | table | inverted MUTATIONS_NAMES | Mapping from prefab name to 1-based index. |
wagstaff | Entity or nil | nil | Reference to the currently spawned Wagstaff NPC. |
defeated_mutations | table | {} | List of indices (1-based) corresponding to defeated mutations. |
num_mutations | number | 3 | Total number of tracked mutations (size of MUTATIONS_NAMES). |
Main functions
RefreshDefeatedMutationsTable()
- Description: Resets internal state by clearing defeated mutations and Wagstaff reference, and reinitializes
num_mutations. - Parameters: None.
- Returns: Nothing.
IsWagstaffSpawned()
- Description: Checks if a Wagstaff NPC is currently spawned and valid (not eroding out).
- Parameters: None.
- Returns:
trueifwagstaffis valid and not eroding, otherwisefalse.
GetNumDefeatedMutations()
- Description: Returns the number of mutations recorded as defeated.
- Parameters: None.
- Returns: Number of defeated mutations (length of
defeated_mutations).
HasDefeatedAllMutations()
- Description: Returns whether all tracked mutations have been defeated.
- Parameters: None.
- Returns:
trueifGetNumDefeatedMutations()≥num_mutations, otherwisefalse.
HasDefeatedThisMutation(prefab)
- Description: Checks if the specified mutation prefab has been defeated.
- Parameters:
prefab(string) — prefab name (e.g.,"mutatedwarg"). - Returns:
trueif the prefab is recognized and recorded as defeated; otherwisefalse. - Error states: Returns
falseifprefabis not inMUTATIONS_NAMES.
SetMutationDefeated(ent)
- Description: Records a defeated mutation and triggers appropriate behavior: spawns Wagstaff (if Wagboss is not yet defeated), sets extended destroy time on the corpse, or awards the reward if quest is complete.
- Parameters:
ent(Entity) — the defeated mutation entity. - Returns: Nothing.
- Error states: No effect if the mutation is already recorded or not in the tracked list.
TriggerWagstaffAppearance(ent)
- Description: Spawns a
wagstaff_npc_mutationsNPC near the defeated mutation's position and makes Wagstaff comment on the encounter. - Parameters:
ent(Entity) — the defeated mutation entity (used for positioning and facing). - Returns: Nothing.
ShouldGiveReward()
- Description: Determines whether the quest reward should be given (either task is completed or all mutations defeated).
- Parameters: None.
- Returns:
trueiftask_completedistrueorHasDefeatedAllMutations()istrue; otherwisefalse.
IsTaskCompleted()
- Description: Returns whether the final reward has been awarded.
- Parameters: None.
- Returns:
trueiftask_completedistrue; otherwisefalse.
OnRewardGiven()
- Description: Marks the task as completed and fires the
ms_lunarriftmutationsmanager_taskcompletedevent. Resets defeated mutations table if all mutations were defeated. - Parameters: None.
- Returns: Nothing.
OnSave()
- Description: Serializes component state for world save.
- Parameters: None.
- Returns: Table with
defeated_mutations(array of indices) andtask_completed(boolean), ornilif empty.
OnLoad(data)
- Description: Restores component state from world save data.
- Parameters:
data(table ornil) — serialized state fromOnSave(). - Returns: Nothing.
GetDebugString()
- Description: Returns a formatted debug string for inspecting the manager’s current state.
- Parameters: None.
- Returns: String in format:
"Mutations Defeated: X/Y [ list ] || Task Completed: YES/NO".
Events & listeners
- Listens to: None identified.
- Pushes:
ms_lunarriftmutationsmanager_taskcompleted— fired whenOnRewardGiven()is called.