Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- author: [vik] mindbl4ster
- description:
- get connections for each city
- parameter:
- 0: (optional)NUMBER - StartIndex
- 1: (optional)NUMBER - Amount of following indices
- 2: (optional)NUMBER - -1: Random distribution - else ending connection index
- return
- 0: ARRAY - [ [List of indices, including start], [List of positions ] ]
- notes
- */
- private["_startIndex","_checkpoints","_endingIndex"];
- _startIndex = [_this, 0, -1, [0] ] call bis_fnc_param;
- _checkpoints = [_this, 1, -1, [0] ] call bis_fnc_param;
- _endingIndex = [_this, 2, -1, [0] ] call bis_fnc_param; //---> gonna get pretty complicated :(
- _listOfIndicies = [];
- _listOfPositions = [];
- _sizeinfoMatrix = count MB_LocationInfoMatrix;
- if(_startIndex == -1)then{ _startIndex = floor random _sizeinfoMatrix};
- if(_checkpoints == -1)then{ _checkpoints = ceil random _sizeinfoMatrix};
- _listOfIndicies pushback _startIndex;
- _listOfPositions pushback ( (MB_LocationInfoMatrix select _startIndex) select 0);
- //----- create list with connections
- //--- read first connections
- _connections = (MB_locationInfoMatrix select _startIndex) select 1;
- _nextConnection = _connections call BIS_fnc_selectRandom;
- for[{_i=0},{_i<_checkpoints},{_i=_i+1}]do{
- _listOfIndicies pushback _nextConnection;
- _listOfPositions pushback ( (MB_LocationInfoMatrix select _nextConnection) select 0);
- _connections = (MB_locationInfoMatrix select _nextConnection) select 1;
- _lengthCon = count _connections;
- _valCon = [];
- //--- filter connections for place not visited yet
- for[{_j=0},{_j<_lengthCon},{_j=_j+1}]do{
- _valNum = _connections select _j;
- if( !(_valNum in _listOfIndicies))then{_valCon pushback _valNum;};
- };
- if(count _valCon == 0)then{_valCon = _connections}; // allow movement backwards once
- _nextConnection = _valCon call BIS_fnc_selectRandom;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement