Пример #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
        // copied and changed from RespecPilot()
        private static void WipePilotStats(Pilot pilot)
        {
            var sim      = UnityGameInstance.BattleTechGame.Simulation;
            var pilotDef = pilot.pilotDef.CopyToSim();

            foreach (var value in sim.Constants.Story.CampaignCommanderUpdateTags)
            {
                if (!sim.CompanyTags.Contains(value))
                {
                    sim.CompanyTags.Add(value);
                }
            }

            try
            {
                Log($"Base:\t {pilotDef.BaseGunnery} / {pilotDef.BasePiloting} / {pilotDef.BaseGuts} / {pilotDef.BaseTactics}");
                Log($"Bonus:\t {pilotDef.BonusGunnery} / {pilotDef.BonusPiloting} / {pilotDef.BonusGuts} / {pilotDef.BonusTactics}");

                var num = 0;
                num += sim.GetLevelRangeCost(1, pilotDef.SkillGunnery - 1);
                num += sim.GetLevelRangeCost(1, pilotDef.SkillPiloting - 1);
                num += sim.GetLevelRangeCost(1, pilotDef.SkillGuts - 1);
                num += sim.GetLevelRangeCost(1, pilotDef.SkillTactics - 1);

                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);
                Traverse.Create(pilotDef).Property("BonusGunnery").SetValue(1);
                Traverse.Create(pilotDef).Property("BonusPiloting").SetValue(1);
                Traverse.Create(pilotDef).Property("BonusGuts").SetValue(1);
                Traverse.Create(pilotDef).Property("BonusTactics").SetValue(1);



                // pilotDef.abilityDefNames.Clear();
                pilotDef.abilityDefNames.RemoveAll(x => !modSettings.ignoredAbilities.Contains(x));


                pilotDef.SetSpentExperience(0);
                pilotDef.ForceRefreshAbilityDefs();
                pilotDef.ResetBonusStats();
                pilot.FromPilotDef(pilotDef);
                pilot.AddExperience(0, "Respec", num);
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }
Пример #3
0
        PilotReskill(SGBarracksMWDetailPanel __instance, Pilot ___curPilot)
        {
            var sim      = UnityGameInstance.BattleTechGame.Simulation;
            var pilotDef = ___curPilot.pilotDef.CopyToSim();

            foreach (var val in sim.Constants.Story.CampaignCommanderUpdateTags)
            {
                if (!sim.CompanyTags.Contains(val))
                {
                    sim.CompanyTags.Add(val);
                }
            }
            // save xpUsed
            var xpUsed = (
                sim.GetLevelRangeCost(1, pilotDef.SkillPiloting - 1)
                + sim.GetLevelRangeCost(1, pilotDef.SkillGunnery - 1)
                + sim.GetLevelRangeCost(1, pilotDef.SkillGuts - 1)
                + sim.GetLevelRangeCost(1, pilotDef.SkillTactics - 1)
                );

            // handle xpUsed overflow
            if (xpUsed < 0)
            {
                xpUsed = 0x40000000;
            }
            // reset ___curPilot
            Traverse.Create(pilotDef).Property("BasePiloting").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseGunnery").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseGuts").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseTactics").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusPiloting").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusGunnery").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusGuts").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusTactics").SetValue(1);
            pilotDef.abilityDefNames.Clear();
            pilotDef.SetSpentExperience(0);
            pilotDef.ForceRefreshAbilityDefs();
            pilotDef.ResetBonusStats();
            ___curPilot.FromPilotDef(pilotDef);
            // reset xpUsed
            ___curPilot.AddExperience(0, "reset", xpUsed);
            // ___curPilot.AddExperience(0, "reset", 1234567);
            __instance.DisplayPilot(___curPilot);
        }
