More AI Pack Trigger Examples
by Gary Haussmann · 03/24/2006 (6:51 am) · 8 comments
Here is a short set of examples from the "test" mission I'm using to debug and try out the various triggers for use in the "AI Pack" I'm working on with Phil and Dee. In case you haven't read my previous blog entries:
1. This stuff isn't AI at all, but will hopefully make the real AI code easier to use, by allowing you to synchronize the AI to specific events in the game.
2. The expectation is that you can get maybe 80% of the common FPS interactivity done without writing script code, although you may have to edit or copy/add datablocks.
3. No, I don't know when the AI pack will be ready.
OK, so the scenario is your typical fantasy setup, where you need to bind some evil demon dude (or whatever) and then shoot him with exploding crossbow bolts. In this scenario you simply need to light two torches and the evil dude will appear, at which point you kill him. Yay.
So first we slap some triggers at the "front" door to the castle you must enter. The overall effect here is that:
1. When you approach the door, you get a message telling you how to open it.
2. When you operate the door, the two parts of the door slide open.

How this is done: when you enter the volume near the door, the AIVolumeTrigger senses your proximity and sets off an AIEnvironmentEffect trigger. The AIEnvironmentEffect does all the various special effects; in this case, it sends an informative message to you explaining how to open the door (hit 'f').
If you hit 'f' you basically try to set off all AIOperableTrigger objects by sending a message to them. If you are close enough to the AIOperableTrigger and are on the correct team, the AIOperableTrigger will go off. In this case, the AIOperableTrigger fires two AIMovableShapeTrigger objects, which do nothing more than move a TSShape around. Thus the moving TSShapes provide for the "sliding door" effect.
Next we need to "bind" the evil dude. All that is required is to light two torches, simply by running up to them and operating them (the 'f' key again).

How this is done: really all we have is the AIOperableTrigger again, hooked up to an AIEnvironmentalEffect that creates a particle emitter. Not too exciting. However, we also hook up to an AIMultiSourceTrigger, which takes multiple triggers as input and goes off when all the inputs have fired, producing the final effect...
After both torches have been lit, the multisource goes off, creating the evil dude and using an AIEnvironmentalEffect to generate some chat text. Super scary!

Finally, I had this extra screenshot showing some triggers in the editor. The setup shown in the screenshot below is a chest that, when destroyed, explodes and spawns multiple orcs. This is done using the AIDestructableShapeTrigger. I expect the AIDestructableShapeTrigger will be used to make hundreds, nay thousands of destructable crates.

So anyway, that's the current state of the triggers. I need to clean up fields for each trigger object and work on the way trigger names are resolved. Currently, each trigger has to have a globally unique name, which is a little annoying if you need to copy/paste a dozen sliding doors. The plan is to require trigger names to be unique only within a simgroup, so that by grouping triggers appropriately you can re-use the same names over and over. Then there will be more integration with the rest of the AI pack, primarily with dynamically building different AI brains when characters spawn and enabling triggers to send messages to AI entities.
1. This stuff isn't AI at all, but will hopefully make the real AI code easier to use, by allowing you to synchronize the AI to specific events in the game.
2. The expectation is that you can get maybe 80% of the common FPS interactivity done without writing script code, although you may have to edit or copy/add datablocks.
3. No, I don't know when the AI pack will be ready.
OK, so the scenario is your typical fantasy setup, where you need to bind some evil demon dude (or whatever) and then shoot him with exploding crossbow bolts. In this scenario you simply need to light two torches and the evil dude will appear, at which point you kill him. Yay.
So first we slap some triggers at the "front" door to the castle you must enter. The overall effect here is that:
1. When you approach the door, you get a message telling you how to open it.
2. When you operate the door, the two parts of the door slide open.

How this is done: when you enter the volume near the door, the AIVolumeTrigger senses your proximity and sets off an AIEnvironmentEffect trigger. The AIEnvironmentEffect does all the various special effects; in this case, it sends an informative message to you explaining how to open the door (hit 'f').
If you hit 'f' you basically try to set off all AIOperableTrigger objects by sending a message to them. If you are close enough to the AIOperableTrigger and are on the correct team, the AIOperableTrigger will go off. In this case, the AIOperableTrigger fires two AIMovableShapeTrigger objects, which do nothing more than move a TSShape around. Thus the moving TSShapes provide for the "sliding door" effect.
Next we need to "bind" the evil dude. All that is required is to light two torches, simply by running up to them and operating them (the 'f' key again).

How this is done: really all we have is the AIOperableTrigger again, hooked up to an AIEnvironmentalEffect that creates a particle emitter. Not too exciting. However, we also hook up to an AIMultiSourceTrigger, which takes multiple triggers as input and goes off when all the inputs have fired, producing the final effect...
After both torches have been lit, the multisource goes off, creating the evil dude and using an AIEnvironmentalEffect to generate some chat text. Super scary!

Finally, I had this extra screenshot showing some triggers in the editor. The setup shown in the screenshot below is a chest that, when destroyed, explodes and spawns multiple orcs. This is done using the AIDestructableShapeTrigger. I expect the AIDestructableShapeTrigger will be used to make hundreds, nay thousands of destructable crates.

So anyway, that's the current state of the triggers. I need to clean up fields for each trigger object and work on the way trigger names are resolved. Currently, each trigger has to have a globally unique name, which is a little annoying if you need to copy/paste a dozen sliding doors. The plan is to require trigger names to be unique only within a simgroup, so that by grouping triggers appropriately you can re-use the same names over and over. Then there will be more integration with the rest of the AI pack, primarily with dynamically building different AI brains when characters spawn and enabling triggers to send messages to AI entities.
About the author
#2
03/24/2006 (7:06 am)
Awesome. Pure awesome.
#3
03/24/2006 (7:42 am)
Excellent stuff guys :)
#4
03/24/2006 (11:54 am)
Are the AIMovableShapeTriggers coded in source using the triggers Tick/Time functions?
#5
03/26/2006 (3:37 pm)
will the AIPack be integrated with the TLK?
#6
John
03/27/2006 (3:23 pm)
Question: what if this is single player action and one of two triggers is set, but player wants to exit game for later. Have you guys thougt about saving trigger info to file (it would be nice)?John
#7
03/28/2006 (12:07 am)
#8
05/01/2006 (12:51 pm)
there any new information on the Ai pack. Is it coming out. Thank you. 
Torque 3D Owner Tom Perry