Receiving Action Notifications

There are two functions used for this effect, one to signup to receive notifications, and another to retire from receiving them.

  ASignup( action := "*", character := "*", processes := {}, scripts := {} )
  ARetire( action := "*", character := "*", processes := {}, scripts := {} )

Parameters:
 action         The specific action to signup for, eg "Die". "*" signs up for all actions.
 character      The serial of the character whose actions you wish to receive. "*" signs up for all characters.
 processes      An array of running script PID's that you wish to have events sent to for the actions that match the specified (action/character).
 scripts        An array of script names that you wish to be started with an event as the parameter for the actions that match those specified (action/character).

If no processes or scripts are defined, then the function will assume that the current process is requesting it. So, for example:


  ASignup( "*", who.serial ); //Signs up this script to receive notification of any actions by 'who'
  var event := wait_for_event(2); //wait 2 seconds, check if any actions are recorded
  if( event.type == EVID_PLAYER_ACTION )
    SendSysMessage( who, "Action: " + event.action ); //action type, eg "Die"
    SendSysMessage( who, "Data: " + event.data ); //data for this action.
  else
    //do stuff
  endif
  ARetire( "*", who.serial ); //Signs off this script


This simple script will check for 2 seconds to see if the character is doing any supported actions, and display data about them. It's just a basic example but hopefully you get the idea :) The event received (by running scripts, and as the only parameter for started scripts) is a structure as follows:

  event.type            EVID_PLAYER_ACTION
  event.action          Action Type (usually string)
  event.data            Action-Specific data
  event.character       MobileRef to the character who performed the action (or their serial, but that is less likely)

Here are the event.data structures for the predefined actions in actions.inc
 Skill
  data.skill            Skill ID / Attribute Name (whatever was passed as 'skill')

 Die
  data.corpse           Objref to the corpse