From 5c84eebb871b3a327b3f0b6fdc1f438e34721fb6 Mon Sep 17 00:00:00 2001 From: Oskar Niesen Date: Thu, 18 Jul 2024 09:52:49 -0500 Subject: [PATCH] Gift gold fix (#11972) * Fixed evaluateJoinOurWarPlan causing huge gold gift values * Reverted changes that slipped in * Changed the motivation from the thirdCivForce to be 1 based * Removed extra braces --- .../civilization/DeclareWarPlanEvaluator.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/automation/civilization/DeclareWarPlanEvaluator.kt b/core/src/com/unciv/logic/automation/civilization/DeclareWarPlanEvaluator.kt index 5e4c4b8245..b53b5aaf7c 100644 --- a/core/src/com/unciv/logic/automation/civilization/DeclareWarPlanEvaluator.kt +++ b/core/src/com/unciv/logic/automation/civilization/DeclareWarPlanEvaluator.kt @@ -114,7 +114,7 @@ object DeclareWarPlanEvaluator { /** * How much motivation [civInfo] has for [civToJoin] to join them in their war against [target]. * - * @return The movtivation of the plan. If it is > 0 then we can declare the war. + * @return The movtivation of the plan. If it is >= 0 then we can accept their war offer. */ fun evaluateJoinOurWarPlan(civInfo: Civilization, target: Civilization, civToJoin: Civilization, givenMotivation: Float?): Float { if (civInfo.getDiplomacyManager(civToJoin)!!.isRelationshipLevelLT(RelationshipLevel.Favorable)) return -1000f @@ -126,12 +126,15 @@ object DeclareWarPlanEvaluator { val targetForce = target.getStatForRanking(RankingType.Force) val civForce = civInfo.getStatForRanking(RankingType.Force) - // They need to be at least half the targets size + // If we have more force than all enemies and overpower this enemy then we don't need help + if (civForce - civInfo.threatManager.getCombinedForceOfWarringCivs() > targetForce * 2) return 0f + + // They should to be at least half the targets size val thirdCivForce = (civToJoin.getStatForRanking(RankingType.Force) - 0.8f * civToJoin.getCivsAtWarWith().sumOf { it.getStatForRanking(RankingType.Force) }).coerceAtLeast(100f) - motivation += 20 * thirdCivForce / targetForce.toFloat().coerceAtMost(40f) + motivation += (20 * (1 - thirdCivForce / targetForce.toFloat())).coerceAtMost(40f) // If we have less relative force then the target then we have more motivation to accept - motivation += 30 * (1 - (civForce / targetForce.toFloat())).coerceIn(-30f, 30f) + motivation += 20 * (1 - civForce / targetForce.toFloat()).coerceIn(-40f, 40f) return motivation - 20 }