diff --git a/BetterGeoscape/CHReworkMain.cs b/BetterGeoscape/CHReworkMain.cs index 1def5f6..e58400a 100644 --- a/BetterGeoscape/CHReworkMain.cs +++ b/BetterGeoscape/CHReworkMain.cs @@ -524,6 +524,39 @@ public static void CreateDarkEventObjective(string title, string description, Ge } + /* + // Show additional info in objectives + [HarmonyPatch(typeof(UIModuleGeoObjectives), "InitObjective")] + public static class UIModuleGeoObjectives_InitObjective_Patch + { + + public static void Prefix(UIModuleGeoObjectives __instance, ref GeoFactionObjective objective) + { + try + { + if (!(objective is MissionGeoFactionObjective missionGeoFactionObjective) || !(missionGeoFactionObjective.Mission is GeoHavenDefenseMission geoHavenDefenseMission)) + { + return; + } + + IGeoFactionMissionParticipant enemyFaction = geoHavenDefenseMission.GetEnemyFaction(); + Color enemyColor = enemyFaction.ParticipantViewDef.FactionColor; + string enemyColorHex = $"#{ColorUtility.ToHtmlStringRGB(enemyColor)}"; + string enemyName = enemyFaction.ParticipantName.Localize(); + string enemyText = $"{enemyName}"; + + objective.Title = new LocalizedTextBind("Defend {0} against " + enemyText, true); + } + catch (Exception e) + { + Logger.Error(e); + } + } + } + + */ + + [HarmonyPatch(typeof(GeoFactionObjective), "GetIcon")] internal static class BG_GeoFactionObjective_GetIcon_patch { @@ -628,13 +661,13 @@ private static void Postfix(ref float __result, CorruptionStatus __instance) numberOfMutations++; } } - Logger.Always(numberOfMutations.ToString()); + if (numberOfMutations > 0) { __result = 1f + (numberOfMutations*2)/100 * (float)base_TacticalActor.CharacterStats.Corruption; } - Logger.Always(base_TacticalActor.CharacterStats.Corruption.ToString()); + } catch (Exception e) @@ -663,7 +696,7 @@ public static float CalculateMaxCorruption(GeoCharacter character) bionics += 1; } - if (!VoidOmens.VoidOmen12Active) + if (!VoidOmens.VoidOmen10Active) { if (odiPerc < 25) { @@ -725,7 +758,7 @@ public static float CalculateMaxCorruption(GeoCharacter character) } } - if (VoidOmens.VoidOmen12Active) + if (VoidOmens.VoidOmen10Active) { maxCorruption = character.CharacterStats.Willpower.IntMax; @@ -912,7 +945,7 @@ private static void Postfix(ref int __result, CorruptionStatus __instance) int odiPerc = CurrentODI_Level * 100 / ODI_EventIDs.Length; int maxCorruption = 0; // Get max corruption dependent on max WP of the selected actor - if (!VoidOmens.VoidOmen12Active) + if (!VoidOmens.VoidOmen10Active) { if (odiPerc < 25) @@ -963,7 +996,7 @@ private static void Postfix(ref int __result, CorruptionStatus __instance) } } } - if (VoidOmens.VoidOmen12Active) + if (VoidOmens.VoidOmen10Active) { maxCorruption = base_TacticalActor.CharacterStats.Willpower.IntMax; diff --git a/BetterGeoscape/Umbra.cs b/BetterGeoscape/Umbra.cs index 3b68fb6..d6c444c 100644 --- a/BetterGeoscape/Umbra.cs +++ b/BetterGeoscape/Umbra.cs @@ -89,8 +89,7 @@ public static void Postfix(TacticalFaction prevFaction, TacticalFaction nextFact { totalCharactersWithDelirium++; totalDeliriumOnMission += (int)actor.CharacterStats.Corruption.Value.BaseValue; - Logger.Always("Total Delirium on mission is " + totalDeliriumOnMission); - Logger.Always("Number of characters with Delirium is " + totalCharactersWithDelirium); + } } } @@ -103,42 +102,48 @@ public static void Postfix(TacticalFaction prevFaction, TacticalFaction nextFact Logger.Always("Number of characters with Delirium is " + totalCharactersWithDelirium); if (totalDeliriumOnMission >= 10 || totalCharactersWithDelirium >= 5) { - Logger.Always("The if gets past the Delirium check"); + DeathBelcherAbilityDef oilcrabDeathBelcherAbility = Repo.GetAllDefs().FirstOrDefault (ged => ged.name.Equals("Oilcrab_Die_DeathBelcher_AbilityDef")); - Logger.Always("The if gets past the Delirium check"); + DeathBelcherAbilityDef oilfishDeathBelcherAbility = Repo.GetAllDefs().FirstOrDefault (ged => ged.name.Equals("Oilfish_Die_DeathBelcher_AbilityDef")); - Logger.Always("We get past the DB repo"); + foreach (TacticalActor actor in nextFaction.TacticalActors) { Logger.Always("The next faction is " + nextFaction.Faction.FactionDef.name); Logger.Always("The actor is " + actor.name); - if (actor.GameTags.Contains(crabTag) && actor.GetAbilityWithDef(oilcrabDeathBelcherAbility) == null) + if (actor.GameTags.Contains(crabTag) && actor.GetAbilityWithDef(oilcrabDeathBelcherAbility) == null + && !actor.name.Contains("Oilcrab")) + { int roll = UnityEngine.Random.Range(0, 100); - if (VoidOmens.VoidOmen15Active && roll >= 50) + if (VoidOmens.VoidOmen15Active && roll >= 68) { Logger.Always("This Arthron here " + actor + ", got past the crabtag and the blecher ability check!"); AddArthronUmbraDeathBelcherAbility(actor); } - else if (!VoidOmens.VoidOmen15Active && roll >= 75) + else if (!VoidOmens.VoidOmen15Active && roll >= 84) { + Logger.Always("This Arthron here " + actor + ", got past the crabtag and the blecher ability check!"); AddArthronUmbraDeathBelcherAbility(actor); } } - if (actor.GameTags.Contains(fishTag) && actor.GetAbilityWithDef(oilfishDeathBelcherAbility) == null) + if (actor.GameTags.Contains(fishTag) && actor.GetAbilityWithDef(oilfishDeathBelcherAbility) == null + && !actor.name.Contains("Oilfish")) { int roll = UnityEngine.Random.Range(0, 100); - if (VoidOmens.VoidOmen15Active && roll >= 50) + if (VoidOmens.VoidOmen15Active && roll >= 68) { + Logger.Always("This Triton here " + actor + ", got past the crabtag and the blecher ability check!"); AddTritonUmbraDeathBelcherAbility(actor); } - else if (!VoidOmens.VoidOmen15Active && roll >= 75) + else if (!VoidOmens.VoidOmen15Active && roll >= 84) { + Logger.Always("This Triton here " + actor + ", got past the crabtag and the blecher ability check!"); AddTritonUmbraDeathBelcherAbility(actor); } } @@ -166,8 +171,15 @@ public static void Postfix(ref IEnumerable __result, Tact { if (sourceActor.ActorDef.name.Equals("Oilcrab_ActorDef") || sourceActor.ActorDef.name.Equals("Oilfish_ActorDef")) { - List list = __result.ToList(); - list.RemoveWhere(adilityTarget => (adilityTarget.Actor as TacticalActor)?.CharacterStats.Corruption <= 0); + List list = new List(); // = __result.ToList(); + //list.RemoveWhere(adilityTarget => (adilityTarget.Actor as TacticalActor)?.CharacterStats.Corruption <= 0); + foreach (TacticalAbilityTarget source in __result) + { + if (source.Actor is TacticalActor && (source.Actor as TacticalActor).CharacterStats.Corruption > 0) + { + list.Add(source); + } + } __result = list; } } diff --git a/BetterGeoscape/VoidOmens.cs b/BetterGeoscape/VoidOmens.cs index 3213268..8982d64 100644 --- a/BetterGeoscape/VoidOmens.cs +++ b/BetterGeoscape/VoidOmens.cs @@ -32,13 +32,19 @@ internal class VoidOmens private static readonly DefRepository Repo = BetterGeoscapeMain.Repo; public static bool[] darkEventsCheck = new bool[17]; + //VO#3 is WP cost +50% public static bool VoidOmen3Active = false; public static bool VoidOmen3Activated = false; + //VO#7 is more mist in missions public static bool VoidOmen7Active = false; + //VO#10 is no limit to Delirium + public static bool VoidOmen10Active = false; + //VO#12 is +50% strength of alien attacks on Havens + public static bool VoidOmen12Active = false; + //VO#15 is more Umbra public static bool VoidOmen15Active = false; + //VO#16 is Umbras can appear anywhere and attack anyone public static bool VoidOmen16Active = false; - public static bool VoidOmen12Active = false; - public static bool VoidOmen14Active = false; @@ -184,7 +190,7 @@ public static void CreateVoidOmens(GeoLevelController level) } if (j == 12 && darkEventsCheck[j] == false) { - VoidOmen14Active = true; + VoidOmen12Active = true; darkEventsCheck[j] = true; } @@ -215,19 +221,19 @@ public static void CreateVoidOmens(GeoLevelController level) { RandomValueEffectConditionDef randomValueCrabUmbra = Repo.GetAllDefs(). FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralCrabmen_FactionEffectDef]")); - randomValueCrabUmbra.ThresholdValue = 0.25f; + randomValueCrabUmbra.ThresholdValue = 0.16f; RandomValueEffectConditionDef randomValueFishUmbra = Repo.GetAllDefs(). FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralFishmen_FactionEffectDef]")); - randomValueFishUmbra.ThresholdValue = 0.25f; + randomValueFishUmbra.ThresholdValue = 0.16f; } if (darkEventsCheck[15]) { RandomValueEffectConditionDef randomValueCrabUmbra = Repo.GetAllDefs(). FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralCrabmen_FactionEffectDef]")); - randomValueCrabUmbra.ThresholdValue = 0.5f; + randomValueCrabUmbra.ThresholdValue = 0.32f; RandomValueEffectConditionDef randomValueFishUmbra = Repo.GetAllDefs(). FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralFishmen_FactionEffectDef]")); - randomValueFishUmbra.ThresholdValue = 0.5f; + randomValueFishUmbra.ThresholdValue = 0.32f; } darkEventsCheck[j] = true; } @@ -409,7 +415,7 @@ public static void CheckForRemovedVoidOmens(GeoLevelController level) if (darkEventsCheck[12]) { - VoidOmen14Active=false; + VoidOmen12Active=false; darkEventsCheck[12] = false; Logger.Always("The check for VO#12 went ok"); } @@ -438,7 +444,7 @@ public static void CheckForRemovedVoidOmens(GeoLevelController level) if (darkEventsCheck[14]) { TacticalPerceptionDef tacticalPerceptionDef = Repo.GetAllDefs().FirstOrDefault((TacticalPerceptionDef a) => a.name.Equals("Soldier_PerceptionDef")); - tacticalPerceptionDef.PerceptionRange = 35; + tacticalPerceptionDef.PerceptionRange = 30; darkEventsCheck[14] = false; Logger.Always("The check for VO#14 went ok"); } @@ -488,19 +494,18 @@ public static void CheckForVoidOmensRequiringTacticalPatching(GeoLevelController { VoidOmen7Active = true; } - if (level.EventSystem.GetVariable(voidOmen + i) == 9) + if (level.EventSystem.GetVariable(voidOmen + i) == 10) { - VoidOmen15Active = true; + VoidOmen10Active = true; } - if (level.EventSystem.GetVariable(voidOmen + i) == 11) + if (level.EventSystem.GetVariable(voidOmen + i) == 15) { - VoidOmen16Active = true; + VoidOmen15Active = true; } - if (level.EventSystem.GetVariable(voidOmen + i) == 12) + if (level.EventSystem.GetVariable(voidOmen + i) == 16) { - VoidOmen12Active = true; + VoidOmen16Active = true; } - } } catch (Exception e) @@ -615,7 +620,7 @@ public static void RemoveEarliestVoidOmen { Logger.Error(e); } - } + } } } diff --git a/BetterGeoscape/VolandsPlayground.cs b/BetterGeoscape/VolandsPlayground.cs index fb0e0b1..4d25917 100644 --- a/BetterGeoscape/VolandsPlayground.cs +++ b/BetterGeoscape/VolandsPlayground.cs @@ -3,9 +3,11 @@ using Base.Defs; using Base.Entities.Effects.ApplicationConditions; using Base.UI; +using Base.Utils.GameConsole; using Harmony; using PhoenixPoint.Common.Core; using PhoenixPoint.Common.Entities.GameTags; +using PhoenixPoint.Common.Entities.GameTagsTypes; using PhoenixPoint.Common.Entities.Items.SkinData; using PhoenixPoint.Common.Levels.Missions; using PhoenixPoint.Geoscape.Core; @@ -435,9 +437,12 @@ public static void Postfix(ref float __result, TacticalAbility __instance) { try { - if (VoidOmens.VoidOmen3Active && __instance.TacticalActor.IsControlledByPlayer) + if (__result > 0) { - __result += Mathf.RoundToInt(__result * 0.5f); + if (VoidOmens.VoidOmen3Active && __instance.TacticalActor.IsControlledByPlayer) + { + __result += Mathf.RoundToInt(__result * 0.5f); + } } } catch (Exception e) @@ -466,8 +471,34 @@ public static void Prefix(TacticalVoxelMatrix __instance) } } } + /* [HarmonyPatch(typeof(GeoSite), "DestroySite")] + public static class GeoSite_DestroySite_DestroyedHavenGenerateScav_patch + { + internal static bool flag = false; + + public static void Postfix(GeoSite __instance, GeoSiteType ____type) + { + try + { + + if (__instance.Type == GeoSiteType.Haven && !flag) + { + flag = true; + } + else if (flag) + { + __instance.ActiveMission = null; + __instance.CreateScavengingMission(); + flag = false; + } + } + catch (Exception e) + { + Logger.Error(e); + } + } + }*/ - [HarmonyPatch(typeof(SiteEncountersArtCollectionDef), "GetEventArt")] public static class SiteEncountersArtCollectionDef_GetEventArt_InjectArt_patch @@ -507,7 +538,7 @@ public static void Prefix(ref HavenAttacker attacker) { try { - if (VoidOmens.VoidOmen14Active) + if (VoidOmens.VoidOmen12Active) { SharedData sharedData = GameUtl.GameComponent(); if (attacker.Faction.PPFactionDef == sharedData.AlienFactionDef)