Warmongering doesn't apply to civs that are angry at the target civ (#11874)

* Team war now applies warmongering

* Shared war now applies to team war
This commit is contained in:
Oskar Niesen 2024-06-29 15:57:03 -05:00 committed by GitHub
parent dc09ab883b
commit 15d532e287
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,7 +36,7 @@ object DeclareWar {
onWarDeclared(diplomacyManager, true)
onWarDeclared(otherCivDiplomacy, false)
changeOpinions(diplomacyManager, declareWarReason.warType)
changeOpinions(diplomacyManager, declareWarReason)
breakTreaties(diplomacyManager)
@ -164,27 +164,31 @@ object DeclareWar {
diplomacyManager.removeFlag(DiplomacyFlags.BorderConflict)
}
private fun changeOpinions(diplomacyManager: DiplomacyManager, warType: WarType) {
private fun changeOpinions(diplomacyManager: DiplomacyManager, declareWarReason: DeclareWarReason) {
val civInfo = diplomacyManager.civInfo
val otherCiv = diplomacyManager.otherCiv()
val otherCivDiplomacy = diplomacyManager.otherCivDiplomacy()
val warType = declareWarReason.warType
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs, -20f)
otherCivDiplomacy.removeModifier(DiplomaticModifiers.ReturnedCapturedUnits)
// Apply warmongering
if (warType == WarType.DirectWar || warType == WarType.JoinWar) {
if (warType == WarType.DirectWar || warType == WarType.JoinWar || warType == WarType.TeamWar) {
for (thirdCiv in civInfo.getKnownCivs()) {
if (!thirdCiv.isAtWarWith(otherCiv))
// We don't want this modify to stack if there is a defensive pact
if (!thirdCiv.isAtWarWith(otherCiv)
&& thirdCiv.getDiplomacyManager(otherCiv)?.isRelationshipLevelGT(RelationshipLevel.Competitor) != false
&& thirdCiv != declareWarReason.allyCiv) {
// We don't want this modify to stack if there is a defensive pact
thirdCiv.getDiplomacyManager(civInfo)!!
.addModifier(DiplomaticModifiers.WarMongerer, -5f)
}
}
}
// Apply shared enemy modifiers
for (thirdCiv in diplomacyManager.getCommonKnownCivs()) {
if (thirdCiv.isAtWarWith(otherCiv) && !thirdCiv.isAtWarWith(civInfo)) {
if ((thirdCiv.isAtWarWith(otherCiv) || thirdCiv == declareWarReason.allyCiv) && !thirdCiv.isAtWarWith(civInfo)) {
// Improve our relations
if (thirdCiv.isCityState) thirdCiv.getDiplomacyManager(civInfo)!!.addInfluence(10f)
else thirdCiv.getDiplomacyManager(civInfo)!!.addModifier(DiplomaticModifiers.SharedEnemy, 5f * civInfo.getPersonality().modifierFocus(PersonalityValue.Loyal, .3f))