Jump to content
Sign in to follow this  
BullyBoii

scripting units inside a house

Recommended Posts

hi im struggling with spawning in units via a script and then automatically placing those units inside a house

here is my code

_group1 = [getmarkerpos "opfor_spawn_3", EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call bis_fnc_spawnGroup;
{_x setpos (nearestBuilding _x buildingPos random 5);} forEach unit _group1;

i cant see to get the desired effect, which is hindering gameplay, please can you offer some advice. thanks

Share this post


Link to post
Share on other sites

just remember there may not be 5 positions in a particular house - you should count the positions in the house then randomly select that.

example code of how i spawn a cache inside a randomly selected house for [Fock]ers Cache Hunt, I then randomly select the position - i also u this for AI to search houses for the.

_Weapcrates = createVehicle ["Land_HelipadEmpty_F", [((getmarkerpos "middle") select 0) + _dx, ((getmarkerpos "middle") select 1) + _dy, 0], [], 0, "None"];
			house = nearestBuilding _Weapcrates;
//				hint format ["house= %1", house];

			if (Damage house > 0.1) then {house setdamage 0;}; 				

			m=0;
			while { format ["%1", (house) buildingPos m] != "[0,0,0]" } do {m=m+1};
			m=m-1;
			sleep 0.05;

			_total = m;
			_sum = random _total;
			private ["_boxpos"];
				if (_sum <0) then
				{
					_boxpos = 0;
				}
				else
				{
				_boxpos = ceil _sum;
				};
//				hint format ["box pos %1", _boxpos];
			sleep 0.5;

			//create ammo box and move
			caches = createVehicle ["Box_NATO_Wps_F", getmarkerpos "WeaponsInit", [], 0, "None"];
			removeAllWeapons caches;
			caches setPosATL (house buildingPos _boxpos);
			_newboxpos = getposATL caches;

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  

×