Jump to content
Sign in to follow this  
DChristy87

Script for AI to fire upon individual unit that leaves trigger area?

Recommended Posts

I've been at this for days with no results...

I'm attempting to create a POW camp where players will take the role of a POW. When a POW leaves the trigger area, I want any witnessing AI to fire upon the unit that walks out of said trigger area. I need the AI to keep all other POW's as setcaptive though.

I've managed to get the basics down with a simple trigger activated by blufor being present and on act.

p1 setcaptive true;

and on dea

p1 setcaptive false;

(p1 being individual prisoner played by me).

However, this does not help, if there are multiple prisoners (Blufor) they will not fire at me if I walk out of the camp as there are other blufor sitting in the camp keeping my status as setcaptive.

I'm sorry, I'm such a noob :( But we all have to start somewhere right? If someone would be so kind to throw some links my way that could break it down barnie style for me or even guide me themselves, it would be GREATLY appreciated! Thanks in advance!

Share this post


Link to post
Share on other sites

Try using the synchronize "chain looking things" and sync yourself with the trigger.

Share this post


Link to post
Share on other sites

Try this (untested):

- Condition

count thisList != count oldList

- Activation

oldList = oldList - thisList; {_x setCaptive false} forEach oldList; {_x setCaptive true} forEach thisList; oldList = thisList;

You might also have to put this in an init-Line somewhere:

oldList = [];

Share this post


Link to post
Share on other sites

Twin,

Thanks but that wasn't the problem. I've had myself and/or enemy AI synced with the trigger. That was what made my setcaptive true/false work. However, it still gave me the problem of not being shot when other blufor were present.

Tajin,

Thanks for your help, I'll be trying this out tonight when I get home from work! I very much appreciate it! I also found a link (in the same post where you gave the link for all the commands) that had videos by armaidiot explaining how to change factions combining a new module and a trigger. I'll be trying both out. Again, thanks for your help. I'll probably update with my progress, not that anyone cares, but maybe someone else will need the same thing some day.

Share this post


Link to post
Share on other sites

im trying to get this to work for me. I have entered the code(s). It seems to go into captive mode fine, i dont get shot. However, i cannot get it to get out of captive mode once outside the target area.

I have tried setting the DEA using the same code but reversed setcaptive lines.

oldList = oldList - thisList; {_x setCaptive true} forEach oldList; {_x setCaptive false} forEach thisList; oldList = thisList;  

Ive also tried basic as in the

ACT

p1 setcaptive true; hint "on";

DEA

p1 setcaptive false; hint "off";

when i am in the trigger then hint says, off,on,off,on,off,on but i can never get any combo to work.

Share this post


Link to post
Share on other sites

I've been working at this for a while, still trying to figure it out. I tried armaidiots video on the switch factions module and it doesn't seem to work with the present or not present condition in the synced trigger.

Share this post


Link to post
Share on other sites

I also just had a look at this and I actually got different results in Alpha than OA.

If someone else could check something as I can't tonight.

place a trigger blufor repeating

cond round (time %1)==1

on act hint str thislist

Place a few blufor in the trigger

What should happen is that it should give a repeating read out of blufor units in the trigger

When I tested it I got the list but then it switched to [] empty list.

I don't know if it's a bug or that I may have just corrupted the mission some how.

I can't test right now, but if it is coming up empty then there is serious issue.

Also is hint silent mine isn't making a sound any more.

Share this post


Link to post
Share on other sites
I also just had a look at this and I actually got different results in Alpha than OA.

If someone else could check something as I can't tonight.

place a trigger blufor repeating

cond round (time %1)==1

on act hint str thislist

Place a few blufor in the trigger

What should happen is that it should give a repeating read out of blufor units in the trigger

When I tested it I got the list but then it switched to [] empty list.

I don't know if it's a bug or that I may have just corrupted the mission some how.

I can't test right now, but if it is coming up empty then there is serious issue.

Also is hint silent mine isn't making a sound any more.

Seems to work fine, put 10 units in; all seemed to be listed.

As to OP just tested setcaptive and couldn't get him to go false for anything. However a trigger with:

Onact

east setfriend [WEST,1]; west setfriend [EAST,1];

ondea

east setfriend [WEST,0]; west setfriend [EAST,0];

Seemed to work fine, but if your just wanted to turn one person at a time as they leave the trigger it won't work.

Share this post


Link to post
Share on other sites

Oooh, yeah. I'm trying to create it for 1 individual at a time. I've managed to have it work for myself. However, I want it so multiple POWs are in camp and AI engages any POWs that leave the specified area. It's proving to be very difficult.

Share this post


Link to post
Share on other sites

How did you get them set back to false, I tried it on deactivation as well as a complete different trigger, and external script couldn't get it.

Share this post


Link to post
Share on other sites

Thanks Camaris, something must have screwed up.

I have just realised When you use setcaptive he becomes a civilian so of course the trigger reports []

---------- Post added at 01:43 AM ---------- Previous post was at 01:25 AM ----------

This seems to work.

trigger

Blufor present repeating

name trigger intrig

cond this

on act

{_x setcaptive TRUE;null=[_x] spawn {waituntil {(_this select 0) distance intrig >20};(_this select 0) setcaptive FALSE} } foreach thislist;

Share this post


Link to post
Share on other sites

that works; why does it work with distance away from spawn but not outside of a trigger?

Share this post


Link to post
Share on other sites

because when it's out of the trigger the trigger has no knowledge about it. it's not in thislist.

The trigger will only deactivate when the last unit leaves.

Also if you use blufor present to set them captive that in turn makes them civilian so the trigger can no longer even see those in the trigger as they're no longer blufor.

Share this post


Link to post
Share on other sites

F2K Sel,

BEAUTIFUL, it works! Thanks so much for your help! Thank you to everyone else as well, I've learned a lot from all of you. Now that I have something to work with, I can finally start moving forward. Thanks again!

Share this post


Link to post
Share on other sites

im having the issue of delay. If i have OpFor units guarding me, they detect me before the code runs. Should i run this in the init file maybe?

Share this post


Link to post
Share on other sites

For temporary purposes I just turned my guards starting view in the opposite direction of me. I tried sleep 1; but that didn't work. Let me know if the init file works for you though.

Share this post


Link to post
Share on other sites

Yes the problem is that a trigger only runs about every half a second so AI have a chance to fire on units before they become captive.

if you place a gamelogic this should set them captive much quicker. However I can't test right now so base class of the unit may be wrong.

{_x setcaptive true} foreach nearestobjects [getpos this,["B_Soldier_base_F"],50];

Share this post


Link to post
Share on other sites

This is no longer working, anybody have any ideas? maybe something needs to be altered for the beta?

Share this post


Link to post
Share on other sites

Tried the group change thing I posted on armaholic? Seemed to work for me in the editor.

Start the players grouped with a higher rank opfor unit that isn't there. Then change their group when you want them attackable.

escape = createGroup blufor;
[player] joinSilent escape;

Share this post


Link to post
Share on other sites

Oh, sorry I didn't see your reply on armaholic before I replied to this post. I'll try that out when I get home. Thank you for your reply :)

