예제 #1
0
        //private static void AddInjuryDays(SimGameState sim, Pilot pilot, int days)
        //{
        //    int timeoutRemainingDays = sim.GetPilotTimeoutTimeRemaining(pilot);
        //    Logger.Log($"Applying injury time: (existing: {timeoutRemainingDays}) + (new: {days})");
        //    pilot.pilotDef.SetTimeoutTime(timeoutRemainingDays + days);
        //    pilot.pilotDef.PilotTags.Add("pilot_lightinjury");
        //    sim.RefreshInjuries();

        //    //int timeoutRemainingDays = 0;
        //    //if (pilot.pilotDef.TimeoutRemaining > 0)
        //    //{
        //    //    var med = sim.MedBayQueue.GetSubEntry(pilot.Description.Id);
        //    //    Logger.Log($"med.GetRemainingCost: {med.GetRemainingCost()}");
        //    //    Logger.Log($"med.GetCostPaid: {med.GetCostPaid()}");
        //    //    Logger.Log($"med.GetCost: {med.GetCost()}");
        //    //    Logger.Log($"sim.GetDailyHealValue: {sim.GetDailyHealValue()}");
        //    //    timeoutRemainingDays = (int)Math.Ceiling((double)med.GetRemainingCost() / sim.GetDailyHealValue());
        //    //    sim.MedBayQueue.RemoveSubEntry(pilot.Description.Id);
        //    //}
        //    //Logger.Log($"timeoutRemainingDays: {timeoutRemainingDays}, adding: {days}");
        //    //pilot.pilotDef.SetTimeoutTime(timeoutRemainingDays + days);
        //    //pilot.pilotDef.PilotTags.Add("pilot_lightinjury");

        //    //this.RoomManager.RefreshTimeline(false);

        //}



        private static void RespecPilot(Pilot pilot)
        {
            SimGameState sim      = UnityGameInstance.BattleTechGame.Simulation;
            PilotDef     pilotDef = pilot.pilotDef.CopyToSim();

            foreach (string value in sim.Constants.Story.CampaignCommanderUpdateTags)
            {
                if (!sim.CompanyTags.Contains(value))
                {
                    sim.CompanyTags.Add(value);
                }
            }
            //int num = 0;
            //if (pilotDef.BonusPiloting > 0)
            //{
            //    num += sim.GetLevelRangeCost(pilotDef.BasePiloting, pilotDef.SkillPiloting - 1);
            //}
            //if (pilotDef.BonusGunnery > 0)
            //{
            //    num += sim.GetLevelRangeCost(pilotDef.BaseGunnery, pilotDef.SkillGunnery - 1);
            //}
            //if (pilotDef.BonusGuts > 0)
            //{
            //    num += sim.GetLevelRangeCost(pilotDef.BaseGuts, pilotDef.SkillGuts - 1);
            //}
            //if (pilotDef.BonusTactics > 0)
            //{
            //    num += sim.GetLevelRangeCost(pilotDef.BaseTactics, pilotDef.SkillTactics - 1);
            //}
            //if (num <= 0)
            //{
            //    return;
            //}

            // alternate: broken because some pilots start with values in this:
            //int num = pilot.pilotDef.ExperienceSpent;

            int num = GetTrueSpentExperienceValue(sim, pilot);

            Logger.Log($"num: {num}");
            // nerf the pilotdef
            Traverse.Create(pilotDef).Property("BaseGunnery").SetValue(1);
            Traverse.Create(pilotDef).Property("BasePiloting").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseGuts").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseTactics").SetValue(1);

            pilotDef.abilityDefNames.Clear();
            List <string> abilities = SimGameState.GetAbilities(pilotDef.BaseGunnery, pilotDef.BasePiloting, pilotDef.BaseGuts, pilotDef.BaseTactics);

            pilotDef.abilityDefNames.AddRange(abilities);
            pilotDef.SetSpentExperience(0);
            pilotDef.ForceRefreshAbilityDefs();
            pilotDef.ResetBonusStats();
            pilot.FromPilotDef(pilotDef);
            pilot.AddExperience(0, "Respec", num);
        }
