Jump to content
Luft08

How do I get a count of mines in a given area?

Recommended Posts

On my next mission I wish to have the players lay down a mine field as a task. Specifically, I have loaded 30 APERSBoundingMine_Range_Mag into a vehicle and I want the players to place at least 20 mines within a 50 meter area that I marked on the map.

 

How do I get a count of the mines that have been deployed within that area. obviously I don't want to count the mines that have not been deployed.

 

Thanks.

Share this post


Link to post
Share on other sites

What about performing a count using the ”fired” event handler?

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired

Share this post


Link to post
Share on other sites

@Luft08, use this code:

#define MARKER "markerName"

private _markerSize = getMarkerSize MARKER;

private _radius = if ((markerShape MARKER) == "RECTANGLE") then {
    sqrt ((_markerSize select 0) ^ 2 + (_markerSize select 1) ^ 2);
} else { selectMax _markerSize; };

private _minesCount = { _x inArea MARKER } count ((getMarkerPos MARKER) nearObjects ["APERSBoundingMine_Range_Ammo", _radius]);

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Or even:

waitUntil {count (allMines select {(_x distance (getMarkerPos _marker)) < 50}) >= 20};

With _marker being the name of the marker you used.

  • Like 1

Share this post


Link to post
Share on other sites

or in marker area (you can place a marker area and set it invisible (editor or _marker setMarkerAlpha 0) si you don't want to see it on map:
waitUntil {sleep 1; {_x inArea _marker} count allMines >= 20};

  • Like 2

Share this post


Link to post
Share on other sites

I’ve had some trouble with the allMines command, since it seems to not find all kinds of mines. It may work for this mine class, but something to bear in mind if you change the mine class...

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, engima said:

I’ve had some trouble with the allMines command, since it seems to not find all kinds of mines. It may work for this mine class, but something to bear in mind if you change the mine class...

allMines are an array of all activated mines, not deactivated.

Share this post


Link to post
Share on other sites

I would really like to use this to complete a task to mine a trail (UNSUNG, MP, dedicated), but I am unfamiliar with waitUntil. This would go into initServer.sqf?

 

When I try:

waitUntil {sleep 1; {_x inArea trailmarker} count allMines >= 4};

using an ellipse named trailmarker, I get "Error Undefined variable in expression: trailmarker"

 

What am I missing here?

Share this post


Link to post
Share on other sites

Marker names are strings. It needs to be "trailmarker".

 

And if you're unfamiliar with a command - https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands

 

But waitUntil can go anywhere so long as it's inside a spawned/execVM'ed script, basically. This goes into far more detail if you wanted to read into it - https://community.bistudio.com/wiki/Scheduler

  • Thanks 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

×