TPW FALL - realistic falling system for Arma 3

Author: tpw, Das Attorney, MrFlay
Requires: Community Base Addons A3, flay.pbo, tpw_sounds.pbo
Compatibility: SP, MP client (maybe)

Description
-----------
Two of my major annoyances with Arma3:
1 - unrealistic infantry falling simulation. Although things are improving, a falling (not freefalling) unit still looks and behaves like it is made out of styrofoam, with little sense of inertia and no noise. There is essentially no penalty for jumping from heights which would cause stumbling/falling/injury in real life. 
2 - unrealistic reaction to bullets and damage. Units unrealistically flinch until dead when absorbing damage from bullets and explosions that should at least knock them down.  

TPW FALL attempts to remedy the first problem by monitoring the vertical distance travelled by a footbound unit when it is not in contact with the ground, and triggering the appropriate in-built sounds and animations for the different distances. Similarly, the second problem is addressed using falling animations (and optional ragdoll effects) triggered when a unit takes damage from projectiles and explosions. 

TPW FALL works for the player and all units on the map, whether editor placed or spawned, combatant or civilian, and is written to cause no discernable FPS hit even with dozens of units on a map.

Usage
-----
Falling simulation:	
	- Unit will react to the ground after falling/jumping from a height.
	- All falls trigger landing sounds, volume dependent on the height of the fall.
	- Falls into water trigger splashing noises.
	- Freefalling triggers rushing wind noise, opening a chute triggers gentler wind noise.
	- Landing from a fall of < 1 m triggers sounds only.
	- Landing from a fall of 1 - 2 m triggers kneeling animations and noises.
	- Landing from a fall of > 2 m triggers fall to ground animations and noises. Yells are randomly triggered with greater frequency for longer falls.
	- A fatigued unit is more influenced by the fall.
	- A heavier unit is more influenced by the fall.
	- Fall distance is randomised +/- 10% to simulate slightly different reactions to the same fall. A 2 m fall will register between 1.8 to 2.2 m.
	- Unit's fatigue is increased by a fall (approx 10% for a 2 m fall).
	- Units must be within a certain threshold distance of the player to react realistically to falls.
	- Overall sensitivity of the system may be adjusted. 50% sensitivity = 2m fall will register as 1 m fall.
	- A lightly weighed down infantry unit can usually jump from heights of up to 2 m without completely falling to the ground. By comparison a heavily weighed down unit with backpack, launcher, and lots of ammo will likely fall to the ground after a jump of 1-2 m. Fatigue will further decrease the height that a unit can jump from without hitting the deck.  

Bullet hit simulation:
	- Low damage bullet/explosion impacts will trigger animated falling to ground, and a fairly rapid return to the unit's previous stance. 
	- Higher damage impacts will trigger ragdoll falling to ground.
	- Hit units will remain immobilised on the ground after fall, for a time related to the degree of injury.
	- Hit units will have skills reduced for the duration of the fall, with skill reduction related to the degree of injury.
	- Hit units will be fatigued, with fatigue related to the degree of injury.
	- Ragdolling may be disabled, in which case only animated falling will be triggered.
	- Player bullet hit simulation may be disabled.

TPW FALL adds quite a bit more immersion to gameplay since a unit will now behave like it has inertia and react with the ground and bullets. If you attempt to parkour off a 3 m high balcony in full kit, you'll fall and be incapacitated on the ground for a few seconds, just like real life. If you take a NATO round in the chest, you'll be knocked over at the very least.

Known issues
------------
TPW FALL was originally written in mid 2013. In mid 2014 I completely overhauled and optimised the code. However there are still likely bugs and room for improvement.
	- TPW FALL uses switchmove to allow immediate transition to landing animations, which causes a small glitch in 1st person view depending on where you are looking.
	- I am limited in the realism I can achieve with the animation resources of the default game (which are admittedly far superior to earlier Arma versions).
	- I have tried to implement MP compatibility but am not sure if it works properly.
	- If you are using build 137290 or greater, TPW FALL uses the ability of the setunconscious command to immediately place a unit into a ragdoll state. The unit will fall to the ground, roll over writhing, and eventually return to their feet. For earlier builds setunconscious does not work, so ragdolling is implemented by hacks. Units closer than 100m to the player can be induced into a realistic ragdoll state by hitting them with an invisible PhysX enabled object. PhysX does not work beyond 100m from the player, so distant units are ragdolled by hiding them and replacing the hidden unit with a "body double" which is then killed to induce ragdolling. The killed body double is then replaced with the original unit. Unfortunately the transitions between original and body double are not seamless, but hopefully less noticeable at the greater distance.
	- Do not expect or ask for Hollywood style ragdolling with bodies flying from bullet hits. A hit unit simply drops.	
	- TPW FALL does not influence a unit's health or behaviour. I prefer to let the engine or other scripts handle this.
	- TPW FALL uses custom wind rushing noises in tpw_sounds.pbo, and a script only version will not play these sounds. 
	- TPW FALL requires a custom PhysX enabled invisible geometry object in flay.pbo. 

Thanks
------
Das Attorney: PhysX ragdolling code and PhysX enabled object
MrFlay: Original invisible geometry object
zapat: coding tips
Lifted86: help with sound playing
Foxhound: constant support of mod makers
McLupo: videography 	