Jump to content
MBMC

Help need BIS_fnc_nearestRoad

Recommended Posts

Hallo,

I need help with the function BIS_fnc_nearestRoad.

I use it for several scripts for example spawn vehiculars or roadblocks.

I know the function of the first 2 parameters:

	Parameter(s):
	_this select 0:	ARRAY	- The center position
	_this select 1:	NUMBER	- The distance from center position

_posStreet = [_position, _radiusSearchForRoads, []] call BIS_fnc_nearestRoad;

 

but when I want to work with the third parameter blacklisted road object it doesn´t work.

 

	_this select 2:	ARRAY	- List of blacklisted road objects

I know that the Function BIS_fnc_nearestRoad with parameter _list work as an Array.

 

like _array = _array - _list

 

Spoiler

/*
    Author: Nelson Duarte, optimised by Killzone_Kid

    Description:
    Find the nearest road segment to certain position, within given radius

    Parameter(s):
    _this select 0:    ARRAY    - The center position
    _this select 1:    NUMBER    - The distance from center position
    _this select 2:    ARRAY    - List of blacklisted road objects
    
    Returns:
    OBJECT    - Nearest road object on success
    NULL    - If no road object is found within given radius
*/

params [["_pos",[0,0,0]],["_rad",50],["_list",[]],"_dist"];

/// --- validate general input
#include "..\paramsCheck.inc"
#define arr1 [_pos,_rad,_list]
#define arr2 [[],0,[]]
paramsCheck(arr1,isEqualTypeParams,arr2)

private _roads = (_pos nearRoads _rad) - _list;
private _max = -log 0;
private _nearest = objNull;

{
    _dist = _x distanceSqr _pos;
    if (_dist < _max) then {_max = _dist; _nearest = _x};
}
count _roads;

_nearest

 

So my main problem is, what kind of format is allowed in the array _list  (3 parameter of function BIS_fnc_nearestRoad)?

 

I need a restriction for a lot of roads on the map Taunus. On this map are a lot of Paving paths, Concrete slabs and other road objects (mostley Objects from the Addon CUP terrain), they are sometimes under houses. So I want to restrict these objects.

 

What I done:

1. nearestTerrainObjects ( "MAIN ROAD", "TRACK", "ROAD", "TRAIL" ) for the array _list, its a "STRING",

 

1.1_posStreet = [_position, _radiusStreet, ["ROAD"]] call BIS_fnc_nearestRoad; <----- no result

 

2. className (CUP_A1_Road_kos6konec,CUP_A1_Road_kr_new_kos_sil_t) again for the array _list,

 

2.1 example as "STRING",  _posStreet = [_position, _radiusStreet, ["CUP_A1_Road_kos6konec"]] call BIS_fnc_nearestRoad; <----- no result

2.2  example not as "STRING",  _posStreet = [_position, _radiusStreet, [CUP_A1_Road_kos6konec]] call BIS_fnc_nearestRoad; <----- no result

 

3.Then I watched in the array _posStreet what for comments are in there, _posStreet = [2730105: ,1780867: pflaster_hex_9m.p3d,1780868: kos6konec.p3d,1736475: ,1780869: ,1780105: , ],

2730105: this is the ID number but with : , every CUP road object has the ID number and the P3D Name 1780867: pflaster_hex_9m.p3d

the not CUP road objects has only the ID number with that fuc... double point (tested on Altis and Stratis) -----> Its can be a STRING ----> I attempt again with

 

3.1 _posStreet = [_position, _radiusStreet, [1780867: pflaster_hex_9m.p3d]] call BIS_fnc_nearestRoad; <----bad format : double point

3.2 _posStreet = [_position, _radiusStreet, [pflaster_hex_9m.p3d]] call BIS_fnc_nearestRoad; <---- no function

3.3 _posStreet = [_position, _radiusStreet, [1780867]] call BIS_fnc_nearestRoad; <---- no function

 

I work lot of hours on it, but I have no idea now, I hope someone can help me pls.

Maybe there is a other way?

 

p.s. I want to spawn compositions and vehiculars on the normal roads not on the CUP road objects on Taunus

Share this post


Link to post
Share on other sites

Function utilises nearRoads .

You should play around with this command and take note of what it returns.

Share this post


Link to post
Share on other sites
16 minutes ago, Mokka said:

Function utilises nearRoads .

You should play around with this command and take note of what it returns.

