AI Open Borders Offer fix (#10178)

* Increased declined flags time

* AI now only offers open borders if it has the relevant technologies

* Increased the factor of AIs wanting to fight instead of sign open borders
This commit is contained in:
Oskar Niesen 2023-09-26 06:47:25 -05:00 committed by GitHub
parent 920d819595
commit 700e24166a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -835,12 +835,14 @@ object NextTurnAutomation {
} }
private fun offerOpenBorders(civInfo: Civilization) { private fun offerOpenBorders(civInfo: Civilization) {
val civsThatWeCanDeclareFriendshipWith = civInfo.getKnownCivs() if (!civInfo.hasUnique(UniqueType.EnablesOpenBorders)) return
val civsThatWeCanOpenBordersWith = civInfo.getKnownCivs()
.filter { it.isMajorCiv() && !civInfo.isAtWarWith(it) .filter { it.isMajorCiv() && !civInfo.isAtWarWith(it)
&& it.hasUnique(UniqueType.EnablesOpenBorders)
&& !civInfo.getDiplomacyManager(it).hasOpenBorders && !civInfo.getDiplomacyManager(it).hasOpenBorders
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedOpenBorders) } && !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedOpenBorders) }
.sortedByDescending { it.getDiplomacyManager(civInfo).relationshipLevel() }.toList() .sortedByDescending { it.getDiplomacyManager(civInfo).relationshipLevel() }.toList()
for (otherCiv in civsThatWeCanDeclareFriendshipWith) { for (otherCiv in civsThatWeCanOpenBordersWith) {
// Default setting is 3, this will be changed according to different civ. // Default setting is 3, this will be changed according to different civ.
if ((1..10).random() <= 3 && wantsToOpenBorders(civInfo, otherCiv)) { if ((1..10).random() <= 3 && wantsToOpenBorders(civInfo, otherCiv)) {
val tradeLogic = TradeLogic(civInfo, otherCiv) val tradeLogic = TradeLogic(civInfo, otherCiv)
@ -857,7 +859,7 @@ object NextTurnAutomation {
// Don't accept if they are at war with our friends, they might use our land to attack them // Don't accept if they are at war with our friends, they might use our land to attack them
if (civInfo.diplomacy.values.any { it.isRelationshipLevelGE(RelationshipLevel.Friend) && it.otherCiv().isAtWarWith(otherCiv)}) if (civInfo.diplomacy.values.any { it.isRelationshipLevelGE(RelationshipLevel.Friend) && it.otherCiv().isAtWarWith(otherCiv)})
return false return false
if (hasAtLeastMotivationToAttack(civInfo, otherCiv, civInfo.getDiplomacyManager(otherCiv).opinionOfOtherCiv().toInt()) > 0) if (hasAtLeastMotivationToAttack(civInfo, otherCiv, (civInfo.getDiplomacyManager(otherCiv).opinionOfOtherCiv()/ 2 - 10).toInt()) >= 0)
return false return false
return true return true
} }

View File

@ -61,9 +61,9 @@ class TradeRequest : IsPartOfGameInfoSerialization {
if (trade.ourOffers.any { it.name == Constants.researchAgreement }) if (trade.ourOffers.any { it.name == Constants.researchAgreement })
diplomacyManager.setFlag(DiplomacyFlags.DeclinedResearchAgreement,20) diplomacyManager.setFlag(DiplomacyFlags.DeclinedResearchAgreement,20)
if (trade.ourOffers.any { it.name == Constants.defensivePact }) if (trade.ourOffers.any { it.name == Constants.defensivePact })
diplomacyManager.setFlag(DiplomacyFlags.DeclinedDefensivePact,10) diplomacyManager.setFlag(DiplomacyFlags.DeclinedDefensivePact,20)
if (trade.ourOffers.any { it.name == Constants.openBorders }) if (trade.ourOffers.any { it.name == Constants.openBorders })
diplomacyManager.setFlag(DiplomacyFlags.DeclinedOpenBorders, 10) diplomacyManager.setFlag(DiplomacyFlags.DeclinedOpenBorders, if (decliningCiv.isAI()) 10 else 20)
if (trade.isPeaceTreaty()) diplomacyManager.setFlag(DiplomacyFlags.DeclinedPeace, 5) if (trade.isPeaceTreaty()) diplomacyManager.setFlag(DiplomacyFlags.DeclinedPeace, 5)

View File

@ -199,7 +199,7 @@ class AlertPopup(
addLeaderName(otherciv) addLeaderName(otherciv)
addGoodSizedLabel("My friend, shall we declare our friendship to the world?").row() addGoodSizedLabel("My friend, shall we declare our friendship to the world?").row()
addCloseButton("We are not interested.", KeyboardBinding.Cancel) { addCloseButton("We are not interested.", KeyboardBinding.Cancel) {
playerDiploManager.otherCivDiplomacy().setFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship, 10) playerDiploManager.otherCivDiplomacy().setFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship, 20)
}.row() }.row()
addCloseButton("Declare Friendship ([30] turns)", KeyboardBinding.Confirm) { addCloseButton("Declare Friendship ([30] turns)", KeyboardBinding.Confirm) {
playerDiploManager.signDeclarationOfFriendship() playerDiploManager.signDeclarationOfFriendship()