Jump to content
Sign in to follow this  
tpw

TPW CIVS: ambient civilians and traffic for Arma 3

Recommended Posts

Using some of the character animations, like the repair one, for civilians would be nice, or ambient animals within the player's radius.

Yes I'd like to see them stroke a pussy (cat!) Damn no cats in ... why der no cats or dogs ?

Share this post


Link to post
Share on other sites

TPW, you are my hero again. Looking forward to a addon version.

Share this post


Link to post
Share on other sites

MP (but not Dedicated) compatible test scripts:

MP testers urgently required

OK guys I'm getting closer to an addon release but before I do I'd really appreciate if some of you MP afficionados could test these scripts in an MP environment:

Ambient Civs (SP/MP):

/* 
AMBIENT CIVILIAN SCRIPT - MP COMPATIBLE
tpw 20130829

- This script will gradually spawn civilians into houses within a specified radius of the player.
- Civilian density (how many houses per civilian) can be specified.
- Civilian density will halve at night.
- Civilians will then wander from house to house, with a specified number of waypoints
- If a civilian is killed another will spawn 
- Civs are removed if more than the specified radius from the player

Disclaimer: Feel free to use and modify this code, on the proviso that you post back changes and improvements so that everyone can benefit from them, and acknowledge the original author (tpw) in any derivative works. 	

To use: 
1 - Save this script into your mission directory as eg tpw_civ.sqf
2 - Call it with 0 = [200,15,10] execvm "tpw_civ.sqf", where 200 = radius, 5 = number of waypoints, 10 = how many houses per civilian
*/

if (isDedicated) exitWith {};

private ["_civlist","_sqname","_centree","_centrew","_centrec","_centrer"];

// READ IN VARIABLES
tpw_civ_radius = _this select 0;
tpw_civ_waypoints = _this select 1;
tpw_civ_density = _this select 2;

// VARIABLES
_civlist = ["Civilian_F","C_man_1","C_man_1_1_F","C_man_1_2_F","C_man_1_3_F","C_man_polo_1_F","C_man_polo_2_F","C_man_polo_3_F","C_man_polo_4_F","C_man_polo_5_F","C_man_polo_6_F"];

tpw_civ_civarray = []; // array holding spawned civs
tpw_civ_civnum = 0; // number of civs to spawn

// CREATE AI CENTRES SO SPAWNED UNITS KNOW WHO'S AN ENEMY
_centerC = createCenter civilian;

// CREATE ARRAY OF EMPTY SQUADS TO SPAWN CIVS INTO
tpw_civ_civsquadarray = [];
for "_z" from 1 to 100 do
{
_sqname = creategroup civilian;
tpw_civ_civsquadarray set [count tpw_civ_civsquadarray,_sqname];	
};

// WAYPOINTS AT DIFFERENT HOUSES
tpw_civ_fnc_waypoint = 
{
private ["_grp","_house","_m","_pos","_wp"];
//Pick random position within random house
_grp = _this select 0;
_house = tpw_civ_houses select (floor (random (count tpw_civ_houses)));
_wp = getposasl _house;
_grp addWaypoint [_wp, 0];
[_grp, (tpw_civ_waypoints - 1)] setWaypointType "CYCLE";	
};

// SPAWN CIV INTO EMPTY GROUP
tpw_civ_fnc_civspawn =
{
private ["_civ","_spawnpos","_i","_ct","_sqname"];
// Pick a random house for civ to spawn into
_spawnpos = getposasl (tpw_civ_houses select (floor (random (count tpw_civ_houses))));
_civ = _civlist select (floor (random (count _civlist)));

//Find the first empty civ squad to spawn into
for "_i" from 1 to (count tpw_civ_civsquadarray) do
	{
	_ct = _i - 1;		
	_sqname = tpw_civ_civsquadarray select _ct;
	if (count units _sqname == 0) exitwith 
		{
		//Spawn civ into empty group
		_civ createUnit [_spawnpos, _sqname];

		//Mark it as owned by this player
		(leader _sqname) setvariable ["tpw_civ_owner", [player],true];

		//Add it to the array of civs for this player
		tpw_civ_civarray set [count tpw_civ_civarray,leader _sqname];

		//Speed and behaviour
		_sqname setspeedmode "LIMITED";
		_sqname setBehaviour "SAFE";

		//Assign waypoints
		for "_i" from 1 to tpw_civ_waypoints do
			{
			0 = [_sqname] call tpw_civ_fnc_waypoint; 
			};
		[_sqname, (tpw_civ_waypoints - 1)] setWaypointType "CYCLE";
		};
	};
};

// SEE IF ANY CIVS OWNED BY OTHER PLAYERS ARE WITHIN RANGE, WHICH CAN BE USED INSTEAD OF SPAWNING A NEW CIV
tpw_civ_fnc_nearciv =
{
private ["_owner"];
	{
	if (isMultiplayer) then 
		{
		// Live units within range
		if (_x distance vehicle player < tpw_civ_radius && alive _x) then 
			{
			_owner = _x getvariable ["tpw_civ_owner",[]];

			//Units with owners, but not this player
			if ((count _owner > 0) && !(player in _owner)) exitwith
				{
				_owner set [count _owner,player]; // add player as another owner of this civ
				_x setvariable ["tpw_civ_owner",_owner,true]; // update ownership
				tpw_civ_civarray set [count tpw_civ_civarray,_x]; // add this civ to the array of civs for this player
				};
			};
		} foreach allunits;
	};	

//Otherwise, spawn a new civ
[] call tpw_civ_fnc_civspawn;	
};	

// PERIODICALLY UPDATE POOL OF ENTERABLE HOUSES NEAR PLAYER, DETERMINE MAX CIVILIAN NUMBER, DISOWN CIVS FROM DEAD PLAYERS IN MP
0 = [] spawn 
{
while {true} do
	{ 
	private ["_allhouses","_civarray","_deadplayer"];
	_allhouses = nearestObjects [position vehicle player,["House"],tpw_civ_radius]; 
	tpw_civ_houses = []; 
		{
		if (((_x buildingpos 0) select 0) != 0) then 
			{
			tpw_civ_houses  set [count tpw_civ_houses,_x];
			}
		} foreach _allhouses;
	tpw_civ_civnum = floor ((count tpw_civ_houses) / tpw_civ_density);

	// Fewer civs at night
	if (daytime < 5 || daytime > 20) then 
		{
		tpw_civ_civnum = floor (tpw_civ_civnum / 2);
		};

	// Check if any players have been killed and disown their civs
		if (isMultiplayer) then 
		{
			{
			if ((isplayer _x) && !(alive _x)) then
				{
				_deadplayer = _x;
				_civarray = _x getvariable ["tpw_civarray"];
					{
					_x setvariable ["tpw_civ_owner",(_x getvariable "tpw_civ_owner") - [_deadplayer],true];
					} foreach _civarray;
				};
			} foreach allunits;	
		};
	sleep 10;
	};
};

// MAIN LOOP - ADD AND REMOVE CIVS AS NECESSARY
while {true} do 
{
tpw_civ_removearray = [];
//hintsilent format ["%1 of %2",count tpw_civ_civarray,tpw_civ_civnum];
// Add civs if there are less than the calculated civilian density for the player's current location 
if (count tpw_civ_civarray < tpw_civ_civnum) then
	{
	[] call tpw_civ_fnc_nearciv;
	};

	{
	// Remove dead civ from players array (but leave body)
	if !(alive _x) then 
		{
		tpw_civ_removearray set [count tpw_civ_removearray,_x];	
		}
		else
		{	
		// Check if civ is out of range and not visible to player. If so, disown it and remove it from players civ array	
		if (_x distance vehicle player > tpw_civ_radius && ((lineintersects [eyepos player,getposasl _x]) || (terrainintersectasl [eyepos player,getposasl _x]))) then
			{
			_x setvariable ["tpw_civ_owner", (_x getvariable "tpw_civ_owner") - [player],true];			
			tpw_civ_removearray set [count tpw_civ_removearray,_x];	
			};

		// Delete the live civ and its waypoints if it's not owned by anyone	
		if (count (_x getvariable ["tpw_civ_owner",[]]) == 0) then
			{
			while {(count (waypoints( group _x))) > 0} do
				{
				 deleteWaypoint ((waypoints (group _x)) select 0);
				};
			deletevehicle _x;
			};	
		};	
	} foreach tpw_civ_civarray;

//Update players civ array	
tpw_civ_civarray = 	tpw_civ_civarray - tpw_civ_removearray;
player setvariable ["tpw_civarray",tpw_civ_civarray,true];	
sleep random 10;	
};	

