Exemplo n.º 1
0
        private double chanceToHit(double attackAccuracy, double attackerDetection, DesignStats targetStats, bool targetCloaked)
        {
            var targetStealth = targetStats.Jamming + (targetCloaked ? this.mainGame.Statics.ShipFormulas.NaturalCloakBonus : 0);

            return((targetStealth > attackerDetection ? Math.Pow(SigmoidBase, targetStealth - attackerDetection) : 1) *
                   Probability(attackAccuracy - targetStats.Evasion));
        }
Exemplo n.º 2
0
        private double refitCost(Design fromDesign, Design toDesign, DesignStats toDesignStats, StaticsDB statics)
        {
            double cost           = 0;
            var    hullVars       = new Var(AComponentType.LevelKey, toDesign.Hull.Level).Get;
            var    levelRefitCost = statics.ShipFormulas.LevelRefitCost;

            var hullCost = refitComponentCost(fromDesign.Hull, toDesign.Hull, x => x.Cost, null, levelRefitCost);

            if (hullCost > 0)
            {
                cost += hullCost;
            }
            else
            {
                hullCost = toDesign.Hull.TypeInfo.Cost.Evaluate(new Var(AComponentType.LevelKey, toDesign.Hull.Level).Get);
                cost    += hullCost * statics.ShipFormulas.ArmorCostPortion * refitComponentCost(fromDesign.Armor, toDesign.Armor, x => new Formula(1), null, levelRefitCost);
                cost    += hullCost * statics.ShipFormulas.ReactorCostPortion * refitComponentCost(fromDesign.Reactor, toDesign.Reactor, x => new Formula(1), null, levelRefitCost);
                cost    += hullCost * statics.ShipFormulas.SensorCostPortion * refitComponentCost(fromDesign.Sensors, toDesign.Sensors, x => new Formula(1), null, levelRefitCost);
                cost    += hullCost * statics.ShipFormulas.ThrustersCostPortion * refitComponentCost(fromDesign.Thrusters, toDesign.Thrusters, x => new Formula(1), null, levelRefitCost);
            }

            var toDesignVars = DesignBaseVars(toDesign.Hull, toDesign.MissionEquipment, toDesign.SpecialEquipment, statics);

            cost += refitComponentCost(fromDesign.IsDrive, toDesign.IsDrive, x => x.Cost, new Var(IsDriveType.SizeKey, toDesignStats.IsDriveSize), levelRefitCost);
            cost += refitComponentCost(fromDesign.Shield, toDesign.Shield, x => x.Cost, new Var(ShieldType.SizeKey, toDesignStats.ShieldSize), levelRefitCost);
            cost += refitComponentCost(fromDesign.MissionEquipment, toDesign.MissionEquipment, x => x.Cost, null, levelRefitCost);
            cost += refitComponentCost(fromDesign.SpecialEquipment, toDesign.SpecialEquipment, x => x.Cost, new Var(HullType.SizeKey, toDesign.Hull.TypeInfo.SpaceFree.Evaluate(hullVars)), levelRefitCost);

            return(cost);
        }
Exemplo n.º 3
0
 protected void rollCloaking(Combatant unit, DesignStats stats, IEnumerable <Player> players)
 {
     unit.CloakedFor.Clear();
     foreach (var player in players.Where(x => x != unit.Owner))
     {
         if (Probability(stats.Cloaking - sensorStrength(unit.Position, player)) > this.battleGame.Rng.NextDouble())
         {
             unit.CloakedFor.Add(player);
         }
     }
 }
