public static void fillWeaponPredictRecord(ref DamagePredictRecord record, AbstractActor unit, ICombatant target, Weapon weapon, ref List <int> hitLocations, ref float AverageArmor)
        {
            CustomAmmoCategoriesLog.Log.LogWrite("fillWeaponPredictRecord " + unit.DisplayName + " target " + target.DisplayName + " weapon " + weapon.defId + "\n");
            CustomAmmoCategories.applyWeaponAmmoMode(weapon, record.Id.modeId, record.Id.ammoId);
            AbstractActor targetActor = target as AbstractActor;

            if (hitLocations == null)
            {
                hitLocations = target.GetPossibleHitLocations(unit);
                foreach (int hitLocation in hitLocations)
                {
                    CustomAmmoCategoriesLog.Log.LogWrite("Hit Location " + hitLocation + "\n");
                }
            }
            if (float.IsNaN(AverageArmor))
            {
                AverageArmor = CustomAmmoCategories.getTargetAvarageArmor(hitLocations, target);
            }
            float toHit = 0;

            if (weapon.WillFireAtTargetFromPosition(target, unit.CurrentPosition) == true)
            {
                toHit = weapon.GetToHitFromPosition(target, 1, unit.CurrentPosition, target.CurrentPosition, true, (targetActor != null) ? targetActor.IsEvasive : false, false);
            }
            if (toHit < Epsilon)
            {
                record.HeatDamageCoeff = 0f; record.NormDamageCoeff = 0f; record.PredictHeatDamage = 0f;
            }
            ;
            float coolDownCoeff    = 1.0f / (1.0f + CustomAmmoCategories.getWeaponCooldown(weapon));
            float jammCoeff        = 1.0f - CustomAmmoCategories.getWeaponFlatJammingChance(weapon);
            float damageJammCoeff  = CustomAmmoCategories.getWeaponDamageOnJamming(weapon) ? 0.5f : 1.0f;
            float damageShotsCount = (float)weapon.ShotsWhenFired;
            float damagePerShot    = weapon.DamagePerShot;
            float heatPerShot      = weapon.HeatDamagePerShot;

            if (weapon.componentDef.ComponentTags.Contains("wr-clustered_shots") || (CustomAmmoCategories.getWeaponDisabledClustering(weapon) == false))
            {
                damageShotsCount *= (float)weapon.ProjectilesPerShot;
            }
            float piercedLocationsCount = (float)CustomAmmoCategories.getWeaponPierceLocations(hitLocations, target, damagePerShot);
            float hitLocationsCount     = (hitLocations.Count > 0) ? (float)hitLocations.Count : 1.0f;
            float clusterCoeff          = 1.0f + ((piercedLocationsCount / hitLocationsCount) * damageShotsCount) * CustomAmmoCategories.Settings.ClusterAIMult;
            float pierceCoeff           = 1.0f;

            if (AverageArmor > damagePerShot)
            {
                pierceCoeff += (damagePerShot / AverageArmor) * CustomAmmoCategories.Settings.PenetrateAIMult;
            }
            record.NormDamageCoeff   = damagePerShot * damageShotsCount * toHit * coolDownCoeff * jammCoeff * damageJammCoeff * clusterCoeff * pierceCoeff;
            record.HeatDamageCoeff   = heatPerShot * damageShotsCount * toHit * jammCoeff * damageJammCoeff;
            record.PredictHeatDamage = heatPerShot * damageShotsCount * toHit;
            CustomAmmoCategoriesLog.Log.LogWrite(" toHit = " + toHit + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" coolDownCoeff = " + coolDownCoeff + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" jammCoeff = " + jammCoeff + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" damageJammCoeff = " + damageJammCoeff + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" damageShotsCount = " + damageShotsCount + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" damagePerShot = " + damagePerShot + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" heatPerShot = " + heatPerShot + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" piercedLocationsCount = " + piercedLocationsCount + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" hitLocationsCount = " + hitLocationsCount + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" AverageArmor = " + AverageArmor + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" clusterCoeff = " + clusterCoeff + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" pierceCoeff = " + pierceCoeff + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" NormDamageCoeff = " + record.NormDamageCoeff + "\n");
            CustomAmmoCategoriesLog.Log.LogWrite(" HeatDamageCoeff = " + record.HeatDamageCoeff + "\n");
        }