Jump to content
Sign in to follow this  
Armitxes

[RELEASE] Map Interaction Script

Recommended Posts

Map Interaction Script



for a better gameplay experience

Works with Arma 2 and Arma 3

Hello Ladies!

ArmA3 provides such beautiful terrains. ATM, Fishes, bees, snakes, trees.. and yet: nobody uses them.

This makes me some kind of sad because it's quite simple.

  • Fishing areas while the entire ocean is full with fishes?
  • A manually placed ATM while a map provided ATM is right next to it?
  • Harvesting & Mining areas while the entire map is full with resources?
  • Triggers and Locations just to check if a player is in a certain area?
  • Endless list...

What for a complete waste!

This script recognizes ALL map objects within a given range and compares it with a string array given by you.

USAGE

First off, to get the ID of a mapobject you simply go to the mapobject and execute following code. The id of a cellphone for example is "phonebooth_01_f" while "phonebooth" or "phone" already would be sufficient as parameter for the function

hint str((nearestObjects [player, [], 10]) - [player]);

The usage is simple. If you want to know if certain mapobjects/animals are close to the player you provide the IDs of the mapobjects in an array followed by the range in meters.

Usage: _nearMapObjects = [_mapObjectsIdsArray,_distance] call getMapObjects;

Example:
_nearMapObjects = [["water","sacks_goods","b_ficusc1s","b_ficusc2d","bricks","garbage","atm_","phone"],2] call getMapObjects;
if("atm_" in _nearMapObjects) then {
 // do whatever...
}

If the mapobject is within the given range, the given string will be returned. If not, then not. It's also nice to know that the Array is sorted by the distance between the player and the objects. First entry in array is the closest object to the player.

You can use, modify and redistribute this script as much as you want aslong as you give the credits.

/*
* DO NOT REMOVE THIS COMMENT!
* Script written by Armitxes.
* For usage visit: http://forums.bistudio.com/showthread.php?192645-RELEASE-Map-Interaction-Script
*/ 
getMapObjects = {
   private ["_check","_near","_haystack","_compare","_needle"];
   _check = _this select 0;
   _distance = _this select 1;
   _near = [];

   _haystack = [];
   { _haystack = _haystack + (toArray str(_x)); } forEach ((nearestObjects [player, [], _distance]) - [player]);

   {
     _needle = toArray _x;
     _needleLength = count _needle;

     for [{_i=0}, {_i<(count _haystack)}, {_i=_i+1}] do {
       if(
           (_haystack select _i) == (_needle select 0) &&
           (_haystack select (_i+1)) == (_needle select 1)
         ) then
       {
         _compare = [];
         for [{_l=0}, {_l<_needleLength}, {_l=_l+1}] do {
           _compare = _compare + [_haystack select (_i+_l)];
         };

         if(count (_compare-_needle) == 0) then { _near = _near + [_x]; };
       };
     };    
   } forEach _check;

   _near
};

Have fun!

Armitxes

Edited by Armitxes

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  

×