Пример #1
0
            public static bool IsShopActive(SimGameState simState)
            {
                FactionValue owner      = simState.CurSystem.OwnerValue;
                int          reputation = (int)simState.GetReputation(owner);

                return(reputation > -3);
            }
Пример #2
0
            public static void Postfix(SimGameState __instance)
            {
                try
                {
                    if (!__instance.CompanyTags.Contains(FixTaurianReputationTag) && __instance.CompanyTags.Contains("story_complete"))
                    {
                        Logger.Debug($"[SimGameState__OnAttachUXComplete_POSTFIX] Apply reputation fix for the Taurian Concordat");

                        FactionValue TaurianConcordat  = FactionEnumeration.GetFactionByName("TaurianConcordat");
                        int          currentReputation = __instance.GetRawReputation(TaurianConcordat);
                        Logger.Debug($"[SimGameState__OnAttachUXComplete_POSTFIX] currentReputation: {currentReputation}");

                        if (currentReputation < -10)
                        {
                            int reputationToAdd = (currentReputation * -1) - 10;
                            Logger.Debug($"[SimGameState__OnAttachUXComplete_POSTFIX] reputationToAdd: {reputationToAdd}");
                            __instance.AddReputation(TaurianConcordat, reputationToAdd, false, null);
                        }

                        // Done
                        __instance.CompanyTags.Add(FixTaurianReputationTag);
                        Logger.Debug($"[SimGameState__OnAttachUXComplete_POSTFIX] Added {FixTaurianReputationTag} to CompanyTags");
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
Пример #3
0
        static void Postfix(Starmap __instance)
        {
            try {
                WIIC.modLog.Info?.Write($"Patching starmap with new owners (setActiveFactionsForAllSystems: {WIIC.settings.setActiveFactionsForAllSystems})");
                int count        = 0;
                int controlCount = 0;
                foreach (StarSystem system in WIIC.sim.StarSystems)
                {
                    if (WIIC.settings.setActiveFactionsForAllSystems)
                    {
                        Utilities.setActiveFactions(system);
                    }

                    // Check if a previous flareup flipped control of the system
                    if (WIIC.systemControl.ContainsKey(system.ID))
                    {
                        FactionValue ownerFromTag = Utilities.controlFromTag(WIIC.systemControl[system.ID]);
                        WIIC.modLog.Info?.Write($"Found new owner {ownerFromTag.Name} at {system.Name}");

                        Utilities.applyOwner(system, ownerFromTag, false);
                        controlCount++;
                    }
                    count++;
                }
                Utilities.redrawMap();
                WIIC.modLog.Info?.Write($"Finished patching starmap (checked {count} systems, flipped control of {controlCount})");
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
            }
        }
Пример #4
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);
        }
Пример #5
0
        internal static void readFromJson()
        {
            try {
                string path = Path.Combine(modDir, "WIIC_systemControl.json");
                if (!File.Exists(path))
                {
                    modLog.Info?.Write($"No {path} found, doing nothing.");
                    return;
                }

                using (StreamReader reader = new StreamReader(path)) {
                    string jdata = reader.ReadToEnd();
                    Dictionary <string, string> systemControl = JsonConvert.DeserializeObject <Dictionary <string, string> >(jdata);
                    foreach (string id in systemControl.Keys)
                    {
                        StarSystem   system       = sim.GetSystemById(id);
                        FactionValue ownerFromTag = Utilities.controlFromTag(systemControl[id]);
                        modLog.Info?.Write($"id: {id}, system: {system}, tag: {systemControl[id]}, owner: {ownerFromTag}");
                        Utilities.applyOwner(system, ownerFromTag, true);
                    }
                    modLog.Info?.Write($"Set control of {systemControl.Count} star systems based on {path}");
                }
            } catch (Exception e) {
                modLog.Error?.Write(e);
            }
        }
Пример #6
0
        public static void init()
        {
            Settings     s       = WIIC.settings;
            FactionValue invalid = FactionEnumeration.GetInvalidUnsetFactionValue();

            cantBeAttackedTags = new TagSet(s.cantBeAttackedTags);
            clearEmployersTags = new TagSet(s.clearEmployersAndTargetsForSystemTags);

            // Initializing tagsets for use when creating flareups
            foreach (string faction in s.factionActivityTags.Keys)
            {
                if (FactionEnumeration.GetFactionByName(faction) == invalid)
                {
                    WIIC.modLog.Warn?.Write($"Can't find faction {faction} from factionActivityTags");
                    continue;
                }
                factionActivityTags[faction] = new TagSet(s.factionActivityTags[faction]);
            }

            foreach (string faction in s.factionInvasionTags.Keys)
            {
                if (FactionEnumeration.GetFactionByName(faction) == invalid)
                {
                    WIIC.modLog.Warn?.Write($"Can't find faction {faction} from factionInvasionTags");
                    continue;
                }
                factionInvasionTags[faction] = new TagSet(s.factionInvasionTags[faction]);
            }

            // Validation for factions in various settings
            foreach (string faction in s.aggression.Keys)
            {
                if (FactionEnumeration.GetFactionByName(faction) == invalid)
                {
                    WIIC.modLog.Warn?.Write($"Can't find faction {faction} from aggression");
                }
            }
            foreach (string faction in s.hatred.Keys)
            {
                if (FactionEnumeration.GetFactionByName(faction) == invalid)
                {
                    WIIC.modLog.Warn?.Write($"Can't find faction {faction} from hatred");
                }
                foreach (string target in s.hatred[faction].Keys)
                {
                    if (FactionEnumeration.GetFactionByName(target) == invalid)
                    {
                        WIIC.modLog.Warn?.Write($"Can't find faction {target} from hatred[{faction}]");
                    }
                }
            }
            foreach (string faction in s.cantBeAttacked)
            {
                if (FactionEnumeration.GetFactionByName(faction) == invalid)
                {
                    WIIC.modLog.Warn?.Write($"Can't find faction {faction} from cantBeAttacked");
                }
            }
        }
Пример #7
0
        public static CastDef CreateCast(CombatGameState combat, string sourceGUID, Team team, string employerFactionName = "Support")
        {
            string castDefId = $"castDef_{sourceGUID}";

            if (combat.DataManager.CastDefs.Exists(castDefId))
            {
                return(combat.DataManager.CastDefs.Get(castDefId));
            }

            FactionValue actorFaction  = team?.FactionValue;
            bool         factionExists = actorFaction.Name != "INVALID_UNSET" && actorFaction.Name != "NoFaction" &&
                                         actorFaction.FactionDefID != null && actorFaction.FactionDefID.Length != 0 ? true : false;

            if (factionExists)
            {
                Mod.Log.Debug?.Write($"Found factionDef for id:{actorFaction}");
                string     factionId          = actorFaction?.FactionDefID;
                FactionDef employerFactionDef = UnityGameInstance.Instance.Game.DataManager.Factions.Get(factionId);
                if (employerFactionDef == null)
                {
                    Mod.Log.Error?.Write($"Error finding FactionDef for faction with id '{factionId}'");
                }
                else
                {
                    employerFactionName = employerFactionDef.Name.ToUpper();
                }
            }
            else
            {
                Mod.Log.Debug?.Write($"FactionDefID does not exist for faction: {actorFaction}");
            }

            CastDef newCastDef = new CastDef
            {
                // Temp test data
                FactionValue  = actorFaction,
                firstName     = $"{employerFactionName} -",
                showRank      = false,
                showCallsign  = true,
                showFirstName = true,
                showLastName  = false
            };

            // DisplayName order is first, callsign, lastname

            newCastDef.id = castDefId;
            string portraitPath = GetRandomPortraitPath();

            newCastDef.callsign = GetRandomCallsign();
            Mod.Log.Debug?.Write($" Generated cast with callsign: {newCastDef.callsign} and DisplayName: {newCastDef.DisplayName()} using portrait: '{portraitPath}'");

            // Load the associated portrait
            newCastDef.defaultEmotePortrait.portraitAssetPath = portraitPath;
            Mod.Log.Debug?.Write($"Generated random portrait: {portraitPath}.");

            ((DictionaryStore <CastDef>)UnityGameInstance.BattleTechGame.DataManager.CastDefs).Add(newCastDef.id, newCastDef);

            return(newCastDef);
        }
Пример #8
0
 public BehaviorVariableScope GetScopeForFaction(FactionValue faction)
 {
     if (scopesByFaction.ContainsKey(faction.ID))
     {
         return(scopesByFaction[faction.ID]);
     }
     return(null);
 }
Пример #9
0
        public static CastDef CreateCast()
        {
            Contract     contract            = MissionControl.Instance.CurrentContract;
            FactionValue employerFaction     = contract.GetTeamFaction(EncounterRules.EMPLOYER_TEAM_ID);
            string       factionId           = employerFaction.FactionDefID;
            string       employerFactionName = "Military Support";

            if (employerFaction.Name != "INVALID_UNSET" && employerFaction.Name != "NoFaction")
            {
                FactionDef employerFactionDef = UnityGameInstance.Instance.Game.DataManager.Factions.Get(factionId);
                if (employerFactionDef == null)
                {
                    Main.Logger.LogError($"[RuntimeCastFactory] Error finding FactionDef for faction with id '{factionId}'");
                }
                employerFactionName = employerFactionDef.Name.ToUpper();
            }

            string employerFactionKey = (employerFaction.Name != "INVALID_UNSET" && employerFaction.Name != "NoFaction") ? "All" : employerFaction.ToString();

            string gender       = DataManager.Instance.GetRandomGender();
            string firstName    = DataManager.Instance.GetRandomFirstName(gender, employerFactionKey);
            string lastName     = DataManager.Instance.GetRandomLastName(employerFactionKey);
            string rank         = DataManager.Instance.GetRandomRank(employerFactionKey);
            string portraitPath = DataManager.Instance.GetRandomPortraitPath(gender);
            Gender btGender     = Gender.Male;

            if (gender == "Female")
            {
                btGender = Gender.Female;
            }
            if (gender == "Unspecified")
            {
                btGender = Gender.NonBinary;
            }

            CastDef runtimeCastDef = new CastDef();

            // Temp test data
            runtimeCastDef.id            = $"castDef_{rank}{firstName}{lastName}";
            runtimeCastDef.internalName  = $"{rank}{firstName}{lastName}";
            runtimeCastDef.firstName     = $"{rank} {firstName}";
            runtimeCastDef.lastName      = lastName;
            runtimeCastDef.callsign      = rank;
            runtimeCastDef.rank          = employerFactionName;
            runtimeCastDef.gender        = btGender;
            runtimeCastDef.FactionValue  = employerFaction;
            runtimeCastDef.showRank      = true;
            runtimeCastDef.showFirstName = true;
            runtimeCastDef.showCallsign  = false;
            runtimeCastDef.showLastName  = true;
            runtimeCastDef.defaultEmotePortrait.portraitAssetPath = portraitPath;

            ((DictionaryStore <CastDef>)UnityGameInstance.BattleTechGame.DataManager.CastDefs).Add(runtimeCastDef.id, runtimeCastDef);

            return(runtimeCastDef);
        }
Пример #10
0
 public static string GetFactionTag(FactionValue faction)
 {
     try {
         return("planet_faction_" + faction.Name.ToLower());
     }
     catch (Exception e) {
         PersistentMapClient.Logger.LogError(e);
         return(null);
     }
 }
Пример #11
0
            public ScopeDesc(string name, AIMood mood)
            {
                this.Name          = name;
                this.ScopeKind     = ScopeKind.Global;
                this.UnitRole      = UnitRole.Undefined;
                this.AIPersonality = AIPersonality.Undefined;
                this.AISkillID     = AISkillID.Undefined;
                this.Mood          = mood;

                privateFactionValue = FactionEnumeration.GetInvalidUnsetFactionValue();
                FactionID           = privateFactionValue.Name;
            }
Пример #12
0
        public static bool Prefix(FactionValue __instance, ref Color __result)
        {
            var color = FactionColors.GetModdedFactionColor(__instance);

            if (color == null)
            {
                return(true);
            }

            __result = color.Value;
            return(false);
        }
Пример #13
0
            public ScopeDesc(string name, AIMood mood, FactionValue faction) : this(name, mood)
            {
                if (faction == null)
                {
                    faction = FactionEnumeration.GetInvalidUnsetFactionValue();
                }

                privateFactionValue = faction;
                FactionID           = privateFactionValue.Name;

                this.ScopeKind = ScopeKind.Faction;
            }
Пример #14
0
 static void Postfix(StarmapRenderer __instance, FactionValue faction, GameObject logo)
 {
     try {
         if (logo.transform.localScale == Fields.originalTransform.localScale)
         {
             logo.transform.localScale += new Vector3(4f, 4f, 4f);
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Пример #15
0
 public static bool FactionMarketAvailable(SimGameState sim, FactionValue faction)
 {
     RefreshServerSettings();
     if (!isAllied(sim))
     {
         return(false);
     }
     if (serverSettings.GetsAllShops)
     {
         return(true);
     }
     return(sim.IsFactionAlly(faction) && serverSettings.FactionMarketAvailable);
 }
Пример #16
0
 static void Postfix(SGNavigationList __instance, SimGameState simState)
 {
     if (SGNavigationList_Start.storeButton != null)
     {
         FactionValue owner      = simState.CurSystem.OwnerValue;
         int          reputation = (int)simState.GetReputation(owner);
         if (reputation <= -3)
         {
             Mod.Log.Info?.Write("Faction reputation too low, disabling store button.");
             SGNavigationList_Start.storeButton.SetState(ButtonState.Disabled);
         }
     }
 }
Пример #17
0
 public static void RefreshShop()
 {
     Control.LogDebug(DInfo.RefreshShop, $"Refreshing Shops Daily {Control.State.CurrentSystem.Def.Description.Name}");
     Control.RefreshShops("Daily");
     if (owner != Control.State.CurrentSystem.OwnerValue)
     {
         if (owner != null)
         {
             Control.LogDebug(DInfo.RefreshShop, $"Refreshing Shops OwnerChange {Control.State.CurrentSystem.Def.Description.Name}");
             Control.RefreshShops("OwnerChange");
         }
         owner = Control.State.CurrentSystem.OwnerValue;
     }
 }
Пример #18
0
        public static void Reset()
        {
            // Reinitialize state to known values
            Employer       = null;
            EmployerRep    = SimGameReputation.INDIFFERENT;
            EmployerRepRaw = 0;
            IsEmployerAlly = false;
            MRBRating      = 0;

            Compensation = 0;

            PotentialSalvage.Clear();
            HeldbackParts.Clear();
            CompensationParts.Clear();
        }
Пример #19
0
            public static void Prefix(FactionValue theFaction)
            {
                if (Globals.WarStatusTracker == null || Globals.Sim.IsCampaign && !Globals.Sim.CompanyTags.Contains("story_complete"))
                {
                    return;
                }

                if (Globals.WarStatusTracker.DeathListTracker.Find(x => x.Faction == theFaction.Name) == null)
                {
                    return;
                }

                var deathListTracker = Globals.WarStatusTracker.DeathListTracker.Find(x => x.Faction == theFaction.Name);

                AdjustDeathList(deathListTracker, true);
            }
Пример #20
0
        static void Postfix(SG_HiringHall_DetailPanel __instance, Pilot p, LocalizableText ___DescriptionText)
        {
            CrewDetails details = ModState.GetCrewDetails(p.pilotDef);

            StringBuilder sb = new StringBuilder();

            // Check hazard pay
            if (details.HazardPay > 0)
            {
                string hazardPayS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Hazard_Pay],
                                             new object[] { SimGameState.GetCBillString(details.HazardPay) }).ToString();
                Mod.Log.Debug?.Write($"Hazard pay is: {hazardPayS}");
                sb.Append(hazardPayS);
                sb.Append("\n\n");
            }

            // Convert favored and hated faction
            if (details.FavoredFactionId > 0)
            {
                FactionValue faction         = FactionEnumeration.GetFactionByID(details.FavoredFactionId);
                string       favoredFactionS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Faction_Favored],
                                                        new object[] { faction.FactionDef.CapitalizedName }).ToString();
                sb.Append(favoredFactionS);
                sb.Append("\n\n");
                Mod.Log.Debug?.Write($"  Favored Faction is: {favoredFactionS}");
                //Mod.Log.Debug?.Write($"  Favored Faction => name: '{faction.Name}'  friendlyName: '{faction.FriendlyName}'  " +
                //    $"factionDef.Name: {faction.FactionDef?.Name}  factionDef.CapitalizedName: {faction.FactionDef.CapitalizedName}  " +
                //    $"factionDef.ShortName: {faction.FactionDef?.ShortName}  factionDef.CapitalizedShortName: {faction.FactionDef.CapitalizedShortName}  " +
                //    $"");
            }

            if (details.HatedFactionId > 0)
            {
                FactionValue faction       = FactionEnumeration.GetFactionByID(details.HatedFactionId);
                string       hatedFactionS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Faction_Hated],
                                                      new object[] { faction.FactionDef.CapitalizedName }).ToString();
                sb.Append(hatedFactionS);
                sb.Append("\n\n");
                Mod.Log.Debug?.Write($"  Hated Faction is: {hatedFactionS}");
            }

            sb.Append(Interpolator.Interpolate(p.pilotDef.Description.GetLocalizedDetails().ToString(true), ModState.SimGameState.Context, true));

            ___DescriptionText.SetText(sb.ToString());
        }
        public void LegacyGetModifier_Base()
        {
            FactionValue factionValue = new FactionValue();

            factionValue.Name = "1";

            HumanDescriptionDef humanDescDef = new HumanDescriptionDef("-1", "Test", "FNAME", "LNAME", "CSIGN", Gender.Male, factionValue, 1, "foo", "");

            Traverse.Create(humanDescDef).Field("factionValue").SetValue(factionValue);
            Traverse.Create(humanDescDef).Field("factionID").SetValue("1");

            // gun, pilot, guts, tactics
            PilotDef pilotDefHigh = new PilotDef(humanDescDef, 10, 9, 8, 7, 0, 3, false, 0, "voice",
                                                 new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotHigh = new Pilot(pilotDefHigh, "-1", false);

            Assert.AreEqual(5, SkillUtils.GetGunneryModifier(pilotHigh));
            Assert.AreEqual(4, SkillUtils.GetPilotingModifier(pilotHigh));
            Assert.AreEqual(4, SkillUtils.GetGutsModifier(pilotHigh));
            Assert.AreEqual(3, SkillUtils.GetTacticsModifier(pilotHigh));

            PilotDef pilotDefMed = new PilotDef(humanDescDef, 7, 6, 5, 4, 0, 3, false, 0, "voice",
                                                new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotMed = new Pilot(pilotDefMed, "-1", false);

            Assert.AreEqual(3, SkillUtils.GetGunneryModifier(pilotMed));
            Assert.AreEqual(3, SkillUtils.GetPilotingModifier(pilotMed));
            Assert.AreEqual(2, SkillUtils.GetGutsModifier(pilotMed));
            Assert.AreEqual(2, SkillUtils.GetTacticsModifier(pilotMed));

            PilotDef pilotDefLog = new PilotDef(humanDescDef, 4, 3, 2, 1, 0, 3, false, 0, "voice",
                                                new List <string>()
            {
            }, AIPersonality.Undefined, 0, 0, 0);
            Pilot pilotLow = new Pilot(pilotDefLog, "-1", false);

            Assert.AreEqual(2, SkillUtils.GetGunneryModifier(pilotLow));
            Assert.AreEqual(1, SkillUtils.GetPilotingModifier(pilotLow));
            Assert.AreEqual(1, SkillUtils.GetGutsModifier(pilotLow));
            Assert.AreEqual(0, SkillUtils.GetTacticsModifier(pilotLow));
        }
Пример #22
0
        public Flareup(StarSystem flareupLocation, FactionValue attackerFaction, string flareupType, SimGameState __instance)
        {
            Settings s = WIIC.settings;

            sim          = __instance;
            location     = flareupLocation;
            locationID   = flareupLocation.ID;
            attacker     = attackerFaction;
            attackerName = attackerFaction.Name;
            type         = flareupType;
            countdown    = Utilities.rng.Next(s.minCountdown, s.maxCountdown);

            int v;

            attackerStrength = s.attackStrength.TryGetValue(attacker.Name, out v) ? v : s.defaultAttackStrength;
            defenderStrength = s.defenseStrength.TryGetValue(location.OwnerValue.Name, out v) ? v : s.defaultDefenseStrength;

            attackerStrength += Utilities.rng.Next(-s.strengthVariation, s.strengthVariation);
            defenderStrength += Utilities.rng.Next(-s.strengthVariation, s.strengthVariation);

            string stat = $"WIIC_{attacker.Name}_attack_strength";

            attackerStrength += sim.CompanyStats.ContainsStatistic(stat) ? sim.CompanyStats.GetValue <int>(stat) : 0;
            stat              = $"WIIC_{location.OwnerValue.Name}_defense_strength";
            defenderStrength += sim.CompanyStats.ContainsStatistic(stat) ? sim.CompanyStats.GetValue <int>(stat) : 0;

            if (type == "Raid")
            {
                attackerStrength = (int)Math.Ceiling(attackerStrength * s.raidStrengthMultiplier);
                defenderStrength = (int)Math.Ceiling(defenderStrength * s.raidStrengthMultiplier);
            }

            string text = type == "Raid" ? "{0} launches raid on {1} at {2}" : "{0} attacks {1} for control of {2}";

            text = Strings.T(text, attacker.FactionDef.ShortName, location.OwnerValue.FactionDef.ShortName, location.Name);
            Utilities.deferredToasts.Add(text);

            WIIC.modLog.Info?.Write(text);
            if (location == sim.CurSystem)
            {
                spawnParticipationContracts();
            }
        }
Пример #23
0
 public MissionResult(FactionValue employer, FactionValue target, BattleTech.MissionResult result, string systemName, int difficulty, int awardedRep, int planetSupport, int mCount, string missionType, int cbCount, int state, string key, string salt, string data, float score, int con)
 {
     this.awardedRep    = awardedRep;
     this.difficulty    = difficulty;
     this.employer      = employer.Name;
     this.result        = result;
     this.systemName    = systemName;
     this.target        = target.Name;
     this.planetSupport = planetSupport;
     this.mCount        = mCount;
     this.missionType   = missionType;
     this.cbCount       = cbCount;
     this.rtState       = state;
     this.rtKey         = key;
     this.rtSalt        = salt;
     this.rtData        = data;
     this.cscore        = score;
     this.ccCount       = con;
 }
Пример #24
0
            public static void Postfix(SG_Stores_MiniFactionWidget __instance, FactionValue theFaction, FactionValue ___owningFactionValue, LocalizableText ___ReputationBonusText)
            {
                if (GlobalVars.sim == null)
                {
                    return;
                }
                var sellBonus = 0f;

                var curPilots = new List <string>();

                curPilots.Add(GlobalVars.sim.Commander.FetchGUID());
                foreach (var p in GlobalVars.sim.PilotRoster)
                {
                    SpecHolder.HolderInstance.AddToMaps(p);
                    curPilots.Add(p.FetchGUID());
                }

                foreach (var pKey in curPilots)
                {
                    if (SpecHolder.HolderInstance.OpForSpecMap.ContainsKey(pKey))
                    {
                        foreach (var spec in SpecHolder.HolderInstance.OpForSpecMap[pKey])
                        {
                            var opSpec =
                                SpecManager.ManagerInstance.OpForSpecList.FirstOrDefault(x => x.OpForSpecID == spec);
                            if (opSpec != null && opSpec.storeBonus.ContainsKey(___owningFactionValue.Name))
                            {
                                sellBonus += opSpec.storeBonus[___owningFactionValue.Name];
                                ModInit.modLog.LogMessage($"Current sell multiplier from specs: {sellBonus}");
                            }
                        }
                    }
                }

                if (sellBonus == 0f)
                {
                    return;
                }
                ___ReputationBonusText.AppendTextAndRefresh(", {0}% Sell Bonus", new object[]
                {
                    Mathf.RoundToInt(sellBonus * 100f)
                });
            }
Пример #25
0
        // Send a list of items to purchase from the faction store
        public static bool PostBuyItems(Dictionary <string, PurchasedItem> sold, FactionValue owner, bool blackMarket)
        {
            try {
                if (sold == null || owner == null)
                {
                    PersistentMapClient.Logger.LogIfDebug("null owner or dictionary");
                    return(false);
                }
                if (sold.Count() > 0)
                {
                    WarService market = WarService.PostBuyItems;
                    if (blackMarket)
                    {
                        market = WarService.PostBuyBlackMarketItem;
                    }
                    string          testjson = JsonConvert.SerializeObject(sold.Values.ToList <PurchasedItem>());
                    HttpWebRequest  request  = new RequestBuilder(market).Faction(owner).PostData(testjson).Build();
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        StreamReader reader      = new StreamReader(responseStream);
                        string       pitemString = reader.ReadToEnd();
                        if (blackMarket)
                        {
                            PurchasedItem pItem;
                            pItem = JsonConvert.DeserializeObject <PurchasedItem>(pitemString);
                            PersistentMapClient.updateBMarketId(pItem.TransactionId);
                        }

                        return(true);
                    }
                }
                else
                {
                    PersistentMapClient.Logger.Log("No online items purchased, nothing to do");
                    return(true);
                }
            }
            catch (Exception e) {
                PersistentMapClient.Logger.LogError(e);
                return(false);
            }
        }
        private void SwapTeamFactions()
        {
            Contract     contract           = MissionControl.Instance.CurrentContract;
            FactionValue faction1           = contract.GetTeamFaction(team1Guid);
            FactionValue faction2           = contract.GetTeamFaction(team2Guid);
            int          originalFaction1Id = faction1.ID;
            int          originalFaction2Id = faction2.ID;

            Main.LogDebug($"[SwapTeamFactionGameLogic.SwapTeamFactions]) Swapping factions '{team1Guid}:{faction1.Name}' with '{team2Guid}:{faction2.Name}'");
            TeamOverride employer = contract.Override.employerTeam;
            TeamOverride target   = contract.Override.targetTeam;

            contract.Override.employerTeam = target;
            contract.Override.targetTeam   = employer;

            MissionControl.Instance.CurrentContract.SetTeamFaction(team1Guid, originalFaction2Id);
            MissionControl.Instance.CurrentContract.SetTeamFaction(team2Guid, originalFaction1Id);

            contract.Override.RunMadLibs(UnityGameInstance.BattleTechGame.DataManager);
        }
Пример #27
0
        public void apply()
        {
            foreach (string id in systemControl.Keys)
            {
                StarSystem   system       = WIIC.sim.GetSystemById(id);
                FactionValue ownerFromTag = Utilities.controlFromTag(systemControl[id]);
                Utilities.applyOwner(system, ownerFromTag, true);
            }

            WIIC.modLog.Info?.Write($"Set control of {systemControl.Count} star systems based on GalaxyData");

            foreach (string id in flareups.Keys)
            {
                WIIC.flareups[id] = flareups[id];
                WIIC.flareups[id].initAfterDeserialization();
            }

            Utilities.redrawMap();

            WIIC.modLog.Info?.Write($"Created {flareups.Count} flareups based on GalaxyData");
        }
Пример #28
0
        public static CastDef CreateCast(AbstractActor actor)
        {
            string castDefId = $"castDef_{actor.GUID}";

            if (actor.Combat.DataManager.CastDefs.Exists(castDefId))
            {
                return(actor.Combat.DataManager.CastDefs.Get(castDefId));
            }

            FactionValue actorFaction  = actor?.team?.FactionValue;
            bool         factionExists = actorFaction.Name != "INVALID_UNSET" && actorFaction.Name != "NoFaction" &&
                                         actorFaction.FactionDefID != null && actorFaction.FactionDefID.Length != 0 ? true : false;

            string employerFactionName = "Military Support";

            if (factionExists)
            {
                //LogDebug($"Found factionDef for id:{actorFaction}");
                string     factionId          = actorFaction?.FactionDefID;
                FactionDef employerFactionDef = UnityGameInstance.Instance.Game.DataManager.Factions.Get(factionId);
                if (employerFactionDef == null) /*LogDebug($"Error finding FactionDef for faction with id '{factionId}'");*/ } {
Пример #29
0
        static bool Prefix(SimGameState __instance, Contract c)
        {
            int num      = Mathf.Min(c.Override.finalDifficulty + c.Override.difficultyUIModifier, (int)__instance.Constants.Story.GlobalContractDifficultyMax);
            int repLevel = __instance.GetCurrentMRBLevel();

            num -= repLevel;
            FactionValue teamFaction = c.GetTeamFaction("ecc8d4f2-74b4-465d-adf6-84445e5dfc230");

            if (!teamFaction.DoesGainReputation || c.Override.contractDisplayStyle == ContractDisplayStyle.BaseCampaignStory ||
                c.Override.contractDisplayStyle == ContractDisplayStyle.BaseCampaignRestoration || c.Override.contractDisplayStyle == ContractDisplayStyle.BaseFlashpoint ||
                c.Override.contractDisplayStyle == ContractDisplayStyle.HeavyMetalFlashpointCampaign)
            {
                return(true);
            }
            switch (__instance.GetReputation(teamFaction))
            {
            case SimGameReputation.LOATHED:
                return((float)num <= __instance.Constants.CareerMode.LoathedMaxContractDifficulty);

            case SimGameReputation.HATED:
                return((float)num <= __instance.Constants.CareerMode.HatedMaxContractDifficulty);

            case SimGameReputation.DISLIKED:
                return((float)num <= __instance.Constants.CareerMode.DislikedMaxContractDifficulty);

            case SimGameReputation.INDIFFERENT:
                return((float)num <= __instance.Constants.CareerMode.IndifferentMaxContractDifficulty);

            case SimGameReputation.LIKED:
                return((float)num <= __instance.Constants.CareerMode.LikedMaxContractDifficulty);

            case SimGameReputation.FRIENDLY:
                return((float)num <= __instance.Constants.CareerMode.FriendlyMaxContractDifficulty);

            default:
                return((float)num <= __instance.Constants.CareerMode.HonoredMaxContractDifficulty);
            }

            return(false);
        }
Пример #30
0
        private static void PrepContract(
            Contract contract,
            FactionValue employer,
            FactionValue employersAlly,
            FactionValue target,
            FactionValue targetsAlly,
            FactionValue NeutralToAll,
            FactionValue HostileToAll,
            Biome.BIOMESKIN skin,
            int presetSeed,
            StarSystem system)
        {
            if (presetSeed != 0 && !contract.IsPriorityContract)
            {
                var diff = Globals.Rng.Next(min, max + 1);
                contract.SetFinalDifficulty(diff);
            }

            var unitFactionValue1 = FactionEnumeration.GetPlayer1sMercUnitFactionValue();
            var unitFactionValue2 = FactionEnumeration.GetPlayer2sMercUnitFactionValue();

            contract.AddTeamFaction("bf40fd39-ccf9-47c4-94a6-061809681140", unitFactionValue1.ID);
            contract.AddTeamFaction("757173dd-b4e1-4bb5-9bee-d78e623cc867", unitFactionValue2.ID);
            contract.AddTeamFaction("ecc8d4f2-74b4-465d-adf6-84445e5dfc230", employer.ID);
            contract.AddTeamFaction("70af7e7f-39a8-4e81-87c2-bd01dcb01b5e", employersAlly.ID);
            contract.AddTeamFaction("be77cadd-e245-4240-a93e-b99cc98902a5", target.ID);
            contract.AddTeamFaction("31151ed6-cfc2-467e-98c4-9ae5bea784cf", targetsAlly.ID);
            contract.AddTeamFaction("61612bb3-abf9-4586-952a-0559fa9dcd75", NeutralToAll.ID);
            contract.AddTeamFaction("3c9f3a20-ab03-4bcb-8ab6-b1ef0442bbf0", HostileToAll.ID);
            contract.SetupContext();
            var finalDifficulty = contract.Override.finalDifficulty;
            var cbills          = SimGameState.RoundTo(contract.Override.contractRewardOverride < 0
                ? Globals.Sim.CalculateContractValueByContractType(contract.ContractTypeValue, finalDifficulty,
                                                                   Globals.Sim.Constants.Finances.ContractPricePerDifficulty, Globals.Sim.Constants.Finances.ContractPriceVariance, presetSeed)
                : (float)contract.Override.contractRewardOverride, 1000);

            contract.SetInitialReward(cbills);
            contract.SetBiomeSkin(skin);
        }