Home   Help Search Login Register  

Author Topic: Arresting AI  (Read 2681 times)

0 Members and 1 Guest are viewing this topic.

Offline Aske

  • Members
  • *
Arresting AI
« 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?

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Arresting AI
« Reply #1 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.
Xbox Rocks

Offline Aske

  • Members
  • *
Re: Arresting AI
« Reply #2 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.
« Last Edit: 24 Dec 2009, 13:33:07 by Aske »

Offline Morts

  • Members
  • *
Re: Arresting AI
« Reply #3 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?