예제 #2
0
        private static void ReplacePilotStats(PilotDef pilotDef, PilotDef replacementStatPilotDef)
        {
            // set all stats to the subPilot stats
            pilotDef.AddBaseSkill(SkillType.Gunnery, replacementStatPilotDef.BaseGunnery - pilotDef.BaseGunnery);
            pilotDef.AddBaseSkill(SkillType.Piloting, replacementStatPilotDef.BasePiloting - pilotDef.BasePiloting);
            pilotDef.AddBaseSkill(SkillType.Guts, replacementStatPilotDef.BaseGuts - pilotDef.BaseGuts);
            pilotDef.AddBaseSkill(SkillType.Tactics, replacementStatPilotDef.BaseTactics - pilotDef.BaseTactics);

            pilotDef.ResetBonusStats();
            pilotDef.AddSkill(SkillType.Gunnery, replacementStatPilotDef.BonusGunnery);
            pilotDef.AddSkill(SkillType.Piloting, replacementStatPilotDef.BonusPiloting);
            pilotDef.AddSkill(SkillType.Guts, replacementStatPilotDef.BonusGuts);
            pilotDef.AddSkill(SkillType.Tactics, replacementStatPilotDef.BonusTactics);

            // set exp to replacementStatPilotDef
            pilotDef.SetSpentExperience(replacementStatPilotDef.ExperienceSpent);
            pilotDef.SetUnspentExperience(replacementStatPilotDef.ExperienceUnspent);

            // copy abilities
            pilotDef.abilityDefNames.Clear();
            pilotDef.abilityDefNames.AddRange(replacementStatPilotDef.abilityDefNames);
            pilotDef.AbilityDefs?.Clear();
            pilotDef.ForceRefreshAbilityDefs();
        }
예제 #3
0
        private static PilotDef GenerateSkilledCrew(StarSystem starSystem, bool isMechWarrior)
        {
            string callsign = RandomUnusedCallsign();

            CrewTagModifier planetModifiers = starSystem.GetPlanetSkillDistModifier();
            float           planetMod       = isMechWarrior ? planetModifiers.MechWarriors : planetModifiers.VehicleCrews;
            int             skillIdx        = GaussianHelper.RandomCrewSkill(planetMod, 0);

            Mod.Log.Debug?.Write($" - generated skillIdx: {skillIdx} using planetModifier: {planetMod}");

            // Divide skill points by 4 to generate a median for each skill
            float totalSkillPoints = isMechWarrior ?
                                     Mod.Config.HiringHall.MechWarriors.SkillToExpertiseThresholds[skillIdx] :
                                     Mod.Config.HiringHall.VehicleCrews.SkillToExpertiseThresholds[skillIdx];

            // Normalize to the basic 10/10/10/10 max if we pull the highest index
            if (totalSkillPoints > 40)
            {
                totalSkillPoints = 40;
            }
            float medianSkillPoints = totalSkillPoints / 4;
            // Reduce the median by -2 to allow for random add below
            float adjustedMedian = (float)Math.Max(0, medianSkillPoints - 2);

            Mod.Log.Debug?.Write($" - skillPoints =>  total: {totalSkillPoints} median: {medianSkillPoints}  adjusted: {adjustedMedian}");

            // Each skill can vary +2.0 from adjusted, then rounded to an integer.
            int piloting = (int)Math.Round(adjustedMedian + (Mod.Random.NextDouble() * 2));
            int gunnery  = (int)Math.Round(adjustedMedian + (Mod.Random.NextDouble() * 2));
            int guts     = (int)Math.Round(adjustedMedian + (Mod.Random.NextDouble() * 2));
            int tactics  = (int)Math.Round(adjustedMedian + (Mod.Random.NextDouble() * 2));

            Mod.Log.Debug?.Write($" - skills =>  piloting: {piloting}  gunnery: {gunnery}  guts: {guts}  tactics: {tactics}");

            // TODO: randomize health +/- 1?
            int health = 3;

            PilotDef pilotDef = new PilotDef(new HumanDescriptionDef(), gunnery, piloting, guts, tactics, injuries: 0, health,
                                             lethalInjury: false, morale: 1, voice: "", new List <string>(), AIPersonality.Undefined, 0, 0, 0);
            PilotDef generatedDef = GenerateCrew(starSystem, callsign, pilotDef);

            // Add the necessary tags here *in addition* to in CrewDetails to support Abilifier (it needs the tag before
            //   the call to SetPilotAbilities)
            if (!isMechWarrior)
            {
                generatedDef.PilotTags.Add(ModTags.Tag_CU_NoMech_Crew);
                generatedDef.PilotTags.Add(ModTags.Tag_CU_Vehicle_Crew);
            }
            else
            {
                // TODO: Are there any mechwarrior tags?
            }


            // Abilities must be set AFTER the pilotDef is created, to allow Abilifier a chance to hook into them
            // TODO: Randomize ability selections
            GenerateAbilityDefs(generatedDef, new Dictionary <string, int>()
            {
                { ModConsts.Skill_Gunnery, gunnery },
                { ModConsts.Skill_Guts, guts },
                { ModConsts.Skill_Piloting, piloting },
                { ModConsts.Skill_Tactics, tactics },
            },
                                isMechWarrior ? Mod.Config.HiringHall.MechWarriors : Mod.Config.HiringHall.VehicleCrews
                                );

            generatedDef.ForceRefreshAbilityDefs();

            return(generatedDef);
        }
예제 #4
0
            public static bool Prefix(PilotGenerator __instance, PilotDef pilot, string type, int value)
            {
                var sim = UnityGameInstance.BattleTechGame.Simulation;

                value--;
                if (value < 0)
                {
                    return(false);
                }
                if (!sim.AbilityTree.ContainsKey(type))
                {
                    return(false);
                }
                if (sim.AbilityTree[type].Count <= value)
                {
                    return(false);
                }

                List <AbilityDef> list = sim.AbilityTree[type][value];

                if (list.Count == 0)
                {
                    return(false);
                }

                else
                {
                    List <AbilityDef> listAbilities = list.FindAll(x => x.IsPrimaryAbility == true);//get primary abilities

                    List <string> pilotAbilityDefNames = pilot.abilityDefNames;
                    var           abilityFilter        = modSettings.abilityReqs.Values.SelectMany(x => x).ToList();

                    List <AbilityDef> abilitiesWithReqs = listAbilities.Where(ability => abilityFilter.Any(filter => filter.Equals(ability.Id))).ToList();

                    foreach (var abilityWithReq in abilitiesWithReqs)
                    {
                        if (!pilotAbilityDefNames.Contains(modSettings.abilityReqs.FirstOrDefault(x => x.Value.Contains(abilityWithReq.Id)).Key))
                        {
                            listAbilities.Remove(abilityWithReq);
                        }
                    }

                    List <AbilityDef> listTraits = list.FindAll(x => x.IsPrimaryAbility != true);//need to keep all traits
                    if (listAbilities.Count > 0)
                    {
                        int idx = UnityEngine.Random.Range(0, listAbilities.Count); //pick a random primary of the options
                        listTraits.Add(listAbilities[idx]);                         //add only that random primary
                    }
                    pilot.DataManager = sim.DataManager;
                    pilot.ForceRefreshAbilityDefs();
                    for (int i = 0; i < listTraits.Count; i++)
                    {
                        if (sim.CanPilotTakeAbility(pilot, listTraits[i], false))
                        {
                            pilot.abilityDefNames.Add(listTraits[i].Description.Id);
                        }
                    }
                    pilot.ForceRefreshAbilityDefs();
                    return(false);
                }
            }