Jump to content
Sign in to follow this  
MAD T

MAD Ambient Life - (SP/MP)

Recommended Posts

Hello Community

Today i´m releasing my Ambient Life scripts for the community which i made for an upcoming Insurgency mission by Mantis. Currently it features civilians wandering around and cars driving around. Animals will come soon as well as exclusion zones with triggers where you don´t want to have civilians walking or cars driving.

It is a derivative work of TPW´s scripts and uses some code of it though the script works completly different in many ways and is dedicated server compatible. I want to thank TPW for his work without him this would not be possible. http://forums.bistudio.com/showthread.php?164304-TPW-MODS-enhanced-realism-immersion-for-Arma-3-SP

Download Link https://dl.dropboxusercontent.com/u/15758816/MAD_Ambient_Life.altis.zip

If you want to use the scripts in your mission copy MAD_civilians.sqf or MAD_traffic.sqf to your missions folder.

You have to call them like this in your init.sqf.

For civilians

  [10, 500, 10] execVM "MAD_civilians.sqf";  

First parameter is numbers of civs around the player, second is the radius (used for spawning and despawning) and last one is for how many waypoints a civlian has. Script needs to run on both, client and server.

For Traffic

 [5, 500, 1000] execVM "MAD_traffic.sqf";  

First parameter is number of vehicles around the player, second is the min spawn radius (vehicles spawn that far from the player) and the last one is the despawn radrius. Script needs to run on both, client and server.

PS: Function names are still a bit sloopy and it currently lacks some features. Parts of it might change in the future.

Credits & Thanks

tpw - for his TPW MODS which gave the impression of creating this

Bigi, Nikonov and Mantis - for testing

Edited by MAD T

Share this post


Link to post
Share on other sites

Interesting. I suppose you have fixed the "red balls" issue with tpw mods on dedicated servers? I think they are spawned to set the spawn radius of the cars/civs and should be invisible in sp but appear as red balls on dedicated servers.

Share this post


Link to post
Share on other sites

I took only very little code from tpw. Most is written from scratch and works in a different way. There will be no red balls.

Share this post


Link to post
Share on other sites

Does this spawn an instance of civilians from the dedicated server? or are multiple client-side instanced spawned for each player?

Share this post


Link to post
Share on other sites

Civilians and vehicles are spawned for each player individually. But if two players are in the same area there are not spawning more than set in the parameters. So if you set 10 civs there will be only 10 civs in the area even if there are more players in it. Civs and cars are also only spawning on the server to take away bandwith problems which i had before when they spawn on the client (having only a 2k internet connection and a few civs and cars raised my ping to over 900). On the other side it means you need a good server or if you don´t then set the civs and cars value to a lower amount.

Edit: The only reason the script needs to also run on the client is because the client calculates if there are roads or buildings near the player to spawn stuff. The information will be send to the server by simple setting a variable to true or false if the condition ever changes. With that information the server decides if he has to run distance checks for the player on spawned units or even has to use other further commands.

Edited by MAD T

Share this post


Link to post
Share on other sites

I kind of prefered TPWs way to spawn civs randomly over different buildings, instead out of one building. They are quite crowded that way and one time i almost shit my pants, when a door in front of me swung up and 10 people came running out (although it was kinda cool).

Also i hardly saw cars with cars reduced to two per player (same setting i use for tpwcars). Do they have different waypoints, further away from the player?

Share this post


Link to post
Share on other sites

uhm? they do spawn in different houses, at least for me. Their wayoints should never leave the city/town they're as they basically go from house to house.

Share this post


Link to post
Share on other sites

congrats on your work! :bounce3:

Just tried the demo Mission in the editor, but i can't get it to work?

\MAD_Ambient_Life.Altis\MAD_civilians.sqf, line 273
Error in expression <t + 1;
};
} forEach MAD_CivsArray;

