Jump to content
Sign in to follow this  
hogmason

better spawn pos

Recommended Posts

hi guys im after some help in improving my spawn positions script at the moment i am using this


_gamelogic = center;	  
_towns = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000]; 
_RandomTownPosition = position (_towns select (floor (random (count _towns))));			  

_camp1_marker = createMarker ["camp1",_RandomTownPosition];

the problem is it spawn sexactly where it is meant to on the name but how can i add some random distances from this namew and random direction using this

_dis = random 80;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
_pos = [((getpos ????) select 0) + _dx, ((getpos ????) select 1) + _dy, 0];

// or this ///////////			   

_dist = random 300;
_dir = random 360;
_pos = [((getPos ????) select 0) + (sin _dir) * _dist, ((getPos ????) select 1) + (cos _dir) * _dist, 0];

so in short use the select location class with some random direction and dis from the selected location class

---------- Post added at 21:39 ---------- Previous post was at 21:17 ----------

or even more ideal would be to use this

_dist = random 300;
_dir = random 360;
_pos = [((getPos center) select 0) + (sin _dir) * _dist, ((getPos center) select 1) + (cos _dir) * _dist, 0];

but have it check to not spawn in water or buildings

also

with the distance have a minimum of 300 and a max of 1000 is that possible

Share this post


Link to post
Share on other sites

Well, I'm not sure I understand, cause this looks pretty functionnal to me.

You could go with

_pos = getMarkerPos "camp1";
_dist = random 300;
_dir = random 360;
_pos = [(_pos select 0) + (sin _dir) * _dist, _pos select 1) + (cos _dir) * _dist, 0];
"camp1" setMarkerPos _pos;

And then execute your spawning code. Though if you plan on using this several times, you might wanna make it a function, and call it whenever needed.

fnc_randomPos = {
private ["_marker", "_pos", "_dist", "_dir"];

_marker = _this;
_pos = getMarkerPos _marker;
_dist = random 300;
_dir = random 360;
_pos = [(_pos select 0) + (sin _dir) * _dist, (_pos select 1) + (cos _dir) * _dist, 0];
_marker setMarkerPos _pos;
};

Then call it when needed.

_gamelogic = center;	  
_towns = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000]; 
_RandomTownPosition = position (_towns select (floor (random (count _towns))));			  
_camp1_marker = createMarker ["camp1",_RandomTownPosition];
"camp1" call fnc_randomPos;

Edit: Okay. So that's what I thought, this was totally not the question.

You could use Shuko's excellent random position script for that.

Share this post


Link to post
Share on other sites

yeah i have used that script in the past there was a reason i diddnt want to use it this time just cant remember what lol ill get back to that answer

---------- Post added at 22:08 ---------- Previous post was at 22:03 ----------

thats right im spawning camps and shk is awsome but it still allows spawning on buildings

---------- Post added at 22:09 ---------- Previous post was at 22:08 ----------

so say i was to go your way with

fnc_randomPos = {
private ["_marker", "_pos", "_dist", "_dir"];

_marker = _this;
_pos = getMarkerPos _marker;
_dist = random 300;
_dir = random 360;
_pos = [(_pos select 0) + (sin _dir) * _dist, (_pos select 1) + (cos _dir) * _dist, 0];
_marker setMarkerPos _pos;
};

how can i add to check for water and buildings

Share this post


Link to post
Share on other sites

What about this Hog?

CODE]//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: MarKeR, Credit to Kyliana : TAW_Tonic
//////////////////////////////////////////////////////////////////

if (!isServer) exitWith {};

fn_findMissionSpot = {

//Creating the position

private ["_rad","_cnps","_hills","_hillcount","_hillnum","_hill","_marker"];

_rad=20000;
_cnps = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
_hills = nearestLocations [_cnps, ["FlatArea"], _rad];
_hillcount = count _hills;
_hillnum = floor (random _hillcount);
_hill = _hills select _hillnum;

getPos _hill

};

Will also depend on what map you are using... Works great on Chernarus, Takistan and Utes.. Only 3 that I have used it on..

Edited by marker
Stupid copy function on iPad

Share this post


Link to post
Share on other sites

ok so i got it working with this


_pos = center;
_radius = random 2000;
_exp = "(1 + meadow) * (1 - sea) * (1 - houses)";
_prec = 10;

_bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1];
_spot = _bestplace select 0;
_spot2 = _spot select 0;

_camp1_marker = createMarker ["camp1",_spot2];
_camp1_marker setMarkerType "mil_dot";

but now i wonder how can i put in direction random and minimum radius

---------- Post added at 22:28 ---------- Previous post was at 22:26 ----------

cheers marker, im using hells kitchen so only the name places work oh and there is 2 flat areas lol ;(

but that function looks pretty danm good and handy to keep

Share this post


Link to post
Share on other sites
fnc_randomPos = {
private ["_marker", "_pos", "_dist", "_dir","_houseDist"];
_marker = _this;
_pos = getMarkerPos _marker;
_houseDist = 100;
for "_i" from 0 to 100 do 
{
_dist = random 300;
_dir = random 360;
_pos = [(_pos select 0) + (sin _dir) * _dist, (_pos select 1) + (cos _dir) * _dist, 0];
if (!(surfaceIsWater _pos) && (count (nearestObjects [_pos,["House"],_houseDist]) == 0)) exitWith  { _i = 100};
_pos = (markerPos _marker);
};
_marker setMarkerPos _pos;
};

Share this post


Link to post
Share on other sites

No problem mate..

You need to hurry and finish your mission...

Been following your posts for seems like ages now, eager to give it a try...

Share this post


Link to post
Share on other sites

lol yeah its driving me made mate.

---------- Post added at 22:42 ---------- Previous post was at 22:40 ----------

ill try that cuel cheers mate.

---------- Post added at 22:50 ---------- Previous post was at 22:42 ----------

that actually works better then the find best places but i did notice that every now and then even no i set the dis to 2000 that they do spawn f the map like at 5000

---------- Post added at 23:02 ---------- Previous post was at 22:50 ----------

nevermind that was my fualt lol that works great cuel thanks mate.

---------- Post added at 23:22 ---------- Previous post was at 23:02 ----------

cuel how would i also tell it to check for rocks i.e big bloody rocks lol

like how you have "House" i searched the command ---- nearestObjects----- but found nothing regarding the House

Share this post


Link to post
Share on other sites

Make a trigger, radio alpha, on activation

copyToClipboard format ["%1",typeof cursorTarget]

Look at the rocks that you want to exclude and add them (ctrl+v) in the array, such as

(count (nearestObjects [_pos,["House","RockType1"],_houseDist]) == 0)

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  

×