Jump to content

Recommended Posts

Does anyone out there have a random roadblock generator ?

looking to fill the map with Random roadblocks

What i have so far - but need to set the Placements to the road !?


god_number_blocks=3; //avr
God_min_distance_between_blocks=5000;
_roads = [1500,1500,0] nearRoads 25000;
_number_blocks = ceil ((count _roads / 3000) * god_number_blocks);
hint format["attempting to create %1 Road Blocks...",_number_blocks];
_created_blocks = [];
GOD_MARKERS=[];
while{count _roads > 0 && count _created_blocks < _number_blocks} do {
_j = (count _roads - 1) min (round random (count _roads));
_blockpos = _roads select _j;
_roads = _roads - [_blockpos];

if({_x distance _blockpos < God_min_distance_between_blocks} count _created_blocks == 0 && count roadsConnectedTo _blockpos >= 2) then {
	_cid = floor(random 10000);
	_name = format["mrk_%1", _cid];
	_foo = createmarker [_name, getPos _blockpos];
	_foo setmarkertype "mil_dot";
	GOD_MARKERS pushBack _name;

	//Spawn Roadblock Bunkers - how to place them in correct position ?
	_bargate = createVehicle ["Land_BarGate_F", getPos _blockpos, [], 0, "NONE"];
	_bunker1 = createVehicle ["Land_BagBunker_Small_F", _bargate modelToWorld [6.5,-2,-4], [], 0, "NONE"];
	_bunker2 = createVehicle ["Land_BagBunker_Small_F", _bargate modelToWorld [-8,-2,-4], [], 0, "NONE"];
	_created_blocks = _created_blocks + [_blocks];
}

Thanks

Edited by 1PARA{God-Father}

Share this post


Link to post
Share on other sites

You will need to determine the angle based on the direction of the connecting road.

Bis has a nice function for this: BIS_fnc_dirTo.

So you need something like this

_roadBlockDir = [_blockpos, (roadsConnectedTo _blockpos) select 0] call BIS_fnc_dirTo;
_bargate = createVehicle ["Land_BarGate_F", getPos _blockpos, [], _roadBlockDir , "NONE"];

This will be easiest way to do but it will probably be a bit less precise from time to time. If you want this really precise you will need to plot points with isOnRoad and then calculate the center of a road 5 meters in advance and use that pos with the BIS_fnc_dirTo.

Share this post


Link to post
Share on other sites

Nice snippet 1PARA{God-Father}

Compositions can easily be positioned failry accurately since they have a collective center point so to speak, but I've yet to convert my A2 Checkpoint script to A3.

getDir road segment will get it pointing in the proper direction with your code.

god_number_blocks=3;
God_min_distance_between_blocks=5000;
_roads = [1500,1500,0] nearRoads 25000;
_number_blocks = ceil ((count _roads / 3000) * god_number_blocks);
hint format["attempting to create %1 Road Blocks...",_number_blocks];
_created_blocks = [];
GOD_MARKERS=[];
while{count _roads > 0 && count _created_blocks < _number_blocks} do {
_j = (count _roads - 1) min (round random (count _roads));
_blockpos = _roads select _j;
_roads = _roads - [_blockpos];

if({_x distance _blockpos < God_min_distance_between_blocks} count _created_blocks == 0 && count roadsConnectedTo _blockpos >= 2) then
{
	_roadDir = getDir _blockpos;
	_cid = floor(random 10000);
	_name = format["mrk_%1", _cid];
	_foo = createmarker [_name, getPos _blockpos];
	_foo setmarkertype "mil_dot";
	GOD_MARKERS pushBack _name;

	_bargate = createVehicle ["Land_BarGate_F", getPos _blockpos, [], 0, "NONE"];
	_bargate setDir _roadDir;
	_bunker1 = createVehicle ["Land_BagBunker_Small_F", _bargate modelToWorld [6.5,-2,-4], [], 0, "NONE"];
	_bunker2 = createVehicle ["Land_BagBunker_Small_F", _bargate modelToWorld [-8,-2,-4], [], 0, "NONE"];
	_created_blocks = _created_blocks + [_blockpos];
};
};

Share this post


Link to post
Share on other sites
Thanks,

Any way to place them on the ground and @ correct slope as they are off most of the time !

https://www.dropbox.com/s/16ess8ugi99drtt/107410_2015-03-16_00004.png?dl=0

You could just set their Z vector to 0 so they are on the floor no matter what.

e.g

myObject setPos [getpos myObject select 0,getpos myObject select 1,0];

Share this post


Link to post
Share on other sites

getDir road segment will get it pointing in the proper direction with your code.

I've been looking into the automatic placing of roadblocks and am making some progress, but one thing I have found is that getdir doesn't work on road segments. It always returns zero.

Share this post


Link to post
Share on other sites

hi,

 

To randomize a bit your compositions I suggest you to use BIS_fnc_objectsGrabber and BIS_fnc_ObjectsMapper to create your roadblocks. Create few compositions functions and use BIS_fnc_selectRandom to choose one.

 

How to make a composition here.

 

Don't forget to create your composition on the VR island to be sure to don't grab any unwanted "static" island object.

 

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites
You can get direction by passing a selected road segment and a conneted road segment to BIS_fnc_DirTo

Provide a startring position array with _startPos.





_roads = _startPos nearRoads 20;
_roadsSorted = [_roads,[],{_startPos distance _x},"ASCEND"] call BIS_fnc_sortBy;
_nearestRoad = _roadsSorted select 0;
_roadConnectedTo = roadsConnectedTo _nearestRoad;
_connectedRoad = _roadConnectedTo select 0;
_roadCenter = getPos _nearestRoad;
_roadDir = [_nearestRoad, _connectedRoad] call BIS_fnc_DirTo;


I made a script for a simple clear road block side mission road_block.sqf

In BMR_Insurgency v1.44 that is working reliably well and was somewhat inspired/born of this thread and God-father's original code as far as the arrangement so thanks for that God-father.

Though I must admit at first had a hard time with the same issue and so it possibly this has some redundant code though it makes it a little more reliable.

  • Like 1

Share this post


Link to post
Share on other sites

That's pretty much what I did Jiggy. :)

 

I wanted the road block to be at the edge of the town so I find a road on the circumference that has 2 other roads connected to it. Of them I choose the one that is furthest from the centre of town. Then I spawn the roadblock at the original one, and direction it to the last so that it faces the right way. The actual composition of the units is from Fluit's really excellent DEP.

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

×