AI Script Events

 

Script Events occur when something happens to an entity and we wish to possibly run a script because of it. These events are the link between the entity's normal execution and the scripting system. Only those script events that are supported by the program can be executed. These events are defined by the following :

     <event>
     { 
       ... script commands ...
     }
        

where <event> is the name of a supported scripting event. The following list contains all the scripting events currently supported by the scripting system, which entities have this event happen to them and a description of the event.

attributes

for NPC only. This event is executed when the NPC is spawning into the world and is used to alter the attributes of the NPC. The script commands used in this event block are specific to the attributes event and are not used elsewhere in any other events.

spawn

supported by all entities. This event is executed when the entity is first spawned into the level.

playerstart

for the player only. This event is executed 0.5 seconds after the player spawns into the level and gives time for all entities to settle down after spawning.

trigger <name>

supported by all entities. This event happens when another entity executes a trigger script command with this entity as it's target and with <name> as the trigger name.

pain

for NPC only. This event is called when the NPC is in pain.

pain <health>

for NPC only. This event is called when the NPC health first drops below the <health> amount. You can have either a pain event or a pain <health> event in a script block but not both.

painenemy <ainame>

for NPC only. This event is called when the NPC is in pain and the attacker's ainame matches <ainame>.

death

for NPC only. This event is called when the NPC dies.

enemysight <ainame>

for NPC only. This event is called when the NPC first sights an enemy NPC whose ainame matches <ainame>.

sight <ainame>

for NPC only. This event is called when the NPC first sights a friendly NPC whose ainame matches <ainame>.

enemysightcorpse <ainame>

for NPC only. This event is called when the NPC first sights the corpse of an enemy NPC whose ainame matches <ainame>.

friendlysightcorpse

for NPC only. This event is called the first time the NPC sees a corpse of a friendly NPC.

enemydead

for NPC only. This event is called when the NPC's current enemy dies.

bulletimpact

for NPC only. This event is called when a bullet impact is seen or heard by the NPC.

attacksound

for NPC only. This event is called when the NPC fires a weapon.

bulletimpactsound

for NPC only. This event is called when the NPC first hears the bullet impact and is starting to investigate.

inspectbulletstart <ainame>

for NPC only. This event is called when the NPC starts to investigate a bullet impact caused by the entity whose ainame matches <ainame>.

inspectbulletend <ainame>

for NPC only. This event is called when the NPC reaches the location of the bullet fired by the entity whose ainame matches <ainame>.

inspectsoundstart <ainame>

for NPC only. This event is called when the NPC starts to investigate a weapon fired by the entity whose ainame matches <ainame>.

inspectsoundend <ainame>

for NPC only. This event is called when the NPC reaches the location of the weapon fired by the entity whose ainame matches <ainame>.

inspectbodystart <ainame>

for NPC only. This event is called when the NPC starts to go and investigate the corpse of a friendly NPC whose ainame matches <ainame>. Only an NPC with the death remove flag set to off will be invesigated.

inspectbodyend <ainame>

for NPC only. This event is called when the NPC reaches the corpse of a friendly NPC whose ainame matches <ainame>.

inspectfriendlycombatstart

for NPC only. This event is called when the NPC starts to investigate a friendly NPC who is engaged in combat.

statechange <before> <after>

for NPC only. This event is called when the NPC changes it's action state from <before> to <after>. The action states of an NPC are as follows :

  • relaxed
  • alert
  • attack
  • goto
  • aigoto

meleeattack

for NPC only. This event is called just before the NPC starts a melee attack.

farattack

for NPC only. This event is called just before the NPC starts a far (weapon) attack.

If the script block for the entity does not have an event block defined for an event, then when that event occurs, nothing scripting wise will happen. An entity does not need script event blocks for all events that can happen to it.

 

Return to Home Page