Skip to main content

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 construction
  • prefabs/player_common_extensions -- PlayerCommonExtensions for shared player logic
  • prefabs/wx78_common -- WX78Common for shared WX-78 mechanics, dependencies, and initialization
  • widgets/wx78moisturemeter -- WX78MoistureMeter widget creation for moisture UI
  • easing -- easing.inSine for moisture damage calculation interpolation
  • wx78_moduledefs -- WX78ModuleDefinitionFile for module definitions and prefab registration
  • TheWorld -- TheWorld.ismastersim for server-side logic gating
  • TheNet -- TheNet:GetServerGameMode(), TheNet:IsDedicated() for game mode and server type checks
  • TUNING -- Global balance constants for WX-78 stats, timers, thresholds, and skill values
  • ACTIONS -- ACTIONS.SWAPBODIES_MAP, ACTIONS.MAPSCOUTSELECT_MAP for special map actions
  • GLOBAL -- FOODTYPE.GEARS, EQUIPSLOTS.HANDS, FRAMES, TWOPI, GetString for global constants and localization
  • RPC -- RPC.StopUsingDrone, RPC.StopInspectingModules for client-to-server RPC calls
  • SpawnPrefab -- Spawns prefabs like wx78_big_spark, sparks, gears, ice, wx78_backupbody, wx78_possessed_shadow_hitfx, wx78_classified
  • JoinArrays -- Merges asset and prefab arrays with WX78Common dependencies
  • FlattenTree -- Flattens prefab and starting inventory tree structure

Components used:

  • health -- SetMaxHealth, SetCurrentHealth, currenthealth, DoDelta, IsDead, IsInvincible, deltamodifierfn
  • hunger -- SetMax, current
  • sanity -- SetMax, current, DoDelta
  • eater -- SetIgnoresSpoilage, SetCanEatGears, SetOnEatFn
  • freezable -- onfreezefn, IsFrozen
  • timer -- StartTimer, StopTimer, TimerExists
  • upgrademoduleowner -- onmoduleadded, onmoduleremoved, ononemodulepopped, onallmodulespopped, canupgradefn, SetChargeLevel, SetMaxCharge, IsChargeMaxed, IsChargeEmpty, DoDeltaCharge, GetMaxChargeLevel, GetModule, GetModuleTypeCount, GetNumModules, GetUsedSlotCount, IsSwapping, PopAllModules, max_charge
  • dataanalyzer -- StartDataRegen
  • batteryuser -- SetOnBatteryUsedFn
  • wx78_shield -- SetMax, SetCurrent, currentshield, GetPenetrationThreshold, OnTakeDamage, GetCanShieldCharge, GetCurrent, GetMax
  • wx78_dronescouttracker -- SetOnStartTrackingFn, SetOnStopTrackingFn, ReleaseAllDrones
  • foodaffinity -- AddPrefabAffinity
  • sleepingbaguser -- SetCanSleepFn
  • playerlightningtarget -- SetHitChance, SetOnStrikeFn
  • combat -- customdamagemultfn
  • inventory -- GetEquippedItem, GiveItem, IsInsulated
  • talker -- Say, mod_str_fn
  • locomotor -- SetTempGroundSpeedMultiplierModifier
  • skilltreeupdater -- IsActivated
  • playercontroller -- isclientcontrollerattached
  • playeractionpicker -- pointspecialactionsfn
  • wx78_abilitycooldowns -- Added via AddComponent
  • moisture -- GetMoisture, GetMaxMoisture, IsForceDry, SetMoistureLevel
  • finiteuses -- GetUses
  • inventoryitem -- Checked for module return on removal
  • propagator -- Delay on dropped gears
  • activatable -- CanActivate, DoActivate on backup body

Tags:

  • electricdamageimmune -- add
  • batteryuser -- add
  • chessfriend -- add
  • HASHEATER -- add
  • soulless -- add
  • upgrademoduleowner -- add
  • wx78_shield -- add
  • quagmire_shopper -- add
  • wx_remotecontroller -- check
  • invisible -- check

Properties

PropertyTypeDefault ValueDescription
assetstableSee sourceAsset array including scripts, sounds, and anim builds for WX-78
prefabstableSee sourcePrefab array including gears, sparks, modules, and backup body prefabs
TUNING.WX78_HEALTHnumberFrom TUNINGMax health value set in master_postinit
TUNING.WX78_HUNGERnumberFrom TUNINGMax hunger value set in master_postinit
TUNING.WX78_SANITYnumberFrom TUNINGMax sanity value set in master_postinit
TUNING.WX78_INITIAL_MAXCHARGELEVELnumberFrom TUNINGInitial max charge level for upgrade modules
TUNING.WX78_CHARGE_REGENTIMEnumberFrom TUNINGBase charge regeneration time in seconds
TUNING.WX78_MINACCEPTABLEMOISTUREnumberFrom TUNINGMoisture threshold below which no damage occurs
TUNING.WX78_MOISTUREUPDATERATEnumberFrom TUNINGMoisture tracking update rate in frames
TUNING.WX78_LIGHTNING_TARGET_CHANCEnumberFrom TUNINGLightning 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 component
    • mult -- 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 components
    • data -- 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 components
    • data -- 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 components
    • data -- 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.inventory is 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.moisture or inst.components.health is 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 components
    • data -- 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 components
    • food -- 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_classified
    • moduleent -- 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 components
    • moduleent -- 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_classified
    • moduleent -- module entity with upgrademodule component
    • was_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 component
    • moduleent -- 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 components
    • battery -- 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 property
    • bed -- 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 component
    • amount -- damage amount
    • overtime -- damage over time flag
    • cause -- damage cause string
    • ignore_invincible -- boolean to ignore invincibility
    • afflicter -- damage source entity
    • ignore_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 instance
    • data -- 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 entity
    • target -- 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, HUD
    • drone -- 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, HUD
    • drone -- 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 component
    • data -- 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 components
    • pos -- world position (unused)
    • useitem -- item being used
    • right -- 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 instance
    • classified -- 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 target
  • onremove -- Triggers ondetach_wx78_classified on classified entity for cleanup
  • energylevelupdate -- Triggers OnUpgradeModuleChargeChanged to reset regen timer and announce charge state
  • ms_respawnedfromghost -- Triggers OnBecameRobot to configure light and start charge regen
  • ms_becameghost -- Triggers OnBecameGhost to stop moisture, hunger, and charge timers
  • death -- Triggers OnDeath to drop gears and cleanup
  • ms_playerreroll -- Triggers OnDeath for reroll death consequences
  • moisturedelta -- Triggers OnWetnessChanged to handle moisture threshold changes
  • startstarving -- Triggers OnStartStarving to begin hunger drain timer
  • stopstarving -- Triggers OnStopStarving to stop hunger drain timer
  • timerdone -- Triggers OnTimerFinished to dispatch timer completion handlers
  • ondeactivateskill_server -- Triggers OnDeactivateSkill to release drones if scout skill deactivated
  • ms_skilltreeinitialized -- Triggers OnSkillTreeInitialized to release drones if scout skill not activated

Pushes:

  • lightningdamageavoided -- Pushed when lightning strike avoided due to insulation
  • wx78_spark -- Pushed during moisture damage ticks and hunger drain ticks for spark FX
  • do_robot_spark -- Pushed for UI robot spark notification during moisture tracking
  • upgrademodulesdirty -- Pushed when modules are added or popped to sync module state
  • upgrademoduleowner_popallmodules -- Pushed when all modules are popped on death or backup body spawn
  • electrocute -- Pushed immediately when charging from battery for stategraph event
  • refreshcrafting -- Pushed when drone tracking starts/stops to update HUD