Defines the cw.limb library, the per-limb damage system switched on by the limb_damage_system config.

The server adds and heals damage per hit group and networks it. The client keeps the local player's limb damage and supplies the names, textures and colors for the limb display.

Summary

Methods

Returns the hit group a bone belongs to.
Returns the color a limb is drawn in for its health.
Returns the damage of one of a player's limbs.
Returns the health of one of a player's limbs, 100 minus its damage.
Returns the display name of a limb.
Returns the material used to draw a limb on the limb status display.
Heals every damaged limb of a player by the same amount.
Removes damage from one of a player's limbs.
Returns whether the limb damage system is enabled.
Returns whether any of a player's limbs are damaged.
Heals all of a player's limbs at once.
Adds damage to one of a player's limbs.

Methods

cw.limb:BoneToHitGroup(bone)

shared gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:32

Returns the hit group a bone belongs to.

Parameters

  • bone String Bone name, such as 'ValveBiped.Bip01_Head1'

Returns

  • Number The HITGROUP_* value; HITGROUP_CHEST for bones not in cw.limb.bones

Returns the color a limb is drawn in for its health.

Green above 75, yellow above 50, orange above 25 and red otherwise.

Parameters

  • health Number Limb health from 0 to 100

Returns

  • Color The limb's color

cw.limb:GetDamage(player, hitGroup, asFraction)

shared gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:161

On the server

Returns the damage of one of a player's limbs.

Parameters

  • player Player The player to check
  • hitGroup Number The HITGROUP_* of the limb
  • asFraction Boolean optional, defaults to nil Return the damage as a fraction from 0 to 1

Returns

  • Number The limb's damage from 0 to 100 (or 0 to 1); 0 when limb damage is disabled

On the client

Returns the damage of one of the local player's limbs, as networked by the server.

Parameters

  • hitGroup Number The HITGROUP_* of the limb
  • asFraction Boolean optional, defaults to nil Return the damage as a fraction from 0 to 1

Returns

  • Number The limb's damage from 0 to 100 (or 0 to 1); 0 when limb damage is disabled

Defined in

cw.limb:GetHealth(player, hitGroup, asFraction)

shared gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:151

On the server

Returns the health of one of a player's limbs, 100 minus its damage.

With asFraction, the damage fraction is subtracted from 100, so the result stays between 99 and 100 instead of becoming a fraction.

Parameters

  • player Player The player to check
  • hitGroup Number The HITGROUP_* of the limb
  • asFraction Boolean optional, defaults to nil Subtract the damage as a fraction of 100

Returns

  • Number The limb's health

See also

On the client

Returns the health of one of the local player's limbs, 100 minus its damage.

Client version of the server's cw.limb:GetHealth. With asFraction, the damage fraction is subtracted from 100, so the result stays between 99 and 100.

Parameters

  • hitGroup Number The HITGROUP_* of the limb
  • asFraction Boolean optional, defaults to nil Subtract the damage as a fraction of 100

Returns

  • Number The limb's health

Defined in

Returns the display name of a limb.

Parameters

  • hitGroup Number The HITGROUP_* of the limb

Returns

  • String The limb's name, such as 'Right Arm'; 'Generic' for unknown hit groups

cw.limb:GetTexture(hitGroup)

client gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:206

Returns the material used to draw a limb on the limb status display.

Parameters

  • hitGroup Any The HITGROUP_* of the limb, or 'body' for the whole body outline

Returns

  • IMaterial The limb's material, or nil for unknown hit groups

cw.limb:HealBody(player, amount)

server gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:75

Heals every damaged limb of a player by the same amount.

Parameters

  • player Player The player to heal
  • amount Number Damage to remove from each limb

See also

cw.limb:HealDamage(player, hitGroup, amount)

server gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:94

Removes damage from one of a player's limbs.

The amount is rounded up. A fully healed limb is removed from the LimbData character data. The change is sent to the player and the PlayerLimbDamageHealed hook is run (via hook.Run). Does nothing if the limb is not damaged.

Parameters

  • player Player The player to heal
  • hitGroup Number The HITGROUP_* of the limb
  • amount Number Damage to remove

Returns whether the limb damage system is enabled.

Reads the limb_damage_system config.

Returns

  • Boolean Whether limb damage is enabled

cw.limb:IsAnyDamaged(player)

shared gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:131

On the server

Returns whether any of a player's limbs are damaged.

Parameters

  • player Player The player to check

Returns

  • Boolean Whether any limb has damage

On the client

Returns whether any of the local player's limbs are damaged.

Parameters

  • player

Returns

  • Boolean Whether any limb has damage

Defined in

Heals all of a player's limbs at once.

Clears the LimbData character data, tells the player and runs the PlayerLimbDamageReset hook (via hook.Run).

Parameters

  • player Player The player to heal

cw.limb:TakeDamage(player, hitGroup, damage)

server gamemodes/catwork/gamemode/core/libraries/sh_limb.lua:55

Adds damage to one of a player's limbs.

Damage is rounded up and the limb's total is capped at 100. The damage is stored in the LimbData character data, sent to the player and the PlayerLimbTakeDamage hook is run (via hook.Run). Does nothing if the character has no limb data.

Parameters

  • player Player The injured player
  • hitGroup Number The HITGROUP_* of the limb
  • damage Number Damage to add

Defined in