Exemplo n.º 1
0
        private static bool UpdateAbilitiesFromTags(PilotDef pilotDef)
        {
            var reloadAbilities = false;

            foreach (var tag in pilotDef.PilotTags)
            {
                if (!Settings.TagAbilities.ContainsKey(tag))
                {
                    continue;
                }

                foreach (var abilityName in Settings.TagAbilities[tag])
                {
                    if (!HasAbilityDef(dataManager, abilityName))
                    {
                        HBSLog.LogWarning($"Tried to add {abilityName} from tag {tag}, but ability not found!");
                        continue;
                    }

                    if (!pilotDef.abilityDefNames.Contains(abilityName))
                    {
                        HBSLog.Log($"{pilotDef.Description.Id}: Adding '{abilityName}' from tag '{tag}'");
                        pilotDef.abilityDefNames.Add(abilityName);
                        reloadAbilities = true;
                    }
                }
            }

            return(reloadAbilities);
        }
Exemplo n.º 2
0
        private static bool UpdateAbilitiesFromFaction(PilotDef pilotDef, FactionValue faction)
        {
            var reloadAbilities = false;

            if (!Settings.FactionAbilities.ContainsKey(faction.Name))
            {
                return(false);
            }

            foreach (var abilityName in Settings.FactionAbilities[faction.Name])
            {
                if (!HasAbilityDef(dataManager, abilityName))
                {
                    HBSLog.LogWarning(
                        $"Tried to add {abilityName} from faction {faction.Name}, but ability not found!");
                    continue;
                }

                if (!pilotDef.abilityDefNames.Contains(abilityName))
                {
                    HBSLog.Log($"{pilotDef.Description.Id}: Adding '{abilityName}' from faction '{faction.Name}'");
                    pilotDef.abilityDefNames.Add(abilityName);
                    reloadAbilities = true;
                }
            }

            return(reloadAbilities);
        }
Exemplo n.º 3
0
        private Vehicle CreatePathFindingVehicle()
        {
            GameInstance    game        = UnityGameInstance.BattleTechGame;
            CombatGameState combatState = game.Combat;
            string          spawnerId   = Guid.NewGuid().ToString();
            string          uniqueId    = $"{spawnerId}.9999999998";

            HeraldryDef heraldryDef = null;

            combatState.DataManager.Heraldries.TryGet(HeraldryDef.HeraldyrDef_SinglePlayerSkirmishPlayer1, out heraldryDef);

            VehicleDef vehicleDef = null;

            combatState.DataManager.VehicleDefs.TryGet("vehicledef_DEMOLISHER", out vehicleDef);

            PilotDef pilotDef = null;

            combatState.DataManager.PilotDefs.TryGet("pilot_default", out pilotDef);
            Vehicle vehicle = new Vehicle(vehicleDef, pilotDef, new TagSet(), uniqueId, combatState, spawnerId, heraldryDef);

            string teamId = TeamUtils.GetTeamGuid("NeutralToAll");
            Team   team   = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(teamId);

            AccessTools.Field(typeof(AbstractActor), "_team").SetValue(vehicle, team);
            AccessTools.Field(typeof(AbstractActor), "_teamId").SetValue(vehicle, teamId);

            return(vehicle);
        }
Exemplo n.º 4
0
        private Mech CreatePathFinderMech()
        {
            GameInstance    game        = UnityGameInstance.BattleTechGame;
            CombatGameState combatState = game.Combat;
            string          spawnerId   = Guid.NewGuid().ToString();
            string          uniqueId    = $"{spawnerId}.9999999999";

            HeraldryDef heraldryDef = null;

            combatState.DataManager.Heraldries.TryGet(HeraldryDef.HeraldyrDef_SinglePlayerSkirmishPlayer1, out heraldryDef);

            MechDef mechDef = null;

            combatState.DataManager.MechDefs.TryGet("mechdef_spider_SDR-5V", out mechDef);

            PilotDef pilotDef = null;

            combatState.DataManager.PilotDefs.TryGet("pilot_default", out pilotDef);
            Mech mech = new Mech(mechDef, pilotDef, new TagSet(), uniqueId, combatState, spawnerId, heraldryDef);

            string teamId = TeamUtils.GetTeamGuid("NeutralToAll");
            Team   team   = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(teamId);

            AccessTools.Field(typeof(AbstractActor), "_team").SetValue(mech, team);
            AccessTools.Field(typeof(AbstractActor), "_teamId").SetValue(mech, teamId);

            return(mech);
        }
