DamageMonster: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Document server-owned monsters and interactions
 
Complete Lua function catalog
 
Line 33: Line 33:
* Successful damage emits <code>onMonsterDamage</code> and lethal damage emits <code>onMonsterDeath</code>.
* Successful damage emits <code>onMonsterDamage</code> and lethal damage emits <code>onMonsterDeath</code>.


[[Category:Lua Functions]]
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:World Functions]]
[[Category:World Functions]]
[[Category:Monster Functions]]
[[Category:Monster Functions]]

Latest revision as of 09:52, 15 August 2026

damageMonster

Applies authoritative scripted damage to a server-owned monster.

Syntax

bool damageMonster(string monsterId, number damage [, int sourcePlayerId = 0])

Parameters

Name Type Required Description
monsterId string yes The opaque decimal monster identifier returned by spawnMonster or getMonsters.
damage number yes A finite positive damage amount.
sourcePlayerId int no Optional connected source player identifier, or 0 for world/script damage.

Returns

Returns true when damage is applied; otherwise returns false.

Examples

Damage a monster from a trap:

damageMonster(monsterId, 15)

Notes

  • Available only in server-side resource scripts.
  • Player weapon hits use the server's validated combat path; this function is intended for scripted damage sources.
  • Successful damage emits onMonsterDamage and lethal damage emits onMonsterDeath.