vfig on 6/1/2023 at 22:18
over in discord, diamondvehicle had a patrol path that went past a location both on the way out and the way back. they had used a TrolPausePt on the way out, but—because that just sets up an AIWatchObj link, which is proximity triggered—their AI was pausing both on the way out and the way back. so they were asking how to get a patrolling AI to perform an action not by proximity, but only when reaching a specific patrol point.
here is a simple squirrel script that enables that sort of thing. when put on an AI, it makes the AI send TurnOn to every patrol point as it reaches it:
Code:
/* Put this script on a patrolling AI. Whenever it reaches
a patrol point during its patrol, it will send TurnOn to that
patrol point. Then you can do things like, for example:
- put the `TrapRelay` script on a patrol point, and then it will
work like a RelayTrap, firing when the AI reaches it.
- or put the `TrapConverse` script on a patrol point, and a
Conversation property, and then that conversation will run
when the AI reaches the point.
*/
class ActivatePatrolPt extends SqRootScript {
function OnPatrolPoint()
{
SendMessage(message().patrolObj, "TurnOn");
}
}
and here is (
https://www.dropbox.com/s/d9bkh85qelmmawm/test_activatepatrolpt.zip?dl=1) a simple demo mission showing it in action. in this demo, two patrol points have the TrapRelay script on them, one with Trap Control Flags: Invert, and CD linked to a streetlamp, so that it turns on and off as the AI reaches them. a third patrol point has the TrapConverse script and a Conversation property to make the AI play a voice line and do a motion before resuming their patrol.