Home   Help Search Login Register  

Author Topic: Flare sentry script...  (Read 464 times)

0 Members and 2 Guests are viewing this topic.

McFly

  • Guest
Flare sentry script...
« on: 27 Oct 2003, 03:41:39 »
I'm making a mission with multiple sentry checkpoints which can alert nearby vehicles to an enemy's presence by firing a flare.

I've got the flare intermittenly working.  The problem is, if you surprise the sentry (ex: firing from behind a nearby hill without being seen), he'll forget to fire the flare and simply go to engage you.

I use a synchronized trigger (west detected by east) to activate the script.  So, obviously, he shouldn't have to see you to fire the flare (he can hear you).

Here is my script:

Code: [Select]
_unit = _this select 0
_flaretype = _this select 1

_unit setcombatmode "blue"

? _unit ammo _flaretype == 0 : _unit addmagazine _flaretype

@ unitready _unit
_unit fire ["GrenadesMuzzle", _flaretype]
@ unitready _unit

_unit setcombatmode "yellow"

exit

For some reason, he'll occasionally act like he's about to fire (he begins to aim upwards), then he'll stop, reload, and start firing bullets in your direction (if you're visible, otherwise he just drops to the ground and waits for you).

It's like he thinks "screw it, I can handle this myself" and skips the firing action.  Why isn't he waiting until he actually fires the flare before returning to combat mode yellow (engage at will)?  Why isn't he stuck on combat mode blue (never fire) until he fires the flare?

Unnamed

  • Guest
Re:Flare sentry script...
« Reply #1 on: 27 Oct 2003, 05:56:18 »
One problem is Setcombatmode, it takes a couple of seconds to kick in. By the time it does, your guy is firing or moving to engage.

You could try setting his combatmode to Blue with a suitable pause, before the detect trigger is tripped?

Perhaps a better way if you dont have to many units to detect in one go, would be to get the list of detected units from the trigger. Then set them to captive True, using foreach in your detected script. Then back to captive False, once you have launched the flare.

Something like:

Code: [Select]
{_x setcaptive True} ForEach (List  YourTrigger)

@ unitready _unit
_unit fire ["GrenadesMuzzle", _flaretype]
@ unitready _unit

{_x setcaptive False} ForEach (List  YourTrigger)

I think SetCaptive works almost immediately?

McFly

  • Guest
Re:Flare sentry script...
« Reply #2 on: 27 Oct 2003, 07:59:33 »
Ah hah!  I (somewhat) solved it.

Yours was a good idea, Unnamed, but the problem persisted - the sentry would skip the command to fire a flare and simply exit the script.

I realized it wasn't working because the AI won't pause under any circumstance while reloading a magazine.  He'll start the script, begin to load a flare, and wind up exiting the script before he's ready to receive the fire command.

Thus, the only way around that peculiar phenomenon was by adding the correct flares to his init box from the get-go.  He'll initialize with a locked and loaded weapon then, and the script will work.

OFP AI gives me a headache  >:(