Jump to content

Sign in to follow this  
zorilya

Nearest location script problem

Recommended Posts

I have been making a mission in which i'm writing a script internally to manage the reaction and deployment of 2 urals full of Opfor into the AO. i have come across a problem however. my script is layed out roughly as follows;

Trigger when Blufor detected: on acc

Find nearest city or village to detected Blufor

deploy the urals to that location.

my problem is that the map doesn't have certain areas listed in the class names i'm filtering for the location. i.e. a barracks is where the blufor are detected but because it isn't a village the urals move to the closest (500meters away) village.

I modified my script to accomodate for this. it now goes something like;

on acc find nearest village and nearest building. if building is closer deploy to building else deploy to village

However this has an obvious problem since villages are made up of buildings the building is always gonna be closer an my urals are going to deploy next to an outskirt building rather than in the heart of the city for the units to then filter out. whilst this may be preferable in some cases this is a night mission and i'd prefer the deployment to be in a safe place. that being said i'm looking for one of two solutions that i can see.

1. if someone could explain to me how to test if the building is ... say.... 200m closer than the village, then i could ammend my script to accomodate for rural areas and villages alike

2. if someone could explain to me how to generate and area around the origional contact marker for Blufor so that i could trigger the urals to dismount within....say....200 meters so that my urals weren't just blindly running into a hot AO.

3. any other suggestion that i, quite conceivably, have not conceived of due to my lack of knowledge in mission making

Thanks very much

zorilya

Share this post


Link to post
Share on other sites

I can only give the logic, since you did not post a script or code but this is the basic ideas:

#1:

Check the distance and decide which is closest.


_buildingDist = _blueforPos distance _buildingPos;
_VillageDist = _blueforPos distance _villagePos;


if (_buildingDist < _VillageDist) then 
{
// Make urals go to the Building waypoint
}
else
{
// Make urals go to Village waypoint
};



#2:

We can just use a small script to check the distance and stop the urals if they get too close.

while {alive _ural1 && alive _ural2} then
{
_convoyPos = getPosAsl _ural1;
_blueforPos = getPosAsl _bluefore;
if ( (_ural1 distance _blueforPos) < 200) then 
{
	// Make convoy stop.
};

sleep 1;
};

Of course you will have to adapt this logic to your code but this is one way to do it.

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  

×