Skip to content

Combat

This page documents hooks in the combat category.


CanPlayerThrowPunch(client)View Source

Purpose

Determines whether a player may throw a punch with the hands weapon before cooldown and attack logic proceeds.

Category

Combat

Realm

Shared

Parameters

Player client The player attempting to punch.

Returns

boolean|string|nil Return false to block the punch. A second return value may provide the localized error key shown to the player. Returning nil allows the default behavior to continue.

Example Usage

  hook.Add("CanPlayerThrowPunch", "liaExampleCanPlayerThrowPunch", function(client)
      if client:getNetVar("noPunching") then
          return false, "needMorePlaytimeBeforePunch"
      end
  end)

GetDamageScale(hitgroup, dmgInfo, damageScale)View Source

Purpose

Allows plugins or modules to override the damage multiplier before scaled damage is applied.

Category

Combat

Realm

Server

Parameters

number hitgroup The Garry's Mod hitgroup being processed.

CTakeDamageInfo dmgInfo The damage information object being scaled.

number damageScale The current damage multiplier after Lilia's head and limb checks.

Returns

number|nil Return a numeric multiplier to replace the current damage scale. Returning nil allows the default behavior to continue.

Example Usage

  hook.Add("GetDamageScale", "liaExampleGetDamageScale", function(hitgroup, dmgInfo, damageScale)
      if hitgroup == HITGROUP_HEAD then
          return damageScale * 0.75
      end
  end)

GetHandsAttackSpeed(client, defaultDelay)View Source

Purpose

Allows modules to override the primary attack delay used by the hands weapon when punching.

Category

Combat

Realm

Shared

Parameters

Player client The player performing the punch.

number defaultDelay The base primary attack delay defined on the hands weapon.

Returns

number|nil Return a numeric delay to override the default punch cooldown. Returning nil allows the default behavior to continue.

Example Usage

  hook.Add("GetHandsAttackSpeed", "liaExampleGetHandsAttackSpeed", function(client, defaultDelay)
      if client:Crouching() then
          return defaultDelay * 0.9
      end
  end)

GetPlayerPunchDamage(client, damage, context)View Source

Purpose

Allows modules to override or mutate the damage dealt by a hands-weapon punch before the trace attack is applied.

Category

Combat

Realm

Shared

Parameters

Player client The player performing the punch.

number damage The current punch damage value.

table context Mutable context data containing the current `damage` field.

Returns

number|nil Return a numeric damage value to override the punch damage. Returning nil allows the current context damage to be used.

Example Usage

  hook.Add("GetPlayerPunchDamage", "liaExampleGetPlayerPunchDamage", function(client, damage, context)
      if client:InVehicle() then
          return 0
      end
  end)

GetPlayerPunchRagdollTime(client, target)View Source

Purpose

Allows modules to override how long a player stays ragdolled when a non-lethal punch would otherwise knock them out.

Category

Combat

Realm

Shared

Parameters

Player client The player who threw the punch.

Player target The player who is about to be ragdolled by the punch.

Returns

number|nil Return a numeric ragdoll duration in seconds to override the configured default. Returning nil allows the default behavior to continue.

Example Usage

  hook.Add("GetPlayerPunchRagdollTime", "liaExampleGetPlayerPunchRagdollTime", function(client, target)
      if target:isStaffOnDuty() then
          return 5
      end
  end)

PlayerThrowPunch(client, trace)View Source

Purpose

Runs after the hands weapon resolves its punch trace and applies any resulting damage or ragdoll effect.

Category

Combat

Realm

Server

Parameters

Player client The player who threw the punch.

table trace The trace result table used to resolve the punch hit.

Example Usage

  hook.Add("PlayerThrowPunch", "liaExamplePlayerThrowPunch", function(client, trace)
      if trace.Hit and IsValid(trace.Entity) then
          print(client:Nick(), "punched", trace.Entity:GetClass())
      end
  end)

PostScaleDamage(hitgroup, dmgInfo, damageScale)View Source

Purpose

Runs after the current damage scale has been applied to the damage info object.

Category

Combat

Realm

Server

Parameters

number hitgroup The Garry's Mod hitgroup that was processed.

CTakeDamageInfo dmgInfo The scaled damage information object.

number damageScale The multiplier that was applied to the damage.

Example Usage

  hook.Add("PostScaleDamage", "liaExamplePostScaleDamage", function(hitgroup, dmgInfo, damageScale)
      print("[Damage] Applied scale:", damageScale)
  end)

PreScaleDamage(hitgroup, dmgInfo, damageScale)View Source

Purpose

Runs immediately before scaled hitgroup damage is applied so modules can adjust the damage info or scale.

Category

Combat

Realm

Server

Parameters

number hitgroup The hitgroup being processed.

CTakeDamageInfo dmgInfo The mutable damage information object.

number damageScale The scale that is about to be applied.

Example Usage

  hook.Add("PreScaleDamage", "liaExamplePreScaleDamage", function(hitgroup, dmgInfo, damageScale)
      if hitgroup == HITGROUP_HEAD then dmgInfo:ScaleDamage(0.9) end
  end)