// C130 addon v1.0 by HAWK
// Textures from MFS
// animations and scripts by hawk

// some basic defines
#define TEast 0
#define TWest 1
#define TGuerrila 2
#define TCivilian 3
#define TSideUnknown 4
#define TEnemy 5
#define TFriendly 6
#define TLogic 7

#define true 1
#define false 0

// type scope
#define private 0
#define protected 1
#define public 2

class CfgPatches
{
	class C130
	{
		units[] = {C130};
		weapons[] = {c130_Flare};
		requiredVersion = 1.85;
	};
};
class CfgModels
{
	class Default
	{
		sections[] = {};
		sectionsInherit="";
	};
	class Vehicle: Default{};
	class C130: Vehicle 
		{
			sectionsInherit="Vehicle";
			sections[]=
			{
			"cislo",
			"grupa",
			"side",
			"sektor",
			"clan",
			"podsvit pristroju",
			"poskozeni",
			"L svetlo",
			"P svetlo",
			"zasleh",
			"sklo predni p",
			"sklo predni l",
			"vrtule staticka",
			"vrtule blur"
			};
		};
};

class CfgAmmo
{
class Default {};
	class AT3: Default {};
	class CarlGustav: AT3 {};
 	class AA : CarlGustav {};
	class Hellfire: AT3 {};
	class c130_Flare : Hellfire
	{
		cost=20;
		proxyShape = "\hwk_c130\c130_flare.p3d"
		model = "\hwk_c130\c130_flare.p3d";
		maxControlRange=0; 
		simulationStep=0.05;
		simulation=shotRocket;
		hit=0;indirectHit=0;indirectHitRange=0.001;
		minRange=50;minRangeProbab=0.20;
		midRange=300;midRangeProbab=0.95;
		maxRange=500;maxRangeProbab=0.20;
		soundHit[]={"Explosions\expl3",db-50,2};
		irLock=0;
		laserLock=0;
		dispersion=200.000000;
		sideAirFriction=1.0; 
		maneuvrability=0;
		maxSpeed=100;
		initSpeed=-10;
		initTime=0.01; 
		thrustTime=10.0;
		thrust=5;
		explosive=0;
	};	
};


class CfgWeapons
{
class Default {};
	class LAWLauncher: Default {};
	class CarlGustavLauncher : LAWLauncher {};
	class AT3Launcher: CarlGustavLauncher {};
	class HellfireLauncher: AT3Launcher {};
	class MaverickLauncher: HellfireLauncher {};

	class c130_Flare : AT3Launcher	
	{
		ammo=c130_Flare;
		displayName=Flare;
		displayNameMagazine=c130_Flare;
		shortNameMagazine=c130_Flare;
		count=100;
		model = "\hwk_c130\c130_flare.p3d";
		reloadTime=0.75; 
		aiRateOfFire=0.0125; 
		aiRateOfFireDistance=300; 
		sound[]={"\HWK_c130\flare.ogg",db+80,1.5};
		reloadSound[]={Weapons\missload,db-70,1};
		initSpeed=10;
		magazineReloadTime=1.0;
		autoFire = true;
		burst=1;
	};
		
};

class CfgRadio
{
	class stallwarnsndc130
	{
	name = "";
	sound[]={"\HWK_c130\stallwarn.wav",1,1};
	title = ;
	};
	class warnhighsndc130
	{
	sound[]={"\HWK_c130\highwarn.wav",1,1};
	name = "";
	title = ;
 	};
	class missilewarnsndc130
	{
	sound[]={"\HWK_c130\missile.wav",1,1};
	name = "";
	title = ;
 	};
	class warnsndc130
	{
	sound[]={"\HWK_c130\warn.wav",1,1};
	name = "";
	title = ;
 	};	
};
	
class CfgSounds
{
	class enginestartc130
 	{
   	sound[]={"\HWK_c130\enginestart.ogg",1,1};
   	name = "enginestartc130";
	titles[] = {};
 	};
	class enginestopc130
	{
	sound[]={"\HWK_c130\enginestop.ogg",1,1};
	name = "enginestopc130";
	titles[] = {};
 	};
	class rampasndc130
	{
	sound[]={"\HWK_c130\rampa.ogg",1,1};
	name = "rampasndc130";
	titles[] = {};
 	};
	class gearupsndc130
	{
	sound[]={"\HWK_c130\geardn.ogg",1,1};
	name = "gearupsndc130";
	titles[] = {};
 	};
	class geardnsndc130
	{
	sound[]={"\HWK_c130\gearup.ogg",1,1};
	name = "geardnsndc130";
	titles[] = {};
 	};
	class wheelnsndc130
	{
	sound[]={"\HWK_c130\wheeltouch.wav",1,1};
	name = "wheelnsndc130";
	titles[] = {};
 	};
		
};

