Jump to content
Sign in to follow this  
super-truite

get the position of a spotted unit

Recommended Posts

Hi, do someone knows a way to get the position of an enemy unit detected by say an opfor?

I want to use this info to call in artillery on the spotted unit with commandArtilleryFire.

More precisely, let's say my observer don't move and that I centered a trigger activated by "blufor detected by opfor" on it.

How do I get the position of the enemy detected in the trigger area?

Share this post


Link to post
Share on other sites

Yep, an idea. "thislist" is an array that contains all units that are triggering a trigger. Thus, "thislist select 0" is the first unit of the array, "thislist select 1" is the second unit etc.

If you name the trigger, "SpottedUnits" for example, "list SpottedUnits" works as "thislist" and so "list SpottedUnits select 0" is the first unit "still" spotted.

So, if you wanna use an artilley script you'll have to call the artillery on the position of the first unit still triggering the trigger, thus

getpos (list SpottedUnits select 0)

returns the position of the given unit.

Share this post


Link to post
Share on other sites

Thanks a lot. It works!

So I put a mortar named "mortar" and a trigger centered on my observer named "trig" activated by Blufor present detected by opfor and on activation: _nul= [mortar,trig] execVM "mortar.sqf".

in mortar.sqf I put:

if (isServer) then
{
_mortar = _this select 0;
_trigger = _this select 1;
for [{_l = 0},{_l < 3},{_l = _l + 1}] do
{
_mortar  commandArtilleryFire [ getpos (list _trigger select 0),"8Rnd_82mm_Mo_shells", 1];
sleep 3;
};

};

But now I would like to improve this, so that I can aim at the second target in the list, the 3rd ect.

I can repeat what I did with _trigger select 1, _trigger select 2 ... But how can I do this in a loop?

I tried this :

if (isServer) then
{
_mortar = _this select 0;
_trigger = _this select 1;

for [{_k = 0},{_k < count(_trigger)},{_k = _k + 1}] do
{
for [{_l = 0},{_l < 3},{_l = _l + 1}] do
{
_mortar  commandArtilleryFire [ getpos (list _trigger select k),"8Rnd_82mm_Mo_shells", 1];
sleep 3;
};
}
};

, but apparently it is forbidden to access the k-th element of an array like this: (list _trigger select k)...

Share this post


Link to post
Share on other sites

Your missing an underscore on

list _trigger select _k

or you could go for

if (isServer) then
{
_mortar = _this select 0;
_trigger = _this select 1;


{

	for [{_l = 0},{_l < 3},{_l = _l + 1}] do {
		_mortar  commandArtilleryFire [ (getPosATL _x),"8Rnd_82mm_Mo_shells", 1];
		sleep 3;
	};

} forEach list _trigger;

};

Edited by Larrow

Share this post


Link to post
Share on other sites

thank you, it's working. I will post the script when It works like I want (I still need to update the trigger list every say 10 seconds to check if new units are in the area).

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  

×