Exemplo n.º 4
0
        private static void doRestDamage(double maxTargets, double firePower, double shieldEfficiency, double armorEfficiency, Combatant target, DesignStats targetStats)
        {
            var splashTargets = Methods.Clamp(maxTargets, 0, Math.Max(target.Ships.Quantity - 1, 0));

            if (target.RestShields > 0)
            {
                double shieldFire   = firePower - Reduce(firePower, targetStats.ShieldThickness, shieldEfficiency);
                double shieldDamage = Reduce(shieldFire, targetStats.ShieldReduction, 1);
                firePower -= shieldFire - shieldDamage;                 //damage reduction difference

                shieldDamage        = Math.Min(shieldDamage * splashTargets, target.RestShields);
                target.RestShields -= shieldDamage;
                firePower          -= shieldDamage;
            }

            double armorDamage = Reduce(firePower, targetStats.ArmorReduction, armorEfficiency);

            target.RestArmor -= armorDamage * splashTargets;

            if (target.RestArmor <= 0)
            {
                target.Ships.Quantity = Math.Min(target.Ships.Quantity, 1);

                target.RestArmor   = 0;
                target.RestShields = 0;
            }
        }
Exemplo n.º 5
0
        private static void doTopDamage(double firePower, double shieldEfficiency, double armorEfficiency, Combatant target, DesignStats targetStats)
        {
            if (target.TopShields > 0)
            {
                double shieldFire   = firePower - Reduce(firePower, targetStats.ShieldThickness, shieldEfficiency);
                double shieldDamage = Reduce(shieldFire, targetStats.ShieldReduction, 1);
                firePower -= shieldFire - shieldDamage;                 //damage reduction difference

                shieldDamage       = Math.Min(shieldDamage, target.TopShields);
                target.TopShields -= shieldDamage;
                firePower         -= shieldDamage;
            }

            double armorDamage = Reduce(firePower, targetStats.ArmorReduction, armorEfficiency);

            target.TopArmor -= armorDamage;

            if (target.TopArmor <= 0)
            {
                target.Ships.Quantity--;
                var safeCount = Math.Max(target.Ships.Quantity, 1);

                target.TopArmor     = target.RestArmor / safeCount;
                target.TopShields   = target.RestShields / safeCount;
                target.RestArmor   -= target.TopArmor;
                target.RestShields -= target.TopShields;
            }
        }
        private double attackTop(Combatant attacker, AbilityStats abilityStats, double quantity, Combatant target, DesignStats targetStats)
        {
            var distance      = Methods.HexDistance(attacker.Position, target.Position);
            var detection     = sensorStrength(target.Position, attacker.Owner);
            var targetStealth = targetStats.Jamming + (target.CloakedFor.Contains(attacker.Owner) ? this.mainGame.Statics.ShipFormulas.NaturalCloakBonus : 0);
            var spent         = 0.0;

            while (target.HitPoints > 0 && quantity > spent)
            {
                spent++;


                if (targetStealth > detection && Math.Pow(sigmoidBase, targetStealth - detection) > this.game.Rng.NextDouble())
                {
                    continue;
                }

                if (Probability(abilityStats.Accuracy - targetStats.Evasion + distance * abilityStats.AccuracyRangePenalty) < this.game.Rng.NextDouble())
                {
                    continue;
                }

                double firePower = abilityStats.FirePower;

                if (target.ShieldPoints > 0)
                {
                    double shieldFire   = firePower - Reduce(firePower, targetStats.ShieldThickness, abilityStats.ShieldEfficiency);
                    double shieldDamage = Reduce(shieldFire, targetStats.ShieldReduction, 1);
                    firePower -= shieldFire - shieldDamage;                     //damage reduction difference

                    shieldDamage         = Math.Min(shieldDamage, target.ShieldPoints);
                    target.ShieldPoints -= shieldDamage;
                    firePower           -= shieldDamage;
                }

                double armorDamage = Reduce(firePower, targetStats.ArmorReduction, abilityStats.ArmorEfficiency);
                target.HitPoints -= armorDamage;
            }

            if (target.HitPoints <= 0)
            {
                target.Ships.Quantity--;
                target.HitPoints    = targetStats.HitPoints;
                target.ShieldPoints = targetStats.ShieldPoints;
            }

            return(spent);
        }