OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Gone Native on 09 Oct 2008, 20:09:04

Title: GNV Civilians (ACCEPTED)
Post by: Gone Native on 09 Oct 2008, 20:09:04
Gone Native's Civilians:

A populated Sahrani or United Sahrani with four working bus lines and as many moving civilian cars as you want, created using just scripts/functions.

For several kind of missions, like insurgency, counter-insurgency, spy or evade-and-escape missions, it would be nice if Sahrani would be populated with civilians, instead of being a beautiful but empty island.

ColonelSandersLite made an excellent suite of scripts, called "CSL populate island" which allows one to populate any island with civilians without much lag. Unfortunately the included demo mission only populated a part of the south of Sahrani.
The demo mission placed a lot of triggers on the mission editing map, used only as location indicators.
As an improvement I decided to write an additional set of scripts, -actually .sqf's nowadays-, that allows one to populate north- and/or south-Sahrani without the need to place any triggers or any other location indicators on the map in the mission editor.
Besides moving cars, empty cars, boats etc.. just for fun I also created four bus lines who will service all the bus stops on the map.

The download "GNV_Civilians_V1-0.zip" contains a basic demo mission in which you find the .sqf files.
The mission can run as single or multiplayer, and just allows you to have a look on Sahrani filled with GNV Civilian's with just default settings.
The documentation found in the .zip file is in .pdf:

There is a two pages Quick Start, which allows one to populate Sahrani, also in an existing mission, with a few steps: copy the folders into the mission folder. Adjust a few lines in the init.sqs of the mission and a populated Sahrani is up and running with default settings.

To adjust any of the separate script and functions to your needs, there is a six pages Reference Sheet. You can by example skip the boats, but keep the bus lines, and have only a few civilians running around. Or you can test the performance of ArmA on your computer to the limits by populating Sahrani with hundreds of civilians and many moving cars.

For more information, please read the Quick Start and/or the Reference Sheet

Changelog from beta to version 1.0:

Scripting:

Vehicles:

Demo-mission:

Documentation:


OFPEC Download (http://www.ofpec.com/ed_depot/index.php?action=details&id=601)
Title: Re: GNV Civilians
Post by: Trexian on 09 Oct 2008, 20:24:47
:D

Must be something in the stars!  :cool2:

Will check it out!

Edit;
Ok, keep in mind I am still very much a novice at this.  So, probably better to wait for some advice from others. :)

But, I took a look at the bus script, since I was honestly thinking of this EXACT same thing. :D

In looking at your GNV_N_Busses_Create.sqf it looks like there are alot of actions that could be combined more efficiently into iterative loops using arrays.

For instance, all the locations are static - that is, they won't move at all.  Put all the locations into an array like
Code: [Select]
_busstops01 = [[16469.761719, 9296.402344, 11.970000], [15572.099609, 8824.228516, 29.807102], .....];

Then, something like _i = _i + 1 loop, then set the marker position and waypoint position as (_busstops select _i).  Have a different array for each bus line.

That's just an initial observation. :)

LOVE the idea, though.   :clap:

Edit2:
I noticed you use createAgent?  I didn't realize that was working. :) 
Title: Re: GNV Civilians
Post by: Gone Native on 10 Oct 2008, 10:00:18
Yes, you are right.
Working in Real Life in IT and knowing quite a few programming languages I see what you mean.

The creation of waypoints and even more the creation of triggers -that show you the actual location of the bus on the map if you stand at a bus stop-, can be done in iterative loops.

An interesting question is whether code execution runs faster with iterative loops, or that it doesn't matter ?
(Is in this case a loop quicker than a sequence ?)  ???

While making these .sqf's it was more convenient to work this way for purpose of keeping track which behavior should be part of which waypoint. I.e. in Bagango it is essential that a bus runs at "limited" speed, whereas on the road to Corazol "full" speed is possible. Some waypoints are the bus stops, other waypoints are just to keep a bus on the right track.

But if the script suite gets a "final" version, iterative loops are certainly a better choice for readability.


createAgent:
The purpose of using the createAgent statement for me was part of an experiment, to see if I could get around the issue that in single player at least one civilian has to be placed on the map IN the mission editor, to get the scripts working (otherwise there are cars and busses, but no civilians in them ). By the way, in multiplayer this is not an issue.
I didn't know the 'createAgent' statement was not working. A pity, because it is a good statement, allowing quick creation of an independent character.
Title: Re: GNV Civilians
Post by: i0n0s on 10 Oct 2008, 10:58:40
@createAgent:
Use createCenter to create a AI center.
Title: Re: GNV Civilians
Post by: Mandoble on 10 Oct 2008, 11:04:02
Should this be considered as a "beta" resource or as a "ready" resource?
Title: Re: GNV Civilians
Post by: Gone Native on 10 Oct 2008, 12:28:19
A "beta" resource.

Scripting can use some improvement (See above) and the documentation can use some slight improvements.

Furthermore in the vehicle testing I used the basic rule:
If it is the same vehicle having the same collison at the same location, I have to try to solve that issue.
Possible solutions:
- Change in speed
- Change in waypoint
- In rare cases: civilian vehicle slow-down trigger
- In rare cases: place an object, like a wreck or something (sometimes AI seems to prefer a route through a garden, above the road, mostly being stopped by some fence. Place an object proves an effective barrier for that behaviour)

But their might be vehicle-issues that I still haven't solved.
Title: Re: GNV Civilians (BETA)
Post by: Trexian on 10 Oct 2008, 14:25:35
For all I know createAgent may be working now. :)  All I know is that at one time the Biki said it wasn't implemented.  I wonder if some patch along the way may have activated it.   :good:
Title: Re: GNV Civilians (BETA)
Post by: Gone Native on 10 Oct 2008, 15:02:04
If have tested createAgent.
It doesn't work, so it seems that BIS didn't solve it in a patch.

If have also tested createCenter as suggested by i0n0s.
That works fine  :)

Means that there is no need to place at least one civilian IN the mission editor on the map, as long as you use createCenter early on, in the init.sqs or first lines of the sqf's.
Title: Re: GNV Civilians (BETA)
Post by: USM-CPT.Dyson on 15 Oct 2008, 06:10:12
Ran the demo, works pretty good. Sometimes though civilians will stop moving yet appear as if they are just stuck. Also, although my computer is really slow, it seems a bit laggy. I generally don't get lag as bad so I don't know what's going on. Ape example, I run all of mando's and spooner's scripts and I don't get as low of an FPS. Ill do a bit more testing but it freezes up and moves slow on load.
Title: Re: GNV Civilians (BETA)
Post by: Gone Native on 15 Oct 2008, 10:05:27
I developed this script suite on a computer with an Intel E8400. Which is here in the Netherlands a recent, but middle-of-the-road gaming processor. Than I get an average framerate of 20+ depending on where I am and what I do...

The demo mission populates the north AND the south of Sahrani, with around 20 moving vehicles on each side, and 240+ civilians in the north and 340+ civilians in the south. Most scenario's will only have to populate either the south or the north of Sahrani.

A simple way to improve performance is to populate only the north OR the south:
Open the demo-mission init.sqs within the mission folder for editing.
Put a semi-colon  ;  -i.e. a comment-marker in .sqs- before either the line:
res = [] execVM "GNV_Civilians\GNV_Populate_South.sqf"
or the line
res = [] execVM "GNV_Civilians\GNV_Populate_North.sqf"
and only the north or the south will be populated.

In the Reference Sheet you can read how to lower the fill factor of the civilians. So that not 240+ are walking around in the North, but -for example- 120+

By the way: I am implementing the advise of Trexian for iterative loops: Didn't run faster, but made some of the .sqf's significantly smaller.
And I solved some vehicles getting in a nasty 'cycle' within the beachresort of Arcadia and a traffic problem at a junction in nearby Cayo.

Yeah, it certainly freezes up a few seconds during the start of the mission (when all these vehicles and civilians are placed "on the fly").
The behaviour of the civilians is part of the ColonelSandersLite "Populate Island" script suite.
He puts them in groups of up to five, in the limited speed mode, and with a doMove they randomly will stand still or walk to another waypoint within a certain radius.
Unfortunately ArmA civvies prefer the middle of the road and are not aware of any traffic  :(
Don't expect much interesting behaviour of 'vanilla' civilians within ArmA, it's not the Sims.

Title: Re: GNV Civilians (BETA)
Post by: i0n0s on 15 Oct 2008, 11:03:19
So the civilians are there, even if no player is around them?
Since movements will cause load, even if the player is not around, I would recommend that you freeze the civilians when no player is around and simulate their movement via script. That should reduce the load and solve some stocked vehicles ;)
Title: Re: GNV Civilians (BETA)
Post by: Gone Native on 15 Oct 2008, 15:02:35
No, that is not an issue.
The script suite of ColonelSandersLite "Populate Island", creates just a civilian bubble of 550 (ArmA) meters around a human player.
And outside that bubble the civilian's position is remembered, but with a "deleteVehicle" they are removed. One could say "stored".
So no,  they are not all 240+ and 340+ jumping around  :)
Title: Re: GNV Civilians (BETA)
Post by: USM-CPT.Dyson on 15 Oct 2008, 20:01:49
Keep in mind i received the same results when i tested CSL Populate Sahrani the 1st time. I didn't realize that you made no changes to his script. Not really sure what the issue is though :(
Title: Re: GNV Civilians (BETA)
Post by: Commando84 on 15 Oct 2008, 22:54:38
Hi I know you said that the script was very basic but im wondering that if I want to add auto refueled civilian vehicles to my mission kind of like the RBT warefare has for the supply trucks.
Code: [Select]
#Update
~10

