Skip to content

Commit

Permalink
Orcs Ignore Subterranean Challenges
Browse files Browse the repository at this point in the history
- Orc agents will now ignore challenges and rituals that they could perform underground, unless their society is allowed to go underground (has had a mine at any point).
- - This should eliminate an occasional cause of humans having high underground awareness before the game starts, as it can be caused by orcs shopping, or otherwise interacting with the underground before they should.
  • Loading branch information
ilikegoodfood committed Mar 5, 2024
1 parent f5ed13c commit 8e1047e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions Orcs Plus/AgentAIs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ private bool delegate_ValidFor_BuyItem(AgentAI.ChallengeData challengeData, UA u
return result;
}

private bool delegate_ValidFor_Underground(AgentAI.ChallengeData challengeData, UA ua)
{
if (ua.society is SG_Orc orcs)
{
if (challengeData.location.hex.z == 1 && orcs.canGoUnderground())
{
return true;
}
}
else if (ua.society is HolyOrder_Orcs orcCulture)
{
if (challengeData.location.hex.z == 1 && orcCulture.orcSociety != null && orcCulture.orcSociety.canGoUnderground())
{
return true;
}
}

return false;
}

// Orc Upstart
private void populateOrcUpstarts()
{
Expand Down Expand Up @@ -337,6 +357,11 @@ private void populateOrcElders()

comLibAI.RegisterAgentType(typeof(UAEN_OrcElder), new AgentAI.ControlParameters(true));
comLibAI.AddChallengesToAgentType(typeof(UAEN_OrcElder), aiChallenges_Elder);

if (comLibAI.TryGetAgentType(typeof(UAEN_OrcElder), out AgentAI.AIData aiData) && aiData != null)
{
aiData.aiChallenges_UniversalDelegates_ValidFor.Add(delegate_ValidFor_Underground);
}
}

private bool delegate_ValidFor_OwnCulture(AgentAI.ChallengeData challengeData, UA ua)
Expand Down Expand Up @@ -740,6 +765,11 @@ private void populateOrcShamans()

comLibAI.RegisterAgentType(typeof(UAEN_OrcShaman), new AgentAI.ControlParameters(true));
comLibAI.AddChallengesToAgentType(typeof(UAEN_OrcShaman), aiChallenges_Shaman);

if (comLibAI.TryGetAgentType(typeof(UAEN_OrcShaman), out AgentAI.AIData aiData) && aiData != null)
{
aiData.aiChallenges_UniversalDelegates_ValidFor.Add(delegate_ValidFor_Underground);
}
}

private bool delegate_ValidFor_SecretsOfDeath(AgentAI.ChallengeData challengeData, UA ua)
Expand Down
4 changes: 2 additions & 2 deletions Orcs Plus/MA_Orcs_GreatConstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public override double getUtility(List<ReasonMsg> reasons)
}

Sub_Shipwreck wreck = (Sub_Shipwreck)camp.subs.FirstOrDefault(sub => sub is Sub_Shipwreck);
if (camp.location.isCoastal && camp.location.getNeighbours().Any(l => l.isOcean) && wreck != null && !wreck.isReinforced())
if (camp.location.isCoastal && wreck != null && !wreck.isReinforced() && camp.location.getNeighbours().Any(l => l.isOcean))
{
double baseCost = 2 * map.param.ch_orc_buildFortressCostPerNeighbour;
int specilisedNeighbourCount = camp.location.getNeighbours().FindAll(l => l.settlement is Set_OrcCamp camp2 && camp2.specialism > 0).Count;
Expand Down Expand Up @@ -457,7 +457,7 @@ public double getMinesUtility(Set_OrcCamp camp, List<ReasonMsg> reasonMsgs)
int mineCount = orcCulture.specializedCamps.FindAll(c => c.specialism == 6).Count;
utility = 40.0 - (10.0 * mineCount);

reasonMsgs?.Add(new ReasonMsg("Base", 80.0));
reasonMsgs?.Add(new ReasonMsg("Base", 40.0));
reasonMsgs?.Add(new ReasonMsg("Existing mines", -10.0 * mineCount));

return utility;
Expand Down

0 comments on commit 8e1047e

Please sign in to comment.