Modules

Docs / API / Modules / damage

Damage

Players & world

@s2script/sdk/damage

damage pre-hooks (SDKHooks-equivalent).

1 export

Import

import { DamageInfo } from "@s2script/sdk/damage";

Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.

API reference

Generated from the shipped type definitions.

interface
DamageInfo

A block-scoped view of the current damage event (valid only inside a Damage.onPre handler).

import type { DamageInfo } from "@s2script/sdk/damage";
// plugins/basecommands/src/plugin.ts:81 — halve the damage (assign 0 to block it entirely)
ctx.entities.onDamage((info: DamageInfo) => { info.damage = info.damage / 2; });
damage: number
The damage amount (m_flDamage). Assigning MODIFIES the live damage; set to 0 to block.
readonly damageType: number
The damage-type bit flags (m_bitsDamageType).
readonly attacker: EntityRef | null
The attacking entity (m_hAttacker), or null if none/stale.
readonly inflictor: EntityRef | null
The inflicting entity (m_hInflictor), or null if none/stale.
readonly victim: EntityRef | null
The victim — the entity taking damage (the hooked this), or null if stale.
Back to modules All packages

s2script — Source 2 plugin framework

GitHub