Firstly we'll look at NPCs. Most NPC behavior is handled by mission director, with NPC_Staff covering the crew type NPCs. Within NPC_Staff scripts are assigned to characters when you give them the 'work here' command.
Player assigned NPC default AI
Engineers get assigned Engineer.ai
Defense Officers get fight.station.player regardless of where they work
Captains get assigned player.default.
fight.station.player only operates with subordinates which as far as I know only a station can have.
player.default waits for player orders and if in squad follows player from zone to zone, otherwise does nothing.
How NPCs respond to events.
NPC response is handled by an interrupt system. An interrupt is controlled by a handler. A handler is comprised of a set of conditions plus a set of actions. A very simple interrupt is like this
Code: Select all
<handler>
<conditions>
<event_object_attacked object="player.primaryship"/>
</conditions>
<actions>
<show_help force="true" custom="'Player attacked'" />
</actions>
</handler>
Global and Local Interrupts
The preceeding interrupt only works if whatever script its put in is running at the time. Should the entity switch to a different script the behavior is lost. Sometimes you want the same behavior to persist over a wide range of scripts, like responding to an attack. This is what the interrupt.attack script is meant to handle.
The Global Interrupt structure is like this
Code: Select all
<interrupt>
<library>
<handler name="idostuff">
<conditions>
stuff
</conditions>
<actions>
more stuff
</actions>
</conditions>
</handler>
</library>
</interrupt>
Code: Select all
<handler ref="idostuff" />
player.default does not include the handler for being attacked, so doesn't respond. It looks like ships subordinate to a defense manager on board a station would start acting like real ships.
I added the basic attack handler reference to player.default and my ships did indeed start responding to attacks, but the error log uidata gives warning messages about too many interrupt handlers defined in the script.
This is basically where I am now. The more handlers we can use, the better the AI will be able to respond to situations, but the basic player squad AI has so many of them tied up in waiting for commands. This really limits what we can do.