class CfgVehicles
{
	class All {};
	class AllVehicles: All {};
	class Air: AllVehicles {};
	class Plane: Air {};
	class C130:Plane
	{
	class EventHandlers
      {
	init = "[vehicle (_this select 0)] exec {\HWK_c130\script\wheeltouch.sqs};[vehicle (_this select 0)] exec {\HWK_c130\script\highwarn.sqs};[vehicle (_this select 0)] exec {\HWK_c130\script\stall.sqs};[vehicle (_this select 0)] exec {\HWK_c130\script\warninglight.sqs};[vehicle (_this select 0)] exec {\HWK_c130\script\ramplight.sqs};[vehicle (_this select 0)] exec {\HWK_c130\script\fuellight.sqs};if !(isengineon (_this Select 0)) then {[_this select 0] exec {\HWK_c130\script\openramp.sqs}} else{[_this select 0] exec {\HWK_c130\script\gearup.sqs};vehicle (_this select 0) flyinheight 200}";
	
	gear = "if (_this Select 1) then {[_this select 0] exec {\HWK_c130\script\geardown.sqs};[_this select 0] exec {\HWK_c130\script\closegas.sqs}} else {[_this select 0] exec {\HWK_c130\script\gearup.sqs}}";
        
	Engine = "if (_this Select 1) then{[_this select 0] exec {\HWK_c130\script\closeramp.sqs};[_this select 0] exec {\HWK_c130\script\enginestart.sqs}}else {[_this select 0] exec {\HWK_c130\script\openramp.sqs};[_this select 0] exec {\HWK_c130\script\enginestop.sqs}}";
	
	GetOut = "[_this select 0] exec {\HWK_c130\script\desantout.sqs}";	
	Getin = "[_this select 0] exec {\HWK_c130\script\desantin.sqs}";
	
	incomingMissile = "if ((_this select 0)==(_this select 0)) then {(_this select 0) vehicleRadio ""missilewarnsndc130"";(_this select 0) fire ""c130_Flare""}";
	
	hit="[_this select 0] exec {\HWK_c130\script\ostrzal.sqs}";
      	};
		vehicleClass = "HAWK - Vehicles";
		scope=public;
		crew = SoldierWPilot;
		icon = "\HWK_c130\c130icon.paa";
		picture = \HWK_c130\c130.paa;
		side=TWest;
		displayName="C-130 Hercules";
		nameSound="plane";
		transportFuel = 100000;
		transportVehiclesCount = 3;
		transportVehiclesMass = 45000;
		transportAmmo = 100000;
		gearRetracting = true;
		animated=1;
		formationX=20;
		formationZ=20;
		formationTime=10;
		precision=50; // vehicle movement precision
					
		driverAction=ManActCessnaPilot;
		
		insideSoundCoef = 0.5;

		cargoAction[]={ManActCessnaPilot,ManActCargo};

		transportSoldier = 38;
		nightVision=1;
		typicalCargo[]={};
		ejectSpeed[]={0,0,0};
	
		maxSpeed = 600;
		landingSpeed = 180;
				
		soundEngine[]={\HWK_c130\engine.wav,db-10,1};
		
		model="\HWK_c130\c130.p3d";
	
		weapons[]={c130_Flare};
		magazines[]={c130_Flare};
		
		aileronSensitivity = 0.10;
		elevatorSensitivity = 0.4; // relative elevator sensitivity
		brakeDistance=250;
		steerAheadSimul=1; // steer point on path properties
		steerAheadPlan=2;
		noseDownCoef =  0.4; // how much goes nose down during turns
		terrainCoef=0.1;
		turnCoef=0.1;
		armor=50;
				
		dammageHalf[]=
		{
			kiowa_sklo.paa,uh60_kab_sklo2B.paa
			
		};
		dammageFull[]=
		{
			kiowa_sklo.paa,uh60_kab_sklo2C.paa
			
		};

