Jump to content
iV - Ghost

Check if vehicles are inside radius

Recommended Posts

How can I check if vehicles from a defined type (O_APC_Tracked_02_AA_F) are inside a radius around a position?

This should be a condition for a waitUntil loop.

Share this post


Link to post
Share on other sites

But I don't have a area because my position is a icon marker with no radius.

I could use a area marker and inArea but a icon marker look better in this case.

And with nearestObject I can only detect one vehicle.

Share this post


Link to post
Share on other sites

You're going to have to be a little clearer. Do you know the radius you want to check around the position?

Share this post


Link to post
Share on other sites

The radius could be 50m. But it is not important.

This is a working way for detecting only 1 vehicle:

// TRIGGER END
waitUntil {

    sleep 1;
    !alive (getMarkerPos "AA_Mike26_1" nearestObject "O_APC_Tracked_02_AA_F");

};

 

But I need to detect all of the given kind.

 

 

 

EDIT

Maybe something like this:

(getMarkerPos "AA_Mike26_1" nearSupplies 50 select {_x isKindOf "O_APC_Tracked_02_AA_F"}) count vehicle == 0;

 

Share this post


Link to post
Share on other sites
vehicles inAreaArray [getmarkerpos "myiconmarker", 50, 50, 0, false, -1] select {(typeOf _x) isEqualto "O_APC_Tracked_02_AA_F"};

Will return all the Tigrii (little known fact, plural of Tigris) within 50 of your marker. Adjust the marker name to what yours is.

Share this post


Link to post
Share on other sites

In a waitUntil.

 

waitUntil {count (vehicles inAreaArray [getmarkerpos "myiconmarker", 50, 50, 0, false, -1] select {(typeOf _x) isEqualto "O_APC_Tracked_02_AA_F") > 0};

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

OK. Small syntax fail in your version. Should be:

count (vehicles inAreaArray [getmarkerpos "AA_Mike26_1", 50, 50, 0, false, -1] select {(typeOf _x) isEqualto "O_APC_Tracked_02_AA_F"}) == 0;

 

But this detected all "O_APC_Tracked_02_AA_F" in the area.

How can I select only the alive ones?

Share this post


Link to post
Share on other sites
10 minutes ago, iV - Ghost said:

OK. Small syntax fail in your version. Should be:


count (vehicles inAreaArray [getmarkerpos "AA_Mike26_1", 50, 50, 0, false, -1] select {(typeOf _x) isEqualto "O_APC_Tracked_02_AA_F"}) == 0;

 

But this detected all "O_APC_Tracked_02_AA_F" in the area.

How can I select only the alive ones?

count (vehicles inAreaArray [getmarkerpos "AA_Mike26_1", 50, 50, 0, false, -1] select {((typeOf _x) isEqualto "O_APC_Tracked_02_AA_F") and alive _x} == 0;

 

Share this post


Link to post
Share on other sites
count (vehicles inAreaArray [getmarkerpos "AA_Mike26_1", 50, 50, 0, false, -1] select {(typeOf _x) isEqualto "O_APC_Tracked_02_AA_F"} and alive _x) == 0;

Error: No defined variable in _x

Share this post


Link to post
Share on other sites
(getMarkerPos "AA_Mike26_1") nearEntities ["O_APC_Tracked_02_AA_F", 50];
vehicles inAreaArray [getMarkerPos "AA_Mike26_1", 50, 50] select {(alive _x) and {(typeOf _x) == "O_APC_Tracked_02_AA_F"}};

 

Share this post


Link to post
Share on other sites
count (vehicles inAreaArray [getmarkerpos "AA_Mike26_1", 50, 50, 0, false, -1] select {((typeOf _x) isEqualto "O_APC_Tracked_02_AA_F") && {alive _x}}) != 0

 

But like Schatten already says nearEntities gives you better approach

  • Thanks 1

Share this post


Link to post
Share on other sites
!(((entities [["O_APC_Tracked_02_AA_F"], [], false, true]) inAreaArray "AA_Mike26_1") isEqualTo [])

you can also like this if the marker has any shape

Share this post


Link to post
Share on other sites

OK thx a lot. How would the syntax for a waitUntil condition look?

Something like this?

 

count (getmarkerpos "AA_Mike26_1" nearEntities ["O_APC_Tracked_02_AA_F", 50]) == 0;

 

Share this post


Link to post
Share on other sites

@iV - Ghost, just delete semicolon:

waitUntil {
	(count ((getMarkerPos "AA_Mike26_1") nearEntities ["O_APC_Tracked_02_AA_F", 50])) == 0
};

 

Share this post


Link to post
Share on other sites

Why you put it in brackets and let the "== 0" outside of it?

Should it not be:

waitUntil {

    sleep 1;
    count (getmarkerpos "AA_Mike26_1" nearEntities ["O_APC_Tracked_02_AA_F", 50]) == 0;

};

 

Share this post


Link to post
Share on other sites
3 minutes ago, iV - Ghost said:

Why you put it in brackets and let the "== 0" outside of it?

It's for better perception.

 

3 minutes ago, davidoss said:

As the post thema says it schould be opposite of

Yea,

waitUntil {
	(count ((getMarkerPos "AA_Mike26_1") nearEntities ["O_APC_Tracked_02_AA_F", 50])) > 0
};

 

Share this post


Link to post
Share on other sites

Perception? Better for the work of the engine?

Or for my personal perception?

Share this post


Link to post
Share on other sites
4 minutes ago, iV - Ghost said:

Better for the work of the engine?

Or for my personal perception?

The engine doesn't care about extra brackets. It's just for convenience of human perception.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

OK. Sorry for the crazy questions. I try to learn and startet few weeks ago.

I have a lot of stuff to catch up. Thx to all for the help and the explanations!

Share this post


Link to post
Share on other sites
3 minutes ago, Schatten said:

The engine doesn't care about extra brackets. It's just for convenience of human perception.


Not entirely true, few commands demand following parameters to be in brackets, like this:

systemchat str ["oy","vey"] select 1;//prints: ["oy","vey"]
systemchat str (["oy","vey"] select 1);//prints: vey

Cheers

  • Haha 1

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

×