OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Aske on 23 Dec 2009, 23:45:36

Title: Arresting AI
Post by: Aske on 23 Dec 2009, 23:45:36
Hi,
I've got my hands on a small arresting script. It looks like this:

In a trigger I put:

Code: [Select]
_captive = unitName addAction ["Capture", "capture.sqf"];
unitName setCaptive true;
removeAllWeapons unitName;
unitName disableAI "AUTOTARGET";

and in capture.sqf I put:

Code: [Select]
[unitName] joinSilent playername;

The problem is that this is supposed to be used in a multiplayer mission so I would want to whoever captures the unit to get control of him. Not just "playername".

I tried to use nearestobject to determine which blufor soldier was closest and let him get control of the captive. Something like this:

Code: [Select]
nearobj = nearestObject [captive, "SoldierWB"];

and then:

Code: [Select]
[unitName] joinSilent nearobj;

But nearobj is always the blufor unit which spawned closest to "captive" not a dynamic "whoever is closest at the moment". Any suggestions?
Title: Re: Arresting AI
Post by: hoz on 24 Dec 2009, 02:40:29
You probably need to use nearestobjects and get all the objects and stick them in an array. Then parse the array for the closest excluding the captive.
Title: Re: Arresting AI
Post by: Aske on 24 Dec 2009, 12:55:51
And how would that be done? :D

Thanks.

Edit: Solved, I just put: [unitName] joinSilent (nearestobject [unitName, "SoldierWB"]); in the mission.sqf and it seems to work. I guess in this case it looks at the closest "SoldierWB" in the same moment as you press "Capture" in the action menu.
Title: Re: Arresting AI
Post by: Morts on 20 Jun 2010, 10:44:50
Sorry to revive the thread, but is
[unitName] joinSilent (nearestobject [unitName, "SoldierWB"]);

All that goes in the .sqf or do the other two lines still go in there aswell?