		class Reflectors
		{
			class Left
			{
				color[] = {0.8, 0.8, 1.0, 1.0};
				ambient[] = {0.07, 0.07, 0.07, 1.0};
				position = "L svetlo";
				direction = "konec L svetla";
				hitpoint = "L svetlo";
				selection = "L svetlo";
				size = 0.5;
				brightness = 1.0;
			};
			class Right
			{
				color[] = {0.8, 0.8, 1.0, 1.0};
				ambient[] = {0.07, 0.07, 0.07, 1.0};
				position = "P svetlo";
				direction = "konec P svetla";
				hitpoint = "P svetlo";
				selection = "P svetlo";
				size = 0.5;
				brightness = 1.0;
			};
		};


		class IndicatorAltRadar
		{
			// max for this indicator is 1000 feet (i.e. 304m)
			// note: this is actualy Baro altitude (name is wrong)
			selection = "alt";
			axis = "osa_alt";
			angle = -360;
			min = 0;
			max = 304;
		};
		class IndicatorAltBaro
		{
			selection = "nm_alt";
			axis = "osa_nm_alt";
			angle = -180;
			min = 0;
			max = 61;
		};
		class IndicatorSpeed
		{
			selection = "mph";
			axis = "osa_mph";
			angle = -320;
			min = 0;
			max = 125;
		};
		class IndicatorVertSpeed
		{
			selection = "vert_speed";
			axis = "osa_vert_speed";
			angle = -300;
			min = -30;
			max = 30;
		};
		class IndicatorRPM
		{
			selection = "rpm";
			axis = "osa_rpm";
			angle = -320;
			min = 0;
			max = 12;
		};
		class IndicatorCompass
		{
			selection = "kompas";
			axis = "osa_kompas";
			angle = -360;
			min = -3.1415926536;
			max = 3.1415926536;
		};
		class IndicatorWatch
		{
			hour = "hodinova";
			minute = "minutova";
			axis = "osa_time";
			reversed = true;
		};
		class IndicatorAltRadar2
		{
			selection = "alt2";
			axis = "osa_alt2";
			angle = -360;
			min = 0;
			max = 304;
		};
		class IndicatorAltBaro2
		{
			selection = "nm_alt2";
			axis = "osa_nm_alt2";
			angle = -180;
			min = 0;
			max = 61;
		};
		class IndicatorSpeed2
		{
			selection = "mph2";
			axis = "osa_mph2";
			angle = -320;
			min = 0;
			max = 125;
		};
		class IndicatorVertSpeed2
		{
			selection = "vert_speed2";
			axis = "osa_vert_speed2";
			angle = -300;
			min = -30;
			max = 30;
		};
		class IndicatorRPM2
		{
			selection = "rpm2";
			axis = "osa_rpm2";
			angle = -320;
			min = 0;
			max = 12;
		};
		class IndicatorCompass2
		{
			selection = "kompas2";
			axis = "osa_kompas2";
			angle = -360;
			min = -3.1415926536;
			max = 3.1415926536;
		};
		class IndicatorWatch2
		{
			hour = "hodinova2";
			minute = "minutova2";
			axis = "osa_time2";
			reversed = true;
		};

class Animations
	{
	class backgear0
         {
            type="rotation";
            animPeriod=6;
            selection="backgear0";
            axis="osbackgear0";
            angle0=0
            angle1=0.872;
         };
	class backgear1
         {
            type="rotation";
            animPeriod=6;
            selection="backgear1";
            axis="osbackgear1";
            angle0=0
            angle1=0.872;
         };
	 class leftkl
         {
            type="rotation";
            animPeriod=2;
            selection="leftkl";
            axis="osleftkl";
            angle0=0
            angle1=-0.523;
         };
	 class leftkl1
         {
            type="rotation";
            animPeriod=1.2;
            selection="leftkl1";
            axis="osleftkl1";
            angle0=0
            angle1=3.14;
         };
	 class rightkl
         {
            type="rotation";
            animPeriod=2;
            selection="rightkl";
            axis="osrightkl";
            angle0=0
            angle1=0.523;
         };
	class rightkl1
         {
            type="rotation";
            animPeriod=1.2;
            selection="rightkl1";
            axis="osrightkl1";
            angle0=0
            angle1=-3.14;
         };
         class frontkl
         {
            type="rotation";
            animPeriod=2;
            selection="frontkl";
            axis="osfrontkl";
            angle0=0
            angle1=0.195;
         }; 
	class NoseGear
         {
            type="rotation";
            animPeriod=6;
            selection="front_gear";
            axis="osfront_gear";
            angle0=0
            angle1=1.6;
         };
			class rampa
			{
				type="rotation";
				animPeriod=6;
				selection="rampa";
				axis="osrampa";
				angle0=0;
				angle1=0.66;
			};
			class rampa1
			{
				type="rotation";
				animPeriod=5;
				selection="rampa1";
				axis="osrampa1";
				angle0=0;
				angle1=0.523;
			};
			class door1
			{
				type="rotation";
				animPeriod=4;
				selection="door1";
				axis="osdoor1";
				angle0=0;
				angle1=-2.4;
			};
			class door2
			{
				type="rotation";
				animPeriod=3;
				selection="door2";
				axis="osdoors";
				angle0=0;
				angle1=0.785;
			};
			class door3
			{
				type="rotation";
				animPeriod=3;
				selection="door3";
				axis="osdoors";
				angle0=0;
				angle1=-0.785;
			};
			class trotle1
			{
				type="rotation";
				animPeriod=2;
				selection="trotle1";
				axis="ostrotle";
				angle0=0;
				angle1=1.918;
			};
			class trotle2
			{
				type="rotation";
				animPeriod=2;
				selection="trotle2";
				axis="ostrotle";
				angle0=0;
				angle1=1.918;
			};
			class trotle3
			{
				type="rotation";
				animPeriod=2;
				selection="trotle3";
				axis="ostrotle";
				angle0=0;
				angle1=1.918;
			};
			class trotle4
			{
				type="rotation";
				animPeriod=2;
				selection="trotle4";
				axis="ostrotle";
				angle0=0;
				angle1=1.918;
			};
			class reverseprops
			{
				type="rotation";
				animPeriod=1;
				selection="reverseprops";
				axis="ostrotle";
				angle0=0;
				angle1=1.7;
			};

