Jump to content
Sign in to follow this  
bull_a

Return all ATM objects/positions on map

Recommended Posts

Hi all,

 

I've had a quick search on the forums and couldn't find what I was looking for. I'm trying to create an array of "Land_Atm_01_F" objects which I can create markers for on the map.

 

Code:

_worldRadius = worldSize / 2;
_worldCenter = [_worldRadius,_worldRadius,0];
_atmObjects = nearestObjects [_worldCenter,["Land_Atm_01_F","Land_Atm_02_F"],_worldRadius];

_atmObjects; // return

At The Moment (excuse the pun) the function is only returning an empty array. When I position a player and look at an ATM the cursorTarget returns nil. I'm struggling to understand why this is happening, so if anyone can shed light on the situation I would be grateful.

 

Regards,

 

Bull

Share this post


Link to post
Share on other sites

Here is thread from this forum, that might help you.

 

https://forums.bistudio.com/topic/163142-fuel-gas-station-disable/

 

The thema was how to disable all gas stations. Nimrod_Z provided the solution. The script below is from the linked thread. It returns all the positions of " Land_fs_feed_F" on the map.

/*
put function in init file then execute with:  call getFuelpumps;
*/
getFuelpumps = 
{
	_pos = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition");

	_blds=nearestobjects [_pos,["Land_fs_feed_F"], 20000];
	_ary=[];
	{_ary=_ary+[getpos _x]} foreach _blds;
	hint str _ary;
	copyToClipboard str _ary;  
};

Regards

 

Seed

Share this post


Link to post
Share on other sites

ATM objects likely do not have a class, which means you can't search for them by class name.

It is possible to script a search for all classless objects, then filter each object by checking if the string of its object model contains the name you want, but it is slow.

_classlessObjects = nearestObjects [_pos, [], _radius];
if (str _object find " atm_" > 0)
then "_object is an atm";

On a large map like Altis, using nearObjects with such a large radius to return all objects on the map will lock up Arma for a very long time.

Share this post


Link to post
Share on other sites

I don't know what's the technical term for it, but "ATMs aren't that kind of objects". They're like trees, bees, and footprints.

 

The class name filter in nearestobjects won't return anything, and for the same reason cursortarget doesn't detect them.

You can only find their ID and model name "123456: atm_01_f.p3d"

 

So basically you need to go through every single object in the map to find them.

_worldRadius = worldSize / 2;
_worldCenter = [_worldRadius,_worldRadius,0];
_atmObjects = [];
{ 
   if (str _x find ": atm_" > -1) then { _atmObjects pushback _x };
} foreach (nearestObjects [_worldCenter, [], _worldRadius]);

This will take ages to run. Instead, you should find their positions beforehand and store a fixed array of them in your mission.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks all,

 

I was hoping this wouldn't be the case, but I was starting to think that the ATM's were "landscape" objects. Performance is not an issue as it is a script ran once in Pre-Init (just means higher load on the server at the start, along with a slower loading time, not really important atm) 

 

 

Sucks that not all world objects are standardise  :(

 

Thanks for the help,

 

 

Bull

Share this post


Link to post
Share on other sites

One more thing. Searching with _worldRadius around the centre won't cover the corners of the map. You need to use a radius of _worldRadius * 2^0.5 to reach the corners.

Share this post


Link to post
Share on other sites

Hello.

 

I created a script which can return if you are looking at an ATM, it was the best compromise I could come up with for my mission.

_array1 = lineIntersectsWith [eyePos player, ATLtoASL screenToWorld [0.5,0.5]];
if (count _array1 < 1) exitWith {};
_obj = _array1 select ((count _array1) - 1);
_objA = toArray str(_obj);
_objA deleteRange [0, (count _objA) - 12];
if ((toString _objA) in ["atm_01_f.p3d","atm_02_f.p3d"] and player distance _obj < 3) then { execVM "Dialogs\Menu_ATM.sqf" };

I call this script when the player presses the general action key assigned in my mission.

 

Hope this helps.

 

EDIT: A new command has been introduced in the DEV branch called cursorObject which does return map objects such as ATMs.

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  

×