Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
			public static bool Prefix(SimGameState __instance, Contract contract, FactionValue employer, FactionValue employersAlly, FactionValue target, FactionValue targetsAlly, FactionValue NeutralToAll, FactionValue HostileToAll, Biome.BIOMESKIN skin, int presetSeed, StarSystem system)
			{
				{
                    ModInit.modLog.LogMessage($"{contract.Name} presetSeed: {presetSeed}");
                    ModInit.modLog.LogMessage($"{contract.Name} contract.IsPriorityContract: {contract.IsPriorityContract}");
                    if (presetSeed != 0 && !contract.IsPriorityContract)
					{
						int baseDiff = system.Def.GetDifficulty(__instance.SimGameMode) + Mathf.FloorToInt(__instance.GlobalDifficulty);
                        ModInit.modLog.LogMessage($"{contract.Name} baseDiff: {baseDiff}");
						int min;
						int num;
						if (ModState.SysAdjustDifficulty != 0 && ModState.IsSystemActionPatch != null)
						{
							baseDiff += ModState.SysAdjustDifficulty;
                            ModInit.modLog.LogMessage($"{contract.Name} baseDiff: {baseDiff} after + ModState.SysAdjustDifficulty {ModState.SysAdjustDifficulty}");
						}
						else if(ModState.CustomDifficulty > 0 && ModState.IsSystemActionPatch != null)
						{
							baseDiff = ModState.CustomDifficulty;
                            ModInit.modLog.LogMessage($"{contract.Name} baseDiff: {baseDiff} after override from ModState.CustomDifficulty {ModState.CustomDifficulty}");
						}
						int contractDifficultyVariance = __instance.Constants.Story.ContractDifficultyVariance;
                        ModInit.modLog.LogMessage($"{contract.Name} contractDifficultyVariance: {contractDifficultyVariance}");

						min = Mathf.Max(1, baseDiff - contractDifficultyVariance);
                        ModInit.modLog.LogMessage($"{contract.Name}: [min = Mathf.Max(1, baseDiff - contractDifficultyVariance)] min: {min}");
						num = Mathf.Max(1, baseDiff + contractDifficultyVariance);
                        ModInit.modLog.LogMessage($"{contract.Name}: [max = Mathf.Max(1, baseDiff + contractDifficultyVariance)] max: {num}");

						int finalDifficulty = new NetworkRandom
						{
							seed = presetSeed
						}.Int(min, num + 1);
                        ModInit.modLog.LogMessage($"{contract.Name} finalDifficulty = random between min and max+1: {min} and {num+1}: {finalDifficulty}");

                        if (ModInit.modSettings.enableTravelFix)
                        {
                            if(__instance.HasTravelContract==true && contract.Name==__instance.ActiveTravelContract.Name)
                            {
                                finalDifficulty = ModState.LastDiff;
                                ModInit.modLog.LogMessage($"Found Travel Contract: {contract.Name}, using override finalDifficulty from ModState.LastDiff: {finalDifficulty}");
                            }
                            ModState.LastDiff = finalDifficulty;
                            ModInit.modLog.LogMessage($"Setting future travel contract override finalDifficulty at ModState.LastDiff: {finalDifficulty}");
                        }
                        contract.SetFinalDifficulty(finalDifficulty);
                        ModInit.modLog.LogMessage($"Setting {contract.Name} finalDifficulty to: {finalDifficulty}");
					}
					
					FactionValue player1sMercUnitFactionValue = FactionEnumeration.GetPlayer1sMercUnitFactionValue();
					FactionValue player2sMercUnitFactionValue = FactionEnumeration.GetPlayer2sMercUnitFactionValue();
					contract.AddTeamFaction("bf40fd39-ccf9-47c4-94a6-061809681140", player1sMercUnitFactionValue.ID);
					contract.AddTeamFaction("757173dd-b4e1-4bb5-9bee-d78e623cc867", player2sMercUnitFactionValue.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();
					int finalDifficulty2 = contract.Override.finalDifficulty;

                    int num2;
					if (contract.Override.contractRewardOverride >= 0)
					{
						num2 = contract.Override.contractRewardOverride;
                        ModInit.modLog.LogMessage($"Using {num2} for contract reward override");
                    }

					else
					{
						num2 = __instance.CalculateContractValueByContractType(contract.ContractTypeValue, finalDifficulty2, (float)__instance.Constants.Finances.ContractPricePerDifficulty, __instance.Constants.Finances.ContractPriceVariance, presetSeed);
                        ModInit.modLog.LogMessage($"Calculated contract Value using Contract.CalculateContractValueByContractType");
					}
					num2 = SimGameState.RoundTo((float)num2, 1000);
                    ModInit.modLog.LogMessage($"Final contract value: {num2}");
					contract.SetInitialReward(num2);
					contract.SetBiomeSkin(skin);
				}
				return false;
			}
Ejemplo n.º 3
0
            public static bool Prefix(SimGameState __instance, 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)
                    {
                        int baseDiff = system.Def.GetDifficulty(__instance.SimGameMode) + Mathf.FloorToInt(__instance.GlobalDifficulty);
                        int min;
                        int num;
                        if (ModState.SysAdjustDifficulty != 0 && ModState.IsSystemActionPatch != null)
                        {
                            baseDiff += ModState.SysAdjustDifficulty;
                        }
                        else if (ModState.CustomDifficulty > 0 && ModState.IsSystemActionPatch != null)
                        {
                            baseDiff = ModState.CustomDifficulty;
                        }
                        int contractDifficultyVariance = __instance.Constants.Story.ContractDifficultyVariance;
                        min = baseDiff - Mathf.Max(1, baseDiff - contractDifficultyVariance);
                        num = baseDiff + Mathf.Max(1, baseDiff + contractDifficultyVariance);
                        int finalDifficulty = new NetworkRandom
                        {
                            seed = presetSeed
                        }.Int(min, num + 1);
//						if(__instance.HasTravelContract==true && contract.Name==__instance.ActiveTravelContract.Name)
//                        {
//							finalDifficulty = ModState.LastDiff;
//                        }
//						ModState.LastDiff = finalDifficulty;
                        contract.SetFinalDifficulty(finalDifficulty);
                    }

                    FactionValue player1sMercUnitFactionValue = FactionEnumeration.GetPlayer1sMercUnitFactionValue();
                    FactionValue player2sMercUnitFactionValue = FactionEnumeration.GetPlayer2sMercUnitFactionValue();
                    contract.AddTeamFaction("bf40fd39-ccf9-47c4-94a6-061809681140", player1sMercUnitFactionValue.ID);
                    contract.AddTeamFaction("757173dd-b4e1-4bb5-9bee-d78e623cc867", player2sMercUnitFactionValue.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();
                    int finalDifficulty2 = contract.Override.finalDifficulty;

//					if (__instance.HasTravelContract == true && contract.Name == __instance.ActiveTravelContract.Name)
//					{
//						finalDifficulty2 = ModState.LastDiff;
//					}

                    int num2;
                    if (contract.Override.contractRewardOverride >= 0)
                    {
                        num2 = contract.Override.contractRewardOverride;
                    }
                    else
                    {
                        num2 = __instance.CalculateContractValueByContractType(contract.ContractTypeValue, finalDifficulty2, (float)__instance.Constants.Finances.ContractPricePerDifficulty, __instance.Constants.Finances.ContractPriceVariance, presetSeed);
                    }
                    num2 = SimGameState.RoundTo((float)num2, 1000);
                    contract.SetInitialReward(num2);
                    contract.SetBiomeSkin(skin);
                }
                return(false);
            }