Ambient Cars (SP/MP):

/* 
AMBIENT CIVILIAN TRAFFIC SCRIPT - MP COMPATIBLE
tpw 20130829

- This script will gradually spawn civilian traffic, up to a maximum specified, onto roads within a specified radius of the player.
- Cars will then drive, with a specified number of waypoints.
- If a civilian driver is killed  or car damaged another will spawn.
- Cars are removed if more than the specified radius from the player.

Disclaimer: Feel free to use and modify this code, on the proviso that you post back changes and improvements so that everyone can benefit from them, and acknowledge the original author (tpw) in any derivative works. 	

To use: 
1 - Save this script into your mission directory as eg tpw_cars.sqf
2 - Call it with 0 = [1000,15,4] execvm "tpw_cars.sqf", where 1000 = radius, 15 = number of waypoints, 4 = max cars
*/

if (isDedicated) exitWith {};

private ["_civlist","_carlist","_sqname","_centerC"];

// READ IN VARIABLES
tpw_car_radius = _this select 0;
tpw_car_waypoints = _this select 1;
tpw_car_num = _this select 2;


// VARIABLES
_civlist = ["Civilian_F","C_man_1","C_man_1_1_F","C_man_1_2_F","C_man_1_3_F","C_man_polo_1_F","C_man_polo_2_F","C_man_polo_3_F","C_man_polo_4_F","C_man_polo_5_F","C_man_polo_6_F"];

_carlist = ["C_Offroad_01_F","C_Offroad_01_F","C_Offroad_01_F","C_Offroad_01_F","C_Quadbike_01_F"]; // more cars than quadbikes

tpw_car_cararray = []; // array holding spawned cars
tpw_car_farroads = []; // roads > 250m from unit
tpw_car_roadlist = []; // roads near unit

// CREATE AI CENTRE
_centerC = createCenter civilian;


// CREATE ARRAY OF EMPTY SQUADS TO SPAWN CARS INTO
tpw_car_squadarray = [];
for "_z" from 1 to 100 do
{
_sqname = creategroup civilian;
tpw_car_squadarray set [count tpw_car_squadarray,_sqname];	
};

// WAYPOINTS 
tpw_car_fnc_waypoint = 
{
private ["_grp","_road","_wp"];
//Pick random position within random house
_grp = _this select 0;
_road = tpw_car_roadlist select (floor (random (count tpw_car_roadlist)));
_wp = getposasl _road; 
_grp addWaypoint [_wp, 0];
[_grp,(tpw_car_waypoints - 1)] setWaypointType "CYCLE";
};


// SPAWN CIV/CAR INTO EMPTY GROUP
tpw_car_fnc_carspawn =
{
private ["_civ","_car","_roadseg","_spawnpos","_spawndir","_i","_ct","_sqname"];

// Pick a random road segment to spawn car and civ
[] call tpw_car_fnc_roadpos;
_roadseg = tpw_car_farroads select (floor (random (count tpw_car_farroads)));
_spawnpos = getposasl _roadseg;
_spawndir = getdir _roadseg;
_civ = _civlist select (floor (random (count _civlist)));
_car = _carlist select (floor (random (count _carlist)));

//Find the first empty civ squad to spawn into
for "_i" from 1 to (count tpw_car_squadarray) do
	{
	_ct = _i - 1;		
	_sqname = tpw_car_squadarray select _ct;
	if (count units _sqname == 0) exitwith 
		{

		_spawncar = _car createVehicle _spawnpos;
		_spawncar setdir _spawndir; 
		_civ createunit [_spawnpos,_sqname,"this moveindriver _spawncar;this setbehaviour 'CARELESS'"];				

		//Mark it as owned by this player
		_spawncar setvariable ["tpw_car_owner", [player],true];

		//Add car to the array of spawned civs
		tpw_car_cararray set [count tpw_car_cararray,_spawncar];

		//Assign waypoints
		for "_i" from 1 to tpw_car_waypoints do
			{
			0 = [_sqname] call tpw_car_fnc_waypoint; 
			};
		[_sqname, (tpw_car_waypoints - 1)] setWaypointType "CYCLE";
		};
	};
};

// SEE IF ANY CARS OWNED BY OTHER PLAYERS ARE WITHIN RANGE, WHICH CAN BE USED INSTEAD OF SPAWNING A NEW CIV
tpw_car_fnc_nearcar =
{
private ["_owner","_nearcars"];
if (isMultiplayer) then 
	{
	// Array of near cars
	_nearcars = (position player) nearEntities [["Car"], tpw_car_radius];

	// Live units within range
	if (_x distance vehicle player < tpw_car_radius && alive _x) then 
		{	
			{
			_owner = _x getvariable ["tpw_car_owner",[]];

			//Units with owners, but not this player
			if ((count _owner > 0) && !(player in _owner)) exitwith
				{
				_owner set [count _owner,player]; // add player as another owner of this car
				_x setvariable ["tpw_car_owner",_owner,true]; // update ownership
				tpw_car_cararray set [count tpw_car_cararray,_x]; // add this car to the array of cars for this player
				};
			} foreach _nearcars;
		};	
	};
//Otherwise, spawn a new car
[] call tpw_car_fnc_carspawn;	
};		

// POOL OF ROAD POSTIONS NEAR PLAYER
tpw_car_fnc_roadpos = 
{ 
tpw_car_roadlist = (position player) nearRoads tpw_car_radius;
tpw_car_farroads = [];
	{
	if (vehicle player distance position _x > 250) then 
		{
		tpw_car_farroads set [count tpw_car_farroads,_x];
		};
	} foreach tpw_car_roadlist;
};

sleep 3;

// MAIN LOOP - ADD AND REMOVE CARS AS NECESSARY, CHECK IF OTHER PLAYERS HAVE DIED (MP)
while {true} do 
{
//hintsilent format ["%1 of %2",count tpw_car_cararray,tpw_car_num];
private ["_driver","_cararray","_deadplayer"];
tpw_car_removearray = [];
// Add cars
if (count tpw_car_cararray < tpw_car_num) then
	{
	0 = [] call tpw_car_fnc_nearcar;
	};

	//Check if car is out of range and not visible to player. If so, disown it and remove it from players car array	
	{
	if (_x distance vehicle player > tpw_car_radius && ((lineintersects [eyepos player,getposasl _x]) || (terrainintersectasl [eyepos player,getposasl _x]))) then
		{
		_x setvariable ["tpw_car_owner", (_x getvariable "tpw_car_owner") - [player],true];			
		tpw_car_removearray set [count tpw_car_removearray,_x];	
		};

	// Delete the car, driver and waypoints if it's not owned by anyone	
	if (count (_x getvariable ["tpw_car_owner",[]]) == 0) then	
		{
		_driver = driver _x;
		while {(count (waypoints( group _driver))) > 0} do
			{
			 deleteWaypoint ((waypoints (group _driver)) select 0);
			};
		moveout _driver; 
		deletevehicle _driver;
		deletevehicle _x;
		};
	} foreach tpw_car_cararray;	

// Update player's car array	
tpw_car_cararray = 	tpw_car_cararray - tpw_car_removearray;
player setvariable ["tpw_cararray",tpw_car_cararray,true];

// If MP, check if any other players have been killed and disown their cars
if (isMultiplayer) then 
{
	{
	if ((isplayer _x) && !(alive _x)) then
		{
		_deadplayer = _x;
		_cararray = _x getvariable ["tpw_cararray"];
			{
			_x setvariable ["tpw_car_owner",(_x getvariable "tpw_car_owner") - [_deadplayer],true];
			} foreach _cararray;
		};
	} foreach allunits;	
};

sleep random 10;	
};	

What I've done is introduce "ownership" of any spawned civs and cars. The idea being that rather than all players in MP each spawning their own set of ambient civs and cars (which would lead to CPU-straining civ/car counts if there were lots of player units all in one town), a player will share another players spawned civs/cars, and only spawn their own if their are none to share. So if there were 10 players in the town, each set to have 5 ambient civs and 4 cars, the total number of spawned civs would still be 5 or so (not 50), and 4 or so cars (not 40).

Cars and civs are only "despawned" when their ownership count drops to 0 (ie no player has them in their civ list). Additionally, each player will periodically scan the other players, and if a player dies, his ownership will be removed for any civs/cars. This should prevent "orphaned" civs/cars.

It all sounds good on paper and works just fine in SP, but I really need a few of you to test it out in MP and/or look over the code. If it passes muster then I can attempt to make a dedi version, and pack the whole thing up as an addon.

Thanks in advance.

Edited by tpw

Share this post


Link to post
Share on other sites

Hi mate, brilliant work.

Quick question, as alluded to earlier in the thread, when you shoot a civvie in a car does the car still disappear immediately or does the car stay in game?

Share this post


Link to post
Share on other sites
Hi mate, brilliant work.

Quick question, as alluded to earlier in the thread, when you shoot a civvie in a car does the car still disappear immediately or does the car stay in game?

Thanks dale404. I modified it slightly, so that the car will remain until you move out of range and lose line of sight with it.

Share this post


Link to post
Share on other sites
Awesome!

Updating my missions now!

Err, which scipt / d/l for the new please?

These ones

Share this post


Link to post
Share on other sites

Nice work and I like reading good scripts. :)

I will have a look at it.

With regards to multiplay. I am a bit concerned about the ownersip of the player. It could work if script is run on the clientSide but I am unsure when run on the serverside then player might be undifined.

And (lineintersects [eyepos player... is good thinking but doen't it behave erratic in Arma? Maybe just distance is enough to delete out of range civs.

Maybe we can TS and have a little chat.

Cheers.

Edited by piXel

Share this post


Link to post
Share on other sites

For MP, you're going to run into similar problems of CPU overload if players aren't in the same location (10 players across different parts of the map will spawn a total of 50 civs), and you need to account for disconnects and Join In Progress. On the plus side, a lot of this has already been learnt the hard way by the MSO team (e.g. Highhead's CQB module is a similar concept) and the BIS Module Improvement project from zGuba and Wolffy.au, albeit for ArmA2 but the lessons remain the same. If you're keen to make this a fully supportable MP mod I would strongly encourage you to tap up the ALIVE team on Skype for their experience with coding this sort of thing in MP (including dedi & headless client support). It may save you a lot of heartache! (and personally I would appreciate it too, because I'd love to use a lot more of your scripts in an MP environment!)

Share this post


Link to post
Share on other sites

Hehehehe...this mod is the balls!! Love it! I especially get a kick out of how the civilians get curious and converge upon areas where there's been a firefight. I had a bit of a skirmish outside of one of the medium-sized towns and, once done, I had a bunch of offroad vehicles and cowering civilians approach and surround the perimeter, as if to say "we want to see CSAT burn!". I've got civs set to friendly-to-all, however, so maybe they're all just psychopaths. :P

---------- Post added at 14:41 ---------- Previous post was at 13:21 ----------

Oh man. Now I have a problem. Seems that, when I combine this script with an existing mission, the CSAT guys go nuts and start targeting each other, as well as random items (Lantern! Sleeping bag! Tent!). When I remove the script, everything's copacetic. I AM running it from my player's init, however, as follows:

0 = [200,15,10] execVM "tpw_civ.sqf"; 0 = [200,15,10] execVM "tpw_cars.sqf";

I've read about the Game Logics, but have no idea how to implement one using the script. Anyone feel like helping out a noob? I'd really love to incorporate this into my large Altis missions.

Share this post


Link to post
Share on other sites

I took a look at it.

Besides a few typos I think for MP the scripts need to be serverSide. you could use a playableUnits array to evaluate distance with the civilians and cars to keep or delete them.

Typos I noticed in the cars script:

// SEE IF ANY CARS OWNED BY OTHER PLAYERS ARE WITHIN RANGE, WHICH CAN BE USED INSTEAD OF SPAWNING A NEW CIV

tpw_car_fnc_nearcar =

{

private ["_owner","_nearcars"];

if (isMultiplayer) then

{

// Array of near cars

_nearcars = (position player) nearEntities [["Car"], _tpw_car_radius];

// Live units within range

if (_x distance vehicle player < tpw_car_radius && alive _x) then

{

{

_owner = _x getvariable ["tpw_car_owner",[]];

//Units with owners, but not this player

if ((count _owner > 0) && !(player in _owner)) exitwith

{

_owner set [count _owner,player]; // add player as another owner of this car

_x setvariable ["tpw_car_owner",_owner,true]; // update ownership

tpw_car_cararray set [count tpw_ccar_cararray,_x]; // add this car to the array of cars for this player

};

} foreach _nearcars;

};

};

Hope it helps a bit. Keep up the good work!

Edited by piXel

Share this post


Link to post
Share on other sites

TPW, it's me ArmASalt3, as you may notice I have a different Username. This is the one I used when I was in OFP, thank god i got it back.

No problems mate about using the script, even if you make the script even better, theres no shortage of brilliance in you mate.

Just have to find a way to get ALL civilian clothes from the config rather than type each name individually.

Great work on the latest update =)

Share this post


Link to post
Share on other sites
Nice work and I like reading good scripts. :)

I will have a look at it.

With regards to multiplay. I am a bit concerned about the ownersip of the player. It could work if script is run on the clientSide but I am unsure when run on the serverside then player might be undifined.

And (lineintersects [eyepos player... is good thinking but doen't it behave erratic in Arma? Maybe just distance is enough to delete out of range civs.

At the moment I am interested in client MP just to see if the concept of sharing civs actually works. The dedi version is a whole different can of worms regarding players.

lineintersects actually works really well, I use it without issues in my TPW LOS scripts.

For MP, you're going to run into similar problems of CPU overload if players aren't in the same location (10 players across different parts of the map will spawn a total of 50 civs), and you need to account for disconnects and Join In Progress. On the plus side, a lot of this has already been learnt the hard way by the MSO team (e.g. Highhead's CQB module is a similar concept) and the BIS Module Improvement project from zGuba and Wolffy.au, albeit for ArmA2 but the lessons remain the same. If you're keen to make this a fully supportable MP mod I would strongly encourage you to tap up the ALIVE team on Skype for their experience with coding this sort of thing in MP (including dedi & headless client support). It may save you a lot of heartache! (and personally I would appreciate it too, because I'd love to use a lot more of your scripts in an MP environment!)

Thanks mate, I appreciate the input. To my mind there's no way around the fact that if there are different players at different locations then they are all going to require their own civs. For MP client, which is what the current test scripts are for, then the civs are clientside and the load is mainly network load. Part of the reason for giving civs and cars absolutely minimal waypoint behaviour is to keep CPU use low.

Keen might be too strong a word for my MP aspirations. I don't play MP and have zero interest in it and, but every time I release something the MP people demand an MP version. I do this for fun, and once MP is involved the fun seems to disappear to be replaced by responsibility.

Hehehehe...this mod is the balls!! Love it! I especially get a kick out of how the civilians get curious and converge upon areas where there's been a firefight. I had a bit of a skirmish outside of one of the medium-sized towns and, once done, I had a bunch of offroad vehicles and cowering civilians approach and surround the perimeter, as if to say "we want to see CSAT burn!". I've got civs set to friendly-to-all, however, so maybe they're all just psychopaths. :P

---------- Post added at 14:41 ---------- Previous post was at 13:21 ----------

Oh man. Now I have a problem. Seems that, when I combine this script with an existing mission, the CSAT guys go nuts and start targeting each other, as well as random items (Lantern! Sleeping bag! Tent!). When I remove the script, everything's copacetic. I AM running it from my player's init, however, as follows:

0 = [200,15,10] execVM "tpw_civ.sqf"; 0 = [200,15,10] execVM "tpw_cars.sqf";

I've read about the Game Logics, but have no idea how to implement one using the script. Anyone feel like helping out a noob? I'd really love to incorporate this into my large Altis missions.

It's fine to run from the player init. You problem is related to these lines, which you can comment out:

//west setFriend [east, 0];
//east setFriend [west, 0];
//east setFriend [resistance, 0];
//east setFriend [civilian, 0];
//civilian setFriend [east, 0];
//resistance setFriend [east, 0];

I took a look at it.

Besides a few typos I think for MP the scripts need to be serverSide. you could use a playableUnits array to evaluate distance with the civilians and cars to keep or delete them.

Typos I noticed in the cars script:

// SEE IF ANY CARS OWNED BY OTHER PLAYERS ARE WITHIN RANGE, WHICH CAN BE USED INSTEAD OF SPAWNING A NEW CIV

tpw_car_fnc_nearcar =

{

private ["_owner","_nearcars"];

if (isMultiplayer) then

{

// Array of near cars

_nearcars = (position player) nearEntities [["Car"], _tpw_car_radius];

// Live units within range

if (_x distance vehicle player < tpw_car_radius && alive _x) then

{

{

_owner = _x getvariable ["tpw_car_owner",[]];

//Units with owners, but not this player

if ((count _owner > 0) && !(player in _owner)) exitwith

{

_owner set [count _owner,player]; // add player as another owner of this car

_x setvariable ["tpw_car_owner",_owner,true]; // update ownership

tpw_car_cararray set [count tpw_ccar_cararray,_x]; // add this car to the array of cars for this player

};

} foreach _nearcars;

};

};

Hope it helps a bit. Keep up the good work!

Thanks again PiXel, I have fixed that typo. As explained above, the scripts are clientside while I evaluate whether civ sharing works. Server side comes later if the whole thing doesn't end up pissing me off too much!

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

TPW, it's me ArmASalt3, as you may notice I have a different Username. This is the one I used when I was in OFP, thank god i got it back.

No problems mate about using the script, even if you make the script even better, theres no shortage of brilliance in you mate.

Just have to find a way to get ALL civilian clothes from the config rather than type each name individually.

Great work on the latest update =)

Glad you got your name back! I tried your uniform idea and it seems to work OK, except for the hats. For some reason you can't put hats on civs.

Share this post


Link to post
Share on other sites
please can someone make a demo mission for a noob (=me) till there is a addon-version out?

Just hold tight, I will release the addon tonight!

Share this post


Link to post
Share on other sites
yes sir! :p sorry for my impatience..

Keine probleme!

Share this post


Link to post
Share on other sites

Tpw, it looks like the car script throws error when I spawn on an island with no room for cars to spawn. I spawned on Atsalis island north of the main island with the following in my init: 0 = [200,15,10] execvm "tpw_civ.sqf"; 0 = [2000,15,10] execvm "tpw_cars.sqf". Got in a chopper and flew out to sea. As soon as I was in the middle of nowhere I got the "error in undefined" line 136.

Thanks for this script/soon to be mod. It makes the map come alive.

Share this post


Link to post
Share on other sites

Hello there

Really looking forward to the addon version. Glad to hear there are others who mainly SP as well. I mainly play some form of dynamic mission with Arma and having an empty island just feels wrong, no matter the civvie AI intelligence.

I also feel oddly bad when a civvie is killed during one of my operations and forces me naturally to play more carefully rather than saturating the area with arty etc.

Good stuff, hope the animals come soon.

Rgds

LoK

Share this post


Link to post
Share on other sites
Tpw, it looks like the car script throws error when I spawn on an island with no room for cars to spawn. I spawned on Atsalis island north of the main island with the following in my init: 0 = [200,15,10] execvm "tpw_civ.sqf"; 0 = [2000,15,10] execvm "tpw_cars.sqf". Got in a chopper and flew out to sea. As soon as I was in the middle of nowhere I got the "error in undefined" line 136.

Thanks for this script/soon to be mod. It makes the map come alive.

Nice one, thanks for that observation. You are right too. I will add a road segment count check

Share this post


Link to post
Share on other sites

It's fine to run from the player init. You problem is related to these lines, which you can comment out:

//west setFriend [east, 0];
//east setFriend [west, 0];
//east setFriend [resistance, 0];
//east setFriend [civilian, 0];
//civilian setFriend [east, 0];
//resistance setFriend [east, 0];

Ah! Cheers, TPW!! :) I'll give it a go!

Share this post


Link to post
Share on other sites
please can someone make a demo mission for a noob (=me) till there is a addon-version out?

Dale's mission(s?), for sure "Rescue the doctor", has cars and civilians. It's on Steam Workshop.

Share this post


Link to post
Share on other sites
Dale's mission(s?), for sure "Rescue the doctor", has cars and civilians. It's on Steam Workshop.

Indeed it does! Please feel free to de-PBO it if you want. (Its the one on Altis)!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×