@s2script/sdk 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,6 +36,19 @@ export function OnClientPostAdminCheck(client: Client): void {
36
36
  }
37
37
  ```
38
38
 
39
+ For an existing plugin with `s2script.gamedata` declarations, run
40
+ `npx @s2script/sdk migrate engine-functions [plugin-dir]`. The command analyzes the v1 declarations
41
+ and source references, reports ambiguities, and writes `gamedata/functions.jsonc` only when the
42
+ declared contract can be converted without loss. It refuses an existing destination unless you pass
43
+ `--force`. Its JSON report lists files actually changed and the package/source edits you must make
44
+ manually, including removal of the old `s2script.gamedata` field and authored engine permissions
45
+ when adopting the v2 file. A successful conversion does not verify that the v1 declaration listed
46
+ every native argument or that the resulting call works on the current game build. The command alone
47
+ does not provide the runtime compatibility facades for old source code. V1 entity hooks are refused
48
+ because their callbacks may receive a null receiver, which the current v2 receiver contract cannot
49
+ preserve. With `--force`, the report identifies the exact create-or-replace path; concurrent prior
50
+ existence cannot be established by the atomic rename.
51
+
39
52
  This package is **types-only** — the engine injects the implementation at load time, and
40
53
  `s2s build` marks `@s2script/*` external rather than bundling it. Capabilities are imported as
41
54
  per-capability subpaths (`@s2script/sdk/entity`, `@s2script/sdk/timers`, `@s2script/sdk/clients`, …);
package/damage.d.ts CHANGED
@@ -1,22 +1,26 @@
1
1
  /**
2
- * @s2script/damage — the block-scoped {@link DamageInfo} view of a live `CTakeDamageInfo`.
3
- * NO runtime code (injected at load). Engine-generic: `CTakeDamageInfo` is a Source 2 type.
2
+ * @s2script/damage — the borrowed {@link DamageInfo} view of the current damage event.
3
+ * Type-only: the view is supplied by the selected game package (its damage function and damage-info
4
+ * layout are game facts; CS2 maps `CTakeDamageInfo`), through the engine-generic `SDKHook`.
4
5
  *
5
6
  * Subscribe with `SDKHook` (`SDKHookType.OnTakeDamage` / `OnTakeDamagePost`), not a global mux.
6
7
  */
7
8
  import type { EntityRef } from "./entity";
8
9
 
9
10
  /**
10
- * A block-scoped view of the current damage event (valid only inside an `OnTakeDamage` or
11
- * `OnTakeDamagePost` SDKHook).
11
+ * A borrowed view of the current damage event, valid only during the synchronous `OnTakeDamage` or
12
+ * `OnTakeDamagePost` SDKHook callback: reading or writing it afterwards (including after an `await`)
13
+ * throws "expired borrowed view". Returning `HookResult.Handled`/`Stop` from `OnTakeDamage` blocks the
14
+ * hit by setting damage to 0 after every handler ran; the engine's damage function still runs.
12
15
  * @example
13
16
  * import type { DamageInfo } from "@s2script/sdk";
14
17
  * function onTakeDamage(info: DamageInfo) { info.damage = info.damage / 2; }
15
18
  */
16
19
  export interface DamageInfo {
17
20
  /**
18
- * The damage amount (`m_flDamage`). On the pre-hook, assigning MODIFIES the live damage; set to
19
- * 0 to block. On `OnTakeDamagePost`, assignment is ignored (the original already ran).
21
+ * The damage amount (`m_flDamage`). On the pre-hook, assigning MODIFIES the damage the engine
22
+ * applies (later handlers see it); set to 0 to block. A non-finite value is refused (the damage
23
+ * keeps its prior value). On `OnTakeDamagePost`, assignment is ignored (the original already ran).
20
24
  */
21
25
  damage: number;
22
26
  /** The damage-type bit flags (m_bitsDamageType). */