Skip to content

Highlights

With update 3.0.0, highlighting (seeing players through walls) has been moved to its own library — highlight.

Core functions

highlight.ByDistance(ply, ent) SERVER

Automatically highlights all survivors within the radius set by the console command halo_radius for player ply. Used by animatronics on the +RELOAD bind by default.

ParameterTypeDescription
plyPlayerThe player doing the highlighting
entEntityThe animatronic's entity/model for ply (needed for sounds)
lua
hook.Add("KeyPress", "MyHighlight", function(ply, key)
    if key == IN_RELOAD and ply:IsAnimatronic() then
        local ent = pills.getMappedEnt(ply)
        if IsValid(ent) then
            highlight.ByDistance(ply, ent)
        end
    end
end)

highlight.Add(ply, players, duration, color) SERVER

Highlights specified players for ply for a given duration, with the specified color.

ParameterTypeDescription
plyPlayerWho sees the highlight
playersPlayer or table[Player]Who gets highlighted
durationfloatDuration in seconds
colorColor (opt.)Highlight color

Note

This function does not play highlight notification sounds. Use highlight.NotifyTarget() for notifications.

addAffected(ply, duration, color) CLIENT

Highlights ply for the local player for a given duration, with the specified color.

ParameterTypeDescriptionDefault
plyPlayerWho is highlighted
durationfloat (opt.)Duration in secondsConVar halo_time
colorColor (opt.)Highlight colorColor(255,0,0)
forcebool (opt.)Force highlight even if the player is already highlightedfalse

removeAffected(ply, force) CLIENT

Removes the highlight for the local player on ply.

ParameterTypeDescriptionDefault
plyPlayerWho is highlighted
forcebool (opt.)Force disable highlight if the player was force highlightedfalse

Cooldowns

highlight.Cooldown(ply, duration) SERVER

Sets a cooldown on highlighting for the player and updates the UI value.

lua
highlight.Cooldown(ply, 15)  -- 15 second cooldown

INFO

If the animatronic doesn't have the "Highlight" ability in the UI, they won't know about the cooldown.

highlight.GetCooldown(ply) SERVER

Returns the number of seconds until the next highlight can be used.

lua
if highlight.GetCooldown(ply) > 0 then
    ply:ChatPrint("Highlight is not ready yet!")
end

Highlight sounds

highlight.AddVisionSounds(name, snd_affected, snd_unaffected) SERVER

Registers highlight sounds for a specific animatronic.

lua
highlight.AddVisionSounds(
    "pill_wgfreddy2",
    "my_anim/highlight_success.wav",
    "my_anim/highlight_fail.wav"
)

Important

Always specify the full path to the file including the extension in sound paths.

highlight.GetVisionSound(ent) SERVER

Returns a table with sounds: { affected = "...", unaffected = "..." }.

highlight.NotifyTarget(target, ent, isAffected) SERVER

Plays the highlight sound and applies a visual effect on the player's screen.

ParameterTypeDescription
targetPlayerWho to notify
entEntityThe animatronic's model doing the highlighting
isAffectedbooltrue — success sound, false — fail sound
lua
highlight.NotifyTarget(survivor, pillEnt, true)