do

local CBFP_oldUES0202 = UES0202

UES0202 = Class(CBFP_oldUES0202) {
    Weapons = {
        FrontTurret01 = Class(CBFP_oldUES0202.Weapons.FrontTurret01) {},
        BackTurret02 = Class(CBFP_oldUES0202.Weapons.BackTurret02) {},
        CruiseMissile = Class(CBFP_oldUES0202.Weapons.CruiseMissile) {

            # Brute51: This is not really a bug fix, it only fixes the firing animation of this weapon. 

            CurrentRack = 1,

            CreateProjectileAtMuzzle = function(self, muzzle)
                self:ForkThread(self.CreateCruiseMissile, muzzle)
            end,

            CreateCruiseMissile = function(self, muzzle)
                muzzle = self:GetBlueprint().RackBones[self.CurrentRack].MuzzleBones[1]
                CBFP_oldUES0202.Weapons.CruiseMissile.PlayFxMuzzleSequence(self, muzzle)
                if self.CurrentRack < 8 then self.CurrentRack = self.CurrentRack + 1 else self.CurrentRack = 1 end
                WaitSeconds(1)   # the pre-firing animation takes 1 second to play
                if self.unit:IsDead() then return end

                # I'm not calling CBFP_oldUES0202.Weapons.CruiseMissile.CreateProjectileAtMuzzle on purpuse, that function is not the one that I need
                TIFCruiseMissileLauncher.CreateProjectileAtMuzzle(self, muzzle)
            end,

            PlayFxMuzzleSequence = function(self, muzzle)
                # preventing the generic weapon system from playing the muzzle FX: it creates smoke at the wrong
                # muzzles. Doing it manually, see 2nd line in CreateCruiseMissile()
            end,
        },
    },
}

TypeClass = UES0202

end