Jump to content
Sign in to follow this  
buster0083

Causing AI to attack a (player) civilian

Recommended Posts

I'm working on a resistance-esque mission and have started the player as a Civilian rather than de-equipping a BLUFOR soldier and having OPFOR shoot on sight. What I'd ideally like to do would be to have the AI open fire if they see a weapon, but I could settle for a trigger that makes them unfriendly to me as soon as I open fire. As it stands, they still don't respond. Could anyone offer a suggestion?

It would be preferable if the AI wouldn't hose down AI civilians after they turn hostile to the Civilian player but that's not crucial.

Thanks

Share this post


Link to post
Share on other sites

Why don't you simply change that "civilian" to Blufor when he's seen with a weapon drawn?

Your script could look roughly like this:

if (!isServer) exitWith {};

while {alive undercoverguy} do {
 waitUntil {currentWeapon undercoverguy != ""};
 _list = (position undercoverguy) nearEntities [["Man"],100];
 _spotted = { (_x knowsAbout undercoverguy) > 3 } count _list;
 if ( _spotted > 0 ) then {
   undercoverguy joinSilent someblueforguy;
 }

 sleep 0.5;
};

Share this post


Link to post
Share on other sites

while {true} do {
waitUntil {currentWeapon dude != ""};
dude addRating -11111111111;
waitUntil {currentWeapon dude == ""};
dude addRating 111111111111;
sleep 0.5;
};

Should work but untested.

Share this post


Link to post
Share on other sites
I'm working on a resistance-esque mission and have started the player as a Civilian rather than de-equipping a BLUFOR soldier and having OPFOR shoot on sight.

You can use a BLUFOR solide rand set him as captive, i.e.

_unit setCaptive true;

Then, when you want to declare it open season, use

_unit SetCaptive false;

and he will be treated like regular blufor.

@Tajin

IIRC joinSilent requires local argument, so it you run this on a server only, it will not work. It has to run on the client in question. The first if would need to be replaced with

if (!local undercoverguy) exitWith {};

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

Try using setFriend with a 0 instead of a 1 in the relation between the AIs side and Civilians: http://www.ofpec.com/COMREF/index.php

setFriend will, AFAIR, not work during the mission. See the BIKI.

Share this post


Link to post
Share on other sites
The first if would need to be replaced with

if (!local undercoverguy) exitWith {};

That wouldn't work well, the knowsAbout command needs the AI to be local to get accurate results.

Though I was pretty sure, "join" works globally. Either way, just use setcaptive instead.

Share this post


Link to post
Share on other sites

Thanks guys, some good stuff in here - this must surely be one of the most helpful forums I've been on!

Share this post


Link to post
Share on other sites
That wouldn't work well, the knowsAbout command needs the AI to be local to get accurate results.

It should work on the clients, as the argument type is global.

Though I was pretty sure, "join" works globally. Either way, just use setcaptive instead.

join and joinSilent both need local arguments, according to the Biki. Might have changed in the meantime, though :)

Share this post


Link to post
Share on other sites

True, "knowsAbout" does work on clients but it only gives accurate results when you call it where the unit (AI) is local. Hence it is better to run it on the server. ;)

Share this post


Link to post
Share on other sites

Alwarren,

I'm struggling to get a trigger to work to change the setCaptive state - if I use a radio trigger the concept works perfectly, but I've tried a few combinations of the other suggestions in this thread to make the setCaptive become false once the player is carrying a weapon but with no success. How would you go about it? Cheers

Share this post


Link to post
Share on other sites

Pardon me raising a thread from the dead, but still struggling with this one. As a bit of a mix and match of all the suggestions, I'm using this script:

while {true} do {
waitUntil {currentWeapon Resis != ""};
Resis setCaptive 0;
sleep 0.1;
waitUntil {currentWeapon Resis == ""};
Resis setCaptive 1;
sleep 0.5;
}; 

The trouble seems to be I can't get the check to loop. If I spawn the player with no weapon and "waitUntil {currentWeapon Resis == ""}; Resis setCaptive 1;" it works fine; same goes if I do it the other way with a weapon. But using the above to try and have a continuing check doesn't seem to work.

Any pointers on what I'm doing wrong?

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  

×