Exemplo n.º 5
0
        public static int CalculateExperience(PilotDef pilotdef, int minLevel)
        {
            var   sim     = UnityGameInstance.BattleTechGame.Simulation;
            int   TotalXP = 0;
            float exp     = sim.Constants.Pilot.PilotLevelCostExponent;
            float mult    = sim.Constants.Pilot.PilotLevelCostMultiplier;

            for (int i = pilotdef.SkillGunnery; i > minLevel; i--)
            {
                TotalXP += Mathf.CeilToInt(Mathf.Pow((float)i, (exp + exp * Pre_Control.settings.pilot_XP_change))
                                           * (mult + mult * Pre_Control.settings.pilot_XP_change));
            }
            for (int i = pilotdef.SkillPiloting; i > 1; i--)
            {
                TotalXP += Mathf.CeilToInt(Mathf.Pow((float)i, (exp + exp * Pre_Control.settings.pilot_XP_change))
                                           * (mult + mult * Pre_Control.settings.pilot_XP_change));
            }
            for (int i = pilotdef.SkillGuts; i > 1; i--)
            {
                TotalXP += Mathf.CeilToInt(Mathf.Pow((float)i, (exp + exp * Pre_Control.settings.pilot_XP_change))
                                           * (mult + mult * Pre_Control.settings.pilot_XP_change));
            }
            for (int i = pilotdef.SkillTactics; i > 1; i--)
            {
                TotalXP += Mathf.CeilToInt(Mathf.Pow((float)i, (exp + exp * Pre_Control.settings.pilot_XP_change))
                                           * (mult + mult * Pre_Control.settings.pilot_XP_change));
            }
            return(TotalXP);
        }
Exemplo n.º 6
0
 public static void Prefix(SimGameState __instance, PilotDef def, bool updatePilotDiscardPile = false)
 {
     if (def != null)
     {
         PilotQuirkManager.Instance.proccessPilot(def, true);
     }
 }
Exemplo n.º 7
0
        public static PilotDef UpgradeRonin(StarSystem starSystem, PilotDef baseRoninDef)
        {
            CrewDetails details = ReadRoninTags(baseRoninDef);

            ModState.UpdateOrCreateCrewDetails(baseRoninDef, details);
            return(baseRoninDef);
        }
        public static void Postfix(SimGameState __instance, ref int __result, EconomyScale expenditureLevel, bool proRate)
        {
            Mod.Log.Trace?.Write($"SGS:GE entered with {__result}");

            // Evaluate old versus new cost
            int vanillaCosts = 0;
            int newCosts     = 0;

            for (int i = 0; i < __instance.PilotRoster.Count; i++)
            {
                PilotDef def = __instance.PilotRoster[i].pilotDef;
                vanillaCosts += __instance.GetMechWarriorValue(def);

                CrewDetails details = ModState.GetCrewDetails(def);
                newCosts += details.AdjustedSalary;
            }

            // Multiply old costs by expenditure. New has that built in. Then subtract them from the running total
            float expenditureCostModifier = __instance.GetExpenditureCostModifier(expenditureLevel);
            int   vanillaTotal            = Mathf.CeilToInt((float)vanillaCosts * expenditureCostModifier);

            Mod.Log.Trace?.Write($"Removing {vanillaCosts} costs x {expenditureCostModifier} expenditureMulti " +
                                 $"= {vanillaTotal} total vanilla costs.");
            __result -= vanillaTotal;

            // Add the new costs
            __result += newCosts;
        }
