OnMonsterAttack

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 22:31, 14 August 2026 by QCherry (talk | contribs) (Update Lua event reference)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

onMonsterAttack

Triggered when server-owned monster AI begins an authoritative attack against a player.

Availability

This event is available in server-side scripts.

Callback signature

onMonsterAttack(monsterId, targetPlayerId, damage, actionId)

Parameters

Name Type Description
monsterId string The attacking monster ID.
targetPlayerId int The targeted player ID.
damage number The attack's validated damage.
actionId int The replicated monster action ID.

Examples

Handle the event:

addEventHandler("onMonsterAttack", root, function(monsterId, targetPlayerId, damage, actionId)
    outputDebugString("Monster " .. monsterId .. " attacks " .. getPlayerName(targetPlayerId))
end)

Notes

  • Player health changes caused by the attack also emit onPlayerDamage and life-state events.