Skip to content

Commit

Permalink
Bug fix for local faction.
Browse files Browse the repository at this point in the history
  • Loading branch information
donZappo committed Sep 15, 2019
1 parent 85a5ed2 commit b146564
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
11 changes: 8 additions & 3 deletions Galaxy at War/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public static void Postfix(SimGameState __instance)
//} while (i < 100);
//__instance.StopPlayMode();
//return;

if (__instance.DayRemainingInQuarter % Settings.WarFrequency == 0)
{
//LogDebug(">>> PROC");
Expand All @@ -187,7 +186,6 @@ public static void Postfix(SimGameState __instance)
NeedsProcessing = false;
}
}

SaveHandling.SerializeWar();
LogDebug(">>> DONE PROC");
}
Expand Down Expand Up @@ -1150,7 +1148,13 @@ public static void Postfix(SimGameState __instance)
if (contractType == ContractType.AttackDefend || contractType == ContractType.FireMission)
{
if (Settings.IncludedFactions.Contains(teamfaction))
WarStatus.warFactionTracker.Find(x => x.faction == teamfaction).AttackResources += difficulty;
{
if (!Settings.DefensiveFactions.Contains(teamfaction))
WarStatus.warFactionTracker.Find(x => x.faction == teamfaction).AttackResources += difficulty;
else
WarStatus.warFactionTracker.Find(x => x.faction == teamfaction).DefensiveResources += difficulty;
}

if (Settings.IncludedFactions.Contains(enemyfaction))
{
WarStatus.warFactionTracker.Find(x => x.faction == enemyfaction).DefensiveResources -= difficulty;
Expand Down Expand Up @@ -1233,6 +1237,7 @@ public static void Postfix(SimGameState __instance)
}
}
}

public static void SystemDifficulty()
{
bool GetPirateFlex = true;
Expand Down
20 changes: 13 additions & 7 deletions Galaxy at War/HotSpots.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ static void Postfix(StarSystem __instance)

if (Core.NeedsProcessing)
ProcessHotSpots();

isBreadcrumb = true;
sim.CurSystem.SystemBreadcrumbs.Clear();
Traverse.Create(sim.CurSystem).Property("MissionsCompleted").SetValue(20);
Traverse.Create(sim.CurSystem).Property("CurBreadcrumbOverride").SetValue(1);
Traverse.Create(sim.CurSystem).Property("CurMaxBreadcrumbs").SetValue(1);

if (HomeContendedSystems.Count != 0)
{
int i = 0;
Expand All @@ -150,23 +151,30 @@ static void Postfix(StarSystem __instance)
RandomSystem = rand.Next(HomeContendedSystems.Count / 2, HomeContendedSystems.Count);
if (twiddle == -1)
RandomSystem = rand.Next(0, HomeContendedSystems.Count / 2);

var MainBCTarget = HomeContendedSystems[RandomSystem];
if (MainBCTarget == sim.CurSystem)

if (MainBCTarget == sim.CurSystem || (sim.CurSystem.Owner == Faction.Locals && MainBCTarget.Owner != Faction.Locals))
{
HomeContendedSystems.Remove(MainBCTarget);
continue;
}
TemporaryFlip(MainBCTarget, sim.CurSystem.Owner);
if (sim.CurSystem.SystemBreadcrumbs.Count == 0)
{
sim.GeneratePotentialContracts(true, null, MainBCTarget, false);
}
else
{
sim.GeneratePotentialContracts(false, null, MainBCTarget, false);
SystemBonuses(MainBCTarget);
SystemBonuses(MainBCTarget);
}

Core.RefreshContracts(MainBCTarget);
HomeContendedSystems.Remove(MainBCTarget);
if (sim.CurSystem.SystemBreadcrumbs.Count == Core.Settings.InternalHotSpots)
break;

i = sim.CurSystem.SystemBreadcrumbs.Count;
twiddle *= -1;
}
Expand Down Expand Up @@ -280,14 +288,12 @@ public static void TemporaryFlip(StarSystem starSystem, Faction faction)
break;
}
}

if (starSystem.Def.ContractTargets.Count == 0)
if (starSystem.Def.ContractTargets.Count <= 1)
{
starSystem.Def.ContractTargets.Add(Faction.AuriganPirates);
if (!Core.WarStatus.AbandonedSystems.Contains(starSystem.Name))
starSystem.Def.ContractTargets.Add(Faction.Locals);
}

}

//Deployments area.
Expand Down
13 changes: 13 additions & 0 deletions Galaxy at War/SaveHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ public static void RebuildState()
{
Core.AdjustDeathList(deathListTracker, sim, true);
}
foreach (var defensivefaction in Core.Settings.DefensiveFactions)
{
if (Core.WarStatus.warFactionTracker.Find(x => x.faction == defensivefaction) == null)
continue;

var targetfaction = Core.WarStatus.warFactionTracker.Find(x => x.faction == defensivefaction);

if (targetfaction.AttackResources != 0)
{
targetfaction.DefensiveResources += targetfaction.AttackResources;
targetfaction.AttackResources = 0;
}
}
}

public static void ConvertToSave()
Expand Down

0 comments on commit b146564

Please sign in to comment.