Jump to content
kibaBG

[SOLVED] Spawning roadblock perpendicular to road

Recommended Posts

No errors but no joy, the roadblock spawns with direction 0 (default value). Cannot figure out where is the problem: 
 

_uberPos = [[["operation_area"]], [["usa_base_area","iran_base_area"]], {isOnRoad _this }] call BIS_fnc_randomPos;

_nearRoads = _uberPos nearRoads 30;
_road = _nearRoads select 0;
_roadConnectedTo = roadsConnectedTo _road;
_connectedRoad = _roadConnectedTo select 0;
_direction = _road getDir _connectedRoad;
finalDir = (floor _direction) + 90;

_uberPos resize 2;
private _list = nearestTerrainObjects [_uberPos, [], 30, false, true]; 
{_x hideObjectGlobal true;} forEach _list;
[west, "tsk14", ["Enemy checkpoint is stopping civil traffic. Destroy it to allow civilians to travel freely", "Destroy Road Checkpoint", ""], _uberPos, "CREATED", -1, true, "destroy", false] call BIS_fnc_taskCreate;
_camp = 
[
	["Land_BarGate_F",[3.34619,1.90332,0],0,1,0,[0,0],"","",true,false], 
	["Land_HBarrier3",[-7.05566,0.246582,0],270,1,0,[0,0],"","",true,false], 
	["Land_fort_bagfence_long",[-6.98389,4.41455,0],75,1,0,[0,0],"","",true,false], 
	["Barrels",[8.29053,-0.685059,0],60,1,0,[0,0],"","",true,false], 
	["AmmoCrates_NoInteractive_Medium",[-8.604,1.80322,0],90,1,0,[0,-0],"","",true,false], 
	["Land_PortableLight_single_F",[-7.94385,4.61768,0],195,1,0,[0,0],"","",true,false], 
	["Land_fort_bagfence_round",[6.44775,5.65576,0],270,1,0,[0,0],"","",true,false], 
	["Land_HBarrier3",[-8.30957,0.438965,0],180,1,0,[0,0],"","",true,false], 
	["AmmoCrates_NoInteractive_Large",[9.62598,-1.74658,0],135,1,0,[0,-0],"","",true,false], 
	["Land_fort_bagfence_long",[-8.98145,5.51416,0],0,1,0,[0,0],"","",true,false], 
	["Land_CamoNetVar_EAST_EP1",[9.5459,2.80469,0],90,1,0,[0,-0],"","",true,false], 
	["Land_Pallets_F",[10.4063,-0.0678711,0],90,1,0,[0,-0],"","",true,false], 
	["Land_CncBarrier_F",[-8.21826,9.52051,0],1.409,1,0,[0,0],"","",true,false], 
	["Land_fort_bagfence_long",[-11.8525,5.13574,0],345,1,0,[0,0],"","",true,false], 
	["Land_fort_bagfence_long",[10.1436,8.38916,0],0,1,0,[0,0],"","",true,false], 
	["Land_CncBarrier_F",[7.78174,11.2705,0],1.18501,1,0,[0,0],"","",true,false], 
	["Land_fort_bagfence_round",[13.8696,5.65088,0],90,1,0,[0,-0],"","",true,false], 
	["Land_Pallets_F",[-14.8203,-1.479,0],120,1,0,[0,-0],"","",true,false], 
	["Land_fort_bagfence_round",[-15.5137,2.0835,0],270,1,0,[0,0],"","",true,false], 
	["RoadBarrier_F",[-10.2163,11.5317,0],4.50453,1,0,[0,0],"","",true,false], 
	["Land_CncBarrier_F",[-12.5913,9.03613,0],166.185,1,0,[0,-0],"","",true,false], 
	["Land_CncBarrier_F",[11.3872,11.2881,0],1.409,1,0,[0,0],"","",true,false], 
	["RoadBarrier_F",[9.15918,14.2749,0],169.506,1,0,[0,-0],"","",true,false], 
	["Land_CncBarrier_F",[-16.4683,7.53613,0],151.185,1,0,[0,-0],"","",true,false], 
	["Land_CncBarrier_F",[15.0396,10.1587,0],211.409,1,0,[0,0],"","",true,false]
];
[_uberPos, finalDir, _camp, 0] call BIS_fnc_objectsMapper;
obj_checkpoint_small_a = nearestObjects [_uberPos, ["Land_BarGate_F"], 50, true];
_wintrg = createTrigger ["EmptyDetector", _uberPos, true];
_wintrg setTriggerArea [50, 50, 0, false, 30];
_wintrg setTriggerActivation ["NONE", "NONE", false];
_wintrg setTriggerStatements ["{!alive _x} forEach obj_checkpoint_small_a", 
"['tsk14','SUCCEEDED'] call BIS_fnc_taskSetState; _list = (position thisTrigger) nearObjects ['All', 30]; {deleteVehicle _x} forEach _list; finalDir = nil;", ""];


  