	class gasolinerope0
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope0";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };
	class gasolinerope1
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope1";
            axis="osgasolinerope";
            angle0=0
           angle1=0.35;
         };
	class gasolinerope2
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope2";
            axis="osgasolinerope";
            angle0=0
           angle1=0.35;
         };
	class gasolinerope3
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope3";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };
	class gasolinerope4
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope4";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };
	class gasolinerope5
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope5";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };
	class gasolinerope6
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope6";
            axis="osgasolinerope";
            angle0=0
           angle1=0.35;
         };
	class gasolinerope7
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope7";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };
	class gasolinerope8
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope8";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };
	class gasolinerope9
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope9";
            axis="osgasolinerope";
            angle0=0
           angle1=0.35;
         };	
	class gasolinerope10
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope10";
            axis="osgasolinerope";
            angle0=0
            angle1=0.35;
         };	
	class gasolinerope11
         {
            type="rotation";
            animPeriod=15;
            selection="gasolinerope11";
            axis="osgasolinerope";
            angle0=0
           angle1=0.35;
         };
			class cargoload
         		{
            		type="rotation";
            		animPeriod=0.01;
            		selection="something";
            		axis="osrampa";
            		angle0=0
           		angle1=1;
        		};
			class relase
         		{
            		type="rotation";
            		animPeriod=0.01;
            		selection="relase";
            		axis="osrampa";
            		angle0=0
           		angle1=1;
        		};
			class fuellight
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="fuellight";
            		axis="osfuellight";
            		angle0=0
           		angle1=3.14;
        		};
			class ramplight
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="ramplight";
            		axis="osramplight";
            		angle0=0
           		angle1=3.14;
        		};
			class warninglightl
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="warninglightl";
            		axis="oswarninglightl";
            		angle0=0
           		angle1=3.14;
        		};
			class warninglightr
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="warninglightr";
            		axis="oswarninglightr";
            		angle0=0
           		angle1=3.14;
        		};
			class stall
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="stall";
            		axis="osstall";
            		angle0=0
           		angle1=3.14;
        		};
			class hight
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="hight";
            		axis="oshight";
            		angle0=0
           		angle1=3.14;
        		};
			class jumpprepare
         		{
            		type="rotation";
            		animPeriod=0.05;
            		selection="jumpprepare";
            		axis="osjump";
            		angle0=0
           		angle1=3.14;
        		};
			class jump
         		{
            		type="rotation";
            		animPeriod=3;
            		selection="jump";
            		axis="osjump";
            		angle0=0
           		angle1=3.14;
        		};
			
		
	};

		class UserActions
		{
			class reverseprops
			{
				displayName="THRUST REVERSE ON";
				position="ostrotle";
				radius=2;
				condition="(isengineon this) and (speed this < 250) and (this animationPhase ""reverseprops"" == 0)";
				statement="this animate[""reverseprops"",1];[this] exec {\HWK_c130\script\reverseprops.sqs}";
			};
			class unreverseprops
			{
				displayName="THRUST REVERSE OFF";
				position="ostrotle";
				radius=2;
				condition="(this animationPhase ""reverseprops"" > 0)";
				statement="this animate[""reverseprops"",0]";
			};


			class Opendoor1
			{
				displayName="Open door 1";
				position="osdoor1";
				radius=3;
				condition="(speed this < 15) and (this animationPhase ""door1"" < 0.5)";
				statement="this animate[""door1"",1]";
			};
			
			class Closedoor1
			{
				displayName="Close door 1";
				position="osdoors";
				radius=3.5;
				condition="this animationPhase ""door1"" >= 0.5";
				statement="this animate[""door1"",0]";
			};
			class Opendoor2
			{
				displayName="Open door 2";
				position="osdoors";
				radius=3.5;
				condition="this animationPhase ""door2"" < 0.5";
				statement="this animate[""door2"",1]";
			};
			
			class Closedoor2
			{
				displayName="Close door 2";
				position="osdoors";
				radius=3.5;
				condition="this animationPhase ""door2"" >= 0.5";
				statement="this animate[""door2"",0]";
			};
			class Opendoor3
			{
				displayName="Open door 3";
				position="osdoors";
				radius=3.5;
				condition="this animationPhase ""door3"" < 0.5";
				statement="this animate[""door3"",1]";
			};
			
			class Closedoor3
			{
				displayName="Close door 3";
				position="osdoors";
				radius=3.5;
				condition="this animationPhase ""door3"" >= 0.5";
				statement="this animate[""door3"",0]";
			};
			class Opensrampa
			{
				displayName="Open cargo ramp";
				position="osrampa";
				radius=16;
				condition="this animationPhase ""rampa"" < 0.5";
				statement="[this] exec {\HWK_c130\script\openramp.sqs}";
			};

			class Closerampa
			{
				displayName="Close cargo ramp";
				position="osrampa";
				radius=16;
				condition="this animationPhase ""rampa"" >= 0.5";
				statement="[this] exec {\HWK_c130\script\closeramp.sqs}";
			};
			class parasoldiers
			{
				displayName="Prepare Group to jump";
				position="osrampa";
				radius=16;
				condition="((this animationPhase ""jumpprepare"" < 0.5) and (this animationPhase ""jump"" < 0.5) and ((count crew this)>3) and (speed this > 15) and (isengineon this))";
				statement="[this] exec {\HWK_c130\script\parasoldiers.sqs}";
			};
			class jump
			{
				displayName="Group Jump";
				position="osrampa";
				radius=16;
				condition="(this animationPhase ""jump"" < 0.5) and (this animationPhase ""rampa"" >= 0.5) and (this animationPhase ""jumpprepare"" > 0.5) and ((count crew this)>3) and (speed this > 15) and (isengineon this) and ((getpos this select 2) > 40)";
				statement="this animate [""jump"",1]";
			};
			class paracargo
			{
				displayName = "Parachute cargo";
				position="osrampa";
				radius=16;
				condition = "this animationPhase ""cargoload"" > 0";
				statement = "this animate [""relase"",1]";
			};
			class loadcargo
			{
				displayName = "load cargo";
				position="posvehicle";
				radius=4;
				condition = "((vehicle player != vehicle this) and (vehicle player != player) and (speed vehicle this < 5) and (this animationPhase ""cargoload"" < 1))";
				statement = "[this,player] exec {\HWK_c130\script\cargoload.sqs}";
			};
			class opengasolinerope
			{
				displayName = "Deploy fuel hose";
				position="ostrotle";
				radius=2;
				condition = "((speed this > 15) and (isengineon this) and (this animationPhase ""gasolinerope0"" < 0.5))";
				statement = "[this] exec {\HWK_c130\script\opengas.sqs}";
			};
			class closegasolinerope
			{
				displayName = "Retract fuel hose";
				position="ostrotle";
				radius=2;
				condition = "((speed this > 15) and (isengineon this) and (this animationPhase ""gasolinerope0"" > 0.5))";
				statement = "[this] exec {\HWK_c130\script\closegas.sqs}";
			};
			class Tankair
			{
				displayName = "Initiate refuel";
				position="gasolinerope0";
				radius=50;
				condition = "((player distance this < 200) and (vehicle player != vehicle this) and (vehicle player != player) and (isengineon this) and ((getpos this select 2) > 20))";
				statement = "[this,player,(group this),(group player)] exec {\HWK_c130\script\initrefuel.sqs}";
			};
			
		};
	
};