Exemplo n.º 9
0
 public static void Postfix(PilotDef __instance, LoadRequest loadRequest)
 {
     if (__instance.PortraitSettings != null)
     {
         // perform this here on the first save load after character creation
         // this avoids all sorts of exceptions and problems with the character customization UIs
         // this also means we only need to do this in one patch instead of many
         if (!string.IsNullOrEmpty(__instance.PortraitSettings.Description.Icon))
         {
             __instance.Description.SetIcon(__instance.PortraitSettings.Description.Icon);
             __instance.PortraitSettings = null;
             Logger.LogLine(string.Format("Applying Hardset Icon to Pilot: {0}, {1}", (object)__instance.Description.Callsign, (object)__instance.Description.Icon));
         }
     }
     if (!string.IsNullOrEmpty(__instance.Description.Icon))
     {
         //Logger.LogLine(string.Format("Loading Pilot: {0}, {1}", (object)__instance.Description.Callsign, (object)__instance.Description.Icon));
         // Issue a Load request for any custom sprites
         try
         {
             Logger.LogLine(string.Format("Issuing  Load Request Icon for Pilot: {0}, {1}", (object)__instance.Description.Callsign, (object)__instance.Description.Icon));
             loadRequest.AddBlindLoadRequest(BattleTechResourceType.Sprite, __instance.Description.Icon, new bool?(false));
         }
         catch (Exception e)
         {
             Logger.LogError(e);
         }
     }
 }
            public static void Postfix(SimGameState __instance, PilotDef def)
            {
                var p = __instance.PilotRoster.FirstOrDefault(x => x.pilotDef.Description.Id == def.Description.Id);

                SpecHolder.HolderInstance.AddToMaps(p);
                SpecHolder.HolderInstance.ProcessTaggedSpecs(p);
            }
Exemplo n.º 11
0
        static bool Prefix(SimGameState __instance, PilotDef def, ref int __result)
        {
            CrewDetails details = ModState.GetCrewDetails(def);

            __result = details != null ? details.Salary : 0;

            return(false);
        }
        private static Pilot BuildTestPilot()
        {
            PilotDef pilotDef = new PilotDef();
            Guid     guid     = new Guid();

            Pilot pilot = new Pilot(pilotDef, guid.ToString(), false);

            return(pilot);
        }
Exemplo n.º 13
0
 static bool Prefix(SimGameState __instance, PilotDef pilotDef)
 {
     if (__instance.PilotRoster.Any(x => x.pilotDef.Description.Id == pilotDef.Description.Id))
     {
         Mod.Log.Info?.Write($"Pilot {pilotDef.Description.Id} already in Roster! Not adding to Hiring Hall!");
         return(false);
     }
     return(true);
 }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        private static bool UpdateAbilitiesFromTree(PilotDef pilotDef)
        {
            if (pilotDef.abilityDefNames == null)
            {
                return(false);
            }

            var matchingAbilities = new List <string>();
            var missingAbilities  = new List <string>();

            CheckAbilitiesFromProgression(pilotDef.abilityDefNames, constants.Progression.GunnerySkills,
                                          pilotDef.SkillGunnery, missingAbilities, matchingAbilities);
            CheckAbilitiesFromProgression(pilotDef.abilityDefNames, constants.Progression.PilotingSkills,
                                          pilotDef.SkillPiloting, missingAbilities, matchingAbilities);
            CheckAbilitiesFromProgression(pilotDef.abilityDefNames, constants.Progression.GutsSkills,
                                          pilotDef.SkillGuts, missingAbilities, matchingAbilities);
            CheckAbilitiesFromProgression(pilotDef.abilityDefNames, constants.Progression.TacticsSkills,
                                          pilotDef.SkillTactics, missingAbilities, matchingAbilities);

            var reloadAbilities = false;
            var extraAbilities  = pilotDef.abilityDefNames.Except(matchingAbilities).ToList();

            if (GetPrimaryAbilitiesForPilot(dataManager, pilotDef).Count > 3)
            {
                HBSLog.Log($"{pilotDef.Description.Id}: Has too many primary abilities -- not doing anything about it");
            }

            // remove abilities that don't exist anymore
            foreach (var abilityName in extraAbilities)
            {
                if (!Settings.IgnoreAbilities.Exists(x => abilityName.StartsWith(x)) &&
                    ((Settings.RemoveNonTreeAbilities && !progressionAbilities.Contains(abilityName)) ||
                     !HasAbilityDef(dataManager, abilityName)))
                {
                    HBSLog.Log($"{pilotDef.Description.Id}: Removing '{abilityName}'");
                    pilotDef.abilityDefNames.RemoveAll(x => x == abilityName);
                    reloadAbilities = true;
                }
            }

            // add the missing abilities
            foreach (var abilityName in missingAbilities)
            {
                if (!Settings.IgnoreAbilities.Exists(x => abilityName.StartsWith(x)) &&
                    Settings.AddTreeAbilities && CanLearnAbility(dataManager, pilotDef, abilityName))
                {
                    HBSLog.Log($"{pilotDef.Description.Id}: Adding '{abilityName}' from tree");
                    pilotDef.abilityDefNames.Add(abilityName);
                    reloadAbilities = true;
                }
            }



            return(reloadAbilities);
        }
Exemplo n.º 16
0
        //        internal static readonly List<AbilityDef> ModAbilities = new List<AbilityDef>();

        //        internal static void PopulateAbilities()
        //        {
        //            var jsonFiles = new DirectoryInfo(
        //                Path.Combine(modSettings.modDirectory, "Abilities")).GetFiles().ToList();
        //            foreach (var file in jsonFiles)
        //            {
        //                var abilityDef = new AbilityDef();
        //                abilityDef.FromJSON(File.ReadAllText(file.FullName));
        //                if (!ModAbilities.Contains(abilityDef))
        //                {
        //                    ModAbilities.Add(abilityDef);
        //                }
        //                else
        //                {
        //                    Log("Duplicate AbilityDef, id is " + abilityDef.Id);
        //                }
        //            }
        //        }

        // modified copy from assembly
        private static bool HasExistingAbilityAtTier(PilotDef pilotDef, AbilityDef abilityToUse)
        {
            var result = pilotDef.AbilityDefs.Any(x =>
                                                  x.IsPrimaryAbility == true &&
                                                  //x.ReqSkill != SkillType.NotSet &&
                                                  x.ReqSkill == abilityToUse.ReqSkill &&
                                                  x.ReqSkillLevel == abilityToUse.ReqSkillLevel);

            return(result);
        }
Exemplo n.º 17
0
        public static CrewDetails GenerateDetailsForVanillaMechwarrior(PilotDef basePilotDef, bool isFounder = false)
        {
            (FactionValue favored, FactionValue hated) = GenerateCrewFactions(null);
            CrewDetails details = new CrewDetails(basePilotDef, CrewType.MechWarrior, favored, hated);

            ModState.UpdateOrCreateCrewDetails(basePilotDef, details);
            Mod.Log.Info?.Write($" -- pilotDef associated with GUID: {details.GUID}");

            return(details);
        }
Exemplo n.º 18
0
        public static float GetRelativeCombatExperience(this PilotDef pilotDef)
        {
            //int rank = PilotDef.GetPilotRank(pilotDef);

            const float min    = 0.1f;
            const float max    = 1.1f;
            float       result = 0;

            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) MechKills: {pilotDef.MechKills}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) OtherKills: {pilotDef.OtherKills}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) MissionsPiloted: {pilotDef.MissionsPiloted}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) MissionsEjected: {pilotDef.MissionsEjected}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) LifetimeInjuries: {pilotDef.LifetimeInjuries}");

            // What * Importance / PercentageDivisor
            float mechKillsFactor        = pilotDef.MechKills * 1f / 100;
            float otherKillsFactor       = pilotDef.OtherKills * 0.5f / 100;
            float missionsPilotedFactor  = pilotDef.MissionsPiloted * 0.5f / 100;
            float missionsEjectedFactor  = pilotDef.MissionsEjected * 3f / 100;
            float lifetimeInjuriesFactor = pilotDef.LifetimeInjuries * 2f / 100;


            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) mechKillsFactor: {mechKillsFactor}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) otherKillsFactor: {otherKillsFactor}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) missionsPilotedFactor: {missionsPilotedFactor}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) missionsEjectedFactor: {missionsEjectedFactor}");
            Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) lifetimeInjuriesFactor: {lifetimeInjuriesFactor}");


            result += mechKillsFactor;
            result += otherKillsFactor;
            result += missionsPilotedFactor;
            result += missionsEjectedFactor;
            result += lifetimeInjuriesFactor;

            // Prevent division by zero!
            if (pilotDef.MissionsPiloted > 0)
            {
                float averageKillsPerMission = (float)(pilotDef.MechKills + pilotDef.OtherKills) / (float)pilotDef.MissionsPiloted;
                Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) Average kills per mission: {averageKillsPerMission}");

                float averageKillsPerMissionFactor = averageKillsPerMission * 9f / 100;
                Logger.Info($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) averageKillsPerMissionFactor: {averageKillsPerMissionFactor}");

                result += averageKillsPerMissionFactor;
            }

            //result = Math.Max(min, result);
            //result = Math.Min(max, result);
            Mathf.Clamp(result, min, max);

            Logger.Debug($"[PilotDefExtensions_GetRelativeCombatExperience] ({pilotDef.Description.Callsign}) Result: {result}");

            return(result);
        }
