From Arx Libertatis Wiki
Jump to navigation Jump to search

Events in the Arx scripting language are entry points of entity scripts. They are sent by the game engine or by other scripts using the sendevent command. While the engine defines some event names, entity scripts can use arbitrary names for custom events.


on eventname {
  accept or refuse


Events always have a sender entity associated with them. The entity ID of the sender is available in the read-only ^sender script variable.


Scripts can be sent to a single target entity or multiple targets matching some criteria using the sendevent command but are always executed independently for each target.


Events sent by the game engine are usually executed synchronously although there are some exceptions. Events sent by scripts are always executed asynchronously.

Events are first executed in the entity instance script. Commands are executed after on eventname until a accept or refuse command is reached. refuse ends event execution while accept allows execution to continue after on eventname in the entity class script until a accept or refuse command is reached there. If a script does not have a on eventname block, the event is always accepted.

For events sent by the game engine, ending the event with accept or refuse sometimes also determines some further engine behavior. For events send by entity scripts the result is not returned to the sender.


Events can have up to three parameters which can be accessed using the special read-only script variables as string using ^$param1, ^$param2 and ^$param3, as number using ^&param1, ^&param2 and ^&param3 or as int using ^#param1, ^#param2 and ^#param3.

Blocked events

Mega-hidden entities can only receive the reload event and dead NPCs can only receive the die, dead, executeline, reload, inventory2_open and inventory2_close events. Additionally, certain events can be disabled for an entity using the setevent script command.


The following is a (incomplete) list of events sent by the game engine. Scripts can send arbitrarily named events.

on collide_doorSent on collisions involving an entity in the door group.
on collide_fieldSent on collisions with a field created with the Create field (Aam Rune (create)Kaom Rune (protection)Spacium Rune (field)) spell.
on deadSent periodically when dead.
on inventory2_closeSent when closing non-player inventories.
on inventory2_openSent when opening non-player inventories.
on mainSent periodically when not dead.
on stealSent when opening or closing a non-player inventory by pickpocketing.

From: [1]

on null
on init
on inventoryin
on inventoryout
on inventoryuse
on sceneuse
on equipin
on equipout
on reset
on chat
on action
on reachedtarget
on fight
on flee
on hit
on die
on losttarget
on treatin
on treatout
on move
on detectplayer
on undetectplayer
on combine
on npc_follow
on npc_fight
on npc_stay
on custom
on enter_zone
on leave_zone
on initend
on clicked
on insidezone
on controlledzone_inside
on leavezone
on controlledzone_leave
on enterzone
on controlledzone_enter
on load
on spellcast
on reload
on ouch
on hear
on summoned
on spellend
on spelldecision
on strike
on collision_error
on waypoint
on pathend
on critical
on collide_npc
on backstab
on aggression
on collision_error_detail
on game_ready
on cine_end
on key_pressed
on controls_on
on controls_off
on pathfinder_failure
on pathfinder_success
on trap_disarmed
on book_open
on book_close
on identify
on break
on cursormode
on explorationmode

Besides these events, the game engine also uses the internal executeline and null events.