Main file of the Radiation plugin, which aliases it as cwRadSystem and implements containment zones that irradiate the players inside them, radiation sickness and the Geiger counter.

The file holds both realms. The server keeps the sphere and box zones in cwRadSystem.stored, saved per map under plugins/containment/<map>, and once a second adds a zone's radiation to the radlevel character data of the players inside it, reduced by the resistance from cwRadSystem:ModifyPlayerRadResistance (radiation-proof clothing, faction, and a gas mask filter or the Civil Protection cp_filter that drains while in use). OnPlayerRadLevelChanged and PlayerRadThink apply the sickness as the level rises: attribute penalties and chat messages in stages, no stamina regeneration, then knockouts and damage. The client plays the Geiger clicks, draws the radiation bloom, the filter bar and the zone's radiation reading, and lets superadmins see the zones as wireframes with the cwradsys_get and cwradsys_show console commands.

Summary

Hooks

Called after Catwork has loaded the map entities; restores the saved containment zones.
Plays the local player's Geiger counter clicks.
Called to add HUD bars; adds the gas mask filter bar for Civil Protection.
Called every half second; finds the players inside containment zones.
Called to paint the HUD; shows the zone's radiation per second to Geiger counter holders.
Called by cwRadSystem:OnPlayerInContainmentArea to adjust a player's radiation resistance.
Called every half second while a player stands in a containment zone.
Called when a character's radiation level changes; applies radiation sickness.
Called when a player dies; clears their radiation level, networked values and timers.
Returns whether a player can read radiation levels.
Returns whether a player is immune to radiation.
Returns whether a player is in a non-humanoid creature form.
Returns whether a player is in a mechanical Combine form, such as a scanner or turret.
Called every player think with the character's radiation level; applies its effects.
Called when a character's data is restored; fills in missing radiation fields.
Called to check whether a player's stamina regenerates; blocks it above 199 radiation.
Called every player think; runs the radiation hooks for living characters.
Called after a player spawns; clears accumulated radiation on a full respawn.
Called after data is saved; saves the containment zones.
Sends a radiation sickness message to a player's chat, rate limited.
Called to draw screen effects; draws the Combine overlay and radiation bloom.
Saves the containment zones of the current map to the schema data.
Think()client
Called every frame; runs cwRadSystem:GeigerThink when the local player has a Geiger counter.

Hooks

cwRadSystem:ClockworkInitPostEntity()

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:445

Implements hook ClockworkInitPostEntity

Called after Catwork has loaded the map entities; restores the saved containment zones.

Plays the local player's Geiger counter clicks.

While the player is inside a containment zone, picks a click chance and volume from the networked radLevel and plays a player/geiger sound.

Implements hook GetBars

Called to add HUD bars; adds the gas mask filter bar for Civil Protection.

Parameters

  • bars Map The HUD bars being built

Implements hook HalfSecond

Called every half second; finds the players inside containment zones.

Networks every player's inRadArea flag and runs OnPlayerInContainmentArea for each living player with a character who touches a sphere or box zone, or left one less than a second ago, with the strongest radiation level among the zones they are in (0 after leaving).

Called to paint the HUD; shows the zone's radiation per second to Geiger counter holders.

When resistance reduces the absorbed amount, it is shown in brackets after the zone value.

cwRadSystem:ModifyPlayerRadResistance(ply, rad, radresist)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:178

Implements hook ModifyPlayerRadResistance

Called by cwRadSystem:OnPlayerInContainmentArea to adjust a player's radiation resistance.

Adds resistance for radiation-proof clothing, Overwatch, vortigaunts and mechanic forms. Civil Protection drain their cp_filter and other players drain the energy of their equipped gas mask; either grants 93 extra resistance while it has charge left. The remaining charge is networked as the resist_rad integer.

Parameters

  • ply Player The player standing in radiation
  • rad Number Radiation strength of the zone, per second
  • radresist Number The player's base resistance, in percent

Returns

  • Number The modified resistance in percent; 100 or more blocks all radiation

cwRadSystem:OnPlayerInContainmentArea(ply, rad)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:250

Implements hook OnPlayerInContainmentArea

Called every half second while a player stands in a containment zone.

Once per second, reduces rad by the resistance from ModifyPlayerRadResistance and adds the result to the character's radlevel. Networks the zone strength as radLevel and the absorbed amount as radLevelRes for the HUD.

Parameters

  • ply Player The player in the zone
  • rad Number Strongest radiation level among the zones the player is in

cwRadSystem:OnPlayerRadLevelChanged(ply, newrad)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:373

Implements hook OnPlayerRadLevelChanged

Called when a character's radiation level changes; applies radiation sickness.

