Jump to content
Sign in to follow this  
HereIsJones

Positioning Roadside Elements

Recommended Posts

I'm working on some scripts that spawn random encounters (remote insurgent camps, roadblocks, town takeovers etc.).

 

I just finished roadblocks, and now have them positioned center and perpendicular across the road, like:

 

Roadblock Image

 

I mention this, because now I'm trying to generate small "insurgent black markets" on the side of roads, and I'm assuming I'll need to use some of the same functions. The rule I've set is that I need an empty, relatively flat spot just off a road that the market will fit in (about the size of a CH-67 Huron).

 

I'm assuming I can use the following in some order:

 

BIS_fnc_randomPos - find a starting random pos

selectBestPlaces - find relatively flat, treeless areas (meadows)

BIS_fnc_findSafePos - find a relatively flat grade near the starting pos

BIS_fnc_nearestRoad - find a nearby road

roadsConnectedTo - find the direction of the road to align the market to it

findEmptyPosition - find an empty spot the size of a CH-67

 

I've been trying for two days, and I can't get it. Has anyone done anything like this? It doesn't help that some of these return an object, some an array and some locations.

 

Thanks in advance for any light you can shine on this. This is the code I've been playing with (doesn't seem to work) -

    _thisPosList = selectBestPlaces [_thisPos, 800, "(1 + meadow + houses) * (1 - sea)", 15, 1];
    _thisPosSelect = _thisPosList select (floor random (count _thisPosList));

    //choose a pos and use it to find a road segment
    _thisPos =  _thisPosSelect select 0;
    _thisPos = [_thisPos, 5, 500, 20, 0, .16, 0, [], []] call BIS_fnc_findSafePos;
    _thisRoad = [_thisPos, 500, []] call BIS_fnc_nearestRoad;
    //_thisPos = getPos _thisRoad;
    //get direction of road segment
    _roadConnectedTo = roadsConnectedTo _thisRoad;
    _thisDirection = _thisRoad getDir (_roadConnectedTo select 0);
    //then maybe something along the lines of -
    _thispos = _thisPos findEmptyPosition [0, 250, "B_Heli_Transport_03_F"];

 

EDIT - Actually, I think the real question may be, is it possible to generate a collection of pos that are on road segments, then look at each of those pos to find a segment that has a flat empty spot next to it?

 

EDIT - Ok I think this is it.

 

Procedurally generated roadside market

 

This still needs a lot of error and exception handling added to it, but here it is in all its clunky glory.

 

//find a decent random spot
_thisPos = [] call BIS_fnc_randomPos;
_thisPosList = selectBestPlaces [_thisPos, 1000, "(1 + meadow) + (1 + houses) * (1 - sea) * (1 - hills)", 15, 1];
_thisPosSelect = _thisPosList select (floor random (count _thisPosList));
_thisPos =  _thisPosSelect select 0;

//narrow in on road, get road direction
_thisRoad = [_thisPos, 300] call BIS_fnc_nearestRoad;
_roadConnectedTo = roadsConnectedTo _thisRoad;
_thisDirection = _thisRoad getDir (_roadConnectedTo select 0);

_marketFacing = _thisDirection;

//insert code to look 90 degrees from _thispos

_thisPos = _thisRoad getRelPos [15, _thisDirection];

_thisPos isFlatEmpty [5, -1, .15, 10, 0];

 

  • Like 1

Share this post


Link to post
Share on other sites

Wow! Randomly spawned traders.

This would fit very well in a scenario such as Antistasi. Would encourage players to explore more instead of directly commuting back and forth to base, which takes a lot of time and gets pretty repetitive.  

Share this post


Link to post
Share on other sites

I'll check Antistasi out. I originally came up with this for Ravage, but I think it will work with a lot of sandbox mods in general.

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  

×