Wortox Soul Common
Based on game build 722832 | Last updated: 2026-04-28
Overview
wortox_soul_common.lua is a utility module returning a table of helper functions used by Wortox-related prefabs (e.g., wortox_soul, wortox). It encapsulates logic for soul harvesting validation, soul spawning positioning, and the "Soul Hop" healing mechanic. It does not define a spawnable entity itself but is required by other prefab files to access fns.DoHeal, fns.HasSoul, etc. The module relies heavily on TUNING constants for balance values and global entity lists (AllPlayers) for targeting.
Usage example
local fns = require("prefabs/wortox_soul_common")
-- Check if an entity drops a soul:
if fns.HasSoul(victim) then
local count = fns.GetNumSouls(victim)
fns.SpawnSoulsAt(victim, count)
end
-- Heal nearby players (called from a soul release action):
fns.DoHeal(inst)
-- Give stacked souls to a player inventory:
fns.GiveSouls(player_inst, 5, player_inst:GetPosition())
Dependencies & tags
External dependencies:
TUNING-- Global balance constants for healing amounts, ranges, and skill multipliers.AllPlayers-- Global list of player entities used for healing target iteration.SpawnPrefab-- Instantiates soul and FX prefabs (wortox_soul,wortox_soul_spawn,wortox_soul_heal_fx).TheNet-- Networking global used to check PVP status.SOULLESS_TARGET_TAGS-- Global table of tags that prevent soul drops.GetRandomWithVariance,TWOPI,PI-- Math utilities for positioning logic.
Components used:
health-- Checked forIsDead,IsHurt,DoDelta.combat-- Checked forCanTarget,IsAlly,hiteffectsymbol.sanity-- Checked forDoDelta.inventory-- Used inGiveSoulsto transfer items.stackable-- Used inGiveSoulsto set soul stack size.murderable-- Checked inHasSoulas an alternative to combat/health.transform-- Used to get world position for spawning and range checks.
Tags:
playerghost-- Excluded from healing targets.health_as_oldage-- Excluded from healing targets (Wanda specific).soulstealer-- Receives sanity instead of health inDoHeal.saddled-- Excluded from soul harvesting inSoulDamageTest.player-- Checked against PVP settings inSoulDamageTest.dualsoul-- CausesGetNumSoulsto return 2.epic-- CausesGetNumSoulsto return 7-8.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
fns | table | --- | The returned module table containing all exported helper functions. |
DoHeal | function | --- | Exported key. Triggers healing and sanity logic for nearby players. |
HasSoul | function | --- | Exported key. Validates if an entity is eligible to drop a soul. |
SoulDamageTest | function | --- | Exported key. Validates if a kill event should harvest a soul. |
GetNumSouls | function | --- | Exported key. Determines soul count based on entity tags. |
SpawnSoulAt | function | --- | Exported key. Spawns a single soul prefab at coordinates. |
SpawnSoulsAt | function | --- | Exported key. Spawns multiple souls with positioning logic. |
GiveSouls | function | --- | Exported key. Spawns stacked soul item and adds to inventory. |
Main functions
DoHeal(inst)
- Description: Iterates through
AllPlayerswithin range and applies healing or sanity based on target state. Healing amount is reduced per additional target unlessinst.soul_heal_player_efficientis true. Targets withwortox_inclination == "naughty"receive reduced healing (TUNING.SKILLS.WORTOX.NAUGHTY_SOULHEAL_RECEIVED_MULT). Soulstealers receive sanity instead of health if not in overload state. Spawnswortox_soul_heal_fxfor each healed target. - Parameters:
inst-- Entity instance (typically Wortox or released soul) acting as the source. Must haveTransformcomponent.
- Returns: None
- Error states: Errors if
instis nil or missingTransformcomponent (unguardedinst.Transform:GetWorldPosition()). Errors ifAllPlayerscontains an entity withoutcomponents.health.
HasSoul(victim)
- Description: Determines if an entity is valid for soul harvesting. Returns true if the entity has
combat+healthORmurderablecomponents, and does not possess any tags inSOULLESS_TARGET_TAGS. - Parameters:
victim-- Entity instance to check.
- Returns:
trueif eligible,falseotherwise. - Error states: Errors if
victimis nil (unguardedvictim.componentsaccess).
SoulDamageTest(inst, ent, owner)
- Description: Validates if a damage event should result in a soul drop. Checks if
entis theowner(self-damage), ifownercan targetent, ifentis dead, saddled, or a player in non-PVP. Falls back toHasSoul(ent)if all checks pass. - Parameters:
inst-- Unused in logic (legacy parameter).ent-- Entity taking damage.owner-- Entity dealing damage (source of soul harvest).
- Returns:
trueif soul should drop,falseotherwise. - Error states: Errors if
entis nil (unguardedent.componentsaccess).ownernil is handled safely.
GetNumSouls(victim)
- Description: Returns the number of souls to drop based on entity tags.
dualsoulreturns 2.epicreturns random 7-8. Default is 1. - Parameters:
victim-- Entity instance that died.
- Returns: Integer count of souls.
- Error states: Errors if
victimis nil or missingHasTagmethod.
SpawnSoulAt(x, y, z, victim, marksource)
- Description: Spawns a single
wortox_soulprefab at the specified coordinates. Callsfx:Setup(victim)to initialize soul data. Ifmarksourceis true, copies_soulsourcefrom victim to the new soul. - Parameters:
x-- World X coordinate.y-- World Y coordinate.z-- World Z coordinate.victim-- Source entity (passed toSetup).marksource-- Boolean flag to propagate_soulsourcereference.
- Returns: None
- Error states: Errors if
SpawnPrefab("wortox_soul")returns nil (missing prefab) and code attempts to accessfx.Transform.
SpawnSoulsAt(victim, numsouls)
- Description: Spawns multiple souls around the victim. If
numsouls == 2, spawns in a tight cluster. If> 1, distributes in a circle of radius ~1.6-2.0. Ensures at least one soul spawns at the exact victim position (viamarksource = trueon the first call). - Parameters:
victim-- Entity instance to spawn around.numsouls-- Integer count of souls to spawn.
- Returns: None
- Error states: Errors if
victimis nil or missingTransformcomponent.
GiveSouls(inst, num, pos)
- Description: Spawns a single
wortox_soulprefab, sets its stack size tonumviastackablecomponent, and adds it toinst's inventory atpos. - Parameters:
inst-- Entity instance receiving the souls (must haveinventory).num-- Integer stack size.pos-- Vector3 position for the drop (passed toGiveItem).
- Returns: None
- Error states: Errors if
instis nil or missinginventorycomponent. Errors ifwortox_soulprefab is missing.
Events & listeners
Listens to: None identified. This is a utility module; functions are called directly by other code rather than triggered by entity events.
Pushes: None identified. No inst:PushEvent() calls in this module.
World state watchers: None identified. No inst:WatchWorldState() calls in this module.