Пример #4
0
        // modified copy from assembly
        internal static void SetTempPilotSkill(string type, int skill, int expAmount, AbilityDef abilityDef = null)
        {
            var sim         = UnityGameInstance.BattleTechGame.Simulation;
            var abilityTree = sim.AbilityTree[type][skill];

            var panel = Resources.FindObjectsOfTypeAll <SGBarracksAdvancementPanel>().First();

            var traverse = Traverse.Create(panel);

            //    var curPilot = Traverse.Create(panel).Field("curPilot").GetValue<Pilot>();
            var curPilot = traverse.Field("curPilot").GetValue <Pilot>();

            var pilotDef = curPilot.ToPilotDef(true);

            pilotDef.DataManager = sim.DataManager;
            //    var upgradedSkills = Traverse.Create(panel).Field("upgradedSkills").GetValue<OrderedDictionary>();


            var upgradedSkills = traverse.Field("upgradedSkills").GetValue <OrderedDictionary>();

            //    var upgradedPrimarySkills = Traverse.Create(panel).Field("upgradedPrimarySkills").GetValue<List<AbilityDef>>();
            var upgradedPrimarySkills = traverse.Field("upgradedPrimarySkills").GetValue <List <AbilityDef> >();

            for (var i = 0; i < abilityTree.Count; i++)
            {
                Trace($"Looping {type} {skill}: {abilityTree[i].Id}");
                if (expAmount > 0)
                {
                    //    var skillKey = Traverse.Create(panel).Method("GetSkillKey", type, skill).GetValue<string>();
                    var skillKey = traverse.Method("GetSkillKey", type, skill).GetValue <string>();

                    if (!upgradedSkills.Contains(skillKey))
                    {
                        upgradedSkills.Add(skillKey, new KeyValuePair <string, int>(type, skill));
                        Trace($"Add trait {abilityTree[i].Id}");
                    }
                    var abilityToUse = abilityDef ?? abilityTree[i];
                    Trace($"abilityToUse: {abilityToUse.Id}");
                    pilotDef.ForceRefreshAbilityDefs();

                    // extra condition blocks skills from being taken at incorrect location

// original before gnivler fix
//                if (expAmount > 0 &&
//                    abilityToUse.ReqSkillLevel == skill + 1 &&
//                    !pilotDef.abilityDefNames.Contains(abilityToUse.Id) &&
//                    sim.CanPilotTakeAbility(pilotDef, abilityToUse))

//gnivler fix, results in assignment of default lvl5 on player reverting lvl6; relies on new method at top

                    if (!pilotDef.abilityDefNames.Contains(abilityToUse.Id) &&
                        sim.CanPilotTakeAbility(pilotDef, abilityToUse) &&
                        !HasExistingAbilityAtTier(pilotDef, abilityToUse))

                    {
                        Trace("Add primary " + abilityToUse.Id);
                        pilotDef.abilityDefNames.Add(abilityToUse.Id);
                        if (abilityToUse.IsPrimaryAbility)
                        {
                            upgradedPrimarySkills.Add(abilityToUse);
                        }
                        else
                        {
                            // still need to add it, even if it can't be a primary at location
                            Trace("Add trait " + abilityToUse.Id);
                            pilotDef.abilityDefNames.Add(abilityToUse.Id);
                        }
                    }
                }
                else
                {
                    //    var skillKey2 = Traverse.Create(panel).Method("GetSkillKey", type, skill).GetValue<string>();
                    var skillKey2 = traverse.Method("GetSkillKey", type, skill).GetValue <string>();
                    upgradedSkills.Remove(skillKey2);
                    upgradedPrimarySkills.Remove(abilityTree[i]);

                    Trace($"Removing {skillKey2}: {abilityTree[i].Id}");
                    return;
                }
            }

            Trace("\n");

            pilotDef.ForceRefreshAbilityDefs();
            var pilot = new Pilot(pilotDef, curPilot.GUID, true);

            pilot.pilotDef.DataManager = curPilot.pilotDef.DataManager;
            pilot.FromPilotDef(pilotDef); // added this so RT CD can hook it?
            if (expAmount > 0)
            {
                pilot.SpendExperience(0, "Advancement", (uint)expAmount);
            }

            pilot.ModifyPilotStat_Barracks(0, "Advancement", type, (uint)(skill + 1));
            panel.SetPilot(pilot, false);
            Traverse.Create(panel).Method("RefreshPanel").GetValue();
            var callback = Traverse.Create(panel).Field("OnValueChangeCB").GetValue <UnityAction <Pilot> >();

            // callback sets the Reset / Confirm buttons states
            callback.Invoke(pilot);
        }