Example #1
0
 public static void Prefix(SGBarracksAdvancementPanel __instance)
 {
     try
     {
         isIncreased  = false;
         isDecreased  = false;
         isBookish    = false;
         isKlutz      = false;
         isAssassin   = false;
         OnValueClick = false;
         if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish"))
         {
             isBookish = true;
         }
         if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz"))
         {
             isKlutz = true;
         }
         if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin"))
         {
             isAssassin = true;
         }
     }
     catch (Exception e)
     {
         Logger.LogError(e);
     }
 }
Example #2
0
            public static void Prefix(SGBarracksAdvancementPanel __instance)
            {
                try
                {
                    isBookish  = false;
                    isKlutz    = false;
                    isAssassin = false;

                    if (UseSavedPilot)
                    {
                        __instance.curPilot = SavedPilot;
                    }

                    if (__instance.curPilot == null)
                    {
                        return;
                    }

                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish"))
                    {
                        isBookish = true;
                    }
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz"))
                    {
                        isKlutz = true;
                    }
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin"))
                    {
                        isAssassin = true;
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }
Example #3
0
            public static void Postfix(StarSystem __instance)
            {
                if (!Pre_Control.settings.MechBonding)
                {
                    return;
                }

                try
                {
                    var Sim = UnityGameInstance.BattleTechGame.Simulation;
                    if (Sim.IsCampaign && !Sim.CompanyTags.Contains("map_travel_1"))
                    {
                        return;
                    }

                    foreach (PilotDef pilot in __instance.AvailablePilots)
                    {
                        // 8-8-8-8 pilot = 56,000xp
                        int drops = ((pilot.ExperienceSpent + pilot.ExperienceUnspent) * Pre_Control.settings.pilot_drops_for_8_pilot / 56000);

                        pilot.PilotTags.Add("PQ_Mech_Mastery");
                        string PilotTattoo = "PQ_Pilot_GUID_" + PQ_GUID;
                        pilot.PilotTags.Add(PilotTattoo);
                        PQ_GUID++;

                        // Add training in a Chameleon if Inner sphere
                        if (pilot.PilotTags.Contains("pilot_davion") ||
                            pilot.PilotTags.Contains("pilot_liao") ||
                            pilot.PilotTags.Contains("pilot_kurita") ||
                            pilot.PilotTags.Contains("pilot_steiner") ||
                            pilot.PilotTags.Contains("pilot_marik"))
                        {
                            int trainingDrops = UnityEngine.Random.Range(0, 4);
                            if (trainingDrops > drops)
                            {
                                trainingDrops = drops;
                            }
                            if (trainingDrops > 0)
                            {
                                if (!PilotsAndMechs.Keys.Contains(PilotTattoo))
                                {
                                    Dictionary <string, int> tempD = new Dictionary <string, int>();
                                    tempD.Add("Chameleon", trainingDrops);
                                    PilotsAndMechs.Add(PilotTattoo, tempD);
                                    drops -= trainingDrops;
                                }
                            }
                        }

                        if (drops > 0)
                        {
                            int thisDrops1 = UnityEngine.Random.Range(1, drops);
                            int thisDrops2 = 0;
                            int thisDrops3 = 0;

                            drops -= thisDrops1;
                            if (drops > 0)
                            {
                                thisDrops2 = UnityEngine.Random.Range(1, drops);
                                drops     -= thisDrops2;
                            }
                            if (drops > 0)
                            {
                                thisDrops3 = drops;
                            }

                            List <string> includes = new List <string>();
                            List <string> excludes = new List <string>();

                            string team = "";

                            if (pilot.PilotTags.Contains("pilot_davion"))
                            {
                                team = "Davion";
                            }
                            else if (pilot.PilotTags.Contains("pilot_kurita"))
                            {
                                team = "Kurita";
                            }
                            else if (pilot.PilotTags.Contains("pilot_liao"))
                            {
                                team = "Liao";
                            }
                            else if (pilot.PilotTags.Contains("pilot_marik"))
                            {
                                team = "Marik";
                            }
                            else if (pilot.PilotTags.Contains("pilot_steiner"))
                            {
                                team = "Steiner";
                            }
                            else
                            {
                                team = "AuriganMercenaries";
                            }

                            includes.Add("unit_mech");

                            excludes.Add($"unit_very_rare_{team}");
                            excludes.Add($"unit_ext_rare_{team}");
                            excludes.Add($"unit_none_{team}");
                            excludes.Add($"unit_hero_{team}");
                            excludes.Add("unit_LosTech");
                            excludes.Add("unit_era_2900");
                            excludes.Add("unit_clan");
                            if (drops < 20)
                            {
                                excludes.Add("unit_assault");
                            }
                            if (drops < 10)
                            {
                                excludes.Add("unit_heavy");
                            }

                            TagSet unitTagSet         = new TagSet(includes);
                            TagSet unitExcludedTagSet = new TagSet(excludes);

                            DataManager        dm   = __instance.Sim.DataManager;
                            List <UnitDef_MDD> list = MetadataDatabase.Instance.GetMatchingUnitDefs(unitTagSet, unitExcludedTagSet, true, __instance.Sim.CurrentDate, __instance.Sim.CompanyTags);

                            string mechName = "";
                            if (list.Count > 0)
                            {
                                list.Shuffle <UnitDef_MDD>();
                                mechName = dm.MechDefs.Get(list[0].UnitDefID).Chassis.Description.UIName;
                                if (!PilotsAndMechs.Keys.Contains(PilotTattoo))
                                {
                                    Dictionary <string, int> tempD = new Dictionary <string, int>();
                                    tempD.Add(mechName, thisDrops3);
                                    PilotsAndMechs.Add(PilotTattoo, tempD);
                                }
                                else if (PilotsAndMechs[PilotTattoo].ContainsKey(mechName))
                                {
                                    PilotsAndMechs[PilotTattoo][mechName] += thisDrops3;
                                }
                                else
                                {
                                    PilotsAndMechs[PilotTattoo].Add(mechName, thisDrops3);
                                }
                            }
                            else
                            {
                                if (!PilotsAndMechs.Keys.Contains(PilotTattoo))
                                {
                                    Dictionary <string, int> tempD = new Dictionary <string, int>();
                                    tempD.Add("Griffin", thisDrops3);
                                    PilotsAndMechs.Add(PilotTattoo, tempD);
                                }
                                else if (PilotsAndMechs[PilotTattoo].ContainsKey("Griffin"))
                                {
                                    PilotsAndMechs[PilotTattoo]["Griffin"] += thisDrops3;
                                }
                                else
                                {
                                    PilotsAndMechs[PilotTattoo].Add("Griffin", thisDrops3);
                                }
                            }

                            excludes.Add($"unit_rare_{team}");
                            list = MetadataDatabase.Instance.GetMatchingUnitDefs(unitTagSet, unitExcludedTagSet, true, __instance.Sim.CurrentDate, __instance.Sim.CompanyTags);

                            if (list.Count > 0)
                            {
                                list.Shuffle <UnitDef_MDD>();
                                mechName = dm.MechDefs.Get(list[0].UnitDefID).Chassis.Description.UIName;
                                if (PilotsAndMechs[PilotTattoo].ContainsKey(mechName))
                                {
                                    PilotsAndMechs[PilotTattoo][mechName] += thisDrops2;
                                }
                                else
                                {
                                    PilotsAndMechs[PilotTattoo].Add(mechName, thisDrops2);
                                }
                            }
                            else
                            {
                                if (PilotsAndMechs[PilotTattoo].ContainsKey("Griffin"))
                                {
                                    PilotsAndMechs[PilotTattoo]["Griffin"] += thisDrops2;
                                }
                                else
                                {
                                    PilotsAndMechs[PilotTattoo].Add("Griffin", thisDrops2);
                                }
                            }

                            excludes.Add($"unit_uncommon_{team}");
                            list = MetadataDatabase.Instance.GetMatchingUnitDefs(unitTagSet, unitExcludedTagSet, true, __instance.Sim.CurrentDate, __instance.Sim.CompanyTags);

                            if (list.Count > 0)
                            {
                                list.Shuffle <UnitDef_MDD>();
                                mechName = dm.MechDefs.Get(list[0].UnitDefID).Chassis.Description.UIName;
                                if (PilotsAndMechs[PilotTattoo].ContainsKey(mechName))
                                {
                                    PilotsAndMechs[PilotTattoo][mechName] += thisDrops1;
                                }
                                else
                                {
                                    PilotsAndMechs[PilotTattoo].Add(mechName, thisDrops1);
                                }
                            }
                            else
                            {
                                if (PilotsAndMechs[PilotTattoo].ContainsKey("Griffin"))
                                {
                                    PilotsAndMechs[PilotTattoo]["Griffin"] += thisDrops1;
                                }
                                else
                                {
                                    PilotsAndMechs[PilotTattoo].Add("Griffin", thisDrops1);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }

                //Trim out pilots that are no longer needed from the master list.
                var sim = UnityGameInstance.BattleTechGame.Simulation;
                Dictionary <string, Dictionary <string, int> > PAM_Clone = new Dictionary <string, Dictionary <string, int> >(PilotsAndMechs);

                foreach (string pilot in PAM_Clone.Keys)
                {
                    bool TrimPilot = true;
                    foreach (PilotDef pilotdef in __instance.AvailablePilots)
                    {
                        string PilotTattoo = pilotdef.PilotTags.FirstOrDefault(x => x.StartsWith("PQ_Pilot_GUID"));
                        if (PilotTattoo == pilot)
                        {
                            TrimPilot = false;
                        }
                    }
                    foreach (Pilot hiredpilot in sim.PilotRoster)
                    {
                        string PilotTattoo = hiredpilot.pilotDef.PilotTags.FirstOrDefault(x => x.StartsWith("PQ_Pilot_GUID"));
                        if (PilotTattoo == pilot)
                        {
                            TrimPilot = false;
                        }
                    }
                    foreach (Pilot deadpilot in sim.Graveyard)
                    {
                        string PilotTattoo = deadpilot.pilotDef.PilotTags.FirstOrDefault(x => x.StartsWith("PQ_Pilot_GUID"));
                        if (PilotTattoo == pilot)
                        {
                            TrimPilot = false;
                        }
                    }
                    string CommanderTattoo = sim.Commander.pilotDef.PilotTags.FirstOrDefault(x => x.StartsWith("PQ_Pilot_GUID"));
                    if (CommanderTattoo == pilot)
                    {
                        TrimPilot = false;
                    }

                    if (TrimPilot)
                    {
                        PilotsAndMechs.Remove(pilot);
                    }
                }
            }
Example #4
0
            public static void Postfix(SimGameState __instance, ref Pilot pilot)
            {
                try
                {
                    PilotDef pilotDef = pilot.pilotDef.CopyToSim();
                    isIncreased = false;
                    isDecreased = false;
                    isBookish   = pilot.pilotDef.PilotTags.Contains("pilot_bookish");
                    isKlutz     = pilot.pilotDef.PilotTags.Contains("pilot_klutz");
                    isAssassin  = pilot.pilotDef.PilotTags.Contains("pilot_assassin");

                    if (isBookish || isKlutz || isAssassin)
                    {
                        int NewXP = 0;
                        if (pilotDef.BonusPiloting > 0)
                        {
                            if (isKlutz)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }
                            isDecreased = false;
                            NewXP      += __instance.GetLevelRangeCost(pilotDef.BasePiloting, pilotDef.SkillPiloting - 1);
                        }
                        if (pilotDef.BonusGunnery > 0)
                        {
                            isIncreased = false;
                            if (isAssassin)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }
                            NewXP += __instance.GetLevelRangeCost(pilotDef.BaseGunnery, pilotDef.SkillGunnery - 1);
                        }
                        if (pilotDef.BonusGunnery > 0)
                        {
                            if (isBookish)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }
                            isDecreased = false;
                            NewXP      += __instance.GetLevelRangeCost(pilotDef.BaseGunnery, pilotDef.SkillGunnery - 1);
                        }
                        if (pilotDef.BonusTactics > 0)
                        {
                            isIncreased = false;
                            if (isBookish)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }
                            NewXP += __instance.GetLevelRangeCost(pilotDef.BaseTactics, pilotDef.SkillTactics - 1);
                        }
                        int XPAdjust = NewXP - pilot.pilotDef.ExperienceUnspent;
                        pilot.AddExperience(0, "Respec", XPAdjust);
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }
Example #5
0
            public static void Prefix(SGBarracksAdvancementPanel __instance, string type, int skill, ref int expAmount)
            {
                var sim = UnityGameInstance.BattleTechGame.Simulation;

                try
                {
                    isBookish = false;
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish"))
                    {
                        isBookish = true;
                    }

                    isKlutz = false;
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz"))
                    {
                        isKlutz = true;
                    }

                    isAssassin = false;
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin"))
                    {
                        isAssassin = true;
                    }

                    int twiddle = -1;
                    if (OnValueClick)
                    {
                        twiddle = 1;
                    }

                    if (isBookish || isKlutz || isAssassin)
                    {
                        if (type == "Piloting")
                        {
                            if (isKlutz)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }

                            isDecreased = false;
                            expAmount   = twiddle * sim.GetLevelCost(skill);
                        }
                        if (type == "Gunnery")
                        {
                            isIncreased = false;

                            if (isAssassin)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }

                            expAmount = twiddle * sim.GetLevelCost(skill);
                        }
                        if (type == "Guts")
                        {
                            if (isBookish)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }

                            isDecreased = false;
                            expAmount   = twiddle * sim.GetLevelCost(skill);
                        }
                        if (type == "Tactics")
                        {
                            isIncreased = false;
                            if (isBookish)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }

                            expAmount = twiddle * sim.GetLevelCost(skill);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }
Example #6
0
            public static void Prefix(SGBarracksAdvancementPanel __instance, string type)
            {
                try
                {
                    isBookish = false;
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish"))
                    {
                        isBookish = true;
                    }

                    isKlutz = false;
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz"))
                    {
                        isKlutz = true;
                    }

                    isAssassin = false;
                    if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin"))
                    {
                        isAssassin = true;
                    }

                    OnValueClick = true;
                    if (isBookish || isKlutz || isAssassin)
                    {
                        if (type == "Piloting")
                        {
                            if (isKlutz)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }

                            isDecreased = false;
                        }
                        if (type == "Gunnery")
                        {
                            isIncreased = false;

                            if (isAssassin)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }
                        }
                        if (type == "Guts")
                        {
                            if (isBookish)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }

                            isDecreased = false;
                        }
                        if (type == "Tactics")
                        {
                            isIncreased = false;

                            if (isBookish)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }
                        }
                    }
                    else
                    {
                        isIncreased = false;
                        isDecreased = false;
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }
Example #7
0
            public static void Prefix(string type, int index, ref int cost)
            {
                var sim = UnityGameInstance.BattleTechGame.Simulation;

                try
                {
                    isIncreased = false;
                    isDecreased = false;
                    if (isBookish || isKlutz || isAssassin)
                    {
                        if (type == "Piloting")
                        {
                            if (isKlutz)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }

                            isDecreased = false;
                            cost        = sim.GetLevelCost(index);
                        }
                        if (type == "Gunnery")
                        {
                            isIncreased = false;

                            if (isAssassin)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }

                            cost = sim.GetLevelCost(index);
                        }

                        if (type == "Guts")
                        {
                            if (isBookish)
                            {
                                isIncreased = true;
                            }
                            else
                            {
                                isIncreased = false;
                            }

                            isDecreased = false;
                            cost        = sim.GetLevelCost(index);
                        }
                        if (type == "Tactics")
                        {
                            isIncreased = false;

                            if (isBookish)
                            {
                                isDecreased = true;
                            }
                            else
                            {
                                isDecreased = false;
                            }

                            cost = sim.GetLevelCost(index);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError(e);
                }
            }