SetMonsterHealth

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 18:40, 3 September 2026 by QCherry (talk | contribs) (Document Lua APIs available or improved from G1R:MP 0.1.2)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

setMonsterHealth

IMPROVED FROM UPDATE 0.1.2
This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.

Sets a monster's authoritative health.

Syntax

bool setMonsterHealth(string monsterId, number health)

Parameters

Name Type Required Description
monsterId string yes The opaque decimal monster identifier returned by spawnMonster or getMonsters.
health number yes The non-negative health value to apply.

Returns

Returns true when the value is accepted; otherwise returns false. Values above the monster's current maximum health are rejected.

Examples

Restore a monster to full health:

local health, maximum = getMonsterHealth(monsterId)
setMonsterHealth(monsterId, maximum)

Notes

  • Available only in server-side resource scripts.
  • Setting health to zero transitions the monster into the server-owned death state.