Beispiel #1
0
        private void ChooseStochasticDamageType(Projectile projectile)
        {
            float r = SafeRandom.Range(0f, 1f) * 0.999f;
            float probabilitySum = 0f;

            for (int i = 0; i < damageTypes.Count; i++)
            {
                if (damageTypes[i].probability + probabilitySum > r)
                {
                    BaseDamageType.CreateDamage(damageTypes[i].damageType).InflictDamage(this, projectile, damageTypes[i].param);
                    if (!damages.Contains(damageTypes[i].damageType))
                    {
                        damages.Add(damageTypes[i].damageType);
                    }
                    return;
                }
                else
                {
                    probabilitySum += damageTypes[i].probability;
                }
            }
        }
        protected bool PenetrationCheck(Projectiles.Projectile projectile, ushort armorThickness, float angle)
        {
            float penetrationMM = ((projectile.Velocity.magnitude * Mathf.Sqrt(projectile.Mass)) / (SHELL_SHAPE_AND_ARMOR_QUALITY_K * Mathf.Sqrt((float)projectile.FromTurret.GunsCaliber / 100f))) * 100f;
            float varianceMM    = Mathf.Lerp(-Global.Penetration.PENETRATION_VARIANCE_MM, Global.Penetration.PENETRATION_VARIANCE_MM, SafeRandom.Range(0f, 1f));
            float angleImpact   = 1f - (Mathf.InverseLerp(0f, 90f, Mathf.Abs(90f - angle)) * Global.Penetration.MAX_PENETRATION_REDUCTION_FROM_ANGLE_PERCENTAGE);

            float appliedPenetrationMM = (penetrationMM + varianceMM) * angleImpact;

            if (appliedPenetrationMM > armorThickness)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }