TPW AI LOS (TPWLOS)
By TPW 
v1.04 20120901

Introduction:
-------------
This addon improves AI response and realism in closer engagements. It is based on SaOk's excellent line-of-sight code which implements the new lineintersects, terrainintersect, eyepos and eyedirection commands introduced in beta patch 93666.

TPWLOS scans for enemies near each opfor or blufor or independent unit, determines if they have line of sight to the enemy (no buildings or terrain in the way), runs a few more visibility checks based on light level, movement, camouflage etc, and if the enemy is determined as visible then the unit will face towards and shoot at the enemy. Reaction time should be well under a second, which greatly enhances squad response and aggression in CQB situations.

Installation:
-------------
TPWLOS comes as a script version and an addon version.
CBA (community base addons) is required for both versions.
Beta patch 94103 or greater required. Works with patch 1.62.

Script version: 
Save tpw_ai_los.sqf into your mission directory (or wherever you'd like really)
Call it with: null = [] execvm "tpw_ai_los.sqf", in your init.sqf or in the init of any object on the map.

Addon version:
Unpack the addon version and call it by your favourite method. For more info on running mods please check out http://www.armaholic.com/plug.php?e=faq&q=18
If you want to be able to configure it then copy the configuration file to: your_arma_directory\userconfig\tpw_ai_los\tpw_ai_los.hpp

Configuration:
--------------
TPWLOS is highly configurable. The script version has a number of well commented variables to change aspects of the system. The addon version allows the same variables to be changed in the tpwc_ai_sup.hpp config file.

* Startup hint. 0 = no hint, 1 = hint. Default 1.
* Debugging. Units with LOS to a visible enemy will have a blue ball over their heads. 0 = no debugging, 1 = debugging. Default 0.
* Maximum distance (m). LOS stuff only works for units closer than this. Default 100.
* Minimum distance (m). Enemies are considered "visible" no matter what, if less than this distance. Default 25.
* Delay before LOS functions start (sec). Default 1. 
 
Caveats:
--------
* This is more a preliminary proof of concept addon, using beta commands, rather than a fully polished final product.  
* You MUST be using beta 94103 or greater, earlier betas simply lack the commands this system needs.
* Future betas may render this version unworkable.
* CBA is required.
* TPWLOS certainly sharpens up AI in CQB situations, but it does not make them killbots. A completely still enemy 75m away at night might not be "seen" by the AI even if the unit has line of sight to it.
* As far as the author can tell, TPWLOS causes minimal drops to framerate even on low spec machines, with 50 or so AI taking pot shots at each other. Your mileage may vary depending on computer specs and number of AI. I take no responsibility if your computer explodes. 
* TPWLOS is in its infancy and probably won't work the way everyone wants it to. I welcome any feedback and suggestions.

Thanks:
-------
* SaOk for the demonstrating use of the new BIS commands lineintersects, terrainintersect, eyepos and eyedirection.
* Maturin, Kremator, Zonekiller, Orcinus and CameronMcDonald for valuable feedback, input and suggestions.
* Falcon_565 for demonstrating the power of cba_fnc_addPerFrameHandler.
* Ollem for debug cleanup code
* BIS for an amazing piece of software which even allows scope for mods like this.

Changelog:
----------
* 1.00 20120628 
	- initital release
	
* 1.01 20120703 
	- bugfix release (configuration not working)

* 1.02 20120707
	- code cleanup and optimisation

* 1.03 20120822
	- bugfix release (sun angle detection not working - thanks Ollem)

* 1.04 20120901
	- additional bugfixes
	- enemy stance now affects their visibility (Ollem)