Table of Contents

Namespace Anvil.API.Events

Classes

AreaEvents

Built-in events associated with a specific area.

AreaEvents.OnEnter

Called when a new NwGameObject has entered the NwArea.

AreaEvents.OnExit

Called when an NwGameObject leaves the NwArea.

AreaEvents.OnHeartbeat

Called at a regular interval (approx. 6 seconds).

AreaEvents.OnUserDefined

Triggered for an area when the associated Signal(NwArea, int) method is called.

AreaOfEffectEvents

Built-in events for effects created with AreaOfEffect(PersistentVfxTableEntry, ScriptCallbackHandle?, ScriptCallbackHandle?, ScriptCallbackHandle?).

AreaOfEffectEvents.OnEnter

Called when an object enters the area of effect.

AreaOfEffectEvents.OnExit

Called when an object exits the area of effect.

AreaOfEffectEvents.OnHeartbeat

Called at a regular interval (approx. 6 seconds).

AreaOfEffectEvents.OnUserDefined

Triggered for an area of effect when the associated Signal(NwAreaOfEffect, int) method is called.

CreatureEvents

Built-in events associated with a specific creature.

CreatureEvents.OnBlocked

Triggered when a NwCreature is blocked by a door during movement or AI pathing.

CreatureEvents.OnCombatRoundEnd

Triggered at the end of the NwCreature combat round.

CreatureEvents.OnConversation

Triggered when the creature starts dialogue, or hears a listen pattern.

CreatureEvents.OnDamaged

Triggered when the creature takes damage from a game object.

CreatureEvents.OnDeath

Triggered when the creature dies.

CreatureEvents.OnDisturbed

Triggered when the creature's inventory is disturbed.

CreatureEvents.OnHeartbeat

Triggered at a regular interval (approx. 6 seconds).

CreatureEvents.OnPerception

Triggered when the creature perceives another creature (seen, heard, vanished, inaudible).

CreatureEvents.OnPhysicalAttacked

Triggered when the creature is physically attacked by another creature.

CreatureEvents.OnRested

Triggered when the creature finishes resting.

CreatureEvents.OnSpawn

Triggered when the creature spawns into the game.

CreatureEvents.OnSpellCastAt

Triggered when a spell is cast at the creature.

CreatureEvents.OnUserDefined

Triggered for a creature when the associated Signal(NwCreature, int) method is called.

DMEvent

Base class for DM-related native events.

DMEventFactory
DMGiveEvent

Base event for DM actions that grant XP, levels, or gold to a target.

DMGroupTargetEvent

Base event for DM actions targeting one or more objects.

DMSingleTargetEvent

Base event for DM actions targeting a single object.

DMTeleportEvent

Base event for DM teleport actions.

DamageData<T>

Represents the typed damage data used to apply damage to a game object.

DebugEventFactory
DialogEvents

Provides dialog-related script events and helpers sourced from NWScript.

DialogEvents.ActionTaken

Triggered when a dialog "Action Taken" node is executed.

DialogEvents.AppearsWhen

Triggered when a dialog "Appears When" node is executed.

DoorEvents

Built-in events associated with a specific door.

DoorEvents.OnAreaTransitionClick

Triggered when a player clicks a door used for an area transition.

DoorEvents.OnClose

Triggered when the door closes.

DoorEvents.OnConversation

Triggered when the door starts dialogue, or hears a listen pattern.

DoorEvents.OnDamaged

Triggered when the door takes damage.

DoorEvents.OnDeath

Triggered when the door is destroyed.

DoorEvents.OnDisarm

Triggered when a trap on the door is disarmed.

DoorEvents.OnFailToOpen

Triggered when an attempt to open the door fails (e.g., door is locked).

DoorEvents.OnHeartbeat

Triggered at a regular interval for the door.

DoorEvents.OnLock

Triggered when the door is locked.

DoorEvents.OnOpen

Triggered when the door opens.

DoorEvents.OnPhysicalAttacked

Triggered when the door is physically attacked by a creature.

DoorEvents.OnSpellCastAt

Triggered when a spell is cast at the door.