Boosts the player's attributes negatively under the Radiation boost in five stages (above 149, 299, 449, 599 and 899) and shows the matching sickness message. Below 150 the boosts are removed. Does nothing for players with cwRadSystem:PlayerHasRadImmune.

Parameters

  • ply Player The player whose level changed
  • newrad Number The new radlevel

Implements hook PlayerDeath

Called when a player dies; clears their radiation level, networked values and timers.

Parameters

  • ply Player The player that died

cwRadSystem:PlayerHasGeigerCounter(ply)

shared gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:779

Returns whether a player can read radiation levels.

True for Overwatch, Civil Protection, mechanic forms and holders of the ] flag; otherwise checks for a geiger_counter item in the inventory (the server's copy on the server, the local inventory on the client).

Parameters

  • ply Player The player to check

Returns

  • Boolean Whether the player has a Geiger counter

cwRadSystem:PlayerHasRadImmune(ply)

shared gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:814

Returns whether a player is immune to radiation.

Mutants (the isMutant character data), creature and mechanic forms and vortigaunts are immune.

Parameters

  • ply Player The player to check

Returns

  • Boolean Whether the player is immune

Returns whether a player is in a non-humanoid creature form.

The pill-form check is commented out, so this currently always returns nil.

Parameters

  • ply Player The player to check

Returns

  • Boolean Whether the player is a creature; currently always nil

Returns whether a player is in a mechanical Combine form, such as a scanner or turret.

The pill-form check is commented out, so this currently always returns nil.

Parameters

  • ply Player The player to check

Returns

  • Boolean Whether the player is a machine; currently always nil

cwRadSystem:PlayerRadThink(ply, newrad)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:320

Implements hook PlayerRadThink

Called every player think with the character's radiation level; applies its effects.

Above 999 the player takes damage every half second. Above 899 the player has a small chance every think, at most once every 20 seconds, to be knocked out for 5 to 15 seconds.

Parameters

  • ply Player The player thinking
  • newrad Number The character's accumulated radlevel

cwRadSystem:PlayerRestoreCharacterData(ply, data)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:31

Implements hook PlayerRestoreCharacterData

Called when a character's data is restored; fills in missing radiation fields.

Sets radlevel and radresist to 0 and cp_filter to 100 for Civil Protection characters (0 for everyone else) when they are not stored yet.

Parameters

  • ply Player The player whose character is loading
  • data Character The character data table, modified in place

cwRadSystem:PlayerShouldStaminaRegenerate(player)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:414

Implements hook PlayerShouldStaminaRegenerate

Called to check whether a player's stamina regenerates; blocks it above 199 radiation.

Parameters

  • player Player The player to check

Returns

  • Boolean false to block regeneration, nil to leave the decision to others

cwRadSystem:PlayerThink(player, curTime, infoTable)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:281

Implements hook PlayerThink

Called every player think; runs the radiation hooks for living characters.

Runs OnPlayerRadLevelChanged when radlevel differs from the last seen value and PlayerRadThink every think.

Parameters

  • player Player The player thinking
  • curTime Number The current time
  • infoTable Map The player's info table for this think

hook.Add id: ContainmentArea

No documentation available.

cwRadSystem:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)

server gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:58

Implements hook PostPlayerSpawn

Called after a player spawns; clears accumulated radiation on a full respawn.

On a spawn that is neither the first nor a light spawn, resets radlevel and radresist to 0 and refills the Civil Protection filter to 100.

Parameters

  • player Player The player that spawned
  • lightSpawn Boolean Whether this was a light spawn
  • changeClass Boolean Whether the player changed class
  • firstSpawn Boolean Whether this is the character's first spawn

Implements hook PostSaveData

Called after data is saved; saves the containment zones.

Sends a radiation sickness message to a player's chat, rate limited.

After a message is shown the next one is held back for a random 59 to 257 seconds.

Parameters

  • ply Player The player to message
  • text String The message text

cwRadSystem:RenderScreenspaceEffects()

client gamemodes/cwhl2rp/plugins/containmentzones/plugin/sh_plugin.lua:491

Called to draw screen effects; draws the Combine overlay and radiation bloom.

Combine players get the binocular overlay (opaque for Overwatch). Above 449 radiation a pulsing bloom grows stronger with the radiation level and with lost health. Players immune to radiation see neither.

Saves the containment zones of the current map to the schema data.

Writes plugins/containment/<map> with each zone's radiation level, sphere centre and radius or box corners.

Called every frame; runs cwRadSystem:GeigerThink when the local player has a Geiger counter.

Runs at most every 0.06 seconds, and only while the player is inside a containment zone.

Defined in