if (_count < MAD_maxCivDensity) then
{
[(pos>
 Error position: <_count < MAD_maxCivDensity) then
{
[(pos>
 Error Undefined variable in expression: _count

Share this post


Link to post
Share on other sites

Thanks for sending us the release :cool:

Release frontpaged on the Armaholic homepage.

==============================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites
congrats on your work! :bounce3:

Just tried the demo Mission in the editor, but i can't get it to work?

\MAD_Ambient_Life.Altis\MAD_civilians.sqf, line 273
Error in expression <t + 1;
};
} forEach MAD_CivsArray;

if (_count < MAD_maxCivDensity) then
{
[(pos>
 Error position: <_count < MAD_maxCivDensity) then
{
[(pos>
 Error Undefined variable in expression: _count

hm you'll just have to define _count like it would on a dedicated, he probably overlooked it.

so


if (isServer) then
{
if (isMultiplayer) then
{
	while {true} do
	{
		call MAD_deleteCivs;

		{
			_player = _x;
			_count = 0;
			_var = _player getVariable ["MAD_housesNear", false];

			if (_var) then
			{
				{
					if (_x distance _player < MAD_maxCivDistance) then
					{
						_count = _count + 1;
					};
				} forEach MAD_CivsArray;

				if (_count < MAD_maxCivDensity) then
				{
					[(position _player), _count] call MAD_spawnciv;
				};
			};
		} forEach playableUnits;

		sleep 10;
	};
}
else
{
	while {true} do
	{
	   _count = 0;
		call MAD_deleteCivs;

		{
			if (_x distance player < MAD_maxCivDistance) then
			{
				_count = _count + 1;
			};
		} forEach MAD_CivsArray;

		if (_count < MAD_maxCivDensity) then
		{
			[(position player), _count] call MAD_spawnciv;
		};

		sleep 10;
	};
};
};

Share this post


Link to post
Share on other sites

Yeah stupid me. It was late and i forgot to declare the _count variable for single player. Download link got updated and is working now.

Also i hardly saw cars with cars reduced to two per player (same setting i use for tpwcars). Do they have different waypoints, further away from the player?

If you used my standard parameters and only changed the amount of cars then you have 2 cars in 1000 meters and spawning at a minimum distance of 500 meters away from the player. They also do drive a bit different. Instead of randomly choosing a road they drive to randomly choosed locations like towns and villages and search for a waypoint there. Once they arrived there they begin to drive to another location.

Edited by MAD T

Share this post


Link to post
Share on other sites
Yeah stupid me. It was late and i forgot to declare the _count variable for single player. Download link got updated and is working now.

Thanks for fixing it!

Share this post


Link to post
Share on other sites

This is not working for me.

I use scripts like BTC, UPSMON, CTF etc etc so I understand the basics but I cant wrap my head around this one.

I have in my init.sqf

enablesaving [false, false];

[10, 500, 10] execVM "MAD_civilians.sqf";

[5, 500, 1000] execVM "MAD_traffic.sqf";

The 2 sqf's are in the file but I'm still not seeing traffic

Share this post


Link to post
Share on other sites

tested it yesterday for 2 hours on a mission on a dedicated server, works like a charm...we had civs and civ traffic.

Share this post


Link to post
Share on other sites
tested it yesterday for 2 hours on a mission on a dedicated server, works like a charm...we had civs and civ traffic.

I´m glad it worked for you.

This is not working for me.

I use scripts like BTC, UPSMON, CTF etc etc so I understand the basics but I cant wrap my head around this one.

I have in my init.sqf

enablesaving [false, false];

[10, 500, 10] execVM "MAD_civilians.sqf";

[5, 500, 1000] execVM "MAD_traffic.sqf";

The 2 sqf's are in the file but I'm still not seeing traffic

Can you provide more info on that? Any script errors.? Have you tested the demo mission and did that one worked for you?

the same for me, traffic not work i can´t see cars

Did at least civlians worked for you? Traffic might be rare do to my standard settings. Try changing the car amount to maybe 10 and take a helicopter to fly around.

---------------

Currently the scripts are working because i use the same on a dedicated server. I do also not know of any bugs currently. If some of you still can´t get it to work then send me your mission files and i will take a look at it.

Edited by MAD T

Share this post


Link to post
Share on other sites

MAD T, this works like a -charm-. Great job man.

Could you also add the ability to add a X amount of cars that have random damage states to your traffic script?

Share this post


Link to post
Share on other sites

Could you also add the ability to add a X amount of cars that have random damage states to your traffic script?

I could do that but AI drivers are tempted to leave their vehicle when it has little damage. I can do that for parked cars but i currently try to make some code optimisations.

The next update will have these optimisations and animals which i´m releasing today or if not then still this week. I´m currently also trying to figure out a good way for exclusion zones but as it´s weekend now my time to work on it might be a bit limited. So better don´t expect an update today.

Share this post


Link to post
Share on other sites

Will try it out. Thanks for saving me the effort of finishing and porting my old A2 population script. :)

Share this post


Link to post
Share on other sites

Did at least civlians worked for you? Traffic might be rare do to my standard settings. Try changing the car amount to maybe 10 and take a helicopter to fly around.

---------------

Currently the scripts are working because i use the same on a dedicated server. I do also not know of any bugs currently. If some of you still can´t get it to work then send me your mission files and i will take a look at it.

ok, in MP work fine civils and traffic for my,but in SP only civils is working

Thanks MAD T for you job

Share this post


Link to post
Share on other sites

Very nice a quick Q is the limit per location or per player ?

i.e

 [10, 500, 10] execVM "MAD_civilians.sqf";

would spawn 10 civi's is that at the location or per Player

Share this post


Link to post
Share on other sites
Very nice a quick Q is the limit per location or per player ?

i.e

 [10, 500, 10] execVM "MAD_civilians.sqf";

would spawn 10 civi's is that at the location or per Player

Per location. If two players are in the same area there will not spawn more civilians or cars when the limit is reached.

ok, in MP work fine civils and traffic for my,but in SP only civils is working

Hmm that is strange as far as i remember traffic worked for me in SP as well. I will have a look at it later.

Edited by MAD T

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  

×