DoorEvents.OnTrapTriggered

Triggered when a trap attached to the door is triggered.

DoorEvents.OnUnlock

Triggered when the door is unlocked.

DoorEvents.OnUserDefined

Triggered for a door when the associated Signal(NwDoor, int) method is called.

EffectRunScriptEvent

Triggered when a custom scripted effect receives an interval event, or is applied/removed.

EncounterEvents

Built-in events associated with a specific encounter.

EncounterEvents.OnEnter

Triggered when an object enters the encounter.

EncounterEvents.OnExhausted

Triggered when the encounter becomes exhausted (no further spawns).

EncounterEvents.OnExit

Triggered when an object exits the encounter.

EncounterEvents.OnHeartbeat

Triggered at a regular interval for the encounter (approx. 6 seconds).

EncounterEvents.OnUserDefined

Triggered for an encounter when the associated Signal(NwEncounter, int) method is called.

GameEventFactory

Event factory for built-in game events.

GameEventFactory.RegistrationData
HookEventFactory

Provides a base implementation for native function hook events.
See the documentation on FunctionHooks for how to use this class.

ItemEventHandlerEventFactory
ItemHandlerEvent

Base class for simple item handler events.

ModuleEvents

Global module events.

ModuleEvents.OnAcquireItem

Triggered whenever an NwItem is added to a NwGameObject's inventory.

ModuleEvents.OnActivateItem

Triggered when an item that has the item property spell "Unique Power" (targeted) or "Unique Power - Self Only" (self) casts its spell.

ModuleEvents.OnClientEnter

Triggered when a NwPlayer selects a character and logs into the module.

ModuleEvents.OnClientLeave

Triggered when a NwPlayer leaves the server.

ModuleEvents.OnCutsceneAbort

Triggered when a NwPlayer tries to cancel a cutscene (ESC).

ModuleEvents.OnHeartbeat

Triggered every server heartbeat (~6 seconds).

ModuleEvents.OnModuleLoad

Triggered when the module is initially loaded.
This event must be hooked in your service constructor, otherwise it will be missed.

ModuleEvents.OnModuleStart

Triggered when the module starts (after load).

ModuleEvents.OnNuiEvent

Triggered when an event is raised in the NUI system.

ModuleEvents.OnPlayerChat

Triggered when any NwPlayer sends a chat message. Private channel not hooked.

ModuleEvents.OnPlayerDeath

Triggered when a NwPlayer dies.

ModuleEvents.OnPlayerDying

Triggered when a NwPlayer enters a dying state (< 0 HP).

ModuleEvents.OnPlayerEquipItem

Triggered when a NwCreature equips an NwItem.

ModuleEvents.OnPlayerGuiEvent

Triggered when a player clicks on a particular GUI interface.

ModuleEvents.OnPlayerLevelUp

Triggered when a NwPlayer levels up.

ModuleEvents.OnPlayerRespawn

Triggered when a NwPlayer clicks the respawn button on the death screen.

ModuleEvents.OnPlayerRest

Triggered when NwPlayer presses the rest button and begins to rest, cancels rest, or finishes rest.

ModuleEvents.OnPlayerTarget

Triggered when a NwPlayer targets something.

ModuleEvents.OnPlayerTileAction

Triggered when a player performs an action on an area tile.

ModuleEvents.OnPlayerUnequipItem

Triggered just before a NwCreature un-equips an NwItem.

ModuleEvents.OnUnacquireItem

Triggered when a NwItem is removed from a NwCreature's inventory.
This event is also triggered when an item stack is destroyed when combining with another item stack.

ModuleEvents.OnUserDefined

Triggered for the module when the associated Signal(int) method is called.

OnAssociateAdd

Triggered when an associate is added to a creature.

OnAssociateAdd.Factory
OnAssociateRemove

Triggered when an associate is removed from a creature.

OnAssociateRemove.Factory
OnBarterAddItem

Called when a player adds an item to a barter.

OnBarterAddItem.Factory
OnBarterEnd

Triggered when a barter ends between 2 players.

OnBarterEnd.Factory
OnBarterStart