Oh goody, I wonder what it might return. OH I KNOW! Road objects, yay :D

 

Share this post


Link to post
Share on other sites
35 minutes ago, MBMC said:

Hallo,

I need help with the function BIS_fnc_nearestRoad.

I use it for several scripts for example spawn vehiculars or roadblocks.

I know the function of the first 2 parameters:


	Parameter(s):
	_this select 0:	ARRAY	- The center position
	_this select 1:	NUMBER	- The distance from center position

_posStreet = [_position, _radiusSearchForRoads, []] call BIS_fnc_nearestRoad;

 

but when I want to work with the third parameter blacklisted road object it doesn´t work.

 


	_this select 2:	ARRAY	- List of blacklisted road objects

I know that the Function BIS_fnc_nearestRoad with parameter _list work as an Array.

 

like _array = _array - _list

 

  Reveal hidden contents

/*
    Author: Nelson Duarte, optimised by Killzone_Kid

    Description:
    Find the nearest road segment to certain position, within given radius

    Parameter(s):
    _this select 0:    ARRAY    - The center position
    _this select 1:    NUMBER    - The distance from center position
    _this select 2:    ARRAY    - List of blacklisted road objects
    
    Returns:
    OBJECT    - Nearest road object on success
    NULL    - If no road object is found within given radius
*/

params [["_pos",[0,0,0]],["_rad",50],["_list",[]],"_dist"];

/// --- validate general input
#include "..\paramsCheck.inc"
#define arr1 [_pos,_rad,_list]
#define arr2 [[],0,[]]
paramsCheck(arr1,isEqualTypeParams,arr2)

private _roads = (_pos nearRoads _rad) - _list;
private _max = -log 0;
private _nearest = objNull;

{
    _dist = _x distanceSqr _pos;
    if (_dist < _max) then {_max = _dist; _nearest = _x};
}
count _roads;

_nearest

 

So my main problem is, what kind of format is allowed in the array _list  (3 parameter of function BIS_fnc_nearestRoad)?

 

I need a restriction for a lot of roads on the map Taunus. On this map are a lot of Paving paths, Concrete slabs and other road objects (mostley Objects from the Addon CUP terrain), they are sometimes under houses. So I want to restrict these objects.

 

What I done:

1. nearestTerrainObjects ( "MAIN ROAD", "TRACK", "ROAD", "TRAIL" ) for the array _list, its a "STRING",

 

1.1_posStreet = [_position, _radiusStreet, ["ROAD"]] call BIS_fnc_nearestRoad; <----- no result

 

2. className (CUP_A1_Road_kos6konec,CUP_A1_Road_kr_new_kos_sil_t) again for the array _list,

 

2.1 example as "STRING",  _posStreet = [_position, _radiusStreet, ["CUP_A1_Road_kos6konec"]] call BIS_fnc_nearestRoad; <----- no result

2.2  example not as "STRING",  _posStreet = [_position, _radiusStreet, [CUP_A1_Road_kos6konec]] call BIS_fnc_nearestRoad; <----- no result

 

3.Then I watched in the array _posStreet what for comments are in there, _posStreet = [2730105: ,1780867: pflaster_hex_9m.p3d,1780868: kos6konec.p3d,1736475: ,1780869: ,1780105: , ],

2730105: this is the ID number but with : , every CUP road object has the ID number and the P3D Name 1780867: pflaster_hex_9m.p3d

the not CUP road objects has only the ID number with that fuc... double point (tested on Altis and Stratis) -----> Its can be a STRING ----> I attempt again with

 

3.1 _posStreet = [_position, _radiusStreet, [1780867: pflaster_hex_9m.p3d]] call BIS_fnc_nearestRoad; <----bad format : double point

3.2 _posStreet = [_position, _radiusStreet, [pflaster_hex_9m.p3d]] call BIS_fnc_nearestRoad; <---- no function

3.3 _posStreet = [_position, _radiusStreet, [1780867]] call BIS_fnc_nearestRoad; <---- no function

 

I work lot of hours on it, but I have no idea now, I hope someone can help me pls.

Maybe there is a other way?

 

p.s. I want to spawn compositions and vehiculars on the normal roads not on the CUP road objects on Taunus

So is the original position able to pick up on the roads at all?

check : 

_posStreet = [_position,_radiusStreet,["CUP_A1_Road_kos6konec"]] call bis_fnc_nearestRoad; 
if(isNull _posStreet) exitWith {hint "we found no roads!"};

of course with any type of format. It may just end up being that you can't return that piece of the road for whatever reason.

Keep trying to see if you can get anything to come back with something even if there is no blacklist and work your way back in that direction. 

Share this post


Link to post
Share on other sites

List of blacklisted road objects. Not a question of class here. You have to point at the objects. It's not handy.

You can have the object id, marking them on the map with:

0 = [] spawn {

  _posStreet = player nearRoads 200;
  {_mk = createMarker [str(_x),getpos _x]; _mk setMarkerType "mil_dot"; _mk setMarkerText str(_x)} forEach _posStreet;

};

but I did some test. This object id (on Altis, something like 1800058: ) refers to an objNull, so it's not sufficient for the blackList.

I guess you can only blacklist some objects with p3d model, not found yet on Altis. Perhaps on your CUP map.

 

Share this post


Link to post
Share on other sites

thx for the answers but I did a lot of testing with BIS_fnc_nearestRoad it seem to be, that it doesn't work.

 

Now I have create a other solution but I got a Problem:

 

My example code

Spoiler

/* ----------------------------------------------------------------------------
Function: MBMC_fnc_findRoads
Description:
    A function which
    
Parameters:
    - Position
    - Radius

    
Example:
 roadsAll = [main,50] call MBMC_fnc_findRoads;

 

Returns:
_roadsFinish

 

Author:
    MBMC
---------------------------------------------------------------------------------*/
params ["_pos","_size"];

 

private ["_restricted","_roads","_road","_roadsString","_roadString","_streetString","_roadNormal","_i","_f"];

 

_restricted = ["936258: invisibleroadway_square_f.p3d","936259: invisibleroadway_square_f.p3d","936260: invisibleroadway_square_f.p3d","936197: invisibleroadway_square_f.p3d","936198: invisibleroadway_square_f.p3d","936227: invisibleroadway_square_f.p3d","936228: invisibleroadway_square_f.p3d","936226: invisibleroadway_square_f.p3d",
"954684: invisibleroadway_square_f.p3d","954714: invisibleroadway_square_f.p3d","996926: invisibleroadway_square_f.p3d","880985: invisibleroadway_square_f.p3d","880986: invisibleroadway_square_f.p3d","1055536: invisibleroadway_square_f.p3d","1055535: invisibleroadway_square_f.p3d","1043308: invisibleroadway_square_f.p3d","1053036: invisibleroadway_square_f.p3d","1053034: invisibleroadway_square_f.p3d","1053021: invisibleroadway_square_f.p3d","1053035: invisibleroadway_square_f.p3d","1053037: invisibleroadway_square_f.p3d"];

 

_roads = _pos nearRoads _size;
_roads = _roads - _restricted;

_roadsString = [];
_i = 0;

 

while { _i < (count _roads) } do {
    _road = _roads select _i;
    _streetString = format ["%1", _road];   //Here I convert the normal format to a String
    _roadsString set [(count _roadsString), _streetString];
    _i = _i + 1;    
};

 

_roadsString = _roadsString - _restricted;  //So now I can delete the restricted roads
_roadsFinish = [];
_f = 0;

 

while { _f < (count _roadsString) } do {
    _roadString = _roadsString select _f;
    _roadNormal = compile _roadString;    //But I cant get them back as an object. With this solution I get a code back = {1185393:} mayby there is a way to use the code? need a road Object = 1185393: without clinch

/*other solutions:

_roadNormal = _roadString call BIS_fnc_objectFromNetId;    result = <NULL-object>

_roadNormal =  objectFromNetId _roadString;     result = <NULL-object>

_roadNormal = (missionNamespace getVariable [_roadString, objNull]);    result = <NULL-object>

_roadNormal = call compile format['%1',_roadString];     result = 1.18539e+006*/

 


    _roadsFinish set [(count _roadsFinish), _roadNormal];
    _f = _f + 1;    
};

 

// return
_roadsFinish

 

The Summary is that i need a way to get the road object back without the quotation marks or a better way for my problem.

 

Test was now on Lythium and Taunus.

Taunus use a lot of road typs from CUP for example pflaster_hex_9m.p3d.These road typs I must restrict.

Lythium use invisibleroadway_square_f.p3d its part of Arma 3 not an Addon road. These road typs I must restrict.

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

×