Share this post


Link to post
Share on other sites

To pinpoint the problem I think something is wrong here: 
 

_nearRoads = _uberPos nearRoads 30;
_road = _nearRoads select 0;
_roadConnectedTo = roadsConnectedTo _road;
_connectedRoad = _roadConnectedTo select 0;
_direction = _road getDir _connectedRoad;
finalDir = (floor _direction) + 90;

Probably does not give number 0-360 ... Any ideas how to fix it?

Share this post


Link to post
Share on other sites

Can't you make it a composition on its' own layer then hide/unhide it as necessary?

 

getMissionLayerEntities "roadblock" params ["_objects"];
_objects apply { _x enableSimulationGlobal false; _x hideObjectGlobal true; };

 

getMissionLayerEntities "roadblock" params ["_objects"];
_objects apply { _x enableSimulationGlobal true; _x hideObjectGlobal false; };

  • Like 1

Share this post


Link to post
Share on other sites

@major-stiffy The roadblock should be on random position on road, composition layers are good if you use them for one predefined position only ...

Share this post


Link to post
Share on other sites
On 12/20/2024 at 6:49 PM, kibaBG said:

To pinpoint the problem I think something is wrong here: 
 


_nearRoads = _uberPos nearRoads 30;
_road = _nearRoads select 0;
_roadConnectedTo = roadsConnectedTo _road;
_connectedRoad = _roadConnectedTo select 0;
_direction = _road getDir _connectedRoad;
finalDir = (floor _direction) + 90;

Probably does not give number 0-360 ... Any ideas how to fix it?

 

 

No, that doesn't matter , in trigo 370 is same as 010  (check in sin or cos console)

I tested in console:
 

