SlashCo Wiki

SLASHER

SLASHER

Description

Table structure used for SlashCo.RegisterSlasher.
Every playable Slasher (lua/slashco/slasher/*.lua) defines a local SLASHER table with these fields and callbacks and registers it at the end of the file.

Besides the fields below, a Slasher may define any number of additional fields and functions of its own (e.g. SidRage, ThirstyRage) - those are purely internal to that Slasher and are only ever read by its own file through Player:SlasherValue/Player:SlasherFunction, never by the generic framework.

Parameters

string Name

The Slasher's display name. Used as the default registration name in SlashCo.RegisterSlasher, shown in the lobby/picker UI, and used as a fallback for a Document's Name.

number Class

The Slasher's SlashCo.SlasherClass. Used to filter the slasher picker/lobby restrictions and by SlashCo.GetRandomSlasher.

number DangerLevel

The Slasher's DangerLevel. Used to filter the slasher picker/lobby restrictions, by SlashCo.GetRandomSlasher, and to pick the danger announcement sound played when the round starts.

boolean IsSelectable (Optional)

Whether this Slasher can be picked normally - by the slasher picker UI and by SlashCo.GetRandomSlasher. Set to false for internal/legacy entries that should never be spawned directly (e.g. Leuonard, which is additionally hardcoded to be excluded from GetRandomSlasher).

Default: false

string Model (Optional)

Path to the player model used while playing as this Slasher. Read by the player_slasher_base player class when setting the model, and precached automatically by SlashCo.PrecacheSlasher.

Default: models/Humans/Group01/male_07.mdl

table Aliases (Optional)

A list of alternate name strings for the Slasher (e.g. nicknames used in-universe). Used as a fallback for a Document's %%ELEMENT12%% field when the document doesn't define its own, translated through the language key Alias.

Default: {}

string ProTip (Optional)

Language key for a short gameplay tip. Shown as the round's Slasher hint (SlashCo.LobbyData.SelectedSlasherInfo.TIP) when the Slasher is chosen automatically on the Easy difficulty.

string SpeedRating (Optional)

A star-rating string (e.g. "★★☆☆☆") shown in the slasher picker's description to indicate the Slasher's relative speed.

Only required if SLASHER.IsSelectable is true - the picker concatenates this value directly into the description text, so a selectable Slasher without it will error when hovered.

string EyeRating (Optional)

A star-rating string (e.g. "★★★☆☆") shown in the slasher picker's description to indicate the Slasher's relative eyesight/vision. Same requirement as SLASHER.SpeedRating.

string DiffRating (Optional)

A star-rating string shown in the slasher picker's description to indicate the Slasher's relative difficulty to play. Same requirement as SLASHER.SpeedRating.

number GasCanMod (Optional)

How many gas cans should be added or removed for the round because this Slasher is in play. Allowed to be negative. Summed across every spawned Slasher when calculating the round's gas can count, and copied onto SlashCo.CurRound.Slashers[steamID64].GasCanMod when the Slasher is selected.

Default: 0

number ForceGasCanCount (Optional)

Summed (with a fallback of 0) across every spawned Slasher alongside SLASHER.GasCanMod; if the combined total is 0 or greater, it overrides the round's computed gas can count entirely instead of just modifying it.

Default: 0

string ItemToSpawn (Optional)

The ID of an ITEM that should always be spawned at an extra location for every round this Slasher is in (e.g. Sid spawns "Cookie", Thirsty spawns "MilkJug"). Left unset, no extra forced item is spawned.

number SpawnDelay (Optional)

How many seconds into an Escape round this Slasher should spawn after, overriding the difficulty-based delay. -1 means no override. If multiple Slashers are in the round, the smallest override wins.

Default: -1

number ProwlSpeed (Optional)

Run/walk speed used while not chasing (outside of InSlasherChaseMode).

Default: 150

number ChaseSpeed

Run/walk speed used while actively chasing a Survivor. Has no framework fallback, so every Slasher must set this.

number Eyesight

Multiplied by 100 to get the field of view distance used by the per-tick chase-detection scan (Player:FindPlayersInView) and used to scale the Slasher's fog thickness (SlashCo.AddFog). Has no framework fallback, so every Slasher must set this.

This is a separate mechanism from the networked, client-visible "eyesight" value returned by Player:GetEyeSight (which drives the slasher-vision screen brightness effect). By convention every Slasher pushes this field's value into that networked value itself, usually via slasher:SetEyeSight(SLASHER.Eyesight) inside its own SLASHER.OnSpawn/SLASHER.OnTickBehaviour - the generic framework does not copy it there automatically.

number Perception (Optional)

Not read by the generic framework directly. By convention every Slasher uses this field as the initial/base value it pushes into the networked Player:GetPerception value itself (usually via slasher:SetPerception(SLASHER.Perception) inside its own SLASHER.OnSpawn/SLASHER.OnTickBehaviour), which in turn is read generically by the framework (e.g. survivor footstep notice range, sc_beerkeg/sc_activecrazyburger stun duration).

number ChaseRange (Optional)

Distance (in units) within which a Survivor can be spotted and put into chase. Two different fallbacks are used depending on which internal check reads it.

Default: 600 (chase-detection tick) / 1000 (SlashCo.StartChaseMode)

number ChaseRadius (Optional)

Cosine of the cone angle used for the Slasher's field-of-view checks (ents.FindInCone) both for spotting and for maintaining a chase.

Default: 0.91

number ChaseDuration (Optional)

How many seconds a Survivor can be out of sight before the chase ends. Also used to compute the hard failsafe timer for SlashCo.StartChaseMode (ChaseDuration * 10 + 45 seconds).

Default: 10

number ChaseCooldown (Optional)

How many seconds must pass after a chase ends before another one can start.

Default: 3

string ChaseMusic

Sound path played (looping) while this Slasher is chasing. Precached automatically by SlashCo.PrecacheSlasher if set. Has no framework fallback when actually played, so every Slasher must set this.

number KillDistance (Optional)

Maximum distance to a Survivor for SlashCo.Jumpscare to be allowed to trigger (ignored while the target is already being jumpscared).

Default: 135

string KillSound

Sound path played when this Slasher jumpscares a Survivor. Precached automatically by SlashCo.PrecacheSlasher if set. Has no framework fallback when emitted, so every Slasher must set this.

number KillDelay (Optional)

Seconds after a kill before this Slasher is allowed to jumpscare again.

Default: 3

number JumpscareDuration (Optional)

How many seconds the jumpscare freeze/animation lasts before the Survivor actually dies.

Default: 1.5

number AngerPassiveGain (Optional)

Anger gained automatically every second regardless of what the Slasher is doing, added on top of whatever SLASHER.OnAngerTick does.

Default: 0

boolean CustomBackgroundMusic (Optional)

If true for any Slasher in the round, the automatic ambient/anger background music system is skipped entirely, letting the Slasher(s) manage their own background music.

Default: false

string HighAngerBackgroundMusic (Optional)

Sound path used as the round's background music while this Slasher's anger is above 75.

string MediumAngerBackgroundMusic (Optional)

Sound path used as the round's background music while this Slasher's anger is above 50 (and not above 75).

string LowAngerBackgroundMusic (Optional)

Sound path used as the round's background music while this Slasher's anger is above 25 (and not above 50).

number HelicopterArriveTime (Optional)

Forces how many seconds after both generators are activated the escape helicopter arrives. -1 means no override (a randomized default based on difficulty is used instead). If multiple Slashers are in the round, the smallest override wins.

Default: -1

boolean DisableHelicopterMusic (Optional)

If true for any Slasher in the round, the special helicopter-arrival music is not played.

Default: false

boolean CannotBeSpectated (Optional)

If true, spectators cannot spectate this Slasher (it's excluded from SlashCo.GetSpectatableSet, from spectator right-click targeting, and clientside SLASHER.CanBeSeen always returns false for spectators looking at it).

Default: false

function OnBalanceForPlayers (Optional)

Called with (totalSurvivors, additionalSurvivors) - note that unlike the other callbacks this is called directly on the table (no slasher argument) - whenever the survivor count for the round is known: once when the Slasher spawns, and once for every already-spawned Slasher of this type whenever SlashCo.RegisterSlasher runs again (e.g. on a Lua refresh). Typically used to scale balance fields such as SLASHER.ProwlSpeed based on player count.

function Precache (Optional)

Called with no arguments by SlashCo.PrecacheSlasher when a round selects this Slasher, in addition to the automatic precaching of SLASHER.Model, SLASHER.ChaseMusic and SLASHER.KillSound. Use it to precache any extra models/sounds/materials this Slasher needs.

function OnSpawn (Optional)

Called with no extra arguments right after this Slasher's player entity spawns, once run/walk speed and anger have been initialized.

function OnTickBehaviour (Optional)

Called with no extra arguments every server tick (as long as at least one generator exists), after the generic chase/spotting logic has run for this Slasher.

function CanJumpscare (Optional)

Called with (target) right before SlashCo.Jumpscare would jumpscare target. Returning a truthy value cancels the jumpscare.

function OnKillPlayer (Optional)

Called with (target) once a jumpscare kill finishes and this Slasher has unfrozen again.

function OnAngerTick (Optional)

Called with no extra arguments once per second, alongside the automatic SLASHER.AngerPassiveGain gain.

function OnPlayerDeath (Optional)

Called with (victim) on every registered Slasher whenever any player dies (hook SlashCo:PlayerDeath), not just this Slasher's own kills.

function OnBeerKegExplode (Optional)

Called with (beerkeg) on every registered Slasher whenever any sc_beerkeg explodes.

function OnHitByPocketSand (Optional)

Called with (thrower) when this Slasher is blinded by a PocketSand item thrown by thrower.

function OnHitByTeslaCoil (Optional)

Called with no extra arguments when this Slasher gets caught in an active Tesla Coil's final stun burst.

function OnHitByBeerKeg (Optional)

Called with no extra arguments when this Slasher is in range of an exploding beer keg, alongside the automatic SlasherStunDeafen call.

function OnHelicopterSummon (Optional)

Called with no extra arguments on every registered Slasher once both generators are activated and the escape helicopter is summoned.

function OnItemSpawn (Optional)

Called with (itemCount) (the round's updated SlashCo.CurRound.ItemCount) on every spawned Slasher after regular round items have been spawned, after SLASHER.ItemToSpawn (if set) has been placed.

function PickUpAttempt (Optional)

Called with (ent) whenever this Slasher tries to pick up ent with the use key. Returning a non-nil value overrides whether the pickup is allowed; Slashers cannot pick anything up by default.

function OnPrimaryFire (Optional)

Called with (target, trace) (lag-compensated eye trace result) when this Slasher left-clicks.

function OnSecondaryFire (Optional)

Called with (target, trace) when this Slasher right-clicks.

function OnMainAbilityFire (Optional)

Called with (target, trace) when this Slasher presses their main ability key.

function OnSpecialAbilityFire (Optional)

Called with (target, trace) when this Slasher presses their special ability key.

function Animator (Optional)

Called with (velocity) from the CalcMainActivity hook while this Slasher is playing. Return an activity to override the calculated main animation activity.

function Footstep (Optional)

Called with no extra arguments from the PlayerFootstep hook while this Slasher is playing.

function Move (Optional)

Called with (mv) (the CMoveData) from the Move hook while this Slasher is playing.

function FinishMove (Optional)

Called with (mv) (the CMoveData) from the FinishMove hook while this Slasher is playing.

function CanBeSeen (Optional)

Called with no extra arguments from Player:CanBeSeen while this Slasher's player entity is being checked. Returning a non-nil value overrides the default Player:GetVisible result.

function CanSeeFlashlights (Optional)

Called with no extra arguments from Player:CanSeeFlashlights for this Slasher. Returning a non-nil value overrides the default result.

function Visibility (Optional)

Called with (target) for every Survivor that Player:FindPlayersInView otherwise considers visible to this Slasher. Returning exactly 0 removes that Survivor from the result.

function ClientSideEffect (Optional)

Called with no extra arguments every Think while the local player is this Slasher, alongside the slasher-vision dynamic light/particle effects.

function PreDrawHalos (Optional)

Called with no extra arguments from the PreDrawHalos hook while the local player is this Slasher, after generator/clone halos have been drawn. Use it to add extra halo.Add highlights.

function Thirdperson (Optional)

Called with no extra arguments every frame (CalcView) while the local player is this Slasher. Return a truthy value to build a custom third-person camera view this frame; otherwise the default first-person view is used.

function ShouldPlayAmbientSound (Optional)

Called with no extra arguments before the random ambient sound system considers playing a sound near this Slasher. Must return a truthy value for the sound to play - Slashers that don't define this callback never get random ambient sounds.

function InitHud (Optional)

Called with (hudPanel) (the slashco_slasher_stockhud panel) whenever the local player's Slasher HUD is (re)created. Use it together with Player:SlasherHudFunc to set up this Slasher's HUD controls/meters.

function DrawHUD (Optional)

Called with (hudPanel) (the same panel passed to SLASHER.InitHud) every frame from the SlashCo:DrawHUD hook while the local player is playing as this Slasher. Use it to draw this Slasher's HUD.