#****************************************************************************
#**
#**  File     : /cdimage/lua/modules/BlackOpsprojectiles.lua
#**  Author(s): Lt_Hawkeye
#**
#**  Summary  :
#**
#**  Copyright © 2005 Gas Powered Games, Inc.  All rights reserved.
#****************************************************************************
#------------------------------------------------------------------------
#  Lt_hawkeye's Custom Projectiles
#------------------------------------------------------------------------
local Projectile = import('/lua/sim/projectile.lua').Projectile
local DefaultProjectileFile = import('/lua/sim/defaultprojectiles.lua')
local EmitterProjectile = DefaultProjectileFile.EmitterProjectile
local OnWaterEntryEmitterProjectile = DefaultProjectileFile.OnWaterEntryEmitterProjectile
local SingleBeamProjectile = DefaultProjectileFile.SingleBeamProjectile
local SinglePolyTrailProjectile = DefaultProjectileFile.SinglePolyTrailProjectile
local MultiPolyTrailProjectile = DefaultProjectileFile.MultiPolyTrailProjectile
local SingleCompositeEmitterProjectile = DefaultProjectileFile.SingleCompositeEmitterProjectile
local MultiCompositeEmitterProjectile = DefaultProjectileFile.MultiCompositeEmitterProjectile
local Explosion = import('/lua/defaultexplosions.lua')
local EffectTemplate = import('/lua/EffectTemplates.lua')
local BlackOpsEffectTemplate = import('/mods/BlackOps/lua/BlackOpsEffectTemplates.lua')
local DepthCharge = import('/lua/defaultantiprojectile.lua').DepthCharge
local util = import('/lua/utilities.lua')


RailGun01Projectile = Class(MultiPolyTrailProjectile) {
	PolyTrails = BlackOpsEffectTemplate.HGaussCannonPolyTrail,
	PolyTrailOffset = {0,0,0},  
	FxTrails = {'/mods/BlackOps/Effects/Emitters/NapalmTrailFX02.bp',},  
	
    # Hit Effects
    FxImpactUnit = EffectTemplate.CDisintegratorHitUnit01,
    FxImpactAirUnit = EffectTemplate.CDisintegratorHitAirUnit01,
    FxImpactProp = EffectTemplate.CDisintegratorHitUnit01,
    FxImpactLand = EffectTemplate.CDisintegratorHitLand01,
    FxImpactUnderWater = {},
   
}

MiniRocketProjectile = Class(SingleBeamProjectile) {
    DestroyOnImpact = false,
    FxTrails = EffectTemplate.TMissileExhaust02,
    FxTrailOffset = 0,
    BeamName = '/effects/emitters/missile_munition_exhaust_beam_01_emit.bp',

    FxImpactUnit = EffectTemplate.TMissileHit01,
    FxImpactLand = EffectTemplate.TMissileHit01,
    FxImpactProp = EffectTemplate.TMissileHit01,
    FxImpactUnderWater = {},

    OnImpact = function(self, targetType, targetEntity)
        local army = self:GetArmy()
        SingleBeamProjectile.OnImpact(self, targetType, targetEntity)
    end,

    CreateImpactEffects = function( self, army, EffectTable, EffectScale )
        local emit = nil
        for k, v in EffectTable do
            emit = CreateEmitterAtEntity(self,army,v)
            if emit and EffectScale != 1 then
                emit:ScaleEmitter(EffectScale or 1)
            end
        end
    end,
}

MiniRocket02Projectile = Class(SingleBeamProjectile) {
    DestroyOnImpact = false,
    FxTrails = EffectTemplate.TMissileExhaust02,
    FxTrailOffset = 0,
    BeamName = '/effects/emitters/missile_munition_exhaust_beam_01_emit.bp',

    # Hit Effects
    FxImpactUnit = EffectTemplate.CMissileLOAHit01,
    FxImpactLand = EffectTemplate.CMissileLOAHit01,
    FxImpactProp = EffectTemplate.CMissileLOAHit01,
    FxImpactNone = EffectTemplate.CMissileLOAHit01,
    FxImpactUnderWater = {},
    
    CreateImpactEffects = function( self, army, EffectTable, EffectScale )
        local emit = nil
        for k, v in EffectTable do
            emit = CreateEmitterAtEntity(self,army,v)
            if emit and EffectScale != 1 then
                emit:ScaleEmitter(EffectScale or 1)
            end
        end
    end,
    
    OnExitWater = function(self)
		EmitterProjectile.OnExitWater(self)
		local army = self:GetArmy()
		for k, v in self.FxExitWaterEmitter do
			CreateEmitterAtBone(self,-2,army,v)
		end
    end,
}

#***********************************************
#                 SeaDragon Projectiles
#***********************************************

SeaDragonShell = Class(SinglePolyTrailProjectile) {

    PolyTrail = '/effects/emitters/default_polytrail_01_emit.bp',

    # Hit Effects
    FxImpactUnit = EffectTemplate.CMolecularResonanceHitUnit01,
    FxUnitHitScale = 2,
    FxImpactProp = EffectTemplate.CMolecularResonanceHitUnit01,
    FxPropHitScale = 2,    
    FxImpactLand = EffectTemplate.CMolecularResonanceHitUnit01,
    FxLandHitScale = 2,
    FxImpactUnderWater = {},
    DestroyOnImpact = false,

    OnCreate = function(self)
        SinglePolyTrailProjectile.OnCreate(self)
        self.Impacted = false
    end,

    DelayedDestroyThread = function(self)
        WaitSeconds( 0.3 )
        self.CreateImpactEffects( self, self:GetArmy(), self.FxImpactUnit, self.FxUnitHitScale )
        self:Destroy()
    end,

    OnImpact = function(self, TargetType, TargetEntity)
        if self.Impacted == false then
            self.Impacted = true
            if TargetType == 'Terrain' then
                SinglePolyTrailProjectile.OnImpact(self, TargetType, TargetEntity)
                self:ForkThread( self.DelayedDestroyThread )
            else
                SinglePolyTrailProjectile.OnImpact(self, TargetType, TargetEntity)
                self:Destroy()
            end
        end
    end,
}
XCannonProjectile = Class(MultiPolyTrailProjectile) {
    PolyTrails = {
        BlackOpsEffectTemplate.XCannonPolyTrail,
        '/effects/emitters/default_polytrail_01_emit.bp',
    },
    PolyTrailOffset = {0,0}, 

    FxTrails = BlackOpsEffectTemplate.XCannonFXTrail01,
    #PolyTrail = EffectTemplate.CHvyProtonCannonPolyTrail,
    FxImpactUnit = BlackOpsEffectTemplate.XCannonHitUnit,
    FxImpactProp = BlackOpsEffectTemplate.XCannonHitUnit,
    FxImpactLand = EffectTemplate.CHvyProtonCannonHitLand,
    FxImpactUnderWater = EffectTemplate.CHvyProtonCannonHit01,
    FxImpactWater = EffectTemplate.CHvyProtonCannonHit01,
    FxTrailOffset = 0,
}
#------------------------------------------------------------
#				Bismark Projectiles
#-----------------------------------------------------------
ZCannon01Projectile = Class(MultiPolyTrailProjectile) {
	FxImpactTrajectoryAligned = false,
    PolyTrails = BlackOpsEffectTemplate.ZCannonPolytrail01,
    PolyTrailOffset = {0,0,0},
    FxTrails = BlackOpsEffectTemplate.ZCannonFxtrail01,

    # Hit Effects
    FxImpactUnit = BlackOpsEffectTemplate.ZCannonHit01,
    FxImpactProp = BlackOpsEffectTemplate.ZCannonHit01,
    FxImpactLand = BlackOpsEffectTemplate.ZCannonHit01,
    FxImpactWater = BlackOpsEffectTemplate.ZCannonHit01,
    FxLandHitScale = 1.5,
    FxPropHitScale = 1.5,
    FxUnitHitScale = 1.5,
    FxImpactUnderWater = {},
    FxSplatScale = 9,

    OnImpact = function(self, targetType, targetEntity)
        local army = self:GetArmy()
        if targetType == 'Terrain' then
            CreateDecal( self:GetPosition(), util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_001_normals', '', 'Alpha Normals', self.FxSplatScale, self.FxSplatScale, 150, 50, army )
            CreateDecal( self:GetPosition(), util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_002_albedo', '', 'Albedo', self.FxSplatScale * 2, self.FxSplatScale * 2, 150, 50, army )
            self:ShakeCamera(20, 1, 0, 1)
        end
        local pos = self:GetPosition()
        DamageArea(self, pos, self.DamageData.DamageRadius, 1, 'Force', true)
        DamageArea(self, pos, self.DamageData.DamageRadius, 1, 'Force', true)
        EmitterProjectile.OnImpact(self, targetType, targetEntity)
    end,
}

#------------------------------------------------------------------------
#  Cybran Dumb MISSILE PROJECTILES
#------------------------------------------------------------------------
DumbRocketProjectile = Class(SingleBeamProjectile) {
    FxTrails = {'/effects/emitters/missile_cruise_munition_trail_01_emit.bp',},
    #FxTrailScale = 1,
#	PolyTrail = EffectTemplate.CCorsairMissilePolyTrail01,    
    BeamName = '/effects/emitters/missile_exhaust_fire_beam_01_emit.bp',
    #BeamScale = 0.25,
    FxImpactUnit = EffectTemplate.CCorsairMissileUnitHit01,
    FxImpactProp = EffectTemplate.CCorsairMissileHit01,
    FxImpactLand = EffectTemplate.CCorsairMissileLandHit01,
    FxImpactUnderWater = {},
}

DumbRocketProjectile02 = Class(EmitterProjectile) {
    FxTrails = {'/effects/emitters/mortar_munition_01_emit.bp',},
    FxImpactUnit = EffectTemplate.CCorsairMissileUnitHit01,
    FxImpactProp = EffectTemplate.CCorsairMissileHit01,
    FxImpactLand = EffectTemplate.CCorsairMissileLandHit01,
    FxImpactUnderWater = {},
}
#------------------------------------------------------------------------
#
#  Scorp Laser
#
#------------------------------------------------------------------------

ScorpPulseLaser = Class(MultiPolyTrailProjectile) {
    PolyTrails = {
        EffectTemplate.CHvyProtonCannonPolyTrail,
        '/effects/emitters/electron_bolter_trail_01_emit.bp',
        #'/effects/emitters/default_polytrail_01_emit.bp',
    },
    PolyTrailScale = 0.5,
    PolyTrailOffset = {0,0}, 

    #FxTrails = EffectTemplate.CHvyProtonCannonFXTrail01,
    #PolyTrail = EffectTemplate.CHvyProtonCannonPolyTrail,
    FxImpactUnit = EffectTemplate.CHvyProtonCannonHitUnit,
    FxUnitHitScale = 0.5,
    FxImpactProp = EffectTemplate.CHvyProtonCannonHitUnit,
    FxPropHitScale = 0.5,
    FxImpactLand = EffectTemplate.CHvyProtonCannonHitLand,
    FxLandHitScale = 0.5,
    FxImpactUnderWater = EffectTemplate.CHvyProtonCannonHit01,
    FxUnderWarerHitScale = 0.5,
    FxImpactWater = EffectTemplate.CHvyProtonCannonHit01,
    FxWaterHitScale = 0.5,
    FxTrailOffset = 0,
}
#--------------------------------------------------------
#				Acolyte Missile
#-------------------------------------------------------
AcolyteMissileprojectile = Class(SinglePolyTrailProjectile) {
    PolyTrail = '/effects/emitters/serpentine_missile_trail_emit.bp',
    FxTrails = {'/effects/emitters/saint_munition_01_emit.bp'},
    FxTrailScale = 0.5,

    FxImpactUnit = EffectTemplate.AMissileHit01,
    FxUnitHitScale = 3,
    FxImpactProp = EffectTemplate.AMissileHit01,
    FXPropHitScale = 3,
    FxImpactNone = EffectTemplate.AMissileHit01,
    FxNoneHitScale = 3,
    FxImpactLand = EffectTemplate.AMissileHit01,
    FXLandHitScale = 3,
    FxImpactProjectile = EffectTemplate.ASaintImpact01,
    FxImpactUnderWater = {},

}
#------------------------------------------------------------
#				Aira Projectiles
#-----------------------------------------------------------
SonicWaveProjectile = Class(MultiPolyTrailProjectile) {
	FxImpactTrajectoryAligned = false,
    PolyTrails = BlackOpsEffectTemplate.WaveCannonPolytrail01,
    PolyTrailOffset = {0,0,0},
    FxTrails = BlackOpsEffectTemplate.WaveCannonFxtrail01,

    # Hit Effects
    FxImpactUnit = EffectTemplate.AGravitonBolterHit01,
    FxImpactProp = EffectTemplate.AGravitonBolterHit01,
    FxImpactLand = EffectTemplate.AGravitonBolterHit01,
    FxLandHitScale = 1.5,
    FxPropHitScale = 1.5,
    FxUnitHitScale = 1.5,
    FxImpactUnderWater = {},

}
#------------------------------------------------------------
#				Seraphim Lambda Projectiles
#-----------------------------------------------------------
EyeBlast01Projectile = Class(EmitterProjectile) {
	FxImpactTrajectoryAligned = false,
    FxTrails = EffectTemplate.SDFExperimentalPhasonProjFXTrails01,
    FxImpactUnit = BlackOpsEffectTemplate.SDFExperimentalPhasonProjHitUnit,
    FxImpactProp = BlackOpsEffectTemplate.SDFExperimentalPhasonProjHit01,
    FxImpactLand = BlackOpsEffectTemplate.SDFExperimentalPhasonProjHit01,
    FxImpactWater = BlackOpsEffectTemplate.SDFExperimentalPhasonProjHit01,
}

#------------------------------------------------------------------------
#  CYBRAN SUB LAUNCHED TORPEDO
#------------------------------------------------------------------------
AssaultTorpedoSubProjectile = Class(EmitterProjectile) {
    FxTrails = {'/effects/emitters/torpedo_underwater_wake_02_emit.bp',},

    # Hit Effects
    FxImpactUnit = EffectTemplate.CTorpedoUnitHit01,
    FxImpactProp = EffectTemplate.CTorpedoUnitHit01,
    FxImpactUnderWater = EffectTemplate.CTorpedoUnitHit01,    
    FxImpactLand = EffectTemplate.CTorpedoUnitHit01,
    FxLandHitScale = 4,
    FxPropHitScale = 4,
    FxUnitHitScale = 4,
    FxNoneHitScale = 4,
    FxImpactNone = {},
}

ShadowCannonProjectile = Class(MultiPolyTrailProjectile) {
    PolyTrails = {
		'/mods/BlackOps/effects/emitters/shadow_bolter_trail_01_emit.bp',
		'/mods/BlackOps/effects/emitters/shadowcannon_polytrail_01_emit.bp',
	},
    PolyTrailOffset = {0,0}, 

    FxTrails = BlackOpsEffectTemplate.ShadowCannonFXTrail01,
    #PolyTrail = BlackOpsEffectTemplate.MGQAICannonHitUnit,
    FxImpactUnit = BlackOpsEffectTemplate.MGQAICannonHitUnit,
    FxImpactProp = BlackOpsEffectTemplate.MGQAICannonHitUnit,
    FxImpactLand = BlackOpsEffectTemplate.MGQAICannonHitUnit,
    FxImpactUnderWater = BlackOpsEffectTemplate.MGQAICannonHitUnit,
    FxImpactWater = BlackOpsEffectTemplate.MGQAICannonHitUnit,
    FxLandHitScale = 1.2,
    FxPropHitScale = 1.2,
    FxUnitHitScale = 1.2,
    FxNoneHitScale = 1.2,
    FxTrailOffset = 0,
}

HellFireMissileProjectile = Class(SingleCompositeEmitterProjectile) {
    FxTrails = {'/effects/emitters/missile_cruise_munition_trail_01_emit.bp',},
    FxTrailScale = 0.25,
#	PolyTrail = EffectTemplate.CCorsairMissilePolyTrail01,    
    BeamName = '/effects/emitters/missile_exhaust_fire_beam_01_emit.bp',
    FxImpactUnit = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactProp = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactLand = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactWater = EffectTemplate.TNapalmHvyCarpetBombHitWater01,
    FxImpactUnderWater = {},
}

ACUShadowCannonProjectile = Class(MultiPolyTrailProjectile) {
    PolyTrails = {
		'/effects/emitters/electron_bolter_trail_01_emit.bp',
		'/mods/BlackOps/effects/emitters/shadowcannon_polytrail_01_emit.bp',
	},
    PolyTrailOffset = {0,0}, 

    FxTrails = BlackOpsEffectTemplate.ShadowCannonFXTrail01,
    #PolyTrail = EffectTemplate.CHvyProtonCannonPolyTrail,
    FxImpactUnit = BlackOpsEffectTemplate.ACUShadowCannonHit01,
    FxImpactProp = BlackOpsEffectTemplate.ACUShadowCannonHit01,
    FxImpactLand = BlackOpsEffectTemplate.ACUShadowCannonHit01,
    FxImpactUnderWater = BlackOpsEffectTemplate.ACUShadowCannonHit01,
    FxImpactWater = BlackOpsEffectTemplate.ACUShadowCannonHit01,
    FxLandHitScale = 0.7,
    FxPropHitScale = 0.7,
    FxUnitHitScale = 0.7,
    FxNoneHitScale = 0.7,
    FxTrailOffset = 0,
}

#------------------------------------------------------------------------
#  TERRAN Heavy GAUSS CANNON PROJECTILES
#------------------------------------------------------------------------
HawkGaussCannonProjectile = Class(MultiPolyTrailProjectile) {
    FxTrails = {},
    PolyTrails = EffectTemplate.TGaussCannonPolyTrail,
    PolyTrailOffset = {0,0},
    FxImpactUnit = EffectTemplate.TMissileHit01,
    FxImpactProp = EffectTemplate.TMissileHit01,
    FxImpactLand = EffectTemplate.TMissileHit01,
    FxTrailOffset = 0,
    FxImpactUnderWater = {},
}

#------------------------------------------------------------------------
#  AEON ARTILLERY PROJECTILES
#------------------------------------------------------------------------
WraithProjectile = Class(SinglePolyTrailProjectile) {
	FxImpactLand = BlackOpsEffectTemplate.WraithCannonHit01,
    FxImpactNone = BlackOpsEffectTemplate.WraithCannonHit01,
	FxImpactProp = BlackOpsEffectTemplate.WraithCannonHit01,    
    FxImpactUnit = BlackOpsEffectTemplate.WraithCannonHit01,    
    FxImpactUnderWater = {},
    FxImpactProjectile = {},
    FxLandHitScale = 0.7,
    FxPropHitScale = 0.7,
    FxUnitHitScale = 0.7,
    FxNoneHitScale = 0.7,
    PolyTrail = BlackOpsEffectTemplate.WraithPolytrail01,
    FxTrails = BlackOpsEffectTemplate.WraithMunition01,
}


#------------------------------------------------------------------------
#
#  Fire test
#
#------------------------------------------------------------------------

Juggfire01 = Class(MultiPolyTrailProjectile) {
	PolyTrails = BlackOpsEffectTemplate.HGaussCannonPolyTrail,
    FxTrails = {
		'/mods/BlackOps/effects/emitters/Juggfire01_emit.bp',
		'/effects/emitters/napalm_hvy_thin_smoke_emit.bp',
#		'/effects/emitters/napalm_hvy_thick_smoke_emit.bp',
#		'/effects/emitters/napalm_hvy_03_emit.bp',
	},
	PolyTrailOffset = {0,0,0},    

    # Hit Effects
    FxImpactUnit = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactProp = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactLand = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxLandHitScale = 0.5,
    FxPropHitScale = 0.5,
    FxUnitHitScale = 0.5,
    FxImpactUnderWater = {},
#    FxTrails = {},
    FxTrailOffset = 0,
}

#------------------------------------------------------------------------
#  Flamethrower Projectile
#------------------------------------------------------------------------
NapalmProjectile01 = Class(EmitterProjectile) {
    FxTrails = {'/mods/BlackOps/Effects/Emitters/NapalmTrailFX.bp',},
    
    FxImpactTrajectoryAligned = false,

    # Hit Effects
    FxImpactUnit = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactProp = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactLand = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactWater = EffectTemplate.TNapalmHvyCarpetBombHitWater01,
    FxImpactUnderWater = {},
}
NapalmProjectile02 = Class(EmitterProjectile) {
    FxTrails = {'/mods/BlackOps/Effects/Emitters/NapalmTrailFX.bp',},
   	FxTrailScale = 0.5,
    
    FxImpactTrajectoryAligned = false,

    # Hit Effects
    FxImpactUnit = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactProp = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactLand = EffectTemplate.TNapalmHvyCarpetBombHitLand01,
    FxImpactWater = EffectTemplate.TNapalmHvyCarpetBombHitWater01,
    FxImpactUnderWater = {},
    FxLandHitScale = 0.5,
    FxPropHitScale = 0.5,
    FxUnitHitScale = 0.5,
    FxNoneHitScale = 0.5,
}

#------------------------------------------------------------------------
#  ARTEMIS CANNON PROJECTILES
#------------------------------------------------------------------------
ArtemisCannonProjectile = Class(SinglePolyTrailProjectile) {
	PolyTrail = BlackOpsEffectTemplate.ArtemisPolytrail01,
    FxTrails = BlackOpsEffectTemplate.ArtemisFXTrail,

    FxImpactUnit = EffectTemplate.AReactonCannonHitUnit01,
    FxImpactProp = EffectTemplate.AReactonCannonHitUnit01,
    FxImpactLand = EffectTemplate.AReactonCannonHitLand01,
}
DummyArtemisCannonProjectile = Class(MultiPolyTrailProjectile) {
	PolyTrail = BlackOpsEffectTemplate.DummyArtemisPolytrail01,
    FxTrails = BlackOpsEffectTemplate.DummyArtemisFXTrail,

    FxImpactUnit = EffectTemplate.AReactonCannonHitUnit01,
    FxImpactProp = EffectTemplate.AReactonCannonHitUnit01,
    FxImpactLand = EffectTemplate.AReactonCannonHitLand01,
}

#------------------------------------------------------------------------
#  AEON ABOVE WATER LAUNCHED TORPEDO
#------------------------------------------------------------------------
AMTorpedoShipProjectile = Class(OnWaterEntryEmitterProjectile) {
    FxInitial = {},
    FxTrails = {'/effects/emitters/torpedo_munition_trail_01_emit.bp',},
    FxTrailScale = 1,
    TrailDelay = 0,
    TrackTime = 0,

    FxUnitHitScale = 1.25,
    FxImpactLand = {},
    FxImpactUnit = EffectTemplate.ATorpedoUnitHit01,
    FxImpactProp = EffectTemplate.ATorpedoUnitHit01,
    FxImpactUnderWater = EffectTemplate.DefaultProjectileUnderWaterImpact,
    FxImpactProjectile = EffectTemplate.ATorpedoUnitHit01,
    FxImpactProjectileUnderWater = EffectTemplate.DefaultProjectileUnderWaterImpact,
    FxKilled = EffectTemplate.ATorpedoUnitHit01,
    FxImpactNone = {},

    OnCreate = function(self,inWater)
        OnWaterEntryEmitterProjectile.OnCreate(self,inWater)
        # if we are starting in the water then immediately switch to tracking in water
        if inWater == true then
            self:TrackTarget(true):StayUnderwater(false)
            self:OnEnterWater(self)
        else
            self:TrackTarget(true)
        end
    end, 
}

AMTorpedoCluster = Class(SingleCompositeEmitterProjectile) {
    FxInitial = {},
#    FxTrails = {'/effects/emitters/serpentine_missile_trail_emit.bp',},
    PolyTrail = '/effects/emitters/serpentine_missile_trail_emit.bp',
    BeamName = '/effects/emitters/serpentine_missle_exhaust_beam_01_emit.bp',
    FxTrailScale = 1,
    TrailDelay = 0,
    TrackTime = 0,

    FxUnitHitScale = 1.25,
    FxImpactLand = {},
    FxImpactUnit = EffectTemplate.ATorpedoUnitHit01,
    FxImpactProp = EffectTemplate.ATorpedoUnitHit01,
    FxImpactUnderWater = EffectTemplate.ATorpedoUnitHitUnderWater01,
    FxImpactProjectile = EffectTemplate.ATorpedoUnitHit01,
    FxImpactProjectileUnderWater = EffectTemplate.ATorpedoUnitHitUnderWater01,
    FxKilled = EffectTemplate.ATorpedoUnitHit01,
    FxImpactNone = {},
    
     OnCreate = function(self,inWater)
        SingleCompositeEmitterProjectile.OnCreate(self,inWater)
        # if we are starting in the water then immediately switch to tracking in water
        if inWater == true then
            self:TrackTarget(true):StayUnderwater(false)
            self:OnEnterWater(self)
        else
            self:TrackTarget(true)
        end
    end, 
}




#------------------------------------------------------------------------
#  AEON GUIDED AA PROJECTILES
#------------------------------------------------------------------------
GoldAAProjectile = Class(SinglePolyTrailProjectile) {
    FxTrails =  BlackOpsEffectTemplate.GoldAAFxTrails,
	PolyTrail = BlackOpsEffectTemplate.GoldAAPolyTrail,  ###'/effects/emitters/aeon_missile_trail_02_emit.bp',    

    FxImpactUnit = EffectTemplate.AMercyGuidedMissileSplitMissileHitUnit,
    FxImpactAirUnit = EffectTemplate.AMercyGuidedMissileSplitMissileHitUnit,
    FxImpactProp = EffectTemplate.AMercyGuidedMissileSplitMissileHit,
    FxImpactNone = EffectTemplate.AMercyGuidedMissileSplitMissileHit,
    FxImpactLand = EffectTemplate.AMercyGuidedMissileSplitMissileHitLand,
    FxImpactUnderWater = {},
}
#------------------------------------------------------------------------
#  SERAPHIM TAU CANNON
#------------------------------------------------------------------------
STauCannon02 = Class(MultiPolyTrailProjectile) {
	FxImpactLand = EffectTemplate.STauCannonHit,
    FxImpactNone = EffectTemplate.STauCannonHit,
    FxImpactProp = EffectTemplate.STauCannonHit,    
    FxImpactUnit = EffectTemplate.STauCannonHit,
    FxImpactShield = EffectTemplate.ADisruptorHitShield,
    FxTrails = EffectTemplate.STauCannonProjectileTrails,
    PolyTrailOffset = {0,0},    
    PolyTrails = EffectTemplate.STauCannonProjectilePolyTrails,
}

SOmegaCannonOverCharge = Class(MultiPolyTrailProjectile) {
	FxImpactTrajectoryAligned = false,
	FxImpactLand = BlackOpsEffectTemplate.OmegaOverChargeLandHit,
    FxImpactNone = BlackOpsEffectTemplate.OmegaOverChargeLandHit,
    FxImpactProp = BlackOpsEffectTemplate.OmegaOverChargeLandHit,    
    FxImpactUnit = BlackOpsEffectTemplate.OmegaOverChargeUnitHit,
    FxLandHitScale = 4,
    FxPropHitScale = 4,
    FxUnitHitScale = 4,
    FxNoneHitScale = 4,
    FxTrails = BlackOpsEffectTemplate.OmegaOverChargeProjectileFxTrails,
    PolyTrails = BlackOpsEffectTemplate.OmegaOverChargeProjectileTrails,
    PolyTrailOffset = {0,0,0},
}
------------------------------------------------------------------------
#  SERAPHIM LAANSE TACTICAL MISSILE
#------------------------------------------------------------------------
SLaanseTacticalMissile = Class(SinglePolyTrailProjectile) {
    FxImpactLand = EffectTemplate.SLaanseMissleHit,
    FxImpactProp = EffectTemplate.SLaanseMissleHitUnit,
    FxImpactUnderWater = {},
    FxImpactUnit = EffectTemplate.SLaanseMissleHitUnit,    
    FxTrails = EffectTemplate.SLaanseMissleExhaust02,
    PolyTrail = EffectTemplate.SLaanseMissleExhaust01,


}
#------------------------------------------------------------------------
#  MGAI PROJECTILES
#------------------------------------------------------------------------
MGHeadshotProjectile = Class(MultiPolyTrailProjectile) {
	FxImpactTrajectoryAligned = false,
    PolyTrails = BlackOpsEffectTemplate.MGHeadshotPolytrail01,
    PolyTrailOffset = {0,0,0},
    FxTrails = BlackOpsEffectTemplate.MGHeadshotFxtrail01,

    # Hit Effects
	FxImpactLand = BlackOpsEffectTemplate.MGHeadshotHit01,
    FxImpactNone = BlackOpsEffectTemplate.MGHeadshotHit01,
    FxImpactProp = BlackOpsEffectTemplate.MGHeadshotHit01,    
    FxImpactUnit = BlackOpsEffectTemplate.MGHeadshotHit01,
    FxLandHitScale = 1.5,
    FxPropHitScale = 1.5,
    FxUnitHitScale = 1.5,
    FxImpactUnderWater = {},
}

MGQAIRocketProjectile = Class(SingleBeamProjectile) {
    BeamName = '/effects/emitters/missile_loa_munition_exhaust_beam_01_emit.bp',
    FxTrails = {'/effects/emitters/missile_cruise_munition_trail_01_emit.bp',},
    PolyTrailOffset = -0.05,

    FxImpactUnit = BlackOpsEffectTemplate.MissileUnitHit01,
    FxImpactProp = BlackOpsEffectTemplate.MissileLandHit01,
    FxImpactLand = BlackOpsEffectTemplate.MissileLandHit01,
    FxImpactUnderWater = {},

    
}

MGQAIRocketChildProjectile = Class(SingleCompositeEmitterProjectile) {
    PolyTrail = '/mods/BlackOps/effects/emitters/mgqai_missile_trail_emit.bp',
    BeamName = '/mods/BlackOps/effects/emitters/mgqai_missle_exhaust_beam_01_emit.bp',
    PolyTrailOffset = -0.05,

    FxImpactUnit = BlackOpsEffectTemplate.MissileUnitHit01,
    FxImpactProp = BlackOpsEffectTemplate.MissileLandHit01,
    FxImpactLand = BlackOpsEffectTemplate.MissileLandHit01,
    FxImpactUnderWater = {},

    
}

MGQAIPlasmaArtyChildProjectile = Class(EmitterProjectile) {
    #PolyTrail = BlackOpsEffectTemplate.MGQAIPlasmaArtyPolytrail01,
    FxTrails = BlackOpsEffectTemplate.MGQAIPlasmaArtyChildFxtrail01,

    # Hit Effects
    FxImpactUnit = BlackOpsEffectTemplate.MGQAIPlasmaArtyHitLand01,
    FxImpactProp = BlackOpsEffectTemplate.MGQAIPlasmaArtyHitLand01,
    FxImpactLand = BlackOpsEffectTemplate.MGQAIPlasmaArtyHitLand01,
    FxImpactUnderWater = BlackOpsEffectTemplate.MGQAIPlasmaArtyHitLand01,
    FxImpactWater = BlackOpsEffectTemplate.MGQAIPlasmaArtyHitLand01,
    FxImpactUnderWater = {},
    OnCreate = function(self, TargetType, TargetEntity)
    local projectile = self
		
		SetDamageThread = ForkThread(function(self)
			projectile.DamageData = {
	            DamageRadius = 3,
	            DamageAmount = 20,
	            DoTPulses = 15,
            	DoTTime = 4.5,
	            DamageType = 'Normal',
	            DamageFriendly = true,
	            MetaImpactAmount = nil,
	            MetaImpactRadius = nil,
	        }
			KillThread(self)
		end)
		EmitterProjectile.OnCreate(self, TargetType, TargetEntity)
	end,

}

MGQAIPlasmaArtyProjectile = Class(EmitterProjectile) {
    #PolyTrail = BlackOpsEffectTemplate.MGQAIPlasmaArtyPolytrail01,
    FxTrails = BlackOpsEffectTemplate.MGQAIPlasmaArtyFxtrail01,

    # Hit Effects
    FxImpactUnit = {},
    FxImpactLand = {},
    FxImpactUnderWater = {},

    ChildProjectile = '/mods/BlackOps/projectiles/MGQAIPlasmaArtyChild01/MGQAIPlasmaArtyChild01_proj.bp',

    OnCreate = function(self)
        EmitterProjectile.OnCreate(self)
        self.Impacted = false
    end,
    DoDamage = function(self, instigator, damageData, targetEntity)
        EmitterProjectile.DoDamage(self, instigator, damageData, targetEntity)
    end,
    OnImpact = function(self, TargetType, TargetEntity)
        if self.Impacted == false and TargetType != 'Air' then
            self.Impacted = true
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(0,Random(1,5),Random(1.5,5))
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(Random(1,4),Random(1,5),Random(1,2))
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(0,Random(1,5),-Random(1.5,5))
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(Random(1.5,5),Random(1,5),0)
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(-Random(1,4),Random(1,5),-Random(1,2))
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(-Random(1.5,4.5),Random(1,5),0)
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(-Random(1,4),Random(1,5),Random(2,4))
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(-Random(1,2),Random(1,7),-Random(1,3))
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(-Random(2.5,3.5),Random(2,6),0)
            self:CreateChildProjectile(self.ChildProjectile):SetVelocity(-Random(2,3),Random(2,3),Random(3,5))
            EmitterProjectile.OnImpact(self, TargetType, TargetEntity)
        end
    end,
    
    # Overiding Destruction
    OnImpactDestroy = function( self, TargetType, TargetEntity)
        self:ForkThread( self.DelayedDestroyThread )
    end,

    DelayedDestroyThread = function(self)
        WaitSeconds( 0.5 )
        self:Destroy()
    end,
}

MGQAILaserHeavyProjectile = Class(MultiPolyTrailProjectile) {
    PolyTrails = {
        '/effects/emitters/electron_bolter_trail_01_emit.bp',
		'/effects/emitters/default_polytrail_03_emit.bp',
	},
	PolyTrailOffset = {0,0}, 
	FxTrails = {'/effects/emitters/electron_bolter_munition_01_emit.bp',},
	
    # Hit Effects
    FxImpactUnit = EffectTemplate.CLaserHitUnit01,
    FxImpactProp = EffectTemplate.CLaserHitUnit01,
    FxImpactLand = EffectTemplate.CLaserHitLand01,
    FxImpactUnderWater = {},
}