_uberpos = getpos player;
_nearRoads = _uberpos nearRoads 30;
_road = _nearRoads select 0;
_roadConnectedTo = roadsConnectedTo _road;
_connectedRoad = _roadConnectedTo select 0;
_direction = _road getDir _connectedRoad;
finalDir = _direction;
_camp =[
 ["Land_BarGate_F",[3.34619,1.90332,0],0,1,0,[0,0],"","",true,false],  
 ["Land_HBarrier3",[-7.05566,0.246582,0],270,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_long",[-6.98389,4.41455,0],75,1,0,[0,0],"","",true,false],  
 ["Barrels",[8.29053,-0.685059,0],60,1,0,[0,0],"","",true,false],  
 ["AmmoCrates_NoInteractive_Medium",[-8.604,1.80322,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_PortableLight_single_F",[-7.94385,4.61768,0],195,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_round",[6.44775,5.65576,0],270,1,0,[0,0],"","",true,false],  
 ["Land_HBarrier3",[-8.30957,0.438965,0],180,1,0,[0,0],"","",true,false],  
 ["AmmoCrates_NoInteractive_Large",[9.62598,-1.74658,0],135,1,0,[0,-0],"","",true,false],  
 ["Land_fort_bagfence_long",[-8.98145,5.51416,0],0,1,0,[0,0],"","",true,false],  
 ["Land_CamoNetVar_EAST_EP1",[9.5459,2.80469,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_Pallets_F",[10.4063,-0.0678711,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[-8.21826,9.52051,0],1.409,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_long",[-11.8525,5.13574,0],345,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_long",[10.1436,8.38916,0],0,1,0,[0,0],"","",true,false],  
 ["Land_CncBarrier_F",[7.78174,11.2705,0],1.18501,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_round",[13.8696,5.65088,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_Pallets_F",[-14.8203,-1.479,0],120,1,0,[0,-0],"","",true,false],  
 ["Land_fort_bagfence_round",[-15.5137,2.0835,0],270,1,0,[0,0],"","",true,false],  
 ["RoadBarrier_F",[-10.2163,11.5317,0],4.50453,1,0,[0,0],"","",true,false],  
 ["Land_CncBarrier_F",[-12.5913,9.03613,0],166.185,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[11.3872,11.2881,0],1.409,1,0,[0,0],"","",true,false],  
 ["RoadBarrier_F",[9.15918,14.2749,0],169.506,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[-16.4683,7.53613,0],151.185,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[15.0396,10.1587,0],211.409,1,0,[0,0],"","",true,false]
];
[_uberPos, finalDir, _camp, 0] call BIS_fnc_objectsMapper;


On Stratis roads (from repratable radio module, then referring to player's position as you can see in 1st line). That works without any resizing nor added angle for direction.
Just not so fine in turning roads, but on straight segments, the roadblock is OK.
Perhaps, check for another map than yours, or be sure you don't add anything about your placed objects in any other script..
 

  • Thanks 2

Share this post


Link to post
Share on other sites

@pierremgi Thanks for the example, I got it working! :slayer:
 

_allRoads = [7988,8237] nearRoads 7500;
_rroad = selectRandom _allRoads;
uberPos = getPos _rroad;
_nearRoads = uberPos nearRoads 30;
_road = _nearRoads select 0;
_roadConnectedTo = roadsConnectedTo _road;
_connectedRoad = _roadConnectedTo select 0;
_direction = _road getDir _connectedRoad;
finalDir = _direction;
_camp =[
 ["Land_BarGate_F",[3.34619,1.90332,0],0,1,0,[0,0],"","",true,false],  
 ["Land_HBarrier3",[-7.05566,0.246582,0],270,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_long",[-6.98389,4.41455,0],75,1,0,[0,0],"","",true,false],  
 ["Barrels",[8.29053,-0.685059,0],60,1,0,[0,0],"","",true,false],  
 ["AmmoCrates_NoInteractive_Medium",[-8.604,1.80322,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_PortableLight_single_F",[-7.94385,4.61768,0],195,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_round",[6.44775,5.65576,0],270,1,0,[0,0],"","",true,false],  
 ["Land_HBarrier3",[-8.30957,0.438965,0],180,1,0,[0,0],"","",true,false],  
 ["AmmoCrates_NoInteractive_Large",[9.62598,-1.74658,0],135,1,0,[0,-0],"","",true,false],  
 ["Land_fort_bagfence_long",[-8.98145,5.51416,0],0,1,0,[0,0],"","",true,false],  
 ["Land_CamoNetVar_EAST_EP1",[9.5459,2.80469,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_Pallets_F",[10.4063,-0.0678711,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[-8.21826,9.52051,0],1.409,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_long",[-11.8525,5.13574,0],345,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_long",[10.1436,8.38916,0],0,1,0,[0,0],"","",true,false],  
 ["Land_CncBarrier_F",[7.78174,11.2705,0],1.18501,1,0,[0,0],"","",true,false],  
 ["Land_fort_bagfence_round",[13.8696,5.65088,0],90,1,0,[0,-0],"","",true,false],  
 ["Land_Pallets_F",[-14.8203,-1.479,0],120,1,0,[0,-0],"","",true,false],  
 ["Land_fort_bagfence_round",[-15.5137,2.0835,0],270,1,0,[0,0],"","",true,false],  
 ["RoadBarrier_F",[-10.2163,11.5317,0],4.50453,1,0,[0,0],"","",true,false],  
 ["Land_CncBarrier_F",[-12.5913,9.03613,0],166.185,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[11.3872,11.2881,0],1.409,1,0,[0,0],"","",true,false],  
 ["RoadBarrier_F",[9.15918,14.2749,0],169.506,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[-16.4683,7.53613,0],151.185,1,0,[0,-0],"","",true,false],  
 ["Land_CncBarrier_F",[15.0396,10.1587,0],211.409,1,0,[0,0],"","",true,false]
];
[uberPos, finalDir, _camp, 0] call BIS_fnc_objectsMapper;

This gives perfectly positioned roadblock on a random road in an area with radius 7500 meters. 

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

×