public static void ShooterSkillAffectsStats() { Thing gun = UnittestUtils.GetThingByName("Gun_SniperRifle"); RangedWeaponStats stats = new RangedWeaponStats(gun); Pawn clueless = UnittestUtils.GetTestPawn(0); Pawn professional = UnittestUtils.GetTestPawn(10); Pawn legendary = UnittestUtils.GetTestPawn(20); float expectedDPS = stats.GetRawDPS(); // Raw DPS (shouldn't change since only traits affect aim time) Assert(stats.GetRawDPS(clueless)).To.Be.Approximately(expectedDPS); Assert(stats.GetRawDPS(professional)).To.Be.Approximately(expectedDPS); Assert(stats.GetRawDPS(legendary)).To.Be.Approximately(expectedDPS); // Optimal range Assert(stats.FindOptimalRange(clueless)).To.Be.Approximately(1f); Assert(stats.FindOptimalRange(professional)).To.Be.Approximately(12f); Assert(stats.FindOptimalRange(legendary)).To.Be.Approximately(25f); // Hit chance Assert(stats.GetAdjustedHitChanceFactor(3f, clueless)).To.Be.Approximately(0.352f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(12f, clueless)).To.Be.Approximately(0.173f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(25f, clueless)).To.Be.Approximately(0.047f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(40f, clueless)).To.Be.Approximately(0.018f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(3f, professional)).To.Be.Approximately(0.456f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(12f, professional)).To.Be.Approximately(0.486f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(25f, professional)).To.Be.Approximately(0.402f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(40f, professional)).To.Be.Approximately(0.260f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(3f, legendary)).To.Be.Approximately(0.485f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(12f, legendary)).To.Be.Approximately(0.620f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(25f, legendary)).To.Be.Approximately(0.669f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(40f, legendary)).To.Be.Approximately(0.589f, DERIVED_DELTA); // DPS Assert(stats.GetAdjustedDPS(3f, clueless)).To.Be.Approximately(0.352f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(12f, clueless)).To.Be.Approximately(0.173f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(25f, clueless)).To.Be.Approximately(0.047f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(40f, clueless)).To.Be.Approximately(0.018f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(3f, professional)).To.Be.Approximately(0.456f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(12f, professional)).To.Be.Approximately(0.486f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(25f, professional)).To.Be.Approximately(0.402f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(40f, professional)).To.Be.Approximately(0.260f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(3f, legendary)).To.Be.Approximately(0.485f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(12f, legendary)).To.Be.Approximately(0.620f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(25f, legendary)).To.Be.Approximately(0.669f * expectedDPS, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(40f, legendary)).To.Be.Approximately(0.589f * expectedDPS, DERIVED_DELTA); }
public static void ShooterTraitsAffectsStats() { Thing gun = UnittestUtils.GetThingByName("Gun_SniperRifle"); RangedWeaponStats stats = new RangedWeaponStats(gun); Pawn triggerHappy = UnittestUtils.GetTestPawn(10); triggerHappy.AddTrait("ShootingAccuracy", -1); Pawn carefulShooter = UnittestUtils.GetTestPawn(10); carefulShooter.AddTrait("ShootingAccuracy", 1); // Raw DPS Assert(stats.GetRawDPS(triggerHappy)).To.Be.Approximately(6.1728f); Assert(stats.GetRawDPS(carefulShooter)).To.Be.Approximately(3.7453f); // Optimal range Assert(stats.FindOptimalRange(triggerHappy)).To.Be.Approximately(1f); Assert(stats.FindOptimalRange(carefulShooter)).To.Be.Approximately(12f); // Hit chance Assert(stats.GetAdjustedHitChanceFactor(3f, triggerHappy)).To.Be.Approximately(0.422f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(12f, triggerHappy)).To.Be.Approximately(0.355f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(25f, triggerHappy)).To.Be.Approximately(0.209f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(40f, triggerHappy)).To.Be.Approximately(0.092f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(3f, carefulShooter)).To.Be.Approximately(0.473f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(12f, carefulShooter)).To.Be.Approximately(0.563f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(25f, carefulShooter)).To.Be.Approximately(0.546f, DERIVED_DELTA); Assert(stats.GetAdjustedHitChanceFactor(40f, carefulShooter)).To.Be.Approximately(0.426f, DERIVED_DELTA); // DPS Assert(stats.GetAdjustedDPS(3f, triggerHappy)).To.Be.Approximately(0.422f * 6.1728f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(12f, triggerHappy)).To.Be.Approximately(0.355f * 6.1728f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(25f, triggerHappy)).To.Be.Approximately(0.209f * 6.1728f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(40f, triggerHappy)).To.Be.Approximately(0.092f * 6.1728f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(3f, carefulShooter)).To.Be.Approximately(0.473f * 3.7453f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(12f, carefulShooter)).To.Be.Approximately(0.563f * 3.7453f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(25f, carefulShooter)).To.Be.Approximately(0.546f * 3.7453f, DERIVED_DELTA); Assert(stats.GetAdjustedDPS(40f, carefulShooter)).To.Be.Approximately(0.426f * 3.7453f, DERIVED_DELTA); }