Triggered when a barter is initiated between two players.

OnBarterStart.Factory
OnCalendarTimeChange

Triggered when the module calendar/time changes.

OnCalendarTimeChange.Factory
OnChatMessageSend

Triggered when a chat message is about to be sent.

OnCheckEffectImmunity

Triggered when an effect checks for creature immunities.
Use this event to force an effect to bypass creature immunities.

OnCheckEffectImmunity.Factory
OnClientConnect

Triggered when a player attempts to connect to the server (before character select).
This event can be cancelled to prevent a player from connecting to the server.

OnClientConnect.Factory
OnClientDisconnect

Triggered when a player disconnects from the server.
This event is also called if the player connects, and then disconnects on the character select screen.

OnClientDisconnect.Factory
OnClientLevelUpBegin

Triggered when a player initiates the level-up process.

OnClientLevelUpBegin.Factory
OnCombatDRBroken

Triggered when a creature's damage resistance or damage reduction is broken/bypassed.

OnCombatDRBroken.Factory
OnCombatModeToggle

Triggered when a creature toggles a combat mode.

OnCombatModeToggle.Factory
OnCombatRoundStart

Triggered when a creature starts a new combat round.

OnCombatRoundStart.Factory
OnCombatStatusChange

Triggered when a player's combat status changes.

OnCombatStatusChange.Factory
OnCreatureAcquireItem

Triggered when a creature acquires an item.

OnCreatureAcquireItem.Factory
OnCreatureAttack

Triggered for each individual melee or ranged attack in a flurry.

OnCreatureAttack.Factory
OnCreatureCheckProficiencies

Triggered when an item is tested against a creature's proficiencies to determine if it may be equipped.

OnCreatureCheckProficiencies.Factory
OnCreatureDamage

Triggered when damage is applied to a creature or placeable.

OnCreatureDamage.Factory
OnDMAppear

Triggered when a DM appears in the game world, becoming visible to all other players.

OnDMChangeDifficulty

Triggered when a DM changes the module difficulty.

OnDMDisableTrap

Triggered when a DM toggles the trap state of a door/placeable/trigger.

OnDMDisappear

Triggered when a DM disappears from the game world, becoming invisible to all other players.

OnDMDumpLocals

Triggered when a DM requests a dump/output of local variables.

OnDMForceRest

Triggered when a DM forces their current selection of creatures to rest.

OnDMGetFactionReputation

Triggered when a DM queries module-wide faction reputation values.

OnDMGetVariable

Triggered when a DM reads a variable from an object.

OnDMGiveAlignment

Triggered when a DM adjusts a target's alignment.

OnDMGiveGold

Triggered when a DM gives gold to a player.

OnDMGiveItem

Triggered when a DM gives an item to a target.

OnDMGiveLevel

Triggered when a DM gives a level to a player.

OnDMGiveXP

Triggered when a DM gives XP to a player.

OnDMGoTo

Triggered when a DM teleports/jumps to a specific object.

OnDMHeal

Triggered when a DM heals their current selection of creatures.

OnDMJumpAllPlayersToPoint

Triggered when a DM teleports all online players in the module to a specific location.

OnDMJumpTargetToPoint

Triggered when a DM jumps one or more targets to a point.

OnDMJumpToPoint

Triggered when a DM teleports to a specific location.

OnDMKill

Triggered when a DM kills their current selection of creatures.

OnDMLimbo

Triggered when a DM moves their current selection of creatures to limbo.

OnDMPlayerDMLogin

Triggered when a player attempts to log in as DM.

OnDMPlayerDMLogout

Triggered when a temporary player DM logs out, and becomes a regular player.

OnDMPossess

Triggered when a DM possesses a creature.

OnDMPossessFullPower

Triggered when a DM possesses a creature with full DM powers.

OnDMSetDate

Triggered when a DM modifies the module date.

OnDMSetFaction

Triggered when a DM sets an object's faction.

OnDMSetFactionReputation

Triggered when a DM sets module-wide faction reputation values.

OnDMSetStat

Triggered when a DM sets an ability score on a creature.

OnDMSetTime

Triggered when a DM modifies the module time.

OnDMSetVariable

Triggered when a DM sets a variable on an object.

OnDMSpawnObject

Triggered when a DM spawns an object.

OnDMSpawnTrapOnObject

Triggered when a DM spawns a trap on a target object.

OnDMTakeItem

Triggered when a DM takes an item from an object.

OnDMToggleAI

Triggered when a DM toggles the AI state of their current selection of creatures.

OnDMToggleImmortal

Triggered when a DM toggles the Immortal state of their current selection of creatures.

OnDMToggleInvulnerable

Triggered when a DM toggles the invulnerability state of their current selection of creatures.

OnDMToggleLock

Triggered when a DM toggles the lock state of a door/placeable.

OnDMViewInventory

Triggered when a DM opens or closes a target's inventory.

OnDebugPlayVisualEffect

Triggered when a DM/player in debug mode attempts to spawn a visual effect.

OnDebugRunScript

Triggered when a script has been requested to execute from the nwscript debug window.

OnDebugRunScriptChunk

Triggered when a DM/player in debug mode has requested a script chunk to be executed.

OnDetectModeUpdate

Triggered when a creature enters or exits detect mode.

OnDetectModeUpdate.Factory
OnDisarmWeapon

Triggered when a disarm effect is applied to an object.

OnDisarmWeapon.Factory
OnDispelMagicApply

Triggered when a DispelMagicAll(int) or DispelMagicBest(int) effect is applied to an object.

OnDispelMagicApply.Factory
OnDoListenDetection

Triggered when a creature attempts to detect a target via Listen.

OnDoListenDetection.Factory
OnDoSpotDetection

Triggered when a creature attempts to detect a target via Spot.

OnDoSpotDetection.Factory
OnDoorSetOpenState

Triggered when a door's open state is changed (open/closed/destroyed).

OnDoorSetOpenState.Factory
OnEffectApply

Triggered when an effect is about to be applied to a creature.

OnEffectApply.Factory
OnEffectRemove

Triggered when an effect is about to be removed from a creature.

OnEffectRemove.Factory
OnExamineObject

Triggered when a player examines an object.

OnExamineObject.Factory
OnExamineTrap

Triggered when a player examines a trap.

OnExamineTrap.Factory
OnFamiliarPossess

Triggered when a creature possesses its familiar.

OnFamiliarPossess.Factory
OnFamiliarUnpossess

Triggered when a creature unpossesses its familiar.

OnFamiliarUnpossess.Factory
OnHeal

Triggered when a healing effect is applied to a target.

OnHeal.Factory
OnHealKitUse

Triggered when a heal kit is used by a creature.

OnHealKitUse.Factory
OnInventoryGoldAdd

Triggered when gold is added to a creature's inventory.

OnInventoryGoldAdd.Factory
OnInventoryGoldRemove

Triggered when gold is removed from a creature's inventory.

OnInventoryGoldRemove.Factory
OnInventoryItemAdd

Triggered when an item is added to an inventory of an item or placeable.

OnInventoryItemAdd.Factory
OnInventoryItemRemove

Triggered when an item is removed from an inventory of an item or placeable.

OnInventoryItemRemove.Factory
OnItemDecrementStackSize

Triggered when an item is destroyed, reducing the stack size of an item.

OnItemDestroy

Triggered when an item is destroyed, deleting the item.

OnItemEquip

Triggered when a creature attempts to equip an item.

OnItemEquip.Factory
OnItemInventoryClose

Triggered when a creature closes a container item.

OnItemInventoryClose.Factory
OnItemInventoryOpen

Triggered when a creature opens a container item.

OnItemInventoryOpen.Factory
OnItemPayToIdentify

Triggered when a creature pays a store to identify an item.

OnItemPayToIdentify.Factory
OnItemScrollLearn

Triggered when a creature is about to learn a spell from a scroll.

OnItemScrollLearn.Factory
OnItemSplit
OnItemSplit.Factory
OnItemUnequip

Triggered when a creature attempts to unequip an item.

OnItemUnequip.Factory
OnItemUse

