//
//
//
//	Filename : Drone.cs

// Drone Audio

datablock AudioProfile(DroneSoftImpactSound)
{
   filename    = "~/data/sound/Vehicles/Xplode.wav";
   description = AudioClose3d;
   preload = true;
   effect = SoftImpactEffect;
};

datablock AudioProfile(DroneHardImpactSound)
{
   filename    = "~/data/sound/Vehicles/Xplode.wav";
   description = AudioClose3d;
   preload = true;
   effect = HardImpactEffect;
};

datablock AudioProfile(DroneExitWaterMediumSound)
{
   fileName = "~/data/sound/Vehicles/Thrust.WAV";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(DroneImpactWaterSoftSound)
{
   fileName = "~/data/sound/Vehicles/Thrust.WAV";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(DroneImpactWaterMediumSound)
{
   fileName = "~/data/sound/Vehicles/Thrust.WAV";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(DroneWakeMediumSplashSound)
{
   fileName = "~/data/sound/Vehicles/Thrust.WAV";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(DroneThrustSound)
{
   filename    = "~/data/sound/Vehicles/Thrust.WAV";
   description = AudioDefaultLooping3d;
   preload = true;
   effect = ScoutFlyerThrustEffect;
};

datablock AudioProfile(DroneEngineSound)
{
   filename    = "~/data/sound/Vehicles/EngineHum.WAV";
   description = AudioDefaultLooping3d;
   preload = true;
};
// End Drone Audio
//-------------------------------------------------------------
// Vehicle Drone Explosion
datablock ParticleData(DroneExplosionParticle)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 0.2;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 750;
   lifetimeVarianceMS   = 150;
   textureName          = "~/data/shapes/rifle/smokeParticle";
   colors[0]     = "0 0.2 1 1.0";
   colors[1]     = "0 0.2 1 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 1.0;
};

datablock ParticleEmitterData(DroneExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 1;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 60;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   particles		= "DroneExplosionParticle";
};

datablock ExplosionData(DroneVehicleExplosion)
{
   explosionShape = "~/data/shapes/vehicles/Drone.dts";

   particleEmitter = DroneExplosionEmitter;
   particleDensity = 50;
   particleRadius = 0.2;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = true;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;
};
// End Drone Explosion
//---------------------------------------------------------------------------------------
// Vehicle Drone Debris
datablock DebrisData(DroneShapeDebris)
{
	explodeOnMaxBounce = false;

	elasticity = 0.15;
	friction = 0.5;

	lifetime = 4.0;
	lifetimeVariance = 0.0;

	minSpinSpeed = 40;
	maxSpinSpeed = 600;

	numBounces = 5;
	bounceVariance = 0;

	staticOnMaxBounce = true;
	gravModifier = 1.0;

	useRadiusMass = true;
	baseRadius = 1;

	velocity = 20.0;
	velocityVariance = 12.0;
};
// Drone Contrail // which i dont think is workin :)
datablock ParticleData(DroneContrailParticle)
{
   dragCoefficient      = 1.5;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 3000;
   lifetimeVarianceMS   = 0;
   textureName          = "~/data/shapes/rifle/smokeParticle";
   colors[0]     = "0.6 0.6 0.6 0.5";
   colors[1]     = "0.2 0.2 0.2 0";
   sizes[0]      = 0.6;
   sizes[1]      = 5;
};

datablock ParticleEmitterData(DroneContrailEmitter)
{
   ejectionPeriodMS = 5;
   periodVarianceMS = 0;
   ejectionVelocity = 1;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 10;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   particles = "DroneContrailParticle";
};

datablock ParticleData(DroneJetParticle)
{
   dragCoefficient      = 1.5;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 200;
   lifetimeVarianceMS   = 0;
   textureName          = "~/data/shapes/rifle/smokeParticle";
   colors[0]     = "0.9 0.7 0.3 0.6";
   colors[1]     = "0.3 0.3 0.5 0";
   sizes[0]      = 2;
   sizes[1]      = 6;
};

datablock ParticleEmitterData(DroneJetEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 0;
   ejectionVelocity = 20;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 10;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   particles = "DroneJetParticle";
};
// End Drone Debris
//---------------------------------------------------------------------------------------
// Drone Definition
datablock FlyingVehicleData(Drone)
{
	spawnOffset						= "0 0 2";
	emap							= true;
	category						= "Vehicles";
	shapeFile						= "~/data/shapes/vehicles/Drone.dts";
	multipassenger					= false;
	computeCRC						= true;
									
	debrisShapeName					= "~/data/shapes/vehicles/Drone.dts";
	debris							= DroneShapeDebris;
	renderWhenDestroyed				= false;

	drag							= 0.15;
	density							= 1.0;

	mountPose[0]					= sitting;
	numMountPoints					= 2;  
	isProtectedMountPoint[0]		= true;
	cameraMaxDist					= 11;
	cameraOffset					= 2.5;
	cameraLag						= 0.9;
	explosion						= DroneVehicleExplosion;
	explosionDamage					= 10.5;
	explosionRadius					= 15.0;

	maxDamage						= 50.40;
	destroyedLevel					= 50.40;
									
	isShielded						= true; 
	energyPerDamagePoint			= 160;
	maxEnergy						= 280;      // Afterburner and any energy weapon pool
	rechargeRate					= 0.8;

	minDrag							= 10;           // Linear Drag (eventually slows you down when not thrusting...constant drag)
	rotationalDrag					= 10;        // Anguler Drag (dampens the drift after you stop moving the mouse...also tumble drag)

	maxAutoSpeed					= 15;       // Autostabilizer kicks in when less than this speed. (meters/second)
	autoAngularForce				= 15;       // Angular stabilizer force (this force levels you out when autostabilizer kicks in)
	autoLinearForce					= 15;        // Linear stabilzer force (this slows you down when autostabilizer kicks in)
	autoInputDamping				= 0.95;      // Dampen control input so you don't` whack out at very slow speeds

	// Maneuvering
	maxSteeringAngle				= 5;    // Max radiens you can rotate the wheel. Smaller number is more maneuverable.
	horizontalSurfaceForce			= 6;   // Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
	verticalSurfaceForce			= 4;     // Vertical center "wing" (controls side slip. lower numbers make MORE slide.)
	maneuveringForce				= 6000;      // Horizontal jets (W,S,D,A key thrust)
	steeringForce					= 1200;         // Steering jets (force applied when you move the mouse)
	steeringRollForce				= 400;      // Steering jets (how much you heel over when you turn)
	rollForce						= 0;  // Auto-roll (self-correction to right you after you roll/invert)
	hoverHeight						= 2;        // Height off the ground at rest
	createHoverHeight				= 3;  // Height off the ground when created
	maxForwardSpeed					= 20;  // speed in which forward thrust force is no longer applied (meters/second)

	// Turbo Jet
	jetForce						= 3000;      // Afterburner thrust (this is in addition to normal thrust)
	minJetEnergy					= 28;     // Afterburner can't be used if below this threshhold.
	jetEnergyDrain					= 2.8;       // Energy use of the afterburners (low number is less drain...can be fractional)                                                                                                                                                                                                                                                                                          // Auto stabilize speed
	vertThrustMultiple				= 3.0;

	// Rigid body
	mass							= 190;        // Mass of the vehicle
	bodyFriction					= 1;     // Don't mess with this.
	bodyRestitution					= 0.5;   // When you hit the ground, how much you rebound. (between 0 and 1)
	minRollSpeed					= 0;     // Don't mess with this.
	softImpactSpeed					= 25;       // Sound hooks. This is the soft hit.
	hardImpactSpeed					= 35;    // Sound hooks. This is the hard hit.

	// Ground Impact Damage (uses DamageType::Ground)
	minImpactSpeed					= 10;      // If hit ground at speed above this then it's an impact. Meters/second
	speedDamageScale				= 0.06;

	// Object Impact Damage (uses DamageType::Impact)
	collDamageThresholdVel			= 23.0;
	collDamageMultiplier			= 0.02;

	//
	minTrailSpeed					= 15;      // The speed your contrail shows up at.
	trailEmitter					= DroneContrailEmitter;
	forwardJetEmitter				= DroneJetEmitter;
	downJetEmitter					= DroneJetEmitter;

	//
	jetSound						= DroneThrustSound;
	engineSound						= DroneEngineSound;
	softImpactSound					= DroneSoftImpactSound;
	hardImpactSound					= DroneHardImpactSound;
	//
	softSplashSoundVelocity			= 10.0; 
	mediumSplashSoundVelocity		= 15.0;   
	hardSplashSoundVelocity			= 20.0;   
	exitSplashSoundVelocity			= 10.0;

	exitingWater					= DroneExitWaterMediumSound;
	impactWaterEasy					= DroneImpactWaterSoftSound;
	impactWaterMedium				= DroneImpactWaterMediumSound;
	impactWaterHard					= DroneImpactWaterMediumSound;
	waterWakeSound					= DroneWakeMediumSplashSound; 

//	dustEmitter						= VehicleLiftoffDustEmitter;
	
	triggerDustHeight				= 4.0;
	dustHeight						= 1.0;

//	damageEmitter[0]				= LightDamageSmoke;

//	damageEmitter[1]				= HeavyDamageSmoke;

//	damageEmitter[2]				= DamageBubbles;

	damageEmitterOffset[0]			= "0.0 -3.0 0.0 ";
	damageLevelTolerance[0]			= 0.3;
	damageLevelTolerance[1]			= 0.7;
	numDmgEmitterAreas				= 3;
						
	//
	max[RocketAmmo]					= 1000;

	minMountDist					= 2;

	splashEmitter[0]				= VehicleFoamDropletsEmitter;
	splashEmitter[1]				= VehicleFoamEmitter;

	shieldImpact					= VehicleShieldImpact;

	cmdCategory						= "Tactical";
	cmdIcon							= CMDFlyingScoutIcon;
	cmdMiniIconName					= "commander/MiniIcons/com_scout_grey";
	targetNameTag					= 'Drone';
	targetTypeTag					= 'FlyingVehicle';
	sensorData						= AWACPulseSensor;
	sensorRadius					= AWACPulseSensor.detectRadius;
	sensorColor						= "255 194 9";
									
	checkRadius						= 5.5;
	observeParameters				= "1 10 10";
									
	shieldEffectScale				= "0.937 1.125 0.60";
};
// End Drone Definition
//----------------------------------------------------------------------------------------
// Vehicle Drone Functions

function Drone::onDamage(%this, %obj, %delta)
{
	Parent::onDamage(%this, %obj);
	%currentDamage = %obj.getDamageLevel();
	if(%currentDamage > %obj.destroyedLevel)
	{
		if(%obj.getDamageState() !$= "Destroyed")
		{
			if(%obj.respawnTime !$= "")
				%obj.marker.schedule = %obj.marker.data.schedule(%obj.respawnTime, "respawn", %obj.marker); 
			%obj.setDamageState(Destroyed);
		}
	}
	else
	{
		if(%obj.getDamageState() !$= "Enabled")
			%obj.setDamageState(Enabled);
	}
}