Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Voland163 committed Jun 10, 2022
2 parents c8581dd + 7cccab5 commit 6ae57b3
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 40 deletions.
45 changes: 39 additions & 6 deletions BetterGeoscape/CHReworkMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $"<color={enemyColorHex}>{enemyName}</color>";
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
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -663,7 +696,7 @@ public static float CalculateMaxCorruption(GeoCharacter character)
bionics += 1;
}

if (!VoidOmens.VoidOmen12Active)
if (!VoidOmens.VoidOmen10Active)
{
if (odiPerc < 25)
{
Expand Down Expand Up @@ -725,7 +758,7 @@ public static float CalculateMaxCorruption(GeoCharacter character)
}

}
if (VoidOmens.VoidOmen12Active)
if (VoidOmens.VoidOmen10Active)
{
maxCorruption = character.CharacterStats.Willpower.IntMax;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
38 changes: 25 additions & 13 deletions BetterGeoscape/Umbra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}
}
Expand All @@ -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<DeathBelcherAbilityDef>().FirstOrDefault
(ged => ged.name.Equals("Oilcrab_Die_DeathBelcher_AbilityDef"));
Logger.Always("The if gets past the Delirium check");

DeathBelcherAbilityDef oilfishDeathBelcherAbility =
Repo.GetAllDefs<DeathBelcherAbilityDef>().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<DeathBelcherAbility>(oilcrabDeathBelcherAbility) == null)
if (actor.GameTags.Contains(crabTag) && actor.GetAbilityWithDef<DeathBelcherAbility>(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<DeathBelcherAbility>(oilfishDeathBelcherAbility) == null)
if (actor.GameTags.Contains(fishTag) && actor.GetAbilityWithDef<DeathBelcherAbility>(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);
}
}
Expand Down Expand Up @@ -166,8 +171,15 @@ public static void Postfix(ref IEnumerable<TacticalAbilityTarget> __result, Tact
{
if (sourceActor.ActorDef.name.Equals("Oilcrab_ActorDef") || sourceActor.ActorDef.name.Equals("Oilfish_ActorDef"))
{
List<TacticalAbilityTarget> list = __result.ToList();
list.RemoveWhere(adilityTarget => (adilityTarget.Actor as TacticalActor)?.CharacterStats.Corruption <= 0);
List<TacticalAbilityTarget> list = new List<TacticalAbilityTarget>(); // = __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;
}
}
Expand Down
39 changes: 22 additions & 17 deletions BetterGeoscape/VoidOmens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand Down Expand Up @@ -184,7 +190,7 @@ public static void CreateVoidOmens(GeoLevelController level)
}
if (j == 12 && darkEventsCheck[j] == false)
{
VoidOmen14Active = true;
VoidOmen12Active = true;
darkEventsCheck[j] = true;

}
Expand Down Expand Up @@ -215,19 +221,19 @@ public static void CreateVoidOmens(GeoLevelController level)
{
RandomValueEffectConditionDef randomValueCrabUmbra = Repo.GetAllDefs<RandomValueEffectConditionDef>().
FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralCrabmen_FactionEffectDef]"));
randomValueCrabUmbra.ThresholdValue = 0.25f;
randomValueCrabUmbra.ThresholdValue = 0.16f;
RandomValueEffectConditionDef randomValueFishUmbra = Repo.GetAllDefs<RandomValueEffectConditionDef>().
FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralFishmen_FactionEffectDef]"));
randomValueFishUmbra.ThresholdValue = 0.25f;
randomValueFishUmbra.ThresholdValue = 0.16f;
}
if (darkEventsCheck[15])
{
RandomValueEffectConditionDef randomValueCrabUmbra = Repo.GetAllDefs<RandomValueEffectConditionDef>().
FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralCrabmen_FactionEffectDef]"));
randomValueCrabUmbra.ThresholdValue = 0.5f;
randomValueCrabUmbra.ThresholdValue = 0.32f;
RandomValueEffectConditionDef randomValueFishUmbra = Repo.GetAllDefs<RandomValueEffectConditionDef>().
FirstOrDefault(ged => ged.name.Equals("E_RandomValue [UmbralFishmen_FactionEffectDef]"));
randomValueFishUmbra.ThresholdValue = 0.5f;
randomValueFishUmbra.ThresholdValue = 0.32f;
}
darkEventsCheck[j] = true;
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -438,7 +444,7 @@ public static void CheckForRemovedVoidOmens(GeoLevelController level)
if (darkEventsCheck[14])
{
TacticalPerceptionDef tacticalPerceptionDef = Repo.GetAllDefs<TacticalPerceptionDef>().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");
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -615,7 +620,7 @@ public static void RemoveEarliestVoidOmen
{
Logger.Error(e);
}
}
}
}
}

Expand Down
39 changes: 35 additions & 4 deletions BetterGeoscape/VolandsPlayground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -507,7 +538,7 @@ public static void Prefix(ref HavenAttacker attacker)
{
try
{
if (VoidOmens.VoidOmen14Active)
if (VoidOmens.VoidOmen12Active)
{
SharedData sharedData = GameUtl.GameComponent<SharedData>();
if (attacker.Faction.PPFactionDef == sharedData.AlienFactionDef)
Expand Down

0 comments on commit 6ae57b3

Please sign in to comment.