Jump to content
Sign in to follow this  
SeriaL_KilleR

Creating Objectives in random areas

Recommended Posts

Hello,

i want to port wasteland, which is based on chernarus to another map. Inside this mission, there are scripts, which create objectives in random areas, including tanks, helis etc. to be captured. The code, which is used to pick a random area is the following:

_rad=20000;
_centerPos = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
_flatAreas = nearestLocations [_centerPos, ["FlatArea"], _rad];
_randomPos = getpos (_flatAreas select random (count _flatAreas -1));

if(str(sideMissionPos) == str(_randomPos)) then
{
_flatAreas = _flatAreas - _randomPos;    
};
_randomPos = getpos (_flatAreas select random (count _flatAreas -1));
mainMissionPos = str(_randomPos);

As you can see, it uses FlatAreas, which are defined inside the chernarus map itself. The script just grabs these information and uses them to create the objectives around FlatAreas. Now..the map i want to use doesn't have these FlatAreas :(

I know that you can use the editor to create gamelogic markers, which can create locations, i tried it but somehow it didn't work. Maybe i made a mistake in the process...

Can anyone tell me, if and how it is possible to create FlatAreas using the editor or a script without editing the map itself? Or does anyone know how to change the code above to use sth. different, not based on location types, to create the objectives in random areas all over the map?

Share this post


Link to post
Share on other sites

You could try generating a random location and use isFlatEmpty to check if it is suitable... Since wasteland only does these missions once in half an hour or so, you could re-try a number of times until you find an area that is suitable...

Share this post


Link to post
Share on other sites

Or try using

http://community.bistudio.com/wiki/findEmptyPosition

findemptyposition...


Description:
   Searches for an empty position around a center location.

   The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [maxDistance].

   If a [vehicleType] parameter is specified, then the search will look for empty positions that are big enough to hold that vehicle type.

   If an empty position isn't found, an empty array is returned.

Syntax

Syntax:
   center findEmptyPosition [radius,maxDistance] or [radius,maxDistance,vehicleType]
Parameters:
   center: Array - 
   [radius,maxDistance,vehicleType]: Array - 
Return Value:
   Array

Examples

Example 1:
[code]
   _position = _center_position findEmptyPosition[ 1 , 100 , "UH60M_EP1" ];) 

[/code]

Share this post


Link to post
Share on other sites

Tried the findEmptyPosition thing, but unfortunatly, it takes ages for the missions to spawn, if they spawn at all.

Is there a way to create a location by picking a random marker, lets say mission_marker1-70? How would i have to integrate this in the original code above? Sorry, but i am not really good at scripting, i know some basics but thats it :(

Share this post


Link to post
Share on other sites

if you mean placing a load of markers yourself and then applying the code to that - below concept is what you can use.

_preplacedmkr = ["mission_marker1-70","mission_marker1-71","mission_marker1-72" ]; //list all your markers
_placement = select (floor random (count _preplacedmkr ));

//e.g spawning a vehicle at the random location.
_veh = createVehicle ["2S6M_Tunguska",getMarkerPos _placement [], 0, "NONE"]; 

or use for random location from marker

//position between 10 and 100m from marker position
_Randomplacement = [getmarkerPos _placement , 10 + random 90, random 360] call BIS_fnc_relPos;

_veh = createVehicle ["2S6M_Tunguska",getPos _Randomplacement [], 0, "NONE"];

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  

×