示例#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);
        }
        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();
        }