mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-28 21:58:54 +07:00
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:
@ -835,12 +835,14 @@ object NextTurnAutomation {
|
||||
}
|
||||
|
||||
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)
|
||||
&& it.hasUnique(UniqueType.EnablesOpenBorders)
|
||||
&& !civInfo.getDiplomacyManager(it).hasOpenBorders
|
||||
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedOpenBorders) }
|
||||
.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.
|
||||
if ((1..10).random() <= 3 && wantsToOpenBorders(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
|
||||
if (civInfo.diplomacy.values.any { it.isRelationshipLevelGE(RelationshipLevel.Friend) && it.otherCiv().isAtWarWith(otherCiv)})
|
||||
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 true
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ class TradeRequest : IsPartOfGameInfoSerialization {
|
||||
if (trade.ourOffers.any { it.name == Constants.researchAgreement })
|
||||
diplomacyManager.setFlag(DiplomacyFlags.DeclinedResearchAgreement,20)
|
||||
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 })
|
||||
diplomacyManager.setFlag(DiplomacyFlags.DeclinedOpenBorders, 10)
|
||||
diplomacyManager.setFlag(DiplomacyFlags.DeclinedOpenBorders, if (decliningCiv.isAI()) 10 else 20)
|
||||
|
||||
if (trade.isPeaceTreaty()) diplomacyManager.setFlag(DiplomacyFlags.DeclinedPeace, 5)
|
||||
|
||||
|
@ -199,7 +199,7 @@ class AlertPopup(
|
||||
addLeaderName(otherciv)
|
||||
addGoodSizedLabel("My friend, shall we declare our friendship to the world?").row()
|
||||
addCloseButton("We are not interested.", KeyboardBinding.Cancel) {
|
||||
playerDiploManager.otherCivDiplomacy().setFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship, 10)
|
||||
playerDiploManager.otherCivDiplomacy().setFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship, 20)
|
||||
}.row()
|
||||
addCloseButton("Declare Friendship ([30] turns)", KeyboardBinding.Confirm) {
|
||||
playerDiploManager.signDeclarationOfFriendship()
|
||||
|
Reference in New Issue
Block a user