Triggered when a creature attempts to use an item.

OnItemUse.Factory
OnItemValidateEquip

Triggered when validating whether a creature can equip an item.

OnItemValidateEquip.Factory
OnItemValidateUse

Triggered when validating whether a creature can use an item.

OnItemValidateUse.Factory
OnLevelDown

Triggered when a creature levels down.

OnLevelDown.Factory
OnLevelUp

Triggered when a creature levels up.

OnLevelUp.Factory
OnLevelUpAutomatic

Triggered when a creature levels up automatically using a class package.

OnLevelUpAutomatic.Factory
OnLoadCharacterFinish

Triggered immediately after a player character is loaded by the server.

OnLoadCharacterFinish.Factory
OnMapPinAddPin

Triggered when a player is about to place a map pin.

OnMapPinAddPin.Factory
OnMapPinChangePin

Triggered when a player is about to change an existing map pin.

OnMapPinChangePin.Factory
OnMapPinDestroyPin

Triggered when a player is about to delete an existing map pin.

OnMapPinDestroyPin.Factory
OnObjectUse

Triggered when a creature is about to use an object.

OnObjectUse.Factory
OnPartyEvent

Triggered when a player performs a party-related action (invite, kick, transfer leadership, etc.).

OnPartyEvent.Factory
OnPlayerQuickChat

Triggered when a player uses a quick chat command.

OnPlayerQuickChat.Factory
OnPolymorphApply

Triggered when a creature is about to be affected by a polymorph effect.

OnPolymorphApply.Factory
OnPolymorphRemove

Triggered when a creature is about to lose a polymorph effect.

OnPolymorphRemove.Factory
OnServerCharacterSave

Triggered when the server is about to save a character to the server vault.
This is called once for every character when the server is exiting, when a player leaves the server, or when ExportCharacter() & ExportAllCharacters() is called.
Set PreventSave to skip saving the character.

OnServerCharacterSave.Factory
OnServerSendArea

Triggered when the server sends area data to a player.

OnServerSendArea.Factory
OnSpellAction

Triggered when a creature queues the spell casting action.

OnSpellAction.Factory
OnSpellBroadcast

Triggered when a spell cast event is broadcast by a creature.

OnSpellBroadcast.Factory
OnSpellCast

Triggered when a game object casts a spell.

OnSpellCast.Factory
OnSpellInterrupt

Triggered when a casting creature is interrupted and the spell fails.

OnSpellInterrupt.Factory
OnSpellSlotClear

Triggered when a memorized spell slot is cleared.

OnSpellSlotClear.Factory
OnSpellSlotMemorize

Triggered when a creature memorizes a spell into a slot.

OnSpellSlotMemorize.Factory
OnStealthModeUpdate

Triggered when a creature enters or exits stealth mode.

OnStealthModeUpdate.Factory
OnStoreRequestBuy

Triggered when a creature requests to buy an item from a store.

OnStoreRequestBuy.Factory
OnStoreRequestSell

Triggered when a creature requests to sell an item to a store.

OnStoreRequestSell.Factory
OnTrapDisarm

Triggered when a creature attempts to disarm a trap.

OnTrapDisarm.Factory
OnTrapEnter

Triggered when a game object enters a trap trigger.

OnTrapEnter.Factory
OnTrapExamine

Triggered when a creature attempts to examine a trap.

OnTrapExamine.Factory
OnTrapFlag

Triggered when a creature attempts to flag a trap.

OnTrapFlag.Factory
OnTrapRecover

Triggered when a creature attempts to recover a trap.

OnTrapRecover.Factory
OnTrapSet

Triggered when a creature attempts to set a trap.

OnTrapSet.Factory
OnTriggerEnter

Triggered when an object enters a trigger.

OnTriggerEnter.Factory
OnUseFeat

Triggered when a creature attempts to use a feat.

OnUseFeat.Factory
OnUseSkill

Triggered when a creature attempts to use a skill.

OnUseSkill.Factory
PlaceableEvents

Built-in events associated with a specific placeable.

PlaceableEvents.OnClose

