Wx78
Based on game build 722832 | Last updated: 2026-04-28
Overview
WX-78 is a robot player character prefab that uses the MakePlayerCharacter wrapper from player_common.lua for base player skeleton construction. The character features a unique charge-based upgrade module system, moisture vulnerability that causes damage and spark effects, lightning strike immunity with charge gain, and a backup body resurrection mechanic. All core robot mechanics are initialized through common_postinit (client + master) and master_postinit (server-only) functions, with extensive component dependencies for health, sanity, hunger, shield, module management, and drone scouting capabilities.
Usage example
-- Spawn WX-78 player character (typically handled by character selection)
local wx78 = SpawnPrefab("wx78")
-- Access WX-78 specific components
local moduleowner = wx78.components.upgrademoduleowner
local shield = wx78.components.wx78_shield
local moisture = wx78.components.moisture
-- Check current charge level
local charge = moduleowner:GetMaxChargeLevel()
local current = moduleowner.charge_level
-- Check shield status
local shield_current = shield:GetCurrent()
local shield_max = shield:GetMax()
-- Check moisture level
local wetness = moisture:GetMoisture()
Dependencies & tags
External dependencies:
prefabs/player_common-- MakePlayerCharacter wrapper for player character prefab constructionprefabs/player_common_extensions-- PlayerCommonExtensions for shared player logicprefabs/wx78_common-- WX78Common for shared WX-78 mechanics, dependencies, and initializationwidgets/wx78moisturemeter-- WX78MoistureMeter widget creation for moisture UIeasing-- easing.inSine for moisture damage calculation interpolationwx78_moduledefs-- WX78ModuleDefinitionFile for module definitions and prefab registrationTheWorld-- TheWorld.ismastersim for server-side logic gatingTheNet-- TheNet:GetServerGameMode(), TheNet:IsDedicated() for game mode and server type checksTUNING-- Global balance constants for WX-78 stats, timers, thresholds, and skill valuesACTIONS-- ACTIONS.SWAPBODIES_MAP, ACTIONS.MAPSCOUTSELECT_MAP for special map actionsGLOBAL-- FOODTYPE.GEARS, EQUIPSLOTS.HANDS, FRAMES, TWOPI, GetString for global constants and localizationRPC-- RPC.StopUsingDrone, RPC.StopInspectingModules for client-to-server RPC callsSpawnPrefab-- Spawns prefabs like wx78_big_spark, sparks, gears, ice, wx78_backupbody, wx78_possessed_shadow_hitfx, wx78_classifiedJoinArrays-- Merges asset and prefab arrays with WX78Common dependenciesFlattenTree-- Flattens prefab and starting inventory tree structure
Components used:
health-- SetMaxHealth, SetCurrentHealth, currenthealth, DoDelta, IsDead, IsInvincible, deltamodifierfnhunger-- SetMax, currentsanity-- SetMax, current, DoDeltaeater-- SetIgnoresSpoilage, SetCanEatGears, SetOnEatFnfreezable-- onfreezefn, IsFrozentimer-- StartTimer, StopTimer, TimerExistsupgrademoduleowner-- onmoduleadded, onmoduleremoved, ononemodulepopped, onallmodulespopped, canupgradefn, SetChargeLevel, SetMaxCharge, IsChargeMaxed, IsChargeEmpty, DoDeltaCharge, GetMaxChargeLevel, GetModule, GetModuleTypeCount, GetNumModules, GetUsedSlotCount, IsSwapping, PopAllModules, max_chargedataanalyzer-- StartDataRegenbatteryuser-- SetOnBatteryUsedFnwx78_shield-- SetMax, SetCurrent, currentshield, GetPenetrationThreshold, OnTakeDamage, GetCanShieldCharge, GetCurrent, GetMaxwx78_dronescouttracker-- SetOnStartTrackingFn, SetOnStopTrackingFn, ReleaseAllDronesfoodaffinity-- AddPrefabAffinitysleepingbaguser-- SetCanSleepFnplayerlightningtarget-- SetHitChance, SetOnStrikeFncombat-- customdamagemultfninventory-- GetEquippedItem, GiveItem, IsInsulatedtalker-- Say, mod_str_fnlocomotor-- SetTempGroundSpeedMultiplierModifierskilltreeupdater-- IsActivatedplayercontroller-- isclientcontrollerattachedplayeractionpicker-- pointspecialactionsfnwx78_abilitycooldowns-- Added via AddComponentmoisture-- GetMoisture, GetMaxMoisture, IsForceDry, SetMoistureLevelfiniteuses-- GetUsesinventoryitem-- Checked for module return on removalpropagator-- Delay on dropped gearsactivatable-- CanActivate, DoActivate on backup body
Tags:
electricdamageimmune-- addbatteryuser-- addchessfriend-- addHASHEATER-- addsoulless-- addupgrademoduleowner-- addwx78_shield-- addquagmire_shopper-- addwx_remotecontroller-- checkinvisible-- check
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
assets | table | See source | Asset array including scripts, sounds, and anim builds for WX-78 |
prefabs | table | See source | Prefab array including gears, sparks, modules, and backup body prefabs |
TUNING.WX78_HEALTH | number | From TUNING | Max health value set in master_postinit |
TUNING.WX78_HUNGER | number | From TUNING | Max hunger value set in master_postinit |
TUNING.WX78_SANITY | number | From TUNING | Max sanity value set in master_postinit |
TUNING.WX78_INITIAL_MAXCHARGELEVEL | number | From TUNING | Initial max charge level for upgrade modules |
TUNING.WX78_CHARGE_REGENTIME | number | From TUNING | Base charge regeneration time in seconds |
TUNING.WX78_MINACCEPTABLEMOISTURE | number | From TUNING | Moisture threshold below which no damage occurs |
TUNING.WX78_MOISTUREUPDATERATE | number | From TUNING | Moisture tracking update rate in frames |
TUNING.WX78_LIGHTNING_TARGET_CHANCE | number | From TUNING | Lightning strike hit chance multiplier |
Main functions
SpawnBigSpark(inst)
- Description: Spawns a wx78_big_spark prefab and aligns it to the target instance.
- Parameters:
inst-- entity instance to align spark effect to
- Returns: nil
- Error states: None
COMMON_GetShieldPenetrationThreshold(inst)
- Description: Returns the shield penetration threshold from wx78_shield component, classified netvar, or default value 15.
- Parameters:
inst-- entity instance with wx78_shield component or classified data
- Returns: number penetration threshold value
- Error states: None
COMMON_GetCurrentShield(inst)
- Description: Returns current shield value from wx78_shield component, classified netvar, or default 0.
- Parameters:
inst-- entity instance with wx78_shield component or classified data
- Returns: number current shield value
- Error states: None
COMMON_GetMaxShield(inst)
- Description: Returns max shield value from wx78_shield component, classified netvar, or default 1.
- Parameters:
inst-- entity instance with wx78_shield component or classified data
- Returns: number max shield value
- Error states: None
COMMON_GetCanShieldCharge(inst)
- Description: Returns whether shield can charge from wx78_shield component, classified netvar, or default false.
- Parameters:
inst-- entity instance with wx78_shield component or classified data
- Returns: boolean whether shield can charge
- Error states: None
COMMON_ModifySpeedMultiplier(inst, mult)
- Description: Modifies speed multiplier based on wx78_circuitry_betabuffs_2 skill activation. Reduces slow debuff penalty based on movespeed module count.
- Parameters:
inst-- entity instance with skilltreeupdater componentmult-- current speed multiplier value
- Returns: number modified speed multiplier
- Error states: None
COMMON_ExtraConfigurePlayerLocomotor(inst)
- Description: Sets temp ground speed multiplier modifier on locomotor component using inst.ModifySpeedMultiplier.
- Parameters:
inst-- entity instance with locomotor component
- Returns: nil
- Error states: None
COMMON_StopUsingDrone(inst)
- Description: Stops using drone remote controller item if equipped and in use. Sends RPC to server if no inventory component.
- Parameters:
inst-- entity instance with inventory component
- Returns: nil
- Error states: None
COMMON_StopInspectingModules(inst)
- Description: Pushes stopinspectingmodule event if upgrademoduleowner exists, otherwise sends RPC to server.
- Parameters:
inst-- entity instance with upgrademoduleowner component
- Returns: nil
- Error states: None
GetChargeRegenTime(inst)
- Description: Returns charge regen time from TUNING, modified by wx78_circuitry_bettercharge skill multiplier.
- Parameters:
inst-- entity instance with skilltreeupdater component
- Returns: number charge regeneration time in seconds
- Error states: None
StartChargeRegenTimer(inst)
- Description: Starts the chargeregenupdate timer using GetChargeRegenTime for duration.
- Parameters:
inst-- entity instance with timer component
- Returns: nil
- Error states: None
do_chargeregen_update(inst)
- Description: Adds 1 charge if not at max charge level.
- Parameters:
inst-- entity instance with upgrademoduleowner component
- Returns: nil
- Error states: None
OnUpgradeModuleChargeChanged(inst, data)
- Description: Resets charge regen timer on energy level change. Announces discharge when dropping to 0, or charge when reaching max.
- Parameters:
inst-- entity instance with timer and talker componentsdata-- event data with old_level, new_level, isloading fields
- Returns: nil
- Error states: None
OnLoad(inst, data)
- Description: Restores saved WX-78 state including gears eaten count, health, sanity, hunger, and shield values. Handles pre-refresh save compatibility.
- Parameters:
inst-- entity instance with health, sanity, hunger, wx78_shield componentsdata-- saved data table with gears_eaten, level, _wx78_health, _wx78_sanity, _wx78_hunger, _wx78_shield
- Returns: nil
- Error states: None
OnSave(inst, data)
- Description: Saves WX-78 state including gears eaten count, health, sanity, hunger, and shield values for persistence.
- Parameters:
inst-- entity instance with health, sanity, hunger, wx78_shield componentsdata-- table to populate with save data
- Returns: nil
- Error states: None
OnLightningStrike(inst)
- Description: Handles lightning strike: heals and adds charge if not insulated, avoids damage if insulated. Pushes lightningdamageavoided event if insulated.
- Parameters:
inst-- entity instance with health, inventory, sanity, upgrademoduleowner components
- Returns: nil
- Error states: Errors if
inst.components.inventoryis nil (no nil guard present before IsInsulated() call)
COMMON_GetMinimumAcceptableMoisture(inst)
- Description: Returns TUNING.WX78_MINACCEPTABLEMOISTURE threshold value.
- Parameters:
inst-- entity instance (parameter unused, returns TUNING constant)
- Returns: number minimum acceptable moisture value
- Error states: None
initiate_moisture_update(inst)
- Description: Starts moisturetrackingupdate timer if not already running.
- Parameters:
inst-- entity instance with timer component
- Returns: nil
- Error states: None
stop_moisturetracking(inst)
- Description: Stops moisture tracking timer and resets moisture steps counter.
- Parameters:
inst-- entity instance with timer component
- Returns: nil
- Error states: None
moisturetrack_update(inst)
- Description: Updates moisture tracking: spawns sparks, applies damage based on moisture level using easing.inSine, drains charge, resets shield. Pushes wx78_spark and do_robot_spark events.
- Parameters:
inst-- entity instance with moisture, health, upgrademoduleowner, wx78_shield components
- Returns: nil
- Error states: Errors if
inst.components.moistureorinst.components.healthis nil (no nil guard present before access)
OnWetnessChanged(inst, data)
- Description: Handles wetness changes: spawns ice if cold module active and moisture high enough, starts/stops moisture tracking based on threshold crossings.
- Parameters:
inst-- entity instance with moisture, upgrademoduleowner componentsdata-- event data with new and old moisture values
- Returns: nil
- Error states: None
OnBecameRobot(inst)
- Description: Sets nocorpse flag, configures overcharge light values (radius, falloff, intensity, colour), starts charge regen timer if not maxed.
- Parameters:
inst-- entity instance with upgrademoduleowner, Light components
- Returns: nil
- Error states: None
OnBecameGhost(inst)
- Description: Stops moisture tracking, hunger drain, and charge regen timers when becoming ghost.
- Parameters:
inst-- entity instance with timer component
- Returns: nil
- Error states: None
DoDeathConsequences(inst)
- Description: Pops all upgrade modules and sets charge level to 0 on death.
- Parameters:
inst-- entity instance with upgrademoduleowner component
- Returns: nil
- Error states: None
OnDeath(inst)
- Description: Handles death: calls DoDeathConsequences if no backup body save, stops timers, drops gears based on gears_eaten count with random velocity.
- Parameters:
inst-- entity instance with Transform, health components
- Returns: nil
- Error states: None
OnEat(inst, food)
- Description: Handles eating: increments gears_eaten if foodtype is GEARS and plays levelup sound, adds charge if food has chargevalue.
- Parameters:
inst-- entity instance with SoundEmitter, upgrademoduleowner componentsfood-- food entity with edible component
- Returns: nil
- Error states: None
OnFrozen(inst)
- Description: Handles freezing: spawns big spark and drains charge if not already empty.
- Parameters:
inst-- entity instance with freezable, upgrademoduleowner components
- Returns: nil
- Error states: None
OnUpgradeModuleAdded(inst, moduleent)
- Description: Pushes upgrademodulesdirty event and updates classified netvar for new module.
- Parameters:
inst-- entity instance with upgrademoduleowner, wx78_classifiedmoduleent-- module entity with upgrademodule component
- Returns: nil
- Error states: None
OnUpgradeModuleRemoved(inst, moduleent)
- Description: Returns module to inventory if not swapping and has uses remaining, unless player is dead.
- Parameters:
inst-- entity instance with upgrademoduleowner, inventory, health componentsmoduleent-- module entity with finiteuses, inventoryitem components
- Returns: nil
- Error states: None
OnOneUpgradeModulePopped(inst, moduleent, was_activated)
- Description: Handles single module pop: drains charge if activated (with skill bonus), pushes upgrademodulesdirty event, updates classified netvars.
- Parameters:
inst-- entity instance with upgrademoduleowner, skilltreeupdater, wx78_classifiedmoduleent-- module entity with upgrademodule componentwas_activated-- boolean whether module was activated
- Returns: nil
- Error states: None
OnAllUpgradeModulesRemoved(inst)
- Description: Spawns big spark, pushes upgrademoduleowner_popallmodules event, clears all classified module netvars.
- Parameters:
inst-- entity instance with wx78_classified
- Returns: nil
- Error states: None
CanUseUpgradeModule(inst, moduleent)
- Description: Checks if module can be used based on available charge slots. Returns false with NOTENOUGHSLOTS reason if insufficient space.
- Parameters:
inst-- entity instance with upgrademoduleowner componentmoduleent-- module entity with upgrademodule component
- Returns: boolean success, string reason if false
- Error states: None
OnChargeFromBattery(inst, battery, mult)
- Description: Handles battery charging: returns false if charge full, otherwise heals, drains sanity, adds charge, pushes electrocute event.
- Parameters:
inst-- entity instance with health, sanity, upgrademoduleowner componentsbattery-- battery entity (unused)mult-- charge multiplier (unused)
- Returns: boolean success, string reason if false
- Error states: None
CanSleepInBagFn(wx, bed)
- Description: Checks if WX-78 can sleep: returns false with ANNOUNCE_NOSLEEPHASPERMANENTLIGHT if light module radius is active.
- Parameters:
wx-- WX-78 instance with _lightmodule_radius propertybed-- sleeping bag entity (unused)
- Returns: boolean can sleep, string reason if false
- Error states: None
OnStartStarving(inst)
- Description: Starts hungerdraintick timer when starving begins.
- Parameters:
inst-- entity instance with timer component
- Returns: nil
- Error states: None
OnStopStarving(inst)
- Description: Stops hungerdraintick timer when starving ends.
- Parameters:
inst-- entity instance with timer component
- Returns: nil
- Error states: None
on_hunger_drain_tick(inst)
- Description: Drains charge on hunger tick, spawns big spark if visible, pushes wx78_spark event, restarts timer.
- Parameters:
inst-- entity instance with health, upgrademoduleowner, sg, entity components
- Returns: nil
- Error states: None
RedirectToWxShield(inst, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb)
- Description: Redirects health damage to wx78_shield component OnTakeDamage method.
- Parameters:
inst-- entity instance with wx78_shield componentamount-- damage amountovertime-- damage over time flagcause-- damage cause stringignore_invincible-- boolean to ignore invincibilityafflicter-- damage source entityignore_absorb-- boolean to ignore absorption
- Returns: number damage value from shield handler
- Error states: None
OnTimerFinished(inst, data)
- Description: Dispatches timer completion to appropriate handler based on timer name (hungerdraintick, moisturetrackingupdate, chargeregenupdate).
- Parameters:
inst-- entity instancedata-- timer data with name field
- Returns: nil
- Error states: None
CustomCombatDamage(inst, target)
- Description: Returns shadow heart damage multiplier if target has wx78_shadow_heart_debuff, spawns hit FX, otherwise returns 1.
- Parameters:
inst-- WX-78 attacker entitytarget-- damage target entity
- Returns: number damage multiplier
- Error states: None
OnDroneStartTracking(inst, drone)
- Description: Increments drone scout count netvar, pushes refreshcrafting event if HUD exists.
- Parameters:
inst-- entity instance with wx78_classified, HUDdrone-- drone entity being tracked (unused)
- Returns: nil
- Error states: None
OnDroneStopTracking(inst, drone)
- Description: Decrements drone scout count netvar, pushes refreshcrafting event if HUD exists.
- Parameters:
inst-- entity instance with wx78_classified, HUDdrone-- drone entity being tracked (unused)
- Returns: nil
- Error states: None
OnDeactivateSkill(inst, data)
- Description: Releases all drones if wx78_scoutdrone_1 skill is deactivated.
- Parameters:
inst-- entity instance with wx78_dronescouttracker componentdata-- skill deactivation data with skill field
- Returns: nil
- Error states: None
OnSkillTreeInitialized(inst)
- Description: Releases all drones if wx78_scoutdrone_1 skill is not activated on skill tree init.
- Parameters:
inst-- entity instance with skilltreeupdater, wx78_dronescouttracker components
- Returns: nil
- Error states: None
TryToSpawnBackupBody(inst)
- Description: Spawns backup body if available: sets charge to 0, activates body, removes from scene. Calls DoDeathConsequences on failure.
- Parameters:
inst-- entity instance with Transform, upgrademoduleowner, activatable components
- Returns: boolean success
- Error states: None
GetPointSpecialActions(inst, pos, useitem, right)
- Description: Returns special map actions: collects upgrade module actions if client controller, adds SWAPBODIES_MAP and MAPSCOUTSELECT_MAP based on skill activation.
- Parameters:
inst-- entity instance with playercontroller, skilltreeupdater componentspos-- world position (unused)useitem-- item being usedright-- boolean for right-click actions
- Returns: table of actions
- Error states: None
OnSetOwner(inst)
- Description: Sets pointspecialactionsfn on playeractionpicker, sets classified target on master sim.
- Parameters:
inst-- entity instance with playeractionpicker, wx78_classified
- Returns: nil
- Error states: None
AttachClassified_wx78(inst, classified)
- Description: Attaches classified entity, sets up onremove listener for detachment.
- Parameters:
inst-- entity instanceclassified-- classified entity to attach
- Returns: nil
- Error states: None
DetachClassified_wx78(inst)
- Description: Detaches classified entity and clears references.
- Parameters:
inst-- entity instance
- Returns: nil
- Error states: None
OnRemoveEntity(inst)
- Description: Cleans up classified entity on removal: removes on master, detaches on client, calls original OnRemoveEntity if exists.
- Parameters:
inst-- entity instance with wx78_classified
- Returns: nil
- Error states: None
common_postinit(inst)
- Description: Client-side initialization: adds tags (electricdamageimmune, batteryuser, chessfriend, HASHEATER, soulless, upgrademoduleowner, wx78_shield, quagmire_shopper conditional), sets up classified attachment/detachment functions, listens to setowner event, configures anim overrides, talker mod_str_fn, foley sound, adds wx78_abilitycooldowns component, sets up common helper functions, initializes WX78Common.
- Parameters:
inst-- player entity instance
- Returns: nil
- Error states: None
master_postinit(inst)
- Description: Server-only initialization: sets refusesbowtoroyalty, starting_inventory, customidlestate, spawns wx78_classified, sets max health/hunger/sanity from TUNING, initializes gears_eaten and moisture_steps, configures eater (ignores spoilage, eats gears, OnEat fn), sets freezable onfreezefn, adds upgrademoduleowner with callbacks and charge settings, adds dataanalyzer, adds batteryuser with OnChargeFromBattery, adds wx78_shield with damage redirect, adds wx78_dronescouttracker with tracking callbacks, sets food affinity, sets sleeping bag fn, listens to multiple events (respawn, ghost, death, moisture, starving, timer, skill), sets lightning target chance and strike fn, calls OnBecameRobot, sets temperature module leaning, TryToSpawnBackupBody, OnSave/OnLoad, initializes WX78Common master, handles event server data for lavaarena/quagmire or sets custom combat damage.
- Parameters:
inst-- player entity instance on master sim
- Returns: nil
- Error states: None
Events & listeners
Listens to:
setowner-- Triggers OnSetOwner to configure playeractionpicker and classified targetonremove-- Triggers ondetach_wx78_classified on classified entity for cleanupenergylevelupdate-- Triggers OnUpgradeModuleChargeChanged to reset regen timer and announce charge statems_respawnedfromghost-- Triggers OnBecameRobot to configure light and start charge regenms_becameghost-- Triggers OnBecameGhost to stop moisture, hunger, and charge timersdeath-- Triggers OnDeath to drop gears and cleanupms_playerreroll-- Triggers OnDeath for reroll death consequencesmoisturedelta-- Triggers OnWetnessChanged to handle moisture threshold changesstartstarving-- Triggers OnStartStarving to begin hunger drain timerstopstarving-- Triggers OnStopStarving to stop hunger drain timertimerdone-- Triggers OnTimerFinished to dispatch timer completion handlersondeactivateskill_server-- Triggers OnDeactivateSkill to release drones if scout skill deactivatedms_skilltreeinitialized-- Triggers OnSkillTreeInitialized to release drones if scout skill not activated
Pushes:
lightningdamageavoided-- Pushed when lightning strike avoided due to insulationwx78_spark-- Pushed during moisture damage ticks and hunger drain ticks for spark FXdo_robot_spark-- Pushed for UI robot spark notification during moisture trackingupgrademodulesdirty-- Pushed when modules are added or popped to sync module stateupgrademoduleowner_popallmodules-- Pushed when all modules are popped on death or backup body spawnelectrocute-- Pushed immediately when charging from battery for stategraph eventrefreshcrafting-- Pushed when drone tracking starts/stops to update HUD