public void LegacyGetModifier_Base()
        {
            FactionValue factionValue = new FactionValue();

            factionValue.Name = "1";

            HumanDescriptionDef humanDescDef = new HumanDescriptionDef("-1", "Test", "FNAME", "LNAME", "CSIGN", Gender.Male, factionValue, 1, "foo", "");

            Traverse.Create(humanDescDef).Field("factionValue").SetValue(factionValue);
            Traverse.Create(humanDescDef).Field("factionID").SetValue("1");

            // gun, pilot, guts, tactics
            PilotDef pilotDefHigh = new PilotDef(humanDescDef, 10, 9, 8, 7, 0, 3, false, 0, "voice",
                                                 new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotHigh = new Pilot(pilotDefHigh, "-1", false);

            Assert.AreEqual(5, SkillUtils.GetGunneryModifier(pilotHigh));
            Assert.AreEqual(4, SkillUtils.GetPilotingModifier(pilotHigh));
            Assert.AreEqual(4, SkillUtils.GetGutsModifier(pilotHigh));
            Assert.AreEqual(3, SkillUtils.GetTacticsModifier(pilotHigh));

            PilotDef pilotDefMed = new PilotDef(humanDescDef, 7, 6, 5, 4, 0, 3, false, 0, "voice",
                                                new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotMed = new Pilot(pilotDefMed, "-1", false);

            Assert.AreEqual(3, SkillUtils.GetGunneryModifier(pilotMed));
            Assert.AreEqual(3, SkillUtils.GetPilotingModifier(pilotMed));
            Assert.AreEqual(2, SkillUtils.GetGutsModifier(pilotMed));
            Assert.AreEqual(2, SkillUtils.GetTacticsModifier(pilotMed));

            PilotDef pilotDefLog = new PilotDef(humanDescDef, 4, 3, 2, 1, 0, 3, false, 0, "voice",
                                                new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotLow = new Pilot(pilotDefLog, "-1", false);

            Assert.AreEqual(2, SkillUtils.GetGunneryModifier(pilotLow));
            Assert.AreEqual(1, SkillUtils.GetPilotingModifier(pilotLow));
            Assert.AreEqual(1, SkillUtils.GetGutsModifier(pilotLow));
            Assert.AreEqual(0, SkillUtils.GetTacticsModifier(pilotLow));
        }
Пример #2
0
        public static bool MakeResistCheck(Pilot pilot)
        {
            int   normalizedGunnery = SkillUtils.GetGunneryModifier(pilot);
            float baseResist        = normalizedGunnery * Mod.Config.Combat.PainTolerance.ResistPerGuts;
            float resistPenalty     = ModState.InjuryResistPenalty;
            float resistChance      = Math.Max(0, baseResist - resistPenalty);

            Mod.Log.Debug?.Write($"baseResist:{baseResist} - resistPenalty:{resistPenalty} = resistChance:{resistChance}");

            int  check   = Mod.Random.Next(0, 100);
            bool success = resistChance >= check;

            if (success)
            {
                Mod.Log.Info?.Write($"Pilot:{pilot?.Name} resisted injury with check:{check} <= resistChance:{resistChance}");
            }
            else
            {
                Mod.Log.Info?.Write($"Pilot failed to resist injury with check:{check} > resistChance:{resistChance}");
            }

            return(success);
        }
        public void LegacyGetModifier_Abilities()
        {
            AbilityDef gutsDef8 = new AbilityDef();

            Traverse.Create(gutsDef8).Property("Description").SetValue(new BaseDescriptionDef("AbilityDefG8", "ABC", "DEF", "-1"));
            AbilityDef gutsDef5 = new AbilityDef();

            Traverse.Create(gutsDef5).Property("Description").SetValue(new BaseDescriptionDef("AbilityDefG5", "ABC", "DEF", "-1"));

            FactionValue factionValue = new FactionValue();

            factionValue.Name = "1";

            HumanDescriptionDef humanDescDef = new HumanDescriptionDef("-1", "Test", "FNAME", "LNAME", "CSIGN", Gender.Male, factionValue, 1, "foo", "");

            Traverse.Create(humanDescDef).Field("factionValue").SetValue(factionValue);
            Traverse.Create(humanDescDef).Field("factionID").SetValue("1");

            // gun, pilot, guts, tactics
            PilotDef pilotDefHigh = new PilotDef(humanDescDef, 10, 9, 8, 7, 0, 3, false, 0, "voice",
                                                 new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotHigh = new Pilot(pilotDefHigh, "-1", false);

            Traverse.Create(pilotHigh).Property("Abilities").SetValue(new List <Ability>());

            pilotHigh.Abilities.Add(new Ability(gutsDef8));
            pilotHigh.Abilities.Add(new Ability(gutsDef5));

            Assert.AreEqual(7, SkillUtils.GetGunneryModifier(pilotHigh));
            Assert.AreEqual(4, SkillUtils.GetPilotingModifier(pilotHigh));
            Assert.AreEqual(4, SkillUtils.GetGutsModifier(pilotHigh));
            Assert.AreEqual(3, SkillUtils.GetTacticsModifier(pilotHigh));

            PilotDef pilotDefMed = new PilotDef(humanDescDef, 7, 6, 5, 4, 0, 3, false, 0, "voice",
                                                new List <string>()
            {
                "AbilityDefG5"
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotMed = new Pilot(pilotDefMed, "-1", false);

            Traverse.Create(pilotMed).Property("Abilities").SetValue(new List <Ability>());

            pilotMed.Abilities.Add(new Ability(gutsDef5));

            Assert.AreEqual(4, SkillUtils.GetGunneryModifier(pilotMed));
            Assert.AreEqual(3, SkillUtils.GetPilotingModifier(pilotMed));
            Assert.AreEqual(2, SkillUtils.GetGutsModifier(pilotMed));
            Assert.AreEqual(2, SkillUtils.GetTacticsModifier(pilotMed));

            PilotDef pilotDefLog = new PilotDef(humanDescDef, 4, 3, 2, 1, 0, 3, false, 0, "voice",
                                                new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotLow = new Pilot(pilotDefLog, "-1", false);

            Assert.AreEqual(2, SkillUtils.GetGunneryModifier(pilotLow));
            Assert.AreEqual(1, SkillUtils.GetPilotingModifier(pilotLow));
            Assert.AreEqual(1, SkillUtils.GetGutsModifier(pilotLow));
            Assert.AreEqual(0, SkillUtils.GetTacticsModifier(pilotLow));
        }