Exemplo n.º 19
0
 public static void Prefix(SimGameState __instance, Pilot p)
 {
     if (p != null)
     {
         PilotDef def = p.pilotDef;
         if (def != null)
         {
             PilotQuirkManager.Instance.proccessPilot(def, false);
         }
     }
 }
Exemplo n.º 20
0
        private static PilotDef GenerateSkillessCrew(StarSystem starSystem, string callsign, out int crewSize, out int crewSkill)
        {
            // Determine crew size and skill
            crewSize  = GaussianHelper.RandomCrewSize(0, 0);
            crewSkill = GaussianHelper.RandomCrewSkill(0, 0);
            Mod.Log.Debug?.Write($" - random crewSize: {crewSize}  crewSkill: {crewSkill}");

            PilotDef pilotDef = new PilotDef(new HumanDescriptionDef(), 1, 1, 1, 1, 1, 1, lethalInjury: false, 1, "", new List <string>(), AIPersonality.Undefined, 0, 0, 0);

            return(GenerateCrew(starSystem, callsign, pilotDef));
        }
Exemplo n.º 21
0
        // === COMBAT CREWS ===
        public static PilotDef GenerateMechWarrior(StarSystem starSystem)
        {
            PilotDef crew = GenerateSkilledCrew(starSystem, true);

            Mod.Log.Debug?.Write($"CREATED MECHWARRIOR CREW");

            (FactionValue favored, FactionValue hated) = GenerateCrewFactions(starSystem);
            CrewDetails details = new CrewDetails(crew, CrewType.MechWarrior, favored, hated);

            ModState.UpdateOrCreateCrewDetails(crew, details);
            return(crew);
        }
Exemplo n.º 22
0
 static void Postfix(LanceConfiguratorPanel __instance, ref LanceConfiguration __result, LanceLoadoutSlot[] ___loadoutSlots)
 {
     try {
         if (CustomUnitsAPI.Detected())
         {
             return;
         }
         Fields.callsigns.Clear();
         LanceConfiguration lanceConfiguration = new LanceConfiguration();
         for (int i = 0; i < ___loadoutSlots.Length; i++)
         {
             LanceLoadoutSlot lanceLoadoutSlot = ___loadoutSlots[i];
             MechDef          mechDef          = null;
             PilotDef         pilotDef         = null;
             if (lanceLoadoutSlot.SelectedMech != null)
             {
                 mechDef = lanceLoadoutSlot.SelectedMech.MechDef;
             }
             if (lanceLoadoutSlot.SelectedPilot != null)
             {
                 pilotDef = lanceLoadoutSlot.SelectedPilot.Pilot.pilotDef;
             }
             if (mechDef != null && pilotDef != null)
             {
                 if (i < Settings.DEFAULT_MECH_SLOTS)
                 {
                     lanceConfiguration.AddUnit(__instance.playerGUID, mechDef, pilotDef);
                 }
                 else
                 {
                     //if (i >= BiggerDrops.settings.additinalMechSlots + Settings.DEFAULT_MECH_SLOTS) { break; }
                     Logger.M.TWL(0, "LanceConfiguratorPanel.CreateLanceConfiguration. Index:" + i + " additional slots border:" + (BiggerDrops.settings.additinalMechSlots + Settings.DEFAULT_MECH_SLOTS) + " player slots border:" + (BiggerDrops.settings.additinalPlayerMechSlots + Settings.DEFAULT_MECH_SLOTS));
                     if (i >= BiggerDrops.settings.additinalPlayerMechSlots + Settings.DEFAULT_MECH_SLOTS)
                     {
                         Fields.callsigns.Add(pilotDef.Description.Callsign);
                         //EMPLOYER ID
                         Logger.M.WL(1, "adding to employer lance " + Settings.EMPLOYER_LANCE_GUID + " mech:" + mechDef.Description.Id + " pilot:" + pilotDef.Description.Id);
                         lanceConfiguration.AddUnit(Settings.EMPLOYER_LANCE_GUID, mechDef, pilotDef);
                     }
                     else
                     {
                         Logger.M.WL(1, "adding to player lance " + __instance.playerGUID + " mech:" + mechDef.Description.Id + " pilot:" + pilotDef.Description.Id);
                         lanceConfiguration.AddUnit(__instance.playerGUID, mechDef, pilotDef);
                     }
                 }
             }
         }
         __result = lanceConfiguration;
     } catch (Exception e) {
         Logger.LogError(e);
     }
 }