Share this post


Link to post
Share on other sites

The original script still works but if you were to use the second post {_x setcaptive true} foreach nearestobjects [getpos this,["B_Soldier_base_F"],50]; it fails.

The reason is the trigger is set to blufor but when you use setcaptive i makes the are units into civiliana as mentioned before.

This stops the blufor trigger assigning them the code and they never get unset again

A script may be better.

first in a game logic . the logic will be the center of the area

men = nearestobjects [getpos this,["B_Soldier_base_F"],30];null=[men,this,30] execvm "limits.sqf";

that will find blufor units in a radius of 30 meters and assign them the script.

save as "limits.sqf"

_units  = _this select 0;//units captive
_pos  = _this select 1;// game logic position
_dist = _this select 2; // safe area 

{
 removeallweapons _x; 
 _x allowfleeing 0;
_x setcaptive true;

[_x,_pos,_dist] spawn {waituntil {(_this select 0) distance  ((_this select 1)) > (_this select 2)};(_this select 0) setcaptive FALSE;hint "run" }; 

} foreach _units;

Share this post


Link to post
Share on other sites

So with multiple playable characters set to spawn within the logic area (30), do I have to put something special in each of the units init. field? Or do I need to name each of the playable units and add those names to a list somewhere? Also, is there anything I can do about surround AI "sleeping" so they don't load before they're able to understand bluefor is actually captive?

---------- Post added at 13:49 ---------- Previous post was at 13:46 ----------

Also, if a player dies and I have the respawn set to put them back to the Captive zone, will they be considered captive again?

---------- Post added at 13:51 ---------- Previous post was at 13:49 ----------

Aaaaand...Once you leave the allow range (30) and become a fugitive and decide to return within the distance of 30, will they consider you captive again or is a one time deal?

Share this post


Link to post
Share on other sites

Why is there respawn in a prison break scenario? :)

The 30m thing in the above example looks like it's a one time thing.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×