Skip to content

Commit

Permalink
Mars 1.50 (#210)
Browse files Browse the repository at this point in the history
* Fix: Better mining logic
* more mining logic improvement
* Fix: Improve remnant random empire target selection.
* Fix: Expansion AI -increase system selection divider and increase search radius increase time.
* Fix: selecting a trait preferred env should overwrite scripted starting planet env.
*Fix: scrapship - do not select unsafe planets as target planets for scrap.
*Fix: scrapship - change target planet if current target planet is not safe anymore.
  • Loading branch information
gkapulis authored Jan 15, 2025
1 parent aab5e14 commit 97b25b9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Ship_Game/AI/ExpansionAI/ExpansionPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ [StarDataConstructor] ExpansionPlanner() {}
public ExpansionPlanner(Empire empire)
{
Owner = empire;
SetMaxSystemsToCheckedDiv(Owner.IsExpansionists ? 4 : 6);
SetMaxSystemsToCheckedDiv(Owner.IsExpansionists ? 8 : 10);
ResetExpandSearchTimer();
}

Expand Down
3 changes: 2 additions & 1 deletion Ship_Game/Commands/Goals/RemnantEngageEmpire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ GoalStep WaitForCompletion()
if (Fleet.TaskStep != 7 && TargetPlanet?.Owner == TargetEmpire) // Not cleared enemy at target planet yet
return GoalStep.TryAgain;

if (!Remnants.TargetEmpireStillValid(TargetEmpire))
if (!Remnants.TargetEmpireStillValid(TargetEmpire,
stickToSameRandomTarget: TargetPlanet?.System.HasPlanetsOwnedBy(TargetEmpire) == true))
{
if (!Remnants.FindValidTarget(out Empire newVictim))
return ReturnToClosestPortalAndReroute();
Expand Down
16 changes: 16 additions & 0 deletions Ship_Game/Commands/Goals/ScrapShip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ GoalStep WaitForOldShipAtPlanet()
if (!OldShipOnPlan)
return GoalStep.GoalFailed;

if (!PlanetBuildingAt.Safe)
{
OldShip.AI.ClearOrders();
if (!Owner.FindPlanetToScrapIn(OldShip, out Planet buildAt))
{
return GoalStep.GoalFailed;
}
else
{
PlanetBuildingAt = buildAt;
OldShip.AI.IgnoreCombat = true;
OldShip.AI.OrderMoveAndScrap(buildAt);
}
}


if (OldShip.Position.InRadius(PlanetBuildingAt.Position, PlanetBuildingAt.Radius + 300f))
return GoalStep.GoToNextStep;

Expand Down
8 changes: 4 additions & 4 deletions Ship_Game/EmpireDifficultyModifers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public DifficultyModifiers(Empire empire, GameDifficulty difficulty)
ExpansionMultiplier = 1.0f;
ExpansionCheckInterval = 7; // every 7 turns
MinStartingColonies = 3;
ExpandSearchTurns = 50;
ExpandSearchTurns = 200;
RemnantTurnsLevelUp = 350;
RemnantResourceMod = 0.5f;
RemnantNumBombers = 0.75f;
Expand Down Expand Up @@ -132,7 +132,7 @@ public DifficultyModifiers(Empire empire, GameDifficulty difficulty)
ExpansionMultiplier = 0.5f;
ExpansionCheckInterval = 5; // every 5 turns
MinStartingColonies = 5;
ExpandSearchTurns = 30;
ExpandSearchTurns = 150;
RemnantTurnsLevelUp = 325;
RemnantResourceMod = 1f;
RemnantNumBombers = 1f;
Expand Down Expand Up @@ -178,7 +178,7 @@ public DifficultyModifiers(Empire empire, GameDifficulty difficulty)
ExpansionMultiplier = 0.25f;
ExpansionCheckInterval = 3; // every 3 turns
MinStartingColonies = 6;
ExpandSearchTurns = 20;
ExpandSearchTurns = 100;
RemnantTurnsLevelUp = 300;
RemnantResourceMod = 1.5f;
RemnantNumBombers = 1.25f;
Expand Down Expand Up @@ -226,7 +226,7 @@ public DifficultyModifiers(Empire empire, GameDifficulty difficulty)
ExpansionMultiplier = 0.1f; // 10x lower threshold, Insane AI can expand as much as it wants!
ExpansionCheckInterval = 1; // every turn, there is no limit!
MinStartingColonies = 6;
ExpandSearchTurns = 20;
ExpandSearchTurns = 100;
RemnantTurnsLevelUp = 275;
RemnantResourceMod = 2f;
RemnantNumBombers = 1.5f;
Expand Down
2 changes: 1 addition & 1 deletion Ship_Game/Empire_RallyPlanets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public bool FindPlanetToScrapIn(Ship ship, out Planet planet)
}

var scrapGoals = AI.FindGoals(g => g.Type == GoalType.ScrapShip);
var potentialPlanets = OwnedPlanets.SortedDescending(p => p.MissingProdHereForScrap(scrapGoals)).TakeItems(5);
var potentialPlanets = SafePlanets.SortedDescending(p => p.MissingProdHereForScrap(scrapGoals)).TakeItems(5);
if (potentialPlanets.Length == 0)
return false;

Expand Down
4 changes: 2 additions & 2 deletions Ship_Game/Remnants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@ public Planet GetTargetPlanetForFleetTaskWhenNoPortals(Vector2 fleetPos)
return targetEmpire.GetPlanets().FindMin(p => p.Position.SqDist(fleetPos));
}

public bool TargetEmpireStillValid(Empire currentTarget)
public bool TargetEmpireStillValid(Empire currentTarget, bool stickToSameRandomTarget = true)
{
if (Hibernating)
return false;

if (UsingRandomTargets() && !currentTarget.IsDefeated)
return true;
return stickToSameRandomTarget;

FindValidTarget(out Empire expectedTarget);
return expectedTarget == currentTarget;
Expand Down
11 changes: 8 additions & 3 deletions Ship_Game/Universe/SolarBodies/Planet/Planet_Generate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ void GeneratePlanetFromSystemData(RandomBase random, SolarSystemData.Ring data,

public void GenerateNewHomeWorld(RandomBase random, Empire owner, SolarSystemData.Ring data = null)
{
PlanetType type = data?.WhichPlanet > 0 ? ResourceManager.Planets.PlanetOrRandom(data.WhichPlanet)
: ResourceManager.Planets.RandomPlanet(owner.data.PreferredEnvPlanet);

PlanetType type = GetPLanetType();
float scale = 1f * owner.data.Traits.HomeworldSizeMultiplier; // base max pop is affected by scale
InitPlanetType(type, scale, fromSave: false);
SetOwner(owner);
Expand All @@ -204,6 +202,13 @@ public void GenerateNewHomeWorld(RandomBase random, Empire owner, SolarSystemDat

UpdateDevelopmentLevel();
CreateHomeWorldBuildings();

PlanetType GetPLanetType()
{
PlanetType traitPreferredType = ResourceManager.Planets.RandomPlanet(owner.data.PreferredEnvPlanet);
PlanetType xmlDataPreferredtype = data?.WhichPlanet > 0 ? ResourceManager.Planets.PlanetOrRandom(data.WhichPlanet) : null;
return xmlDataPreferredtype?.Category == traitPreferredType.Category ? xmlDataPreferredtype : traitPreferredType;
}
}

void SetTileHabitability(RandomBase random, float tileChance, out int numHabitableTiles)
Expand Down

0 comments on commit 97b25b9

Please sign in to comment.