Triggered when NwCreature closes a NwPlaceable.

PlaceableEvents.OnConversation

Triggered when this placeable starts a conversation or hears a listened-for message.

PlaceableEvents.OnDamaged

Triggered when NwGameObject damages NwPlaceable.

PlaceableEvents.OnDeath

Triggered when NwCreature destroys NwPlaceable.

PlaceableEvents.OnDisarm

Triggered when NwPlaceable is disarmed.

PlaceableEvents.OnDisturbed

Triggered when NwPlaceable inventory is disturbed.

PlaceableEvents.OnHeartbeat

Triggered every 6 seconds for NwPlaceable.

PlaceableEvents.OnLeftClick

Triggered when NwPlaceable is left-clicked.

PlaceableEvents.OnLock

Triggered when NwPlaceable is locked.

PlaceableEvents.OnOpen

Triggered when NwPlaceable is opened.

PlaceableEvents.OnPhysicalAttacked

Triggered when NwPlaceable is physically attacked.

PlaceableEvents.OnSpellCastAt

Triggered when Spell is cast at NwPlaceable.

PlaceableEvents.OnTrapTriggered

Triggered when a trap on NwPlaceable is triggered.

PlaceableEvents.OnUnlock

Triggered when NwPlaceable is unlocked.

PlaceableEvents.OnUsed

Triggered when NwPlaceable is used.

PlaceableEvents.OnUserDefined

Triggered for a placeable when the associated Signal(NwPlaceable, int) method is called.

SpellEvents
SpellEvents.OnSpellCast

Triggered as the spell "impact script" when a spell is successfully cast.

StoreEvents

Built-in events associated with a specific store.

StoreEvents.OnClose

Triggered when a NwStore is closed.

StoreEvents.OnOpen

Triggered when an NwStore is opened.

TimeOfDayState

Module time-of-day state constants

TrapEvent

Base event type for trap actions.

TrapHookEventFactory
TriggerEvents

Built-in events associated with a specific trigger.

TriggerEvents.OnClicked

Triggered when a NwTrigger is clicked.

TriggerEvents.OnDisarmed

Triggered when a NwTrigger is disarmed.

TriggerEvents.OnEnter

Triggered when an object enters an NwTrigger.

TriggerEvents.OnExit

Triggered when an object exits an NwTrigger.

TriggerEvents.OnHeartbeat

Triggered every 6 seconds for NwTrigger.

TriggerEvents.OnTrapTriggered

Triggered when a trap on a NwTrigger is triggered.

TriggerEvents.OnUserDefined

Triggered for a trigger when the associated Signal(NwTrigger, int) method is called.

Structs

NullRegistrationData

Placeholder registration data for event factories that do not require any metadata.

Interfaces

IEvent

Base interface for all game and engine events managed by the EventService.

IEventFactory

Defines an event factory capable of managing event subscriptions/lifecycles.

IEventFactory<TRegisterData>

Defines a typed event factory that manages event subscriptions/lifecycles with additional metadata related to the event.

IEventSkippable

Defines an event payload that can be skipped before default processing.

Enums

AttackResult

Represents the resolved outcome of an individual attack.

CheckProficiencyOverride

An override value for a creature's item proficiency check.

CombatStatus

Indicates a player's combat status change.

DRType

The type of damage reduction that was broken.

DispelMagicType

Specifies the type of dispel magic effect.

DumpLocalsType

Specifies the target scope for dumping local variables.

EquipValidationResult

Represents the result of validating whether an item can be equipped.

ForceNewModeOverride

Specifies how to override the engine's behavior when applying a new combat mode.

PartyEventType

Represents the different party-related actions a player can perform.

SneakAttack

Indicates whether an attack qualifies for sneak/death attack bonuses.

StealthModeOverride

Specifies override behavior when entering stealth mode.

TimeChangeType

Identifies which unit of time changed.

ToggleModeEventType

Specifies whether a mode is being entered or exited.

VisibilityOverride

Controls whether detection should be forced to succeed or fail, or use default behavior.

WeaponAttackType

Categorizes the weapon or natural attack slot used for a strike.