Exemplo n.º 23
0
        public static PilotDef GenerateVehicleCrew(StarSystem starSystem)
        {
            PilotDef crew = GenerateSkilledCrew(starSystem, false);

            Mod.Log.Debug?.Write($"CREATED VEHICLE CREW");

            (FactionValue favored, FactionValue hated) = GenerateCrewFactions(starSystem);
            CrewDetails details = new CrewDetails(crew, CrewType.VehicleCrew, favored, hated);

            ModState.UpdateOrCreateCrewDetails(crew, details);

            return(crew);
        }
Exemplo n.º 24
0
        private static List <string> GetPrimaryAbilitiesForPilot(DataManager dm, PilotDef pilotDef)
        {
            var primaryAbilities = new List <string>();

            foreach (var abilityName in pilotDef.abilityDefNames)
            {
                var abilityDef = GetAbilityDef(dm, abilityName);
                if (abilityDef != null && abilityDef.IsPrimaryAbility)
                {
                    primaryAbilities.Add(abilityName);
                }
            }
            return(primaryAbilities);
        }
Exemplo n.º 25
0
        private List <PilotQuirk> getQuirks(PilotDef pilotDef, bool usePools = false)
        {
            List <PilotQuirk> pilotQuirks = new List <PilotQuirk>();

            if (pilotDef != null)
            {
                List <string> tags       = pilotDef.PilotTags.ToList();
                List <string> usedQuirks = new List <string>();
                foreach (string tag in tags)
                {
                    //Main.modLog.LogMessage($"Processing tag: {tag}");
                    PilotQuirk quirk;
                    if (quirks.TryGetValue(tag, out quirk))
                    {
                        pilotQuirks.Add(quirk);
                        usedQuirks.Add(tag);
                    }
                }

                if (usePools)
                {
                    foreach (string tag in tags)
                    {
                        QuirkPool quirkpool;
                        if (quirkPools.TryGetValue(tag, out quirkpool))
                        {
                            List <string> choosenQuirks = getPooledQuirks(quirkpool);
                            foreach (string possibleQuirk in choosenQuirks)
                            {
                                PilotQuirk quirk;
                                if (quirks.TryGetValue(possibleQuirk, out quirk))
                                {
                                    if (!usedQuirks.Contains(possibleQuirk))
                                    {
                                        pilotQuirks.Add(quirk);
                                        usedQuirks.Add(possibleQuirk);
                                        Main.modLog.LogMessage($"Adding Randomized Quirk: {possibleQuirk}");
                                    }
                                    else
                                    {
                                        Main.modLog.LogMessage($"Skipped adding randomized quirk {possibleQuirk}, because it was already used");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(pilotQuirks);
        }
Exemplo n.º 26
0
 public static void Postfix(ref PilotDef __result)
 {
     if (__result.PilotTags.Contains("pilot_bookish"))
     {
         __result.ExperienceSpent = CalculateExperience(__result, 1);
     }
     if (__result.PilotTags.Contains("pilot_klutz"))
     {
         __result.ExperienceSpent = CalculateExperience(__result, 1);
     }
     if (__result.PilotTags.Contains("pilot_assassin"))
     {
         __result.ExperienceSpent = CalculateExperience(__result, 1);
     }
 }
Exemplo n.º 27
0
        public static PilotDef GenerateAerospaceCrew(StarSystem starSystem)
        {
            int    callsignIdx = Mod.Random.Next(0, Mod.CrewNames.Aerospace.Count - 1);
            string newCallsign = Mod.CrewNames.Aerospace[callsignIdx];

            PilotDef def = GenerateSkillessCrew(starSystem, newCallsign, out int crewSize, out int crewSkill);

            // Before returning, initialize the cache value
            (FactionValue favored, FactionValue hated) = GenerateCrewFactions(starSystem);
            CrewDetails details = new CrewDetails(def, CrewType.AerospaceWing, favored, hated, crewSize, crewSkill);

            ModState.UpdateOrCreateCrewDetails(def, details);

            return(def);
        }
Exemplo n.º 28
0
        static void Prefix(ref SpawnableUnit __instance, PilotDef pilotDef)
        {
            try {
                if (!string.IsNullOrEmpty(pilotDef.Voice))
                {
                    string        text2   = string.Format("vo_{0}", pilotDef.Voice);
                    AudioBankList bankId2 = (AudioBankList)Enum.Parse(typeof(AudioBankList), text2, true);
                    SceneSingletonBehavior <WwiseManager> .Instance.LoadBank(bankId2);

                    SceneSingletonBehavior <WwiseManager> .Instance.voBanks.Add(text2);
                }
            }
            catch (Exception e) {
                Logger.LogError(e);
            }
        }
Exemplo n.º 29
0
        static bool Prefix(SimGameState __instance, PilotDef def, ref string __result)
        {
            string salaryLabel = "------";

            if (!def.IsFree)
            {
                CrewDetails details     = ModState.GetCrewDetails(def);
                string      cbillString = SimGameState.GetCBillString(Mathf.RoundToInt(details.AdjustedSalary));
                salaryLabel = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Salary_Label],
                                       new object[] { cbillString })
                              .ToString();
            }
            __result = salaryLabel;

            return(false);
        }
        public static AbstractActor SpawnAmbushMech(Team team, Lance ambushLance, Vector3 ambushOrigin, Vector3 spawnPos, Quaternion spawnRot, List <MechAndPilotDef> spawnPool)
        {
            // Randomly determine one of the spawnpairs from the current ambushdef
            List <MechAndPilotDef> shuffledSpawns = new List <MechAndPilotDef>();

            shuffledSpawns.AddRange(spawnPool);
            shuffledSpawns.Shuffle();

            MechAndPilotDef ambushDef = shuffledSpawns[0];

            PilotDef pilotDef = ModState.Combat.DataManager.PilotDefs.Get(ambushDef.PilotDefId);
            MechDef  mechDef  = ModState.Combat.DataManager.MechDefs.Get(ambushDef.MechDefId);

            mechDef.Refresh();

            // Adjust position so we don't spawn in the ground.
            spawnPos.y = ModState.Combat.MapMetaData.GetLerpedHeightAt(spawnPos, true);

            // Rotate to face the ambush origin
            Vector3    spawnDirection = Vector3.RotateTowards(spawnRot.eulerAngles, ambushOrigin, 1f, 0f);
            Quaternion spawnRotation  = Quaternion.LookRotation(spawnDirection);

            Mech mech = ActorFactory.CreateMech(mechDef, pilotDef, team.EncounterTags, ModState.Combat, team.GetNextSupportUnitGuid(), "", null);

            mech.Init(spawnPos, spawnRotation.eulerAngles.y, true);
            mech.InitGameRep(null);
            Mod.Log.Debug?.Write($"Spawned mech {CombatantUtils.Label(mech)} at position: {spawnPos}");

            if (mech == null)
            {
                Mod.Log.Error?.Write($"Failed to spawn mechDefId: {ambushDef.MechDefId} / pilotDefId: {ambushDef.PilotDefId} !");
            }

            Mod.Log.Debug?.Write($" Spawned ambush mech, adding to team: {team} and lance: {ambushLance}");
            team.AddUnit(mech);
            mech.AddToTeam(team);
            mech.AddToLance(ambushLance);

            mech.BehaviorTree = BehaviorTreeFactory.MakeBehaviorTree(ModState.Combat.BattleTechGame, mech, BehaviorTreeIDEnum.CoreAITree);
            Mod.Log.Debug?.Write("Enabled mech behavior tree");

            UnitSpawnedMessage message = new UnitSpawnedMessage("CJ_MECH", mech.GUID);

            ModState.Combat.MessageCenter.PublishMessage(message);

            return(mech);
        }