_base = Call Compile Format["%1Base",Str _side]

if (IsNull _vehicle) then {Goto "Quit"};
if (IsNull Driver _vehicle) then {Goto "Quit"};
if (!Alive Driver _vehicle) then {Goto "Quit"};
if (!CanMove _vehicle || GetDammage _vehicle >= 1) then {Goto "Quit"};
if (IsNull _destination) then {Goto "GetDestination"};
;;added by {USI} Studios to refuel supply trucks,thanks to oktane from the BI forums
if (fuel _vehicle < 0.3) then (_vehicle setFuel 1);

Any1 know how would i add this piece o script to this great populate island script?
Title: Re: GNV Civilians (BETA)
Post by: wolffy.au on 16 Oct 2008, 08:59:37
Oh, this is great news GN - I was writing the same thing but only for Paraiso. I'll look thru the code and let you know of any issues I find or patches. You've just saved me a heap of work so i'll be happy to help out.
Title: Re: GNV Civilians (BETA)
Post by: Gone Native on 16 Oct 2008, 11:54:08

Quote
Commando84:
Any1 know how would i add this piece o script to this great populate island script?

In the GNV_ scripts all by the script created civilian vehicles get a 'setFuel 1.0' and 'setDamage 0.0' at each waypoint that they reach.
This means that small damage is not an issue and the vehicles will never run out of fuel  :cool2:

The advantage is that serious damage in between waypoints, mostly because of combat or an accident, is not affected by this waypoint statement.
If the car is disabled, it is not 'suddenly' magically repaired. But small damage during gameplay, like hitting roadsigns and barriers or hitting other vehicles, is not rendering the civilian vehicle after a while out of service.
Title: Re: GNV Civilians (BETA)
Post by: Commando84 on 16 Oct 2008, 18:50:20
sweet thx dude!  :good:
Title: Re: GNV Civilians (Ready)
Post by: Gone Native on 20 Oct 2008, 22:31:11
GNV Civilians went from beta to version 1.0

You can read the change log and find the fresh download in the first post of this thread.
Title: Re: GNV Civilians (Ready)
Post by: Mandoble on 20 Oct 2008, 23:00:01
Nice work Gone Native, might be you want to adjust the civilian population to not be quite close to the bus lanes. I know pretty well it is not your fault, but you know that ArmA driving is plain terrible and the buses keep killing civilians crossing the roads, and then stopping and not being able the maneouver in the street, that if not just crashing against other cars. My suggestion would be to have the bus lanes as clean as possible mainly for player usage when necesary.
Title: Re: GNV Civilians (Ready)
Post by: Mr.Peanut on 21 Oct 2008, 15:49:03
A certain amount of roadkill is realistic, don't you think?
Title: Re: GNV Civilians (Ready)
Post by: Gone Native on 21 Oct 2008, 16:58:44
@Mandoble:
What you suggest is a lot of work.

Example: Mercalillo has the main roads going in a T-junction through the hamlet.
Now it is filled with civilians with just one statement.
If one likes to keep the main roads clear you need three statements:
one above the T; one left of the T; one right of the T.

Something for version 1.1  ;)

It is also a pity that in ArmA the civilian AI prefers to walk the exact middle of the road.  :no:
More natural behaviour would be to walk on the side of a road. Even when one walks on a vehicle dirt track you don't walk exactly in the middle.


Another interesting issue is better multiplayer behaviour:
Now each human player has it's own "bubble" of civilians around him.
Works to some extend well with only a few human players, but doesn't work nicely with a lot of human players.

A solution might be to give each location where one creates civilians also a unique boolean variable (true/false) which is global to all human players.
If the creation of civilians in location X is already triggered by human player A the boolean for that location is put on 'true'.
If another player, let's say player B get nears location X, the creation of civilians is not triggered, because the location boolean, is on 'true', meaning: another human player has already triggered the creation of civilians for that location.
Title: Re: GNV Civilians (Ready)
Post by: desrat on 29 Oct 2008, 23:27:23
Any luck on full MP compatability as yet?  Would love to make use of this in somthing..
Title: Re: GNV Civilians (Ready)
Post by: Gone Native on 30 Oct 2008, 21:14:16
I will work on a version 1.1 in which I will implement the comments of Mandoble (i.e. try to keep road the bus travels free from civilians) and and I will think about trying to solve the -more than a few players- multiplayer issue.

Solving both issues will make the population part of the script suite more complicated, so might affect performance. (The vehicle part of the script suite, like the buslines and cars, are uneffected by this and can at present without any problems be used in multiplayer).

Anyway: it might take some time before there will be a version 1.1

In the present situation each human player has it's own "bubble" with civilians, so if you keep the civilian _fillfactor low, that might work for your mission. It depends on how many human players you expect to gather within a civilian area like a town or a hamlet.
Title: Re: GNV Civilians (Ready)
Post by: desrat on 01 Nov 2008, 18:01:41
Well I'm talking 30 player co-op for my missions, and want civilians to help increase the realism factor, I could place them manually of course but I'm lazy and any option to automate anything apeals to me :)

Thats why I like Mykes ArmA Co-Op Essential pack where you place an editor item (I believe he uses a road cone as an example) as the centre of a spawn radius that tells the server to spawn enemies/civilians when your within a certain distance of that area, maybe this is something you could look at fiddling with to use and just enable the transport links.

That way the misson planners have the power to place civs just where they're needed and not have to populate the whole north/south, again hopefully improving system resource useage.

Maybe I'm totally off here but that would work for me..
Title: Re: GNV Civilians (Ready)
Post by: Gone Native on 02 Nov 2008, 16:03:55
What might work better for you (because of performance and you don't need half an island with civilians) and is quite easy to do:

In the mission editor, choose "groups F2"; "Civilians"; "Type: Infantry Squad"; "Name: Crowd"

This will place a group of nine random civilians.
Than give them just one waypoint of the type "Dismissed".
Make their behaviour etc.. to your own taste, but I usually choose "careless", "full speed", if these civilians are in a combat zone.
"Dismissed" means that they will walk around like dismissed soldiers, even sitting if they are relaxed.

Two of these groups in a hamlet or a few in a small town and you have your civilians in a warzone.
Title: Re: GNV Civilians (Ready)
Post by: desrat on 02 Nov 2008, 22:09:37
Yes that would do the trick but what I really need is those units held in cache untill needed and then spawned rather than having these civs all over, my mission is a dynamic campaign with multiple targets and populating areas dynamically is really a better all round soloution to me..

I wish I had the know how to do this myself, I really do but I'm still doing baby steps when it comes to scripting and need to draw heavily on other people's great work..


#EDIT - Removed unnecessary quote      h-
Title: Re: GNV Civilians (Ready)
Post by: Kremator on 02 Nov 2008, 23:10:56
Can't DAC2 do that for you?  That would make it a dynamic spawn.

[TAO] Kremator
Title: Re: GNV Civilians (Ready)
Post by: desrat on 03 Nov 2008, 00:17:06
Can't DAC2 do that for you?

Interesting scripts, haven't come across these before although we (my team) do use some mapfact addons already, so thanks for pointing them out..

EDIT: This is a little overly complicated to implement and I have to admit is taking some effort getting my head around, but I'll get there so thx again for the re-direct..
Title: Re: GNV Civilians (ACCEPTED)
Post by: laggy on 15 Mar 2009, 15:03:14
Hi Gone Native and thanks for a great script.

This will definitely make your missions more "alive" without too much effort. Good Job!

One question though:

How are the civilians deleted when the players are out of range to see them?
In a mission I would like the players to be able to make a civilian take them somewhere.
That civilian would be "picked" from your generated createUnit'd units.
How can I bypass the deleting function for that or those picked units?

Is the deleting based on "present in area" or group or name or what?

Thanks again,

Laggy
Title: Re: GNV Civilians (ACCEPTED)
Post by: Gone Native on 22 Mar 2009, 15:36:31
Sorry for reacting after a week, but I rarely visit this forum now-a-days.

If a player gets within 550 "ArmA" meters of a defined civilian spawn area, a group of civilians will spawn in a  rectangle, which size is defined in GNV_x_Populate.sqf.
After the player leaves that 550 "ArmA" meters radius, they will be removed with a deleteGroup statement.
You can look for that in the CSL_ part of the script suite.

I advise against using one of these spawned civilians for some special purspose within a mission.
Because:
First: they don't have an individual (vehicle or object) name. Makes it difficult to single them out and address them.
Secondly: they have orders to walk around within the defined rectangle, and their objective will shift at a random time for a random amount of "ArmA" meters.

So you have to identify your nearest civilian within the group -note that the 'civilians' contain 20 different type of civilians-, remove him from the group (because the group gets different orders).
I think that it can be done, but won't be easy. I would simply spawn a few civilians that at least have a individual (vehicle) name, so can be controlled by the mission maker.
Title: Re: GNV Civilians (ACCEPTED)
Post by: laggy on 22 Mar 2009, 16:21:44
Thanks a lot.

Great script  :clap:
Title: Re: GNV Civilians (ACCEPTED)
Post by: Grimfist on 06 Nov 2009, 22:13:23
sorry to dig up an old thread, but the DL isnt working, there is an older version on armaholic, but i want to try this one. TIA,
Grim