Exemplo n.º 1
0
 public static double CalculateTankInDps(double healPerSecond,
                                         ResistanceProfile resistanceProfile,
                                         DamageProfile damageProfile = null)
 {
     damageProfile = damageProfile ?? DamageProfile.OMNI_DAMAGE_PROFILE;
     return healPerSecond
            / (damageProfile.EmRatio * (1.0 - resistanceProfile.EmResistance)
               + damageProfile.KineticRatio * (1.0 - resistanceProfile.KineticResistance)
               + damageProfile.ThermalRatio * (1.0 - resistanceProfile.ThermalResistance)
               + damageProfile.ExplosiveRatio * (1.0 - resistanceProfile.ExplosiveResistance));
 }
Exemplo n.º 2
0
 private static float CalculateDamage(ResistanceProfile rp, DamageProfile dp, float multip)
 {
     float damage = 0;
     float explosionDamage = dp.ExplosionDamage, laserDamage = dp.LaserDamage, plasmaDamage = dp.PlasmaDamage, piercingDamage = dp.PiercingDamage;
     if (explosionDamage > 0) {
         damage += explosionDamage * (rp.ExplosionResistance / (100 + rp.ExplosionResistance));
     }
     if (laserDamage > 0) {
         damage += laserDamage * (rp.LaserResistance / (100 + rp.LaserResistance));
     }
     if (plasmaDamage > 0) {
         damage += plasmaDamage * (rp.PlasmaResistance / (100 + rp.PlasmaResistance));
     }
     if (piercingDamage > 0) {
         damage += piercingDamage * (rp.PiercingResistance / (100 + rp.PlasmaResistance));
     }
     Debug.Log ("Damage dealt: " + damage);
     return damage * multip;
 }
        public void TestStats()
        {
            var ship = _service.CreateItem("Enyo");
            var items = _service.CreateItems(
                                             "Light Neutron Blaster II",
                                             "Light Neutron Blaster II",
                                             "Light Neutron Blaster II",
                                             "Light Neutron Blaster II",
                                             "1MN Afterburner II",
                                             "X5 Prototype Engine Enervator",
                                             "Initiated Harmonic Warp Scrambler I",
                                             "Magnetic Field Stabilizer II",
                                             "Coreli A-Type Explosive Plating",
                                             "Magnetic Field Stabilizer II",
                                             "Internal Force Field Array I",
                                             "Small Hybrid Burst Aerator I",
                                             "Small Hybrid Collision Accelerator I");

            var context = new Context
                          {
                              Ship = ship,
                              Target = _service.CreateItem("Rifter"),
                              Char = _service.GetAllVCharacter(),
                              Area = new Item()
                          };
            context.Char.InstalledItems.Add(ship);
            ship.InstalledItems.AddRange(items);

            context.Char.Activate(context);

            var hullResistance = new ResistanceProfile
                                 {
                                     EmResistance = 1.0 - ship.GetAttributeById((int) HullDamageResonanceAttribute.EmDamage)
                                                              .Value,
                                     KineticResistance = 1.0 - ship.GetAttributeById((int) HullDamageResonanceAttribute.KineticDamage)
                                                                   .Value,
                                     ThermalResistance = 1.0 - ship.GetAttributeById((int) HullDamageResonanceAttribute.ThermalDamage)
                                                                   .Value,
                                     ExplosiveResistance = 1.0 - ship.GetAttributeById((int) HullDamageResonanceAttribute.ExplosiveDamage)
                                                                     .Value
                                 };

            Assert.AreEqual(0.58, hullResistance.EmResistance, 0.0001);
            Assert.AreEqual(0.58, hullResistance.KineticResistance, 0.0001);
            Assert.AreEqual(0.58, hullResistance.ThermalResistance, 0.0001);
            Assert.AreEqual(0.58, hullResistance.ExplosiveResistance, 0.0001);

            var shieldResistance = new ResistanceProfile
                                   {
                                       EmResistance = 1.0 - ship.GetAttributeById((int) ShieldDamageResonanceAttribute.EmDamage)
                                                                .Value,
                                       KineticResistance = 1.0 - ship.GetAttributeById((int) ShieldDamageResonanceAttribute.KineticDamage)
                                                                     .Value,
                                       ThermalResistance = 1.0 - ship.GetAttributeById((int) ShieldDamageResonanceAttribute.ThermalDamage)
                                                                     .Value,
                                       ExplosiveResistance =
                                           1.0 - ship.GetAttributeById((int) ShieldDamageResonanceAttribute.ExplosiveDamage)
                                                     .Value
                                   };

            Assert.AreEqual(0.115, shieldResistance.EmResistance, 0.0001);
            Assert.AreEqual(0.8673, shieldResistance.KineticResistance, 0.0001);
            Assert.AreEqual(0.646, shieldResistance.ThermalResistance, 0.0001);
            Assert.AreEqual(0.5575, shieldResistance.ExplosiveResistance, 0.0001);

            var armorResistance = new ResistanceProfile
                                  {
                                      EmResistance = 1.0 - ship.GetAttributeById((int) ArmorDamageResonanceAttribute.EmDamage)
                                                               .Value,
                                      KineticResistance = 1.0 - ship.GetAttributeById((int) ArmorDamageResonanceAttribute.KineticDamage)
                                                                    .Value,
                                      ThermalResistance = 1.0 - ship.GetAttributeById((int) ArmorDamageResonanceAttribute.ThermalDamage)
                                                                    .Value,
                                      ExplosiveResistance = 1.0 - ship.GetAttributeById((int) ArmorDamageResonanceAttribute.ExplosiveDamage)
                                                                      .Value
                                  };

            Assert.AreEqual(0.57, armorResistance.EmResistance, 0.0001);
            Assert.AreEqual(0.8603, armorResistance.KineticResistance, 0.0001);
            Assert.AreEqual(0.7205, armorResistance.ThermalResistance, 0.0001);
            Assert.AreEqual(0.567, armorResistance.ExplosiveResistance, 0.0001);

            const int SHIELD_RECHARGE_RATE_ATTRIBUTE_ID = 479;

            var shieldRechargeRate = ship.GetAttributeById(SHIELD_RECHARGE_RATE_ATTRIBUTE_ID)
                .Value;

            const int SHIELD_CAPACITY_ATTRIBUTE_ID = 263;
            var shieldCapacity = ship.GetAttributeById(SHIELD_CAPACITY_ATTRIBUTE_ID)
                .Value;

            var shieldRecharge = new ShieldRecharge(shieldCapacity, shieldRechargeRate);
            
            Assert.AreEqual(
                            5.47,
                            Tank.CalculateTankInDps(shieldRecharge.PeakRecharge, shieldResistance, DamageProfile.OMNI_DAMAGE_PROFILE),
                            0.005);
        }