TPW SKIRMISH - ambient combat system for Arma 3

Authors: tpw, CB65, dakaodo
Requires: Community Base Addons A3

Description
-----------
TPW SKIRMISH is a simple ambient skirmish combat system, which spawns multiple friendly patrolling BLUFOR, OPFOR and INDFOR squads and vehicles (not armour) around the player. The script periodically scans created units, removes distant units, and replaces killed or deleted units up to a user specified maximum. 

Footbound squads spawn into and patrol around nearby houses as well as out in the open. Vehicles will spawn onto and randomly patrol roads in a similar fashion to TPW CARS (except they'll try to kill people with weapons as well as their shit driving). If a unit is killed, other squads from the same side will move towards them in support. Squads reduced to a single unit will consolidate with the nearest existing squad. There are no other AI behaviour modifications, so you can use ASR, bCombat etc to enhance the AI behaviour.

Depending on the range and density of squads specified, TPW SKIRMISH can allow for the occasional surprise encounter out in the sticks, right up to full infantry combat around towns. The random spawning and movement towards killed colleagues generates unpredictable emergent behaviour and ensures that you'll never see the same battle twice.

Support
-------
In addition to patrolling, units can call in Close Air/UAV and Artillery Support on high value targets. If in danger or stealth mode (ie under fire) each AI squad leader periodically scans for units within 1000 m and determines if there are enemy vehicles, or multiple grouped enemies (each enemy within ~30 m of each other). If there are no friendlies or civilians near the target, the squad leader will randomly call in Close Air Support , Close Helicopter Support, UAV Support, Artillery High Explosive, Artillery Smoke, or Artillery Flares if at night. Each squad can only call one support at a time, and no matter how many squads, there can only be one instance of each support type active at a given time. Support calls are announced on radio so you won't blunder into anything nasty from your own sid. By default only NATO BLUFOR can call in support, but it can be enabled for other sides if desired.

To increase battlefield ambience HE Arty, CAS and UAV explsions will leave haze that persists for several minutes, eventually fading out. Similarly bomb craters will glow dull red at night, gradually fading out.    

Usage
-----
TPW SKIRMISH is set and forget once you've activated it and set the appropriate configuration values in the TPW_MODS.hpp. By default it spawns 2 squads and 1 vehicle for each faction, between 500 - 2000 m from the player. Squads are randomly chosen and between 2-8 members. You can of course change these parameters.

Factions
--------
You can select which factions you'd like to participate in the skirmishing, and TPW SKIRMISH allows you to use multiple factions at once. Each squad will consist of soldiers from one faction, you won't get a squad containing soldiers from multiple factions.

Factions for each side:

	0 = user specified
	1 = NATO
	2 = NATO PACIFIC
	3 = CTRG PACIFIC
	4 = CSAT
	5 = CSAT PACIFIC
	6 = AAF
	7 = FIA
	8 = SYNDIKAT

E.g
	tpw_skirmish_friendlytype = [1] will only use NATO friendlies.
	tpw_skirmish_friendlytype = [1,2] will use NATO and NATO PACIFIC as friendlies.
	tpw_skirmish_enemytype = [1,1,1,1,6,-8] will use CSAT enemies the majority of the time, with AAF and Syndikat as additional enemies.

Using a minus sign in front of a faction number will assign Shemag face coverings to them, making them a useful stand-in for ISIS style forces. The Syndikat forces in the above example will all wear shemaghs.

Using this system it's indeed perfectly possible to spawn NATO units as OPFOR and CSAT and INFOR for example. 

Custom factions and support
--------------------------- 
If you have 3rd party addons and would like to use them as factions, then if you know their classnames you can select them by specifying text unique to the factions. For instance, to use the excellent ADF Uncut DPCU Australian forces as friendlies:

	tpw_skirmish_friendlyunitstring = "_DPCU". 
	tpw_skirmish_friendlyvehiclestring = "_DPCU".
	tpw_skirmish_friendlytype = [0,1,5] will then use ADF, NATO and AAF as friendlies.
	
If the script cannot find any units using your specified text, then it will default back to NATO for friendlies, CSAT for OPFOR, and AAF for INDFOR.

Similarly, you can specify the classnames of the support helicopter and close support aircraft and UAV to use for each faction. You nay specify multiple classes for each, which will be chosen from at random. 

E.g
	tpw_skirmish_chsstring = ["b_heli_light_01_armed_f","b_heli_attach_01_f"] will randomly select between Pawnee and Blackfoot as BLUFOR support helis.

You may leave custom faction strings and custom support arrays as empty if you do not need to use them.

Disabling
---------
TPW SKIRMISH can be enabled/disabled at any time with tpw_skirmish_active = true/false. You can put this into a trigger to make areas of a map free of ambient combat thusly:

	Type: None
	Activation: BLUFOR, repeatedly,present
	Condition: vehicle player in thislist && time > 10;
	On act. : tpw_skirmish_active = false
	On dea. : tpw_skirmish_active = true

Issues
------
If you have any comments or ideas I welcome them as always, but let me just stress this right now: TPW SKIRMISH is not intended to be a replacement for MCC/ALIVE/DAC/UPS/UPSMON/etc. If you want highly configurable and plausible AI combat scenarios with garrisoning, static weapons, armour, boats, aircraft, caching, markers, MP support etc, use one of these excellent mods. If you just want to occasionally encounter bad people when you're SP on any map, then TPW SKIRMISH might fit the bill.

For the time being I'm sticking with the concept of asymmetric combat, with a US led NATO only putting ground troops down when they have overwhelming logistical support. So only NATO units (or your user defined friendlies) can call in support by default. You can of course switch enable/disable support for any side.

While I've gone to considerable efforts to reduce the microstuttering and CPU spiking associated with selecting appropriate spawning positions and waypoints, there is an inevitable overhead to spawning AI in A3, and an even bigger overhead when those AI encounter each other. You don't get anything for nothing in this game so expect to lose a few FPS when using TPW SKIRMISH, particularly when the participants start taking pot shots at each other.

By default the script runs once per 10 seconds, so it may take a few minutes to populate the area around the player with combatants. Expect the occasional minor dip in FPS as the squads spawn in.

TPW SKIRMISH heavily changes the dynamics of any mission, and is thus disabled by default.

Thanks
------
- CB65 for the AI support concept, code and debugging. Not to mention friendship and support. 
- Dakadao for taking it upon himself to extensively retool TPW SKIRMISH to enable INDFOR, the ability for all factions to call support, and other miscellaneous code improvements.