Jump to content
Sign in to follow this  
Ranwer135

Vehicles Spawn Around Map?

Recommended Posts

Hello guys,

With my mission "Dynamic Survival Sandbox", I'm currently using [sTELS]Zealot's vehicle spawner.

Problem is, it's only spawning 1 type of vehicle in towns.

So is there a way to actually spawn all types of vehicles. (like cars, helicopters etc)

I also want to be able to spawn all those type of vehicles around the whole map rather than a town.

Thanks,

Ranwer

Share this post


Link to post
Share on other sites

Ok, well I found a simpler one made by "MindSaver". But how can I get his script to work?

Here is the script below:

//	@file Version: 1.0//	@file Author: Mindsaver
if(!X_Server) exitWith {};
private ["_pos","_type","_num"];
for "_i" from 1 to 18 do
{
_pos = getMarkerPos format ["object_%1", _i];


_civilianVehicles = ["C_Offroad_01_F","C_Hatchback", "B_Truck_01_mover_F","C_Quadbike_01_F","C_SUV_01_F","C_Van_01_transport_F","C_Van_01_fuel_F","I_Truck_02_box_F"] call BIS_fnc_selectRandom;
_militaryVehicles = ["B_MRAP_01_hmg_F","O_MRAP_02_F","B_G_Offroad_01_armed_F","O_APC_Wheeled_02_rcws_F","B_Heli_Light_01_F","I_Heli_light_03_unarmed_F"]call BIS_fnc_selectRandom;




_num = floor (random 100);
if (_num < 100) then {_type = 0;};
if (_num < 35) then {_type = 1;};
if (_num < 10) then {_type = 2;};


if (_type == 0) then {_car = createVehicle [_civilianVehicles,_pos,[], 30,"None"];};
if (_type == 1) then {_car = createVehicle [_militaryVehicles,_pos,[], 30,"None"];};


_car setVehicleInit "nul=[this, 20, 600, 0, false] execVM 'Vehicle_Spawn\vehicle.sqf'";
processInitCommands;

//Clear Cars Inventory
   clearMagazineCargoGlobal _car;
   clearWeaponCargoGlobal _car;


//Set Cars Attributes
   _car setFuel (0.50);
   _car setDamage (random 0.50);
   _car setDir (random 360);
_car disableTIEquipment true;
   _car setPosATL [getpos _car select 0,getpos _car select 1,0];
};

I hope someone could help me get this going in Arma 3. :confused: (so I'll be able to make V3.0 for my mission)

Regards,

Ranwer

Share this post


Link to post
Share on other sites

I made some edits to Zealot's script to make it spawn all the civilian vehicles, seemed to work fine for me.

// v1c Civilian Vehicles from [sTELS]Zealot

if(!isServer) exitWith{};

zlt_civveh_round = 0;
zlt_civveh_vehicles = [];
zlt_civveh_spawnedloc = [];

zlt_rnd_seed = 1;

zlt_fnc_random = {
 private ["_a","_c","_m"];
 _a = 75;
 _c = 0;
 _m = 65537;
 zlt_rnd_seed = ( zlt_rnd_seed * _a + _c ) mod (_m);
 (zlt_rnd_seed / _m) ;
};


zlt_fnc_selectrandom = {
_this select floor ( ([] call zlt_fnc_random) * count (_this));
};

zlt_fnc_civvehs = {
_debug = [_this, 1, false] call bis_fnc_param;
_lrange = _this select 2;
_cars = _this select 3;
_t1 = diag_ticktime;


_startpos= _this select 0;
_houses = _startpos nearobjects ["House",_lrange];
//_vehmax =  _cars;
_vehmax = 	(round ((sqrt (count _houses)) * 0.5)) max 1;

_classes = ["C_Offroad_01_F","C_Quadbike_01_F","C_Hatchback_01_F","C_Hatchback_01_sport_F","C_SUV_01_F","C_Van_01_transport_F","C_Van_01_box_F","C_Van_01_fuel_F"];
_vehs = 0;
_attemps = 0;

zlt_rnd_seed =  ((_startpos select 0) + (_startpos select 1) mod 65537);

while {_vehs < _vehmax and _attemps < 10} do {
	_class = (_classes call BIS_fnc_selectRandom);
	//diag_log ["CV",_startpos, _lrange, _houses];

	_house = _houses call zlt_fnc_selectrandom;

	_housepos = _house modeltoworld [0,0,0];
	_newpos = _housepos findEmptyPosition [ 3 , 15, _class ];
	_houses = _houses - [_house];
	if (count _newpos == 0) then {
		_attemps = _attemps + 1;
	} else {
		_veh = _class createVehicle (_newpos ) ;
		_veh setvariable ["zlt_civveh", true];
		zlt_civveh_vehicles set [count zlt_civveh_vehicles, _veh];

		_direction = (random 360);
		_nearRoads = _newpos nearRoads 10;

		if(count _nearRoads > 0) then
		{
			_road = _nearRoads select 0;
			_roadConnectedTo = roadsConnectedTo _road;
			if (count _roadConnectedTo > 0) then {
				_connectedRoad = _roadConnectedTo select 0;
				_direction = [_road, _connectedRoad] call BIS_fnc_DirTo;
			};
		}; 

		_veh setdir _direction;
		_attemps = 0;
		_vehs = _vehs + 1;
		if (_debug) then {
			["crt"+str(_newpos), _newpos] call zlt_fnc_createmarkerlocal;
		};
	};
};
_t2 = diag_ticktime;
if (_debug) then {
	diag_log str ["civeh.sqf", _t2-_t1];
};
};


zlt_civ_checkloop = {


zlt_civveh_notemptyloc = [];

{
	_veh = vehicle _x;
	_isInVeh = (vehicle _x != _x);


	// or _veh getvariable ["zlt_civ_round", -1] != zlt_civveh_round
	if (not _isInVeh or {(_veh getvariable ["zlt_civ_round", -1]) != zlt_civveh_round and _veh isKindOf "LandVehicle"}) then {
		_dist = 1000;
		_locations = nearestLocations [(getpos vehicle _x), ["NameCityCapital","NameCity","NameVillage"], _dist];
		_locations2 = nearestLocations [(getpos vehicle _x), ["NameCityCapital","NameCity","NameVillage"], 2500];
		{
			if ( not (_x in zlt_civveh_spawnedloc) ) then {
				_lrange = 50; _cars = 1;
				switch (type _x) do {
					case ("NameCityCapital") : {_lrange = 250; _cars = 7;};
					case ("NameCity") : {_lrange = 150; _cars = 3;};
				};
				_pos = position _x;
				[ [_pos select 0, _pos select 1, 0], false, _lrange, _cars] call zlt_fnc_civvehs;
				zlt_civveh_spawnedloc set [count zlt_civveh_spawnedloc, _x ]; 
//					_x setside east;
			};
		} foreach _locations;
		{
			zlt_civveh_notemptyloc set [count zlt_civveh_notemptyloc, _x];
		} foreach _locations2;
		if (_isInVeh) then { _veh setvariable ["zlt_civ_round", zlt_civveh_round];};
	};
} foreach playableunits;


{
	_pos = [(position _x) select 0, (position _x) select 1, 0];
	_ent = ( (_pos) nearEntities [["C_Offroad_01_F","C_Quadbike_01_F","C_Hatchback_01_F","C_Hatchback_01_sport_F","C_SUV_01_F","C_Van_01_transport_F","C_Van_01_box_F","C_Van_01_fuel_F"], 300] );
	{
		if ( _x getvariable ["zlt_civveh", false] and {count crew _x == 0 and fuel _x == 1}) then {
			deletevehicle _x;
		};
	} foreach _ent;
	zlt_civveh_spawnedloc = zlt_civveh_spawnedloc - [_x];
} foreach (zlt_civveh_spawnedloc-zlt_civveh_notemptyloc);

zlt_civveh_round = zlt_civveh_round + 1;
};

while {true} do {
//scan loop

sleep 3.4; //magic number
[] call zlt_civ_checkloop;

};

Share this post


Link to post
Share on other sites

TPW pack has script for that. It's pretty good.

Share this post


Link to post
Share on other sites

Thanks guys,

Meatball's script works nicely, so I'll be close to releasing V3.0 :) (could be today)

Cheers!

Ranwer

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  

×