Jump to content

Recommended Posts

Hello.

Is there a command that allows to search for nearby heli pads built into maps?

 

What i am attempting to do is if a selected marker is near a military base, and a heli pad exists, then spawn an empty vehicle on that pad. Knowing a command to find a hanger could also be helpful  :)

 

Thank you for the assist as always!

Share this post


Link to post
Share on other sites

Helipads:

_pads = [0,0,0] nearobjects ["HeliH",worldsize * 10]; //returns 12 pads on altis

Hangars:

_hangars = [0,0,0] nearobjects ["Land_Hangar_F",worldsize * 10];//returns 4 hangars on altis

 

Searching with that big of a radius should be no problem if done once during mission init.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
nearestterrainobjects [player, ["house"],worldsize * 10]

 

will return

 

airport_01_hangar_f.p3d

 airport_02_hangar_left_f.p3d // or *left*. the big hangar on tanoa is in two parts

This will be much cheaper on CPU than nearobjects

 

I should add that this will return many other objects, not just the hangars, but it's possible to filter them out using find..

 

 

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, Grumpy Old Man said:

worldsize * 10

No need to make the radius so large. As all Arma maps are square you can use the distance from center to corner which is ~1.4142 (rough enough approximation) times half the maps width/height.

(worldSize / 2) * 1.4142

sin( 45 ) + cos( 45 ) == 1.4142...

  • Like 1

Share this post


Link to post
Share on other sites

Use the sort and 2d optional parameters in nearestterrainobjects for even better performance.

Its just a shame the command is so poorly documented/implemented. Its type parameter uncovers a whole new class hierarchy that's undocumented and which some of is non sensical. So many of the objects are type 'hide' while practically none of them are building. Yet there is such atomicity that it has a 'fountain' type.

Some might say this is a slapdash and incomplete implementation. Not me. I wouldn't say that. No.

Share this post


Link to post
Share on other sites

One way to improve performance of your code working with static map objects is hardcoding result into mission.

Of course, you still need the code to do the search, but now its performance is way less significant than before. Divide the code into debug mode and release mode. In debug version search code always runs, compares results to hardcoded values and warns if there are any differences. In release hardcoded values always used.

One more option for release is to associate hardcoded values with map version (hardcoded too), that is if map is updated you still do the search. That guarantees mission will work correctly even if not maintained anymore. (in this variant code performance is still significant)

You might say this is not very elegant way of doing things. That's true. Until you concerned enough about performance. In general, everything that can be calculated during build time should be calculated during build time.

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

×