Skip to main content

Shadowthrall Mimics

Overview

This component enables a Shadowthrall entity to spawn mimic versions of nearby items and creatures during Cavenight (darkness phases), provided active shadow rifts are present. It coordinates mimic spawning logic, tracks active mimics and players, and manages scheduling based on rift state and time of day.

Dependencies & Tags

  • Components Added to Mimics: itemmimic (via mimic:AddComponent("itemmimic"))
  • World State Watched: iscavenight (via inst:WatchWorldState)
  • Events listend for: ms_playerjoined, ms_playerleft, ms_riftaddedtopool, ms_riftremovedfrompool
  • Tags Used (from itemmimic_data): MUST_TAGS (required tags), CANT_TAGS (forbidden tags)
  • Conditional Requirement: Requires TheWorld.ismastersim (server-side only)

Properties

PropertyTypeDefault ValueDescription
instEntitynilThe Shadowthrall entity instance. Initialized in constructor.
_activeplayerstable{}Internal list of players currently in the world; triggers mimic spawning.
_activemimicstable{}Tracks active mimic entities (keyed by entity ref).
_scheduled_spawn_attemptstable{}Maps each player to an active periodic task for mimic spawning attempts.
_rift_enabled_modifiersSourceModifierListTracks active rifts with shadow affinity; enables mimic spawning when non-empty.

Main Functions

self.IsTargetMimicable(target)

  • Description: Checks whether a given entity meets the criteria to be mimicked (has required tags and lacks forbidden tags).
  • Parameters:
    target (Entity) — The entity to evaluate.

self.SpawnMimicFor(item)

  • Description: Attempts to spawn a mimic of the provided item/entity. Only succeeds if IsTargetMimicable returns true.
  • Parameters:
    item (Entity) — The entity to copy and spawn as a mimic.
    Returns: booleantrue if mimic spawned successfully, false otherwise.

self.IsEnabled()

  • Description: Returns whether mimic spawning is currently enabled (i.e., at least one shadow rift with shadow affinity is active).
  • Parameters: None
    Returns: boolean

self.GetDebugString()

  • Description: Generates a human-readable debug string with current mimic count, cap, and enabled/disabled status.
  • Parameters: None
    Returns: string

self.Debug_PlayerSpawns(player)

  • Description: Forces an immediate mimic spawning attempt for the specified player (for debugging).
  • Parameters:
    player (Entity) — The player on whose behalf to trigger a spawn attempt.

Events & Listeners

  • ms_playerjoinedOnPlayerJoined — Adds new player to tracking list; starts spawning attempts if Cavenight is active.
  • ms_playerleftOnPlayerLeft — Removes player from tracking; cancels scheduled attempts.
  • ms_riftaddedtopoolOnRiftAddedToPool — Registers a new shadow rift and conditionally enables/disables spawning.
  • ms_riftremovedfrompoolOnRiftRemovedFromPool — Removes rift reference; disables spawning if no rifts remain.
  • onremove (on each mimic) → on_mimic_removed — Internal callback that removes the mimic from _activemimics table.