From 4c5b30eb20f0fb65624630b001dc0d3b762adacf Mon Sep 17 00:00:00 2001 From: RecursiveVision <66801010+RecursiveVision@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:27:12 -0500 Subject: [PATCH] Add WorkWithWillingness & WorkAgainstWillingness --- .../Civilizations/CoreLeaderChanges.sql | 5 + .../Civilizations/LeaderTableChanges.sql | 6 +- .../Defines/DiploOpinionWeights.sql | 24 +- .../AI/LeaderPersonalitySweeps.sql | 86 +++++ CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp | 304 +++++++++++------- CvGameCoreDLL_Expansion2/CvDiplomacyAI.h | 42 +-- CvGameCoreDLL_Expansion2/CvInfos.cpp | 26 +- CvGameCoreDLL_Expansion2/CvInfos.h | 10 +- CvGameCoreDLL_Expansion2/CvVotingClasses.cpp | 63 ++-- 9 files changed, 367 insertions(+), 199 deletions(-) diff --git a/(1) Community Patch/Database Changes/Civilizations/CoreLeaderChanges.sql b/(1) Community Patch/Database Changes/Civilizations/CoreLeaderChanges.sql index 0bb971e72f..b1029b38ad 100644 --- a/(1) Community Patch/Database Changes/Civilizations/CoreLeaderChanges.sql +++ b/(1) Community Patch/Database Changes/Civilizations/CoreLeaderChanges.sql @@ -1,3 +1,8 @@ +-- Sets default WorkWithWillingness and WorkAgainstWillingness values for all base game leaders +-- These are unused base game columns that are being repurposed +UPDATE Leaders SET WorkWithWillingness = DoFWillingness; +UPDATE Leaders SET WorkAgainstWillingness = DenounceWillingness; + -- Sets default victory pursuits for all base game leaders CREATE TEMP TABLE Leader_VictoryPursuits ( TempLeaderType text, diff --git a/(1) Community Patch/Database Changes/Civilizations/LeaderTableChanges.sql b/(1) Community Patch/Database Changes/Civilizations/LeaderTableChanges.sql index 6559e47801..1da7dd6438 100644 --- a/(1) Community Patch/Database Changes/Civilizations/LeaderTableChanges.sql +++ b/(1) Community Patch/Database Changes/Civilizations/LeaderTableChanges.sql @@ -3,7 +3,7 @@ ---------------------------------- -- 3 new columns: Personality, PrimaryVictoryPursuit, SecondaryVictoryPursuit --- Default diplomacy flavors are now 5 (except Chattiness and unused columns) +-- Default diplomacy flavors are now 5 (except Chattiness) CREATE TABLE Leaders_NEW ( ID integer PRIMARY KEY, Type text NOT NULL UNIQUE, @@ -22,13 +22,13 @@ CREATE TABLE Leaders_NEW ( WarmongerHate integer DEFAULT 5, DoFWillingness integer DEFAULT 5, DenounceWillingness integer DEFAULT 5, + WorkWithWillingness integer DEFAULT 5, + WorkAgainstWillingness integer DEFAULT 5, Loyalty integer DEFAULT 5, Forgiveness integer DEFAULT 5, Neediness integer DEFAULT 5, Meanness integer DEFAULT 5, Chattiness integer DEFAULT 4, - WorkWithWillingness integer DEFAULT 0, -- unused - WorkAgainstWillingness integer DEFAULT 0, -- unused PortraitIndex integer DEFAULT -1, IconAtlas text REFERENCES IconTextureAtlases (Atlas), PackageID text diff --git a/(1) Community Patch/Database Changes/Defines/DiploOpinionWeights.sql b/(1) Community Patch/Database Changes/Defines/DiploOpinionWeights.sql index 7c86dfb0bd..3f59bd37dd 100644 --- a/(1) Community Patch/Database Changes/Defines/DiploOpinionWeights.sql +++ b/(1) Community Patch/Database Changes/Defines/DiploOpinionWeights.sql @@ -259,14 +259,14 @@ VALUES ('OPINION_WEIGHT_DENOUNCED_MOST_VALUED_ALLY', 10), -- denounced the AI's most valued DP (if they have a DoF with them) -- We have Denounced the same leaders! --- NOTE: This bonus scales based on the AI's DenounceWillingness flavor. +-- NOTE: This bonus scales based on the AI's WorkAgainstWillingness flavor. ('OPINION_WEIGHT_DENOUNCED_ENEMY', -20), ('OPINION_WEIGHT_DENOUNCED_ENEMY_SUBSEQUENT', -8), -- any after the first ('OPINION_WEIGHT_DENOUNCED_BIGGEST_COMPETITOR', -20), -- mutual denouncement against AI's biggest competitor ('OPINION_WEIGHT_DENOUNCED_BIGGEST_LEAGUE_RIVAL', -20), -- mutual denouncement against AI's biggest World Congress rival -- Other civs that they like more than you have denounced you! --- NOTE: This penalty scales inversely (negatively) based on the AI's DiploBalance flavor. +-- NOTE: This penalty scales based on the AI's WorkAgainstWillingness flavor. ('OPINION_WEIGHT_DENOUNCED_BY_THEIR_FRIEND', 15), ('OPINION_WEIGHT_DENOUNCED_BY_THEIR_FRIEND_SUBSEQUENT', 5), -- any after the first ('OPINION_WEIGHT_DENOUNCED_BY_THEIR_KEY_FRIEND', 15), -- additional penalty if the denouncement comes from a teammate or their most valued friend/ally @@ -402,7 +402,7 @@ VALUES ('OPINION_WEIGHT_DOF_TYPE_BATTLE_BROTHERS', -30), -- bonus for 3+ consecutive DoFs "" -- We have made Declarations of Friendship with the same leaders! --- NOTE: This bonus scales based on the AI's DoFWillingness flavor. +-- NOTE: This bonus scales based on the AI's WorkWithWillingness flavor. ('OPINION_WEIGHT_DOF_WITH_FRIEND', -20), ('OPINION_WEIGHT_DOF_WITH_FRIEND_SUBSEQUENT', -8), -- any after the first ('OPINION_WEIGHT_DOF_WITH_MOST_VALUED_FRIEND', -20), -- made a DoF with AI's most valued friend @@ -462,7 +462,7 @@ VALUES ('OPINION_WEIGHT_BETRAYED_OUR_FRIEND_MULTIPLIER', 200), -- multiplier to all traitor opinion penalties wherein the player betrayed or was betrayed by AI's friends or allies -- Your friends found reason to denounce you! --- NOTE: This penalty scales based on the AI's DenounceWillingness flavor. +-- NOTE: This penalty scales based on the AI's WorkAgainstWillingness flavor. ('OPINION_WEIGHT_DENOUNCED_BY_FRIEND_EACH', 20), -- if they like the denouncer more than you ('OPINION_WEIGHT_DENOUNCED_BY_FRIEND_DONT_LIKE', 10), -- if they like you more than the denouncer @@ -721,12 +721,12 @@ VALUES ('OPINION_WEIGHT_ATTACKED_PROTECTED_MINOR_NUM_TURNS_UNTIL_FORGIVEN', 30), -- scales with Protective approach bias towards City-States ('OPINION_WEIGHT_BULLIED_PROTECTED_MINOR_NUM_TURNS_UNTIL_FORGIVEN', 30), ('OPINION_WEIGHT_SIDED_WITH_THEIR_MINOR_NUM_TURNS_UNTIL_FORGIVEN', 10), - ('OPINION_WEIGHT_WE_LIKED_THEIR_PROPOSAL_NUM_TURNS', 50), -- scales with DoFWillingness - ('OPINION_WEIGHT_WE_DISLIKED_THEIR_PROPOSAL_NUM_TURNS', 50), -- scales with DenounceWillingness - ('OPINION_WEIGHT_THEY_SUPPORTED_OUR_PROPOSAL_NUM_TURNS', 50), -- scales with DoFWillingness and sometimes Neediness - ('OPINION_WEIGHT_THEY_FOILED_OUR_PROPOSAL_NUM_TURNS', 50), -- scales with DenounceWillingness and sometimes Forgiveness - ('OPINION_WEIGHT_THEY_SUPPORTED_OUR_HOSTING_NUM_TURNS', 50), -- scales with DoFWillingness - ('SANCTIONED_US_TURNS_UNTIL_FORGIVEN', 50), -- scales with Meanness if the attempt succeeded, DenounceWillingness otherwise - ('UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN', 50), -- scales with Loyalty if the attempt succeeded, DoFWillingness otherwise + ('OPINION_WEIGHT_WE_LIKED_THEIR_PROPOSAL_NUM_TURNS', 50), -- scales with WorkWithWillingness + ('OPINION_WEIGHT_WE_DISLIKED_THEIR_PROPOSAL_NUM_TURNS', 50), -- scales with WorkAgainstWillingness + ('OPINION_WEIGHT_THEY_SUPPORTED_OUR_PROPOSAL_NUM_TURNS', 50), -- scales with WorkWithWillingness and sometimes Neediness + ('OPINION_WEIGHT_THEY_FOILED_OUR_PROPOSAL_NUM_TURNS', 50), -- scales with WorkAgainstWillingness and sometimes Forgiveness + ('OPINION_WEIGHT_THEY_SUPPORTED_OUR_HOSTING_NUM_TURNS', 50), -- scales with WorkWithWillingness + ('SANCTIONED_US_TURNS_UNTIL_FORGIVEN', 50), -- scales with Meanness if the attempt succeeded, WorkAgainstWillingness otherwise + ('UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN', 50), -- scales with Loyalty if the attempt succeeded, WorkWithWillingness otherwise ('OPINION_WEIGHT_VASSALAGE_PEACEFULLY_REVOKED_NUM_TURNS_UNTIL_FORGOTTEN', 100), -- How many turns the "gave independence when asked" bonus remains for - ('OPINION_WEIGHT_VASSALAGE_FORCIBLY_REVOKED_NUM_TURNS_UNTIL_FORGIVEN', 100); -- How many turns the "refused to give independence" when asked penalty remains for + ('OPINION_WEIGHT_VASSALAGE_FORCIBLY_REVOKED_NUM_TURNS_UNTIL_FORGIVEN', 100); -- How many turns the "refused to give independence" when asked penalty remains for \ No newline at end of file diff --git a/(2) Vox Populi/Database Changes/AI/LeaderPersonalitySweeps.sql b/(2) Vox Populi/Database Changes/AI/LeaderPersonalitySweeps.sql index bbdc9ad21d..9732edaaf7 100644 --- a/(2) Vox Populi/Database Changes/AI/LeaderPersonalitySweeps.sql +++ b/(2) Vox Populi/Database Changes/AI/LeaderPersonalitySweeps.sql @@ -18,6 +18,8 @@ SET WarmongerHate = 5, DoFWillingness = 7, DenounceWillingness = 6, + WorkWithWillingness = 7, + WorkAgainstWillingness = 6, Loyalty = 4, Forgiveness = 5, Neediness = 6, @@ -57,6 +59,8 @@ SET WarmongerHate = 2, DoFWillingness = 5, DenounceWillingness = 7, + WorkWithWillingness = 5, + WorkAgainstWillingness = 7, Loyalty = 7, Forgiveness = 4, Neediness = 3, @@ -96,6 +100,8 @@ SET WarmongerHate = 7, DoFWillingness = 3, DenounceWillingness = 6, + WorkWithWillingness = 3, + WorkAgainstWillingness = 6, Loyalty = 3, Forgiveness = 5, Neediness = 9, @@ -134,6 +140,8 @@ SET WarmongerHate = 7, DoFWillingness = 4, DenounceWillingness = 7, + WorkWithWillingness = 4, + WorkAgainstWillingness = 7, Loyalty = 1, Forgiveness = 3, Neediness = 6, @@ -172,6 +180,8 @@ SET WarmongerHate = 2, DoFWillingness = 3, DenounceWillingness = 5, + WorkWithWillingness = 3, + WorkAgainstWillingness = 5, Loyalty = 3, Forgiveness = 8, Neediness = 10, @@ -210,6 +220,8 @@ SET WarmongerHate = 5, DoFWillingness = 2, DenounceWillingness = 2, + WorkWithWillingness = 2, + WorkAgainstWillingness = 2, Loyalty = 3, Forgiveness = 1, Neediness = 4, @@ -248,6 +260,8 @@ SET WarmongerHate = 8, DoFWillingness = 8, DenounceWillingness = 5, + WorkWithWillingness = 8, + WorkAgainstWillingness = 5, Loyalty = 6, Forgiveness = 8, Neediness = 5, @@ -285,6 +299,8 @@ SET WarmongerHate = 9, DoFWillingness = 6, DenounceWillingness = 6, + WorkWithWillingness = 6, + WorkAgainstWillingness = 6, Loyalty = 6, Forgiveness = 6, Neediness = 7, @@ -322,6 +338,8 @@ SET WarmongerHate = 7, DoFWillingness = 5, DenounceWillingness = 7, + WorkWithWillingness = 5, + WorkAgainstWillingness = 7, Loyalty = 9, Forgiveness = 2, Neediness = 8, @@ -361,6 +379,8 @@ SET WarmongerHate = 4, DoFWillingness = 6, DenounceWillingness = 9, + WorkWithWillingness = 6, + WorkAgainstWillingness = 9, Loyalty = 7, Forgiveness = 6, Neediness = 9, @@ -399,6 +419,8 @@ SET WarmongerHate = 4, DoFWillingness = 5, DenounceWillingness = 6, + WorkWithWillingness = 5, + WorkAgainstWillingness = 6, Loyalty = 5, Forgiveness = 5, Neediness = 5, @@ -438,6 +460,8 @@ SET WarmongerHate = 6, DoFWillingness = 6, DenounceWillingness = 4, + WorkWithWillingness = 6, + WorkAgainstWillingness = 4, Loyalty = 8, Forgiveness = 3, Neediness = 8, @@ -477,6 +501,8 @@ SET WarmongerHate = 5, DoFWillingness = 6, DenounceWillingness = 8, + WorkWithWillingness = 6, + WorkAgainstWillingness = 8, Loyalty = 6, Forgiveness = 4, Neediness = 7, @@ -515,6 +541,8 @@ SET WarmongerHate = 12, DoFWillingness = 10, DenounceWillingness = 7, + WorkWithWillingness = 10, + WorkAgainstWillingness = 7, Loyalty = 5, Forgiveness = 7, Neediness = 7, @@ -554,6 +582,8 @@ SET WarmongerHate = 4, DoFWillingness = 7, DenounceWillingness = 6, + WorkWithWillingness = 7, + WorkAgainstWillingness = 6, Loyalty = 10, Forgiveness = 7, Neediness = 3, @@ -593,6 +623,8 @@ SET WarmongerHate = 12, DoFWillingness = 10, DenounceWillingness = 8, + WorkWithWillingness = 10, + WorkAgainstWillingness = 8, Loyalty = 10, Forgiveness = 7, Neediness = 5, @@ -631,6 +663,8 @@ SET WarmongerHate = 3, DoFWillingness = 7, DenounceWillingness = 4, + WorkWithWillingness = 7, + WorkAgainstWillingness = 4, Loyalty = 8, Forgiveness = 1, Neediness = 8, @@ -669,6 +703,8 @@ SET WarmongerHate = 4, DoFWillingness = 2, DenounceWillingness = 6, + WorkWithWillingness = 2, + WorkAgainstWillingness = 6, Loyalty = 2, Forgiveness = 4, Neediness = 7, @@ -708,6 +744,8 @@ SET WarmongerHate = 8, DoFWillingness = 6, DenounceWillingness = 6, + WorkWithWillingness = 6, + WorkAgainstWillingness = 6, Loyalty = 5, Forgiveness = 5, Neediness = 5, @@ -746,6 +784,8 @@ SET WarmongerHate = 1, DoFWillingness = 8, DenounceWillingness = 5, + WorkWithWillingness = 8, + WorkAgainstWillingness = 5, Loyalty = 3, Forgiveness = 4, Neediness = 8, @@ -784,6 +824,8 @@ SET WarmongerHate = 9, DoFWillingness = 8, DenounceWillingness = 8, + WorkWithWillingness = 8, + WorkAgainstWillingness = 8, Loyalty = 3, Forgiveness = 4, Neediness = 8, @@ -823,6 +865,8 @@ SET WarmongerHate = 7, DoFWillingness = 8, DenounceWillingness = 7, + WorkWithWillingness = 8, + WorkAgainstWillingness = 7, Loyalty = 9, Forgiveness = 10, Neediness = 3, @@ -862,6 +906,8 @@ SET WarmongerHate = 4, DoFWillingness = 4, DenounceWillingness = 8, + WorkWithWillingness = 4, + WorkAgainstWillingness = 8, Loyalty = 6, Forgiveness = 4, Neediness = 8, @@ -900,6 +946,8 @@ SET WarmongerHate = 7, DoFWillingness = 9, DenounceWillingness = 4, + WorkWithWillingness = 9, + WorkAgainstWillingness = 4, Loyalty = 8, Forgiveness = 6, Neediness = 4, @@ -938,6 +986,8 @@ SET WarmongerHate = 9, DoFWillingness = 8, DenounceWillingness = 8, + WorkWithWillingness = 8, + WorkAgainstWillingness = 8, Loyalty = 9, Forgiveness = 7, Neediness = 3, @@ -977,6 +1027,8 @@ SET WarmongerHate = 10, DoFWillingness = 7, DenounceWillingness = 9, + WorkWithWillingness = 7, + WorkAgainstWillingness = 9, Loyalty = 5, Forgiveness = 6, Neediness = 8, @@ -1015,6 +1067,8 @@ SET WarmongerHate = -1, DoFWillingness = 5, DenounceWillingness = 7, + WorkWithWillingness = 5, + WorkAgainstWillingness = 7, Loyalty = 4, Forgiveness = 3, Neediness = 9, @@ -1054,6 +1108,8 @@ SET WarmongerHate = 3, DoFWillingness = 7, DenounceWillingness = 8, + WorkWithWillingness = 7, + WorkAgainstWillingness = 8, Loyalty = 4, Forgiveness = 8, Neediness = 7, @@ -1092,6 +1148,8 @@ SET WarmongerHate = 8, DoFWillingness = 3, DenounceWillingness = 5, + WorkWithWillingness = 3, + WorkAgainstWillingness = 5, Loyalty = 8, Forgiveness = 5, Neediness = 2, @@ -1131,6 +1189,8 @@ SET WarmongerHate = 5, DoFWillingness = 6, DenounceWillingness = 6, + WorkWithWillingness = 6, + WorkAgainstWillingness = 6, Loyalty = 2, Forgiveness = 1, Neediness = 7, @@ -1170,6 +1230,8 @@ SET WarmongerHate = 6, DoFWillingness = 7, DenounceWillingness = 6, + WorkWithWillingness = 7, + WorkAgainstWillingness = 6, Loyalty = 6, Forgiveness = 6, Neediness = 5, @@ -1208,6 +1270,8 @@ SET WarmongerHate = 7, DoFWillingness = 4, DenounceWillingness = 6, + WorkWithWillingness = 4, + WorkAgainstWillingness = 6, Loyalty = 7, Forgiveness = 5, Neediness = 5, @@ -1246,6 +1310,8 @@ SET WarmongerHate = 10, DoFWillingness = 10, DenounceWillingness = 8, + WorkWithWillingness = 10, + WorkAgainstWillingness = 8, Loyalty = 9, Forgiveness = 3, Neediness = 8, @@ -1283,6 +1349,8 @@ SET WarmongerHate = 8, DoFWillingness = 5, DenounceWillingness = 7, + WorkWithWillingness = 5, + WorkAgainstWillingness = 7, Loyalty = 9, Forgiveness = 2, Neediness = 6, @@ -1321,6 +1389,8 @@ SET WarmongerHate = 8, DoFWillingness = 3, DenounceWillingness = 8, + WorkWithWillingness = 3, + WorkAgainstWillingness = 8, Loyalty = 5, Forgiveness = 4, Neediness = 9, @@ -1359,6 +1429,8 @@ SET WarmongerHate = 9, DoFWillingness = 9, DenounceWillingness = 6, + WorkWithWillingness = 9, + WorkAgainstWillingness = 6, Loyalty = 7, Forgiveness = 7, Neediness = 4, @@ -1397,6 +1469,8 @@ SET WarmongerHate = 10, DoFWillingness = 9, DenounceWillingness = 4, + WorkWithWillingness = 9, + WorkAgainstWillingness = 4, Loyalty = 9, Forgiveness = 4, Neediness = 3, @@ -1435,6 +1509,8 @@ SET WarmongerHate = 1, DoFWillingness = 5, DenounceWillingness = 7, + WorkWithWillingness = 5, + WorkAgainstWillingness = 7, Loyalty = 3, Forgiveness = 2, Neediness = 5, @@ -1474,6 +1550,8 @@ SET WarmongerHate = 4, DoFWillingness = 7, DenounceWillingness = 2, + WorkWithWillingness = 7, + WorkAgainstWillingness = 2, Loyalty = 8, Forgiveness = 7, Neediness = 8, @@ -1511,6 +1589,8 @@ SET WarmongerHate = 8, DoFWillingness = 10, DenounceWillingness = 8, + WorkWithWillingness = 10, + WorkAgainstWillingness = 8, Loyalty = 5, Forgiveness = 7, Neediness = 9, @@ -1548,6 +1628,8 @@ SET WarmongerHate = 6, DoFWillingness = 8, DenounceWillingness = 9, + WorkWithWillingness = 8, + WorkAgainstWillingness = 9, Loyalty = 5, Forgiveness = 4, Neediness = 10, @@ -1586,6 +1668,8 @@ SET WarmongerHate = 8, DoFWillingness = 10, DenounceWillingness = 3, + WorkWithWillingness = 10, + WorkAgainstWillingness = 3, Loyalty = 6, Forgiveness = 8, Neediness = 8, @@ -1625,6 +1709,8 @@ SET WarmongerHate = 9, DoFWillingness = 5, DenounceWillingness = 10, + WorkWithWillingness = 5, + WorkAgainstWillingness = 10, Loyalty = 4, Forgiveness = 5, Neediness = 9, diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp index 8a9c967cdb..b63f2778f0 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp @@ -73,6 +73,8 @@ void CvDiplomacyAI::Init(CvPlayer* pPlayer) m_iWarmongerHate = 5; m_iDoFWillingness = 5; m_iDenounceWillingness = 5; + m_iWorkWithWillingness = 5; + m_iWorkAgainstWillingness = 5; m_iLoyalty = 5; m_iForgiveness = 5; m_iNeediness = 5; @@ -425,6 +427,8 @@ void CvDiplomacyAI::Serialize(DiplomacyAI& diplomacyAI, Visitor& visitor) visitor(diplomacyAI.m_iWarmongerHate); visitor(diplomacyAI.m_iDoFWillingness); visitor(diplomacyAI.m_iDenounceWillingness); + visitor(diplomacyAI.m_iWorkWithWillingness); + visitor(diplomacyAI.m_iWorkAgainstWillingness); visitor(diplomacyAI.m_iLoyalty); visitor(diplomacyAI.m_iForgiveness); visitor(diplomacyAI.m_iNeediness); @@ -978,6 +982,8 @@ void CvDiplomacyAI::SlotStateChange() m_iWarmongerHate = 5; m_iDoFWillingness = 5; m_iDenounceWillingness = 5; + m_iWorkWithWillingness = 5; + m_iWorkAgainstWillingness = 5; m_iLoyalty = 5; m_iForgiveness = 5; m_iNeediness = 5; @@ -1848,7 +1854,7 @@ bool CvDiplomacyAI::IsNuclearGandhi(bool bPotentially) const // ************************************ /// Returns a personality weight with a small random element -int CvDiplomacyAI::GetRandomPersonalityWeight(int iOriginalValue, const CvSeeder& seed) +int CvDiplomacyAI::RandomizePersonalityFlavor(int iOriginalValue, const CvSeeder& seed) { int iPlusMinus = range(/*2*/ GD_INT_GET(FLAVOR_RANDOMIZATION_RANGE), 0, (INT_MAX - 1) / 2); @@ -1876,35 +1882,37 @@ void CvDiplomacyAI::DoInitializePersonality(bool bFirstInit) CvLeaderHeadInfo* pkLeaderHeadInfo = GC.getLeaderHeadInfo(leader); if (pkLeaderHeadInfo) { - // Some flavors can be set to -12 to guarantee that the AI will pursue a specific victory condition, if it is enabled. + // Four flavors can be set to -12 to guarantee that the AI will pursue a specific victory condition, if it is enabled. // These should be treated as a 10 for all other purposes. - m_iBoldness = pkLeaderHeadInfo->GetBoldness() == -12 ? 10 : GetRandomPersonalityWeight(pkLeaderHeadInfo->GetBoldness(), CvSeeder::fromRaw(0x0ba129a6).mix(ID)); - m_iMinorCivCompetitiveness = pkLeaderHeadInfo->GetMinorCivCompetitiveness() == -12 ? 10 : GetRandomPersonalityWeight(pkLeaderHeadInfo->GetMinorCivCompetitiveness(), CvSeeder::fromRaw(0x4f28f23d).mix(ID)); - m_iWonderCompetitiveness = pkLeaderHeadInfo->GetWonderCompetitiveness() == -12 ? 10 : GetRandomPersonalityWeight(pkLeaderHeadInfo->GetWonderCompetitiveness(), CvSeeder::fromRaw(0x69d26397).mix(ID)); - m_iWarmongerHate = pkLeaderHeadInfo->GetWarmongerHate() == -12 ? 10 : GetRandomPersonalityWeight(pkLeaderHeadInfo->GetWarmongerHate(), CvSeeder::fromRaw(0x8e1f1b1f).mix(ID)); - - m_iVictoryCompetitiveness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetVictoryCompetitiveness(), CvSeeder::fromRaw(0x5bea8e77).mix(ID)); - m_iDiploBalance = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetDiploBalance(), CvSeeder::fromRaw(0x2f543039).mix(ID)); - m_iDoFWillingness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetDoFWillingness(), CvSeeder::fromRaw(0x2a36ee5b).mix(ID)); - m_iDenounceWillingness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetDenounceWillingness(), CvSeeder::fromRaw(0x84da8912).mix(ID)); - m_iLoyalty = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetLoyalty(), CvSeeder::fromRaw(0x52c2cdd2).mix(ID)); - m_iForgiveness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetForgiveness(), CvSeeder::fromRaw(0x81d9b8ec).mix(ID)); - m_iNeediness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetNeediness(), CvSeeder::fromRaw(0xc0dd3363).mix(ID)); - m_iMeanness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetMeanness(), CvSeeder::fromRaw(0x24ca13c9).mix(ID)); - m_iChattiness = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetChattiness(), CvSeeder::fromRaw(0x5227bf3a).mix(ID)); - - m_aiMajorCivApproachBiases[CIV_APPROACH_WAR] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetWarBias(false), CvSeeder::fromRaw(0xe48d2e04).mix(ID)); - m_aiMajorCivApproachBiases[CIV_APPROACH_HOSTILE] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetHostileBias(false), CvSeeder::fromRaw(0x49b046ba).mix(ID)); - m_aiMajorCivApproachBiases[CIV_APPROACH_DECEPTIVE] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetDeceptiveBias(), CvSeeder::fromRaw(0xa9bc4713).mix(ID)); - m_aiMajorCivApproachBiases[CIV_APPROACH_GUARDED] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetGuardedBias(), CvSeeder::fromRaw(0xab8795d6).mix(ID)); - m_aiMajorCivApproachBiases[CIV_APPROACH_AFRAID] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetAfraidBias(), CvSeeder::fromRaw(0x9a90c196).mix(ID)); - m_aiMajorCivApproachBiases[CIV_APPROACH_NEUTRAL] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetNeutralBias(false), CvSeeder::fromRaw(0xf7729147).mix(ID)); - m_aiMajorCivApproachBiases[CIV_APPROACH_FRIENDLY] = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetFriendlyBias(false), CvSeeder::fromRaw(0x7fecee06).mix(ID)); - - m_iMinorCivWarBias = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetWarBias(true), CvSeeder::fromRaw(0x0be73829).mix(ID)); - m_iMinorCivHostileBias = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetHostileBias(true), CvSeeder::fromRaw(0xc44465ee).mix(ID)); - m_iMinorCivNeutralBias = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetNeutralBias(true), CvSeeder::fromRaw(0x4087c177).mix(ID)); - m_iMinorCivFriendlyBias = GetRandomPersonalityWeight(pkLeaderHeadInfo->GetFriendlyBias(true), CvSeeder::fromRaw(0x4565d312).mix(ID)); + m_iBoldness = pkLeaderHeadInfo->GetBoldness() == -12 ? 10 : RandomizePersonalityFlavor(pkLeaderHeadInfo->GetBoldness(), CvSeeder::fromRaw(0x0ba129a6).mix(ID)); + m_iMinorCivCompetitiveness = pkLeaderHeadInfo->GetMinorCivCompetitiveness() == -12 ? 10 : RandomizePersonalityFlavor(pkLeaderHeadInfo->GetMinorCivCompetitiveness(), CvSeeder::fromRaw(0x4f28f23d).mix(ID)); + m_iWonderCompetitiveness = pkLeaderHeadInfo->GetWonderCompetitiveness() == -12 ? 10 : RandomizePersonalityFlavor(pkLeaderHeadInfo->GetWonderCompetitiveness(), CvSeeder::fromRaw(0x69d26397).mix(ID)); + m_iWarmongerHate = pkLeaderHeadInfo->GetWarmongerHate() == -12 ? 10 : RandomizePersonalityFlavor(pkLeaderHeadInfo->GetWarmongerHate(), CvSeeder::fromRaw(0x8e1f1b1f).mix(ID)); + + m_iVictoryCompetitiveness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetVictoryCompetitiveness(), CvSeeder::fromRaw(0x5bea8e77).mix(ID)); + m_iDiploBalance = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetDiploBalance(), CvSeeder::fromRaw(0x2f543039).mix(ID)); + m_iDoFWillingness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetDoFWillingness(), CvSeeder::fromRaw(0x2a36ee5b).mix(ID)); + m_iDenounceWillingness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetDenounceWillingness(), CvSeeder::fromRaw(0x84da8912).mix(ID)); + m_iWorkWithWillingness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetWorkWithWillingness(), CvSeeder::fromRaw(0x5f5224db).mix(ID)); + m_iWorkAgainstWillingness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetWorkAgainstWillingness(), CvSeeder::fromRaw(0xbe85dbdb).mix(ID)); + m_iLoyalty = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetLoyalty(), CvSeeder::fromRaw(0x52c2cdd2).mix(ID)); + m_iForgiveness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetForgiveness(), CvSeeder::fromRaw(0x81d9b8ec).mix(ID)); + m_iNeediness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetNeediness(), CvSeeder::fromRaw(0xc0dd3363).mix(ID)); + m_iMeanness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetMeanness(), CvSeeder::fromRaw(0x24ca13c9).mix(ID)); + m_iChattiness = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetChattiness(), CvSeeder::fromRaw(0x5227bf3a).mix(ID)); + + m_aiMajorCivApproachBiases[CIV_APPROACH_WAR] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetWarBias(false), CvSeeder::fromRaw(0xe48d2e04).mix(ID)); + m_aiMajorCivApproachBiases[CIV_APPROACH_HOSTILE] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetHostileBias(false), CvSeeder::fromRaw(0x49b046ba).mix(ID)); + m_aiMajorCivApproachBiases[CIV_APPROACH_DECEPTIVE] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetDeceptiveBias(), CvSeeder::fromRaw(0xa9bc4713).mix(ID)); + m_aiMajorCivApproachBiases[CIV_APPROACH_GUARDED] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetGuardedBias(), CvSeeder::fromRaw(0xab8795d6).mix(ID)); + m_aiMajorCivApproachBiases[CIV_APPROACH_AFRAID] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetAfraidBias(), CvSeeder::fromRaw(0x9a90c196).mix(ID)); + m_aiMajorCivApproachBiases[CIV_APPROACH_NEUTRAL] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetNeutralBias(false), CvSeeder::fromRaw(0xf7729147).mix(ID)); + m_aiMajorCivApproachBiases[CIV_APPROACH_FRIENDLY] = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetFriendlyBias(false), CvSeeder::fromRaw(0x7fecee06).mix(ID)); + + m_iMinorCivWarBias = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetWarBias(true), CvSeeder::fromRaw(0x0be73829).mix(ID)); + m_iMinorCivHostileBias = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetHostileBias(true), CvSeeder::fromRaw(0xc44465ee).mix(ID)); + m_iMinorCivNeutralBias = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetNeutralBias(true), CvSeeder::fromRaw(0x4087c177).mix(ID)); + m_iMinorCivFriendlyBias = RandomizePersonalityFlavor(pkLeaderHeadInfo->GetFriendlyBias(true), CvSeeder::fromRaw(0x4565d312).mix(ID)); // Minimal loyalty? We're willing to backstab. if (GetLoyalty() <= 2) @@ -2719,12 +2727,24 @@ int CvDiplomacyAI::GetDoFWillingness() const return m_iDoFWillingness; } -/// How much is this AI leader willing to work with someone AGAINST another player? +/// How much is this AI leader willing to badmouth other players? int CvDiplomacyAI::GetDenounceWillingness() const { return m_iDenounceWillingness; } +/// How much is this AI leader willing to form strategic alliances WITH others? +int CvDiplomacyAI::GetWorkWithWillingness() const +{ + return m_iWorkWithWillingness; +} + +/// How much is this AI leader willing to form strategic alliances AGAINST others? +int CvDiplomacyAI::GetWorkAgainstWillingness() const +{ + return m_iWorkAgainstWillingness; +} + /// How likely is this AI leader to refrain from backstabbing their friends? int CvDiplomacyAI::GetLoyalty() const { @@ -16587,14 +16607,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool if (pLeague != NULL) { - iDiploMultiplier = IsCompetingForVictory() && IsGoingForDiploVictory() ? 3 : 1; - - if (GetDiploBalance() >= 8) - iDiploMultiplier += 1; - else if (GetDiploBalance() <= 3) - iDiploMultiplier -= 1; - - iDiploMultiplier = max(iDiploMultiplier, 1); + iDiploMultiplier = IsCompetingForVictory() && IsGoingForDiploVictory() ? AdjustConditionalModifier(300, GetDiploBalance()) : AdjustConditionalModifier(100, GetDiploBalance()); CvLeagueAI::AlignmentLevels eAlignment = (GetPlayer()->GetLeagueAI()->EvaluateAlignment(ePlayer, /*bIgnoreWar*/ true)); // Our prime league competitor isn't considered aligned with our interests... @@ -16605,11 +16618,11 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool if (IsGoingForDiploVictory()) iDiploMultiplier = 0; else - iDiploMultiplier--; + iDiploMultiplier -= AdjustConditionalModifier(100, GetWorkAgainstWillingness()); } if (bTheyAreCloseToDiploVictory) { - iDiploMultiplier--; + iDiploMultiplier -= AdjustConditionalModifier(100, GetWorkAgainstWillingness()); } iDiploMultiplier = max(iDiploMultiplier, 0); @@ -16620,42 +16633,42 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool case CvLeagueAI::ALIGNMENT_SELF: case CvLeagueAI::ALIGNMENT_TEAMMATE: case CvLeagueAI::ALIGNMENT_LEADER: + case CvLeagueAI::ALIGNMENT_WAR: UNREACHABLE(); case CvLeagueAI::ALIGNMENT_ENEMY: - vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * GetDiploBalance() * iDiploMultiplier; - vApproachScores[CIV_APPROACH_HOSTILE] += vApproachBias[CIV_APPROACH_HOSTILE] * GetDiploBalance() * iDiploMultiplier; - vApproachScores[CIV_APPROACH_DECEPTIVE] += bApplyDeception ? vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier : 0; + vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * GetWorkAgainstWillingness() * iDiploMultiplier / 100; + vApproachScores[CIV_APPROACH_HOSTILE] += vApproachBias[CIV_APPROACH_HOSTILE] * GetWorkAgainstWillingness() * iDiploMultiplier / 100; + vApproachScores[CIV_APPROACH_DECEPTIVE] += bApplyDeception ? vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkAgainstWillingness() * iDiploMultiplier / 100 : 0; break; - case CvLeagueAI::ALIGNMENT_WAR: case CvLeagueAI::ALIGNMENT_HATRED: - vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * GetDiploBalance() * iDiploMultiplier / 2; - vApproachScores[CIV_APPROACH_HOSTILE] += vApproachBias[CIV_APPROACH_HOSTILE] * GetDiploBalance() * iDiploMultiplier / 2; - vApproachScores[CIV_APPROACH_DECEPTIVE] += vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier / 2; + vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * GetWorkAgainstWillingness() * iDiploMultiplier / 200; + vApproachScores[CIV_APPROACH_HOSTILE] += vApproachBias[CIV_APPROACH_HOSTILE] * GetWorkAgainstWillingness() * iDiploMultiplier / 200; + vApproachScores[CIV_APPROACH_DECEPTIVE] += vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkAgainstWillingness() * iDiploMultiplier / 200; break; case CvLeagueAI::ALIGNMENT_RIVAL: - vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * GetDiploBalance() * iDiploMultiplier / 3; - vApproachScores[CIV_APPROACH_DECEPTIVE] += vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier / 3; - vApproachScores[CIV_APPROACH_GUARDED] += vApproachBias[CIV_APPROACH_GUARDED] * GetDiploBalance() * iDiploMultiplier / 3; + vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * GetWorkAgainstWillingness() * iDiploMultiplier / 300; + vApproachScores[CIV_APPROACH_DECEPTIVE] += vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkAgainstWillingness() * iDiploMultiplier / 300; + vApproachScores[CIV_APPROACH_GUARDED] += vApproachBias[CIV_APPROACH_GUARDED] * GetWorkAgainstWillingness() * iDiploMultiplier / 300; break; case CvLeagueAI::ALIGNMENT_NEUTRAL: - vApproachScores[CIV_APPROACH_NEUTRAL] += vApproachBias[CIV_APPROACH_NEUTRAL] * GetDiploBalance() * iDiploMultiplier / 2; + vApproachScores[CIV_APPROACH_NEUTRAL] += vApproachBias[CIV_APPROACH_NEUTRAL] * GetDiploBalance() * iDiploMultiplier / 200; break; case CvLeagueAI::ALIGNMENT_FRIEND: - vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetDiploBalance() * iDiploMultiplier / 3; - vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier / 3; + vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetWorkWithWillingness() * iDiploMultiplier / 300; + vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkWithWillingness() * iDiploMultiplier / 300; break; case CvLeagueAI::ALIGNMENT_CONFIDANT: - vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetDiploBalance() * iDiploMultiplier / 2; - vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier / 2; + vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetWorkWithWillingness() * iDiploMultiplier / 200; + vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkWithWillingness() * iDiploMultiplier / 200; break; case CvLeagueAI::ALIGNMENT_ALLY: - vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetDiploBalance() * iDiploMultiplier; - vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier; + vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetWorkWithWillingness() * iDiploMultiplier / 100; + vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkWithWillingness() * iDiploMultiplier / 100; break; case CvLeagueAI::ALIGNMENT_LIBERATOR: - vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetDiploBalance() * iDiploMultiplier * 2; - vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetDiploBalance() * iDiploMultiplier * 2; - break; + vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] * GetWorkWithWillingness() * iDiploMultiplier / 50; + vApproachScores[CIV_APPROACH_DECEPTIVE] -= vApproachBias[CIV_APPROACH_DECEPTIVE] * GetWorkWithWillingness() * iDiploMultiplier / 50; + break; } } @@ -17846,11 +17859,11 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool } } - vApproachScores[CIV_APPROACH_NEUTRAL] += AdjustConditionalModifier(iSameEnemyNeutralBonus, GetDenounceWillingness()); - vApproachScores[CIV_APPROACH_FRIENDLY] += AdjustConditionalModifier(iSameEnemyFriendlyBonus, GetDenounceWillingness()) + AdjustConditionalModifier(iSameFriendFriendlyBonus, GetDoFWillingness()) + AdjustConditionalModifier(iSameDPFriendlyBonus, GetWarmongerHate()); - vApproachScores[CIV_APPROACH_WAR] -= AdjustConditionalModifier(iSameFriendWarReduction, GetDoFWillingness()) + AdjustConditionalModifier(iSameDPWarReduction, GetWarmongerHate()); - vApproachScores[CIV_APPROACH_HOSTILE] -= AdjustConditionalModifier(iSameFriendHostileReduction, GetDoFWillingness()) + AdjustConditionalModifier(iSameDPHostileReduction, GetWarmongerHate()); - vApproachScores[CIV_APPROACH_GUARDED] -= AdjustConditionalModifier(iSameFriendGuardedReduction, GetDoFWillingness()) + AdjustConditionalModifier(iSameDPGuardedReduction, GetWarmongerHate()); + vApproachScores[CIV_APPROACH_NEUTRAL] += AdjustConditionalModifier(iSameEnemyNeutralBonus, GetWorkAgainstWillingness()); + vApproachScores[CIV_APPROACH_FRIENDLY] += AdjustConditionalModifier(iSameEnemyFriendlyBonus, GetWorkAgainstWillingness()) + AdjustConditionalModifier(iSameFriendFriendlyBonus, GetWorkWithWillingness()) + AdjustConditionalModifier(iSameDPFriendlyBonus, GetWarmongerHate()); + vApproachScores[CIV_APPROACH_WAR] -= AdjustConditionalModifier(iSameFriendWarReduction, GetWorkWithWillingness()) + AdjustConditionalModifier(iSameDPWarReduction, GetWarmongerHate()); + vApproachScores[CIV_APPROACH_HOSTILE] -= AdjustConditionalModifier(iSameFriendHostileReduction, GetWorkWithWillingness()) + AdjustConditionalModifier(iSameDPHostileReduction, GetWarmongerHate()); + vApproachScores[CIV_APPROACH_GUARDED] -= AdjustConditionalModifier(iSameFriendGuardedReduction, GetWorkWithWillingness()) + AdjustConditionalModifier(iSameDPGuardedReduction, GetWarmongerHate()); } // Reduce global penalties for religion/ideology, if appropriate. @@ -18055,10 +18068,10 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool iDenouncedByFriendGuardedReduction += vApproachBias[CIV_APPROACH_GUARDED]; } - // Need to add these ones now as they depend on the OTHER player's DenounceWillingness flavor - int iLoopDenounceWillingness = GetEstimatePlayerDenounceWillingness(eLoopPlayer); - vApproachScores[CIV_APPROACH_GUARDED] -= bEarlyGameCompetitor && GET_PLAYER(eLoopPlayer).GetCurrentEra() <= 2 ? AdjustConditionalModifier(iDenouncedByFriendGuardedReduction * 2, iLoopDenounceWillingness) : AdjustConditionalModifier(iDenouncedByFriendGuardedReduction, iLoopDenounceWillingness); - vApproachScores[CIV_APPROACH_AFRAID] -= bEarlyGameCompetitor && GET_PLAYER(eLoopPlayer).GetCurrentEra() <= 2 ? AdjustConditionalModifier(iDenouncedByFriendAfraidReduction * 2, iLoopDenounceWillingness) : AdjustConditionalModifier(iDenouncedByFriendAfraidReduction, iLoopDenounceWillingness); + // Need to add these ones now as they depend on the OTHER player's WorkAgainstWillingness flavor + int iLoopWorkAgainstWillingness = EstimateWorkAgainstWillingness(eLoopPlayer); + vApproachScores[CIV_APPROACH_GUARDED] -= bEarlyGameCompetitor && GET_PLAYER(eLoopPlayer).GetCurrentEra() <= 2 ? AdjustConditionalModifier(iDenouncedByFriendGuardedReduction * 2, iLoopWorkAgainstWillingness) : AdjustConditionalModifier(iDenouncedByFriendGuardedReduction, iLoopWorkAgainstWillingness); + vApproachScores[CIV_APPROACH_AFRAID] -= bEarlyGameCompetitor && GET_PLAYER(eLoopPlayer).GetCurrentEra() <= 2 ? AdjustConditionalModifier(iDenouncedByFriendAfraidReduction * 2, iLoopWorkAgainstWillingness) : AdjustConditionalModifier(iDenouncedByFriendAfraidReduction, iLoopWorkAgainstWillingness); } if (!pTheirDiplo->IsDenouncedPlayer(eLoopPlayer)) // Do not stack with above modifier to avoid excessive religious/ideological fervor. @@ -18087,11 +18100,11 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool } } - vApproachScores[CIV_APPROACH_WAR] += AdjustConditionalModifier(iFriendsWithEnemyWarPenalty, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendWarPenalty, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendWarPenalty, GetDiploBalance(), true); - vApproachScores[CIV_APPROACH_HOSTILE] += AdjustConditionalModifier(iFriendsWithEnemyHostilePenalty, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendHostilePenalty, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendHostilePenalty, GetDiploBalance(), true); - vApproachScores[CIV_APPROACH_DECEPTIVE] += AdjustConditionalModifier(iFriendsWithEnemyDeceptivePenalty, GetNeediness()) - AdjustConditionalModifier(iEnemiesWithFriendDeceptiveReduction, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendDeceptivePenalty, GetDiploBalance(), true); + vApproachScores[CIV_APPROACH_WAR] += AdjustConditionalModifier(iFriendsWithEnemyWarPenalty, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendWarPenalty, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendWarPenalty, GetWorkAgainstWillingness()); + vApproachScores[CIV_APPROACH_HOSTILE] += AdjustConditionalModifier(iFriendsWithEnemyHostilePenalty, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendHostilePenalty, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendHostilePenalty, GetWorkAgainstWillingness()); + vApproachScores[CIV_APPROACH_DECEPTIVE] += AdjustConditionalModifier(iFriendsWithEnemyDeceptivePenalty, GetNeediness()) - AdjustConditionalModifier(iEnemiesWithFriendDeceptiveReduction, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendDeceptivePenalty, GetWorkAgainstWillingness()); vApproachScores[CIV_APPROACH_GUARDED] += AdjustConditionalModifier(iFriendsWithEnemyGuardedPenalty, GetNeediness()); - vApproachScores[CIV_APPROACH_FRIENDLY] -= AdjustConditionalModifier(iFriendsWithEnemyFriendlyReduction, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendFriendlyReduction, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendFriendlyReduction, GetDiploBalance(), true); + vApproachScores[CIV_APPROACH_FRIENDLY] -= AdjustConditionalModifier(iFriendsWithEnemyFriendlyReduction, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendFriendlyReduction, GetLoyalty()) + AdjustConditionalModifier(iDenouncedByFriendFriendlyReduction, GetWorkAgainstWillingness()); vApproachScores[CIV_APPROACH_NEUTRAL] -= AdjustConditionalModifier(iFriendsWithEnemyNeutralReduction, GetNeediness()) + AdjustConditionalModifier(iEnemiesWithFriendNeutralReduction, GetLoyalty()); } @@ -18121,7 +18134,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool // Scale based on personality - how much do we care about trade loyalty? // Netherlands always has maximum trade loyalty! - iTradeDealValue *= pTraits->IsImportsCountTowardsMonopolies() ? 20 : GetLoyalty() + GetDiploBalance(); + iTradeDealValue *= pTraits->IsImportsCountTowardsMonopolies() ? 20 : GetLoyalty() + GetWorkWithWillingness(); iTradeDealValue /= 20; // Trade deal value is more important in earlier eras @@ -18593,7 +18606,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool } // If we can't take them, we don't want them attacking us after finishing with this guy - if (bThinkingAboutDogpiling && bOtherWarPlayerCloseToTarget && GetMilitaryStrengthComparedToUs(eLoopPlayer) >= STRENGTH_POWERFUL && !IsTeammate(eLoopPlayer) && !IsDoFAccepted(eLoopPlayer) && !IsHasDefensivePact(eLoopPlayer) && GetCoopWarState(eLoopPlayer, ePlayer) < COOP_WAR_STATE_PREPARING) + if (bThinkingAboutDogpiling && bOtherWarPlayerCloseToTarget && GetMilitaryStrengthComparedToUs(eLoopPlayer) >= STRENGTH_POWERFUL && !IsTeammate(eLoopPlayer) && !IsDoFAccepted(eLoopPlayer) && !IsHasDefensivePact(eLoopPlayer)) { bAllowDogpiling = false; break; @@ -18601,7 +18614,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool if (bThinkingAboutDogpiling) { - int iBonusMod = (int)GetVictoryBlockLevel(ePlayer) + (int)GetVictoryDisputeLevel(ePlayer) + (int)GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->GetWarState(ePlayer); + int iBonusMod = max((int)GetVictoryBlockLevel(ePlayer), (int)GetVictoryDisputeLevel(ePlayer)) + (int)GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->GetWarState(ePlayer); if (IsAtWar(ePlayer)) iBonusMod += (int)GetWarState(ePlayer) - 4; @@ -18643,8 +18656,8 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool if (bAllowDogpiling && iBonus > 0) { - vApproachScores[CIV_APPROACH_WAR] += vApproachBias[CIV_APPROACH_WAR] * iBonus / 2; - vApproachScores[CIV_APPROACH_HOSTILE] += vApproachBias[CIV_APPROACH_HOSTILE] * iBonus / 2; + vApproachScores[CIV_APPROACH_WAR] += AdjustConditionalModifier(vApproachBias[CIV_APPROACH_WAR] * iBonus, GetWorkAgainstWillingness()) / 2; + vApproachScores[CIV_APPROACH_HOSTILE] += AdjustConditionalModifier(vApproachBias[CIV_APPROACH_HOSTILE] * iBonus, GetWorkAgainstWillingness()) / 2; } } @@ -18742,7 +18755,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool if (IsGoingForWorldConquest() || GetPlayerNumMajorsConquered(eMyPlayer) > 0) { // Add some weight for leader flavors - vApproachScores[CIV_APPROACH_WAR] += (GetBoldness() + m_pPlayer->GetFlavorManager()->GetPersonalityFlavorForDiplomacy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_OFFENSE"))) * 50; + vApproachScores[CIV_APPROACH_WAR] += (GetBoldness() + GetWorkAgainstWillingness()) * 50; vApproachScores[CIV_APPROACH_HOSTILE] += (GetMeanness() + GetDenounceWillingness()) * 50; // More likely to declare war for each original capital we own @@ -18876,7 +18889,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool // Increase friendship willingness with all civs (that aren't close to winning) if (!IsEndgameAggressiveTo(ePlayer)) { - vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] + (GetDoFWillingness() * 100) + (m_pPlayer->GetFlavorManager()->GetPersonalityFlavorForDiplomacy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_DIPLOMACY")) * 100); + vApproachScores[CIV_APPROACH_FRIENDLY] += vApproachBias[CIV_APPROACH_FRIENDLY] + GetWorkWithWillingness() * 100 + GetDoFWillingness() * 100; // Larger increase if we're close to winning if (bCloseToDiploVictory) @@ -18887,7 +18900,7 @@ void CvDiplomacyAI::SelectBestApproachTowardsMajorCiv(PlayerTypes ePlayer, bool if (bMetValidMinor) { - int iLoweredInfluenceCount = (GetNumTimesTheyLoweredOurInfluence(ePlayer)/2) + GetNumTimesPerformedCoupAgainstUs(ePlayer); + int iLoweredInfluenceCount = GetNumTimesTheyLoweredOurInfluence(ePlayer)/2 + GetNumTimesPerformedCoupAgainstUs(ePlayer); if (iLoweredInfluenceCount > 0) { @@ -43014,9 +43027,9 @@ bool CvDiplomacyAI::IsDenounceFriendAcceptable(PlayerTypes ePlayer) // What is their backstabbing tolerance? if (!kPlayer.GetDiplomacyAI()->WasResurrectedBy(GetID())) { - int iFriendDenounceTolerance = GetEstimatePlayerLoyalty(eLoopPlayer) < 5 ? 2 : 1; + int iFriendDenounceTolerance = EstimateLoyalty(eLoopPlayer) < 5 ? 2 : 1; - if (GetEstimatePlayerForgiveness(eLoopPlayer) > 8) + if (EstimateForgiveness(eLoopPlayer) > 8) iFriendDenounceTolerance++; int iNumCivsEver = GC.getGame().countMajorCivsEverAlive(); @@ -43920,7 +43933,7 @@ int CvDiplomacyAI::GetDenounceWeight(PlayerTypes ePlayer, bool bBias) } } } -#if defined(MOD_BALANCE_CORE) + // Are there any quests that should influence our decision? Ignore if we're already close to a non-domination victory, we shouldn't be making additional enemies over City-States. if (!IsCloseToSpaceshipVictory() && !IsCloseToCultureVictory() && !IsCloseToDiploVictory()) { @@ -43946,7 +43959,6 @@ int CvDiplomacyAI::GetDenounceWeight(PlayerTypes ePlayer, bool bBias) } } } -#endif // Used when friends are asking us to denounce someone if (bBias) @@ -45066,7 +45078,7 @@ void CvDiplomacyAI::TestOpinionModifiers() &CvDiplomacyAI::SetWeLikedTheirProposalTurn, &CvDiplomacyAI::GetWeLikedTheirProposalTurn, /*50*/ GD_INT_GET(OPINION_WEIGHT_WE_LIKED_THEIR_PROPOSAL_NUM_TURNS), - GetDoFWillingness()); + GetWorkWithWillingness()); // Disliked their WC proposal? checkAndUpdateNonStackingOpinionModifier(this, ePlayer, iTurn, @@ -45074,7 +45086,7 @@ void CvDiplomacyAI::TestOpinionModifiers() &CvDiplomacyAI::SetWeDislikedTheirProposalTurn, &CvDiplomacyAI::GetWeDislikedTheirProposalTurn, /*50*/ GD_INT_GET(OPINION_WEIGHT_WE_DISLIKED_THEIR_PROPOSAL_NUM_TURNS), - GetDenounceWillingness()); + GetWorkAgainstWillingness()); int iSupportValue = GetSupportedOurProposalValue(ePlayer); @@ -45082,7 +45094,7 @@ void CvDiplomacyAI::TestOpinionModifiers() if (iSupportValue > 0) { int iProposalTurn = 0; - iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_FOILED_OUR_PROPOSAL_NUM_TURNS), GetDenounceWillingness()); + iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_FOILED_OUR_PROPOSAL_NUM_TURNS), GetWorkAgainstWillingness()); if (IsFoiledOurProposalAndThenSupportedUs(ePlayer)) { // The more recent action should carry higher value if Forgiveness is higher @@ -45112,7 +45124,7 @@ void CvDiplomacyAI::TestOpinionModifiers() else if (iSupportValue < 0) { int iProposalTurn = 0; - iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_PROPOSAL_NUM_TURNS), GetDoFWillingness()); + iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_PROPOSAL_NUM_TURNS), GetWorkWithWillingness()); if (IsSupportedOurProposalAndThenFoiledUs(ePlayer)) { // The more recent action should carry higher value if Neediness is higher @@ -45145,7 +45157,7 @@ void CvDiplomacyAI::TestOpinionModifiers() &CvDiplomacyAI::SetTheySupportedOurHostingTurn, &CvDiplomacyAI::GetTheySupportedOurHostingTurn, /*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_HOSTING_NUM_TURNS), - GetDoFWillingness()); + GetWorkWithWillingness()); // Sanctioned us? checkAndUpdateNonStackingOpinionModifier(this, ePlayer, iTurn, @@ -45153,7 +45165,7 @@ void CvDiplomacyAI::TestOpinionModifiers() &CvDiplomacyAI::SetTheySanctionedUsTurn, &CvDiplomacyAI::GetTheySanctionedUsTurn, /*50*/ GD_INT_GET(SANCTIONED_US_TURNS_UNTIL_FORGIVEN), - HasEverSanctionedUs(ePlayer) ? GetMeanness() : GetDenounceWillingness()); + HasEverSanctionedUs(ePlayer) ? GetMeanness() : GetWorkAgainstWillingness()); // Un-sanctioned us? checkAndUpdateNonStackingOpinionModifier(this, ePlayer, iTurn, @@ -45161,7 +45173,7 @@ void CvDiplomacyAI::TestOpinionModifiers() &CvDiplomacyAI::SetTheyUnsanctionedUsTurn, &CvDiplomacyAI::GetTheyUnsanctionedUsTurn, /*50*/ GD_INT_GET(UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN), - HasEverUnsanctionedUs(ePlayer) ? GetLoyalty() : GetDoFWillingness()); + HasEverUnsanctionedUs(ePlayer) ? GetLoyalty() : GetWorkWithWillingness()); } } @@ -46438,8 +46450,8 @@ int CvDiplomacyAI::GetDenouncedEnemyScore(PlayerTypes ePlayer) const iOpinionWeight += /*-20*/ GD_INT_GET(OPINION_WEIGHT_DENOUNCED_BIGGEST_LEAGUE_RIVAL); } - // Scale with DenounceWillingness - return AdjustConditionalModifier(iOpinionWeight, GetDenounceWillingness()); + // Scale with WorkAgainstWillingness + return AdjustConditionalModifier(iOpinionWeight, GetWorkAgainstWillingness()); } int CvDiplomacyAI::GetDenouncedByOurFriendScore(PlayerTypes ePlayer) const @@ -46495,8 +46507,8 @@ int CvDiplomacyAI::GetDenouncedByOurFriendScore(PlayerTypes ePlayer) const } } - // Scale inversely with DiploBalance - the more the AI is focused on their own sphere of influence, the less they get involved in others' fights - return AdjustConditionalModifier(iOpinionWeight, GetDiploBalance(), true); + // Scale with WorkAgainstWillingness + return AdjustConditionalModifier(iOpinionWeight, GetWorkAgainstWillingness()); } ////////////////////////////////////// @@ -47272,7 +47284,7 @@ int CvDiplomacyAI::GetDOFAcceptedScore(PlayerTypes ePlayer) const } } - // Scale inversely with DoFWillingness - AIs more willing to be friends place less value on individual friends & more on forming blocs; vice versa for AIs who want fewer but closer friends + // Scale inversely with DoFWillingness - AIs more willing to be friends place less value on individual friends; vice versa for AIs who want fewer but closer friends return AdjustConditionalModifier(iOpinionWeight, GetDoFWillingness(), true); } @@ -47330,8 +47342,8 @@ int CvDiplomacyAI::GetDOFWithAnyFriendScore(PlayerTypes ePlayer) const } } - // Scale with DoFWillingness - return AdjustConditionalModifier(iOpinionWeight, GetDoFWillingness()); + // Scale with WorkWithWillingness + return AdjustConditionalModifier(iOpinionWeight, GetWorkWithWillingness()); } int CvDiplomacyAI::GetDOFWithAnyEnemyScore(PlayerTypes ePlayer) const @@ -47577,8 +47589,8 @@ int CvDiplomacyAI::GetFriendDenouncementScore(PlayerTypes ePlayer) } } - // Scale with DenounceWillingness - return AdjustConditionalModifier(iTraitorOpinion, GetDenounceWillingness()); + // Scale with WorkAgainstWillingness + return AdjustConditionalModifier(iTraitorOpinion, GetWorkAgainstWillingness()); } int CvDiplomacyAI::GetPlayerDenouncedFriendScore(PlayerTypes ePlayer) @@ -47829,7 +47841,7 @@ int CvDiplomacyAI::GetLikedTheirProposalScore(PlayerTypes ePlayer) iOpinionWeight /= 100; } - int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_WE_LIKED_THEIR_PROPOSAL_NUM_TURNS), GetDoFWillingness()); + int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_WE_LIKED_THEIR_PROPOSAL_NUM_TURNS), GetWorkWithWillingness()); return AdjustTimedModifier(iOpinionWeight, iDuration, GetWeLikedTheirProposalTurn(ePlayer), TIMED_MODIFIER_STANDARD); } @@ -47853,7 +47865,7 @@ int CvDiplomacyAI::GetDislikedTheirProposalScore(PlayerTypes ePlayer) iOpinionWeight /= 100; } - int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_WE_DISLIKED_THEIR_PROPOSAL_NUM_TURNS), GetDenounceWillingness()); + int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_WE_DISLIKED_THEIR_PROPOSAL_NUM_TURNS), GetWorkAgainstWillingness()); return AdjustTimedModifier(iOpinionWeight, iDuration, GetWeDislikedTheirProposalTurn(ePlayer), TIMED_MODIFIER_STANDARD); } @@ -47872,7 +47884,7 @@ int CvDiplomacyAI::GetSupportedOurProposalScore(PlayerTypes ePlayer) if (iSupportValue > 0) { int iTurn = 0; - int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_FOILED_OUR_PROPOSAL_NUM_TURNS), GetDenounceWillingness()); + int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_FOILED_OUR_PROPOSAL_NUM_TURNS), GetWorkAgainstWillingness()); if (IsFoiledOurProposalAndThenSupportedUs(ePlayer)) { @@ -47912,7 +47924,7 @@ int CvDiplomacyAI::GetSupportedOurProposalScore(PlayerTypes ePlayer) else if (iSupportValue < 0) { int iTurn = 0; - int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_PROPOSAL_NUM_TURNS), GetDoFWillingness()); + int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_PROPOSAL_NUM_TURNS), GetWorkWithWillingness()); if (IsSupportedOurProposalAndThenFoiledUs(ePlayer)) { @@ -47975,7 +47987,7 @@ int CvDiplomacyAI::GetSupportedMyHostingScore(PlayerTypes ePlayer) iOpinionWeight /= 100; } - int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_HOSTING_NUM_TURNS), GetDoFWillingness()); + int iDuration = AdjustModifierDuration(/*50*/ GD_INT_GET(OPINION_WEIGHT_THEY_SUPPORTED_OUR_HOSTING_NUM_TURNS), GetWorkWithWillingness()); return AdjustTimedModifier(iOpinionWeight, iDuration, GetTheySupportedOurHostingTurn(ePlayer), TIMED_MODIFIER_STANDARD); } @@ -48005,7 +48017,7 @@ int CvDiplomacyAI::GetSanctionedUsScore(PlayerTypes ePlayer) iOpinionWeight /= /*200*/ max(GD_INT_GET(OPINION_WEIGHT_THEY_SANCTIONED_US_FAILURE_DIVISOR), 1); } - int iDuration = HasEverSanctionedUs(ePlayer) ? AdjustModifierDuration(/*50*/ GD_INT_GET(SANCTIONED_US_TURNS_UNTIL_FORGIVEN), GetMeanness()) : AdjustModifierDuration(GD_INT_GET(SANCTIONED_US_TURNS_UNTIL_FORGIVEN), GetDenounceWillingness()); + int iDuration = HasEverSanctionedUs(ePlayer) ? AdjustModifierDuration(/*50*/ GD_INT_GET(SANCTIONED_US_TURNS_UNTIL_FORGIVEN), GetMeanness()) : AdjustModifierDuration(GD_INT_GET(SANCTIONED_US_TURNS_UNTIL_FORGIVEN), GetWorkAgainstWillingness()); return AdjustTimedModifier(iOpinionWeight, iDuration, GetTheySanctionedUsTurn(ePlayer), TIMED_MODIFIER_STANDARD); } else if (HasTriedToUnsanctionUs(ePlayer)) @@ -48024,7 +48036,7 @@ int CvDiplomacyAI::GetSanctionedUsScore(PlayerTypes ePlayer) iOpinionWeight /= /*200*/ max(GD_INT_GET(OPINION_WEIGHT_THEY_UNSANCTIONED_US_FAILURE_DIVISOR), 1); } - int iDuration = HasEverUnsanctionedUs(ePlayer) ? AdjustModifierDuration(/*50*/ GD_INT_GET(UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN), GetLoyalty()) : AdjustModifierDuration(GD_INT_GET(UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN), GetDoFWillingness()); + int iDuration = HasEverUnsanctionedUs(ePlayer) ? AdjustModifierDuration(/*50*/ GD_INT_GET(UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN), GetLoyalty()) : AdjustModifierDuration(GD_INT_GET(UNSANCTIONED_US_TURNS_UNTIL_FORGOTTEN), GetWorkWithWillingness()); return AdjustTimedModifier(iOpinionWeight, iDuration, GetTheyUnsanctionedUsTurn(ePlayer), TIMED_MODIFIER_STANDARD); } @@ -49641,7 +49653,7 @@ void CvDiplomacyAI::CancelRenewDeal(PlayerTypes eOtherPlayer, RenewalReason eRea // ... humans can learn this by studying opinion modifiers whenever the AI's approach isn't FRIENDLY (or with Transparent Diplomacy enabled) /// How much do we estimate this other leader gets angry when another player is competing for Victory? -int CvDiplomacyAI::GetEstimatePlayerVictoryCompetitiveness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateVictoryCompetitiveness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49662,7 +49674,7 @@ int CvDiplomacyAI::GetEstimatePlayerVictoryCompetitiveness(PlayerTypes ePlayer) } /// How much do we estimate this other leader gets angry when they're beaten to a World Wonder? -int CvDiplomacyAI::GetEstimatePlayerWonderCompetitiveness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateWonderCompetitiveness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49688,7 +49700,7 @@ int CvDiplomacyAI::GetEstimatePlayerWonderCompetitiveness(PlayerTypes ePlayer) c } /// How much do we estimate this other leader gets angry when another player is befriending "their" minor civs? -int CvDiplomacyAI::GetEstimatePlayerMinorCivCompetitiveness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateMinorCivCompetitiveness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49714,7 +49726,7 @@ int CvDiplomacyAI::GetEstimatePlayerMinorCivCompetitiveness(PlayerTypes ePlayer) } /// What is this other leader's estimated likelihood to take risks / go for World Conquest? -int CvDiplomacyAI::GetEstimatePlayerBoldness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateBoldness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49740,7 +49752,7 @@ int CvDiplomacyAI::GetEstimatePlayerBoldness(PlayerTypes ePlayer) const } /// How much do we estimate this other leader wants to maintain a balance of power in the world? -int CvDiplomacyAI::GetEstimatePlayerDiploBalance(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateDiploBalance(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49761,7 +49773,7 @@ int CvDiplomacyAI::GetEstimatePlayerDiploBalance(PlayerTypes ePlayer) const } /// How much does this other leader gets angry when someone's being a warmonger? -int CvDiplomacyAI::GetEstimatePlayerWarmongerHate(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateWarmongerHate(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49840,7 +49852,7 @@ int CvDiplomacyAI::GetEstimatePlayerWarmongerHate(PlayerTypes ePlayer) const } /// What is this other leader's estimated likelihood to befriend other players? -int CvDiplomacyAI::GetEstimatePlayerDoFWillingness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateDoFWillingness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49860,8 +49872,8 @@ int CvDiplomacyAI::GetEstimatePlayerDoFWillingness(PlayerTypes ePlayer) const return range(GET_PLAYER(ePlayer).getLeaderInfo().GetDoFWillingness(), 1, 10); } -/// What is this other leader's estimated likelihood to work with someone AGAINST another player? -int CvDiplomacyAI::GetEstimatePlayerDenounceWillingness(PlayerTypes ePlayer) const +/// What is this other leader's estimated likelihood to badmouth other players? +int CvDiplomacyAI::EstimateDenounceWillingness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49881,8 +49893,50 @@ int CvDiplomacyAI::GetEstimatePlayerDenounceWillingness(PlayerTypes ePlayer) con return range(GET_PLAYER(ePlayer).getLeaderInfo().GetDenounceWillingness(), 1, 10); } +/// What is this other leader's estimated likelihood to form strategic alliances WITH others? +int CvDiplomacyAI::EstimateWorkWithWillingness(PlayerTypes ePlayer) const +{ + if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; + + // We always know our team's flavors + if (GetTeam() == GET_PLAYER(ePlayer).getTeam()) + { + return GET_PLAYER(ePlayer).GetDiplomacyAI()->GetWorkWithWillingness(); + } + + // Human or Random Personalities? Assume the default flavor value. + if (GET_PLAYER(ePlayer).isHuman() || GC.getGame().isOption(GAMEOPTION_RANDOM_PERSONALITIES)) + { + return 5; + } + + // AI? Use the other player's base XML value. + return range(GET_PLAYER(ePlayer).getLeaderInfo().GetWorkWithWillingness(), 1, 10); +} + +/// What is this other leader's estimated likelihood to form strategic alliances AGAINST others? +int CvDiplomacyAI::EstimateWorkAgainstWillingness(PlayerTypes ePlayer) const +{ + if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; + + // We always know our team's flavors + if (GetTeam() == GET_PLAYER(ePlayer).getTeam()) + { + return GET_PLAYER(ePlayer).GetDiplomacyAI()->GetWorkAgainstWillingness(); + } + + // Human or Random Personalities? Assume the default flavor value. + if (GET_PLAYER(ePlayer).isHuman() || GC.getGame().isOption(GAMEOPTION_RANDOM_PERSONALITIES)) + { + return 5; + } + + // AI? Use the other player's base XML value. + return range(GET_PLAYER(ePlayer).getLeaderInfo().GetWorkAgainstWillingness(), 1, 10); +} + /// What is this other leader's estimated likelihood to refrain from backstabbing their friends? -int CvDiplomacyAI::GetEstimatePlayerLoyalty(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateLoyalty(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49903,7 +49957,7 @@ int CvDiplomacyAI::GetEstimatePlayerLoyalty(PlayerTypes ePlayer) const } /// How much do we estimate this other leader is willing to forgive transgressions against them? -int CvDiplomacyAI::GetEstimatePlayerForgiveness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateForgiveness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49924,7 +49978,7 @@ int CvDiplomacyAI::GetEstimatePlayerForgiveness(PlayerTypes ePlayer) const } /// How much do we estimate this other leader wants the support of its friends in rough times? -int CvDiplomacyAI::GetEstimatePlayerNeediness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateNeediness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49945,7 +49999,7 @@ int CvDiplomacyAI::GetEstimatePlayerNeediness(PlayerTypes ePlayer) const } /// How much do we estimate this other leader likes to talk smack / bully others? -int CvDiplomacyAI::GetEstimatePlayerMeanness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateMeanness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49966,7 +50020,7 @@ int CvDiplomacyAI::GetEstimatePlayerMeanness(PlayerTypes ePlayer) const } /// How much do we estimate this other leader likes to pop up and talk? -int CvDiplomacyAI::GetEstimatePlayerChattiness(PlayerTypes ePlayer) const +int CvDiplomacyAI::EstimateChattiness(PlayerTypes ePlayer) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -49987,7 +50041,7 @@ int CvDiplomacyAI::GetEstimatePlayerChattiness(PlayerTypes ePlayer) const } /// What is our estimate of another leader's bias for a particular Major Civ Approach? -int CvDiplomacyAI::GetEstimatePlayerMajorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const +int CvDiplomacyAI::EstimateMajorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; if (eApproach < 0 || eApproach >= NUM_CIV_APPROACHES) return 0; @@ -50039,7 +50093,7 @@ int CvDiplomacyAI::GetEstimatePlayerMajorCivApproachBias(PlayerTypes ePlayer, Ci } /// What is our estimate of another leader's bias for a particular Minor Civ Approach? -int CvDiplomacyAI::GetEstimatePlayerMinorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const +int CvDiplomacyAI::EstimateMinorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; @@ -50085,7 +50139,7 @@ int CvDiplomacyAI::GetEstimatePlayerMinorCivApproachBias(PlayerTypes ePlayer, Ci } /// What is our estimate of another leader's value for a personality flavor? -int CvDiplomacyAI::GetEstimatePlayerFlavorValue(PlayerTypes ePlayer, FlavorTypes eFlavor) const +int CvDiplomacyAI::EstimateFlavorValue(PlayerTypes ePlayer, FlavorTypes eFlavor) const { if (ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return 0; if (eFlavor < 0 || eFlavor >= GC.getNumFlavorTypes()) return 0; diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h index 69dce97ca6..5af0640fe1 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h @@ -110,10 +110,10 @@ class CvDiplomacyAI bool IsNuclearGandhi(bool bPotentially = false) const; // ************************************ - // Personality Values + // Personality Flavors // ************************************ - int GetRandomPersonalityWeight(int iOriginalValue, const CvSeeder& seed); + int RandomizePersonalityFlavor(int iOriginalValue, const CvSeeder& seed); void DoInitializePersonality(bool bFirstInit); void SelectDefaultVictoryPursuits(); @@ -125,6 +125,8 @@ class CvDiplomacyAI int GetWarmongerHate() const; int GetDoFWillingness() const; int GetDenounceWillingness() const; + int GetWorkWithWillingness() const; + int GetWorkAgainstWillingness() const; int GetLoyalty() const; int GetForgiveness() const; int GetNeediness() const; @@ -1812,22 +1814,24 @@ class CvDiplomacyAI inline bool NotTeam(PlayerTypes eOtherPlayer) const { return GET_PLAYER(eOtherPlayer).getTeam() != (TeamTypes)m_eTeam; } // Estimations of other players' tendencies - int GetEstimatePlayerVictoryCompetitiveness(PlayerTypes ePlayer) const; - int GetEstimatePlayerWonderCompetitiveness(PlayerTypes ePlayer) const; - int GetEstimatePlayerMinorCivCompetitiveness(PlayerTypes ePlayer) const; - int GetEstimatePlayerBoldness(PlayerTypes ePlayer) const; - int GetEstimatePlayerDiploBalance(PlayerTypes ePlayer) const; - int GetEstimatePlayerWarmongerHate(PlayerTypes ePlayer) const; - int GetEstimatePlayerDoFWillingness(PlayerTypes ePlayer) const; - int GetEstimatePlayerDenounceWillingness(PlayerTypes ePlayer) const; - int GetEstimatePlayerLoyalty(PlayerTypes ePlayer) const; - int GetEstimatePlayerForgiveness(PlayerTypes ePlayer) const; - int GetEstimatePlayerNeediness(PlayerTypes ePlayer) const; - int GetEstimatePlayerMeanness(PlayerTypes ePlayer) const; - int GetEstimatePlayerChattiness(PlayerTypes ePlayer) const; - int GetEstimatePlayerMajorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const; - int GetEstimatePlayerMinorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const; - int GetEstimatePlayerFlavorValue(PlayerTypes ePlayer, FlavorTypes eFlavor) const; + int EstimateVictoryCompetitiveness(PlayerTypes ePlayer) const; + int EstimateWonderCompetitiveness(PlayerTypes ePlayer) const; + int EstimateMinorCivCompetitiveness(PlayerTypes ePlayer) const; + int EstimateBoldness(PlayerTypes ePlayer) const; + int EstimateDiploBalance(PlayerTypes ePlayer) const; + int EstimateWarmongerHate(PlayerTypes ePlayer) const; + int EstimateDoFWillingness(PlayerTypes ePlayer) const; + int EstimateDenounceWillingness(PlayerTypes ePlayer) const; + int EstimateWorkWithWillingness(PlayerTypes ePlayer) const; + int EstimateWorkAgainstWillingness(PlayerTypes ePlayer) const; + int EstimateLoyalty(PlayerTypes ePlayer) const; + int EstimateForgiveness(PlayerTypes ePlayer) const; + int EstimateNeediness(PlayerTypes ePlayer) const; + int EstimateMeanness(PlayerTypes ePlayer) const; + int EstimateChattiness(PlayerTypes ePlayer) const; + int EstimateMajorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const; + int EstimateMinorCivApproachBias(PlayerTypes ePlayer, CivApproachTypes eApproach) const; + int EstimateFlavorValue(PlayerTypes ePlayer, FlavorTypes eFlavor) const; bool IsValidUIDiplomacyTarget(PlayerTypes eTargetPlayer); @@ -1896,6 +1900,8 @@ class CvDiplomacyAI unsigned char m_iWarmongerHate; unsigned char m_iDoFWillingness; unsigned char m_iDenounceWillingness; + unsigned char m_iWorkWithWillingness; + unsigned char m_iWorkAgainstWillingness; unsigned char m_iLoyalty; unsigned char m_iForgiveness; unsigned char m_iNeediness; diff --git a/CvGameCoreDLL_Expansion2/CvInfos.cpp b/CvGameCoreDLL_Expansion2/CvInfos.cpp index 67788eea59..9a0be6a152 100644 --- a/CvGameCoreDLL_Expansion2/CvInfos.cpp +++ b/CvGameCoreDLL_Expansion2/CvInfos.cpp @@ -7797,13 +7797,15 @@ CvLeaderHeadInfo::CvLeaderHeadInfo() : m_iBoldness(0), m_iDiploBalance(0), m_iWarmongerHate(0), - m_iDenounceWillingness(0), m_iDoFWillingness(0), + m_iDenounceWillingness(0), + m_iWorkWithWillingness(0), + m_iWorkAgainstWillingness(0), m_iLoyalty(0), - m_iNeediness(0), m_iForgiveness(0), - m_iChattiness(0), + m_iNeediness(0), m_iMeanness(0), + m_iChattiness(0), m_ePrimaryVictoryPursuit(NO_VICTORY_PURSUIT), m_eSecondaryVictoryPursuit(NO_VICTORY_PURSUIT), m_piMajorCivApproachBiases(NULL), @@ -7861,6 +7863,16 @@ int CvLeaderHeadInfo::GetDenounceWillingness() const return m_iDenounceWillingness; } //------------------------------------------------------------------------------ +int CvLeaderHeadInfo::GetWorkWithWillingness() const +{ + return m_iWorkWithWillingness; +} +//------------------------------------------------------------------------------ +int CvLeaderHeadInfo::GetWorkAgainstWillingness() const +{ + return m_iWorkAgainstWillingness; +} +//------------------------------------------------------------------------------ int CvLeaderHeadInfo::GetLoyalty() const { return m_iLoyalty; @@ -8038,13 +8050,15 @@ bool CvLeaderHeadInfo::CacheResults(Database::Results& kResults, CvDatabaseUtili m_iBoldness = kResults.GetInt("Boldness"); m_iDiploBalance = kResults.GetInt("DiploBalance"); m_iWarmongerHate = kResults.GetInt("WarmongerHate"); - m_iDenounceWillingness = kResults.GetInt("DenounceWillingness"); m_iDoFWillingness = kResults.GetInt("DoFWillingness"); + m_iDenounceWillingness = kResults.GetInt("DenounceWillingness"); + m_iWorkWithWillingness = kResults.GetInt("WorkWithWillingness"); + m_iWorkAgainstWillingness = kResults.GetInt("WorkAgainstWillingness"); m_iLoyalty = kResults.GetInt("Loyalty"); - m_iNeediness = kResults.GetInt("Neediness"); m_iForgiveness = kResults.GetInt("Forgiveness"); - m_iChattiness = kResults.GetInt("Chattiness"); + m_iNeediness = kResults.GetInt("Neediness"); m_iMeanness = kResults.GetInt("Meanness"); + m_iChattiness = kResults.GetInt("Chattiness"); //Arrays const char* szType = GetType(); diff --git a/CvGameCoreDLL_Expansion2/CvInfos.h b/CvGameCoreDLL_Expansion2/CvInfos.h index a510f012f3..1ed6f2611d 100644 --- a/CvGameCoreDLL_Expansion2/CvInfos.h +++ b/CvGameCoreDLL_Expansion2/CvInfos.h @@ -2336,6 +2336,8 @@ class CvLeaderHeadInfo : public CvBaseInfo int GetWarmongerHate() const; int GetDoFWillingness() const; int GetDenounceWillingness() const; + int GetWorkWithWillingness() const; + int GetWorkAgainstWillingness() const; int GetLoyalty() const; int GetForgiveness() const; int GetNeediness() const; @@ -2373,13 +2375,15 @@ class CvLeaderHeadInfo : public CvBaseInfo int m_iBoldness; int m_iDiploBalance; int m_iWarmongerHate; - int m_iDenounceWillingness; int m_iDoFWillingness; + int m_iDenounceWillingness; + int m_iWorkWithWillingness; + int m_iWorkAgainstWillingness; int m_iLoyalty; - int m_iNeediness; int m_iForgiveness; - int m_iChattiness; + int m_iNeediness; int m_iMeanness; + int m_iChattiness; int* m_piMajorCivApproachBiases; int* m_piMinorCivApproachBiases; diff --git a/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp b/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp index a3aa28f22f..1e8ef3ebfa 100644 --- a/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp @@ -10980,7 +10980,6 @@ CvLeagueAI::AlignmentLevels CvLeagueAI::EvaluateAlignment(PlayerTypes ePlayer, b if (bUntrustworthy) { iAlignment -= 4; - } // Liberator? if (pDiplo->IsPlayerLiberatedCapital(ePlayer) || pDiplo->IsPlayerLiberatedHolyCity(ePlayer) || pDiplo->WasResurrectedBy(ePlayer)) @@ -10989,15 +10988,14 @@ CvLeagueAI::AlignmentLevels CvLeagueAI::EvaluateAlignment(PlayerTypes ePlayer, b { iAlignment += 4; } - else { iAlignment += 2; } } - if (!GetPlayer()->IsAtWarWith(ePlayer) && pDiplo->GetNumCitiesLiberatedBy(ePlayer) > 0) + if (!GetPlayer()->IsAtWarWith(ePlayer) && pDiplo->GetNumCitiesEverLiberatedBy(ePlayer) > 0) { - iAlignment += pDiplo->GetNumCitiesLiberatedBy(ePlayer); + iAlignment += pDiplo->GetNumCitiesEverLiberatedBy(ePlayer); if (pDiplo->IsPlayerReturnedCapital(ePlayer) || pDiplo->IsPlayerReturnedHolyCity(ePlayer)) { iAlignment += 1; @@ -11005,10 +11003,7 @@ CvLeagueAI::AlignmentLevels CvLeagueAI::EvaluateAlignment(PlayerTypes ePlayer, b } // Captured some of our cities before? - if (pDiplo->GetNumCitiesCapturedBy(ePlayer) > 0) - { - iAlignment -= pDiplo->GetNumCitiesCapturedBy(ePlayer); - } + iAlignment -= pDiplo->GetNumCitiesCapturedBy(ePlayer); int iDisputeLevel = max((int)pDiplo->GetVictoryDisputeLevel(ePlayer), (int)pDiplo->GetVictoryBlockLevel(ePlayer)); if (iDisputeLevel > 0) @@ -11029,6 +11024,10 @@ CvLeagueAI::AlignmentLevels CvLeagueAI::EvaluateAlignment(PlayerTypes ePlayer, b { eAlignment = ALIGNMENT_RIVAL; } + else if (pDiplo->WasResurrectedBy(ePlayer)) + { + eAlignment = !GetPlayer()->IsAITeammateOfHuman() ? ALIGNMENT_LIBERATOR : ALIGNMENT_ALLY; + } else if (iAlignment <= 2) { eAlignment = ALIGNMENT_NEUTRAL; @@ -11041,10 +11040,6 @@ CvLeagueAI::AlignmentLevels CvLeagueAI::EvaluateAlignment(PlayerTypes ePlayer, b { eAlignment = ALIGNMENT_CONFIDANT; } - else if (pDiplo->WasResurrectedBy(ePlayer)) - { - eAlignment = ALIGNMENT_LIBERATOR; - } else { eAlignment = ALIGNMENT_ALLY; @@ -13544,69 +13539,73 @@ int CvLeagueAI::ScoreVoteChoiceYesNo(CvProposal* pProposal, int iChoice, bool bE CvDiplomacyAI* pDiplo = GetPlayer()->GetDiplomacyAI(); if (pLeague) { - int iDiploScore = 0; int iTotalDiploScore = 0; - int iDisputeLevel = 0; int iNumCivs = 1; for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++) { PlayerTypes eLoopPlayer = (PlayerTypes)iPlayerLoop; if (pLeague->CanEverVote(eLoopPlayer) && GET_PLAYER(eLoopPlayer).GetID() != GetPlayer()->GetID() && GET_PLAYER(eLoopPlayer).isAlive() && GET_PLAYER(eLoopPlayer).getNumCities() > 0) { - iDiploScore = (GetPlayer()->GetDiplomacyAI()->GetCivOpinion(eLoopPlayer) - CIV_OPINION_NEUTRAL) * 8; + CivOpinionTypes eOpinion = pDiplo->GetCivOpinion(eLoopPlayer); + int iBadDiploScore = eOpinion < CIV_OPINION_NEUTRAL ? (eOpinion - CIV_OPINION_NEUTRAL) * 800 : 0; + int iGoodDiploScore = eOpinion > CIV_OPINION_NEUTRAL ? (eOpinion - CIV_OPINION_NEUTRAL) * 800 : 0; - if (GetPlayer()->GetDiplomacyAI()->GetMostValuableFriend() == eLoopPlayer || GetPlayer()->GetDiplomacyAI()->GetMostValuableAlly() == eLoopPlayer) + if (pDiplo->GetMostValuableFriend() == eLoopPlayer || pDiplo->GetMostValuableAlly() == eLoopPlayer) { - iDiploScore += 8; + iGoodDiploScore += 800; } - if (GetPlayer()->GetDiplomacyAI()->GetPrimeLeagueAlly() == eLoopPlayer) + if (pDiplo->GetPrimeLeagueAlly() == eLoopPlayer) { - iDiploScore += 8; + iGoodDiploScore += 800; } - if (GetPlayer()->GetDiplomacyAI()->GetBiggestCompetitor() == eLoopPlayer) + if (pDiplo->GetBiggestCompetitor() == eLoopPlayer) { - iDiploScore -= 6; + iBadDiploScore -= 600; } if (GetPlayer()->GetDiplomacyAI()->GetPrimeLeagueCompetitor() == eLoopPlayer) { - iDiploScore -= 6; + iBadDiploScore -= 600; } - iDisputeLevel = max((int)pDiplo->GetVictoryDisputeLevel(eLoopPlayer), (int)pDiplo->GetVictoryBlockLevel(eLoopPlayer)); + int iDisputeLevel = max((int)pDiplo->GetVictoryDisputeLevel(eLoopPlayer), (int)pDiplo->GetVictoryBlockLevel(eLoopPlayer)); if (iDisputeLevel > 0) { - iDiploScore -= iDisputeLevel * 6; + iBadDiploScore -= iDisputeLevel * 200; } + + bool bMaxCooperation = false; AlignmentLevels eAlignment = EvaluateAlignment(eLoopPlayer, false); switch (eAlignment) { case ALIGNMENT_TEAMMATE: case ALIGNMENT_LIBERATOR: case ALIGNMENT_LEADER: - iDiploScore = 100; + iGoodDiploScore = 10000; + bMaxCooperation = true; break; case ALIGNMENT_ALLY: - iDiploScore += 24; + iGoodDiploScore += 2400; break; case ALIGNMENT_CONFIDANT: - iDiploScore += 16; + iGoodDiploScore += 1600; break; case ALIGNMENT_FRIEND: - iDiploScore += 8; + iGoodDiploScore += 800; break; case ALIGNMENT_RIVAL: - iDiploScore += -8; + iBadDiploScore += -800; break; case ALIGNMENT_HATRED: - iDiploScore += -16; + iBadDiploScore += -1600; break; case ALIGNMENT_ENEMY: case ALIGNMENT_WAR: - iDiploScore += -24; + iBadDiploScore += -2400; break; default: break; } + int iDiploScore = bMaxCooperation ? iGoodDiploScore / 200 : (iGoodDiploScore * pDiplo->GetWorkWithWillingness() / 2000) + (iBadDiploScore * pDiplo->GetWorkAgainstWillingness() / 2000); iDiploScore *= GET_PLAYER(eLoopPlayer).GetLeagueAI()->ScoreVoteChoiceYesNo(pProposal, iChoice, bEnact, /*bConsiderGlobal*/ false, /*bForSelf*/ false); iDiploScore /= 100; iTotalDiploScore += iDiploScore; @@ -13614,7 +13613,7 @@ int CvLeagueAI::ScoreVoteChoiceYesNo(CvProposal* pProposal, int iChoice, bool bE } } iTotalDiploScore *= 16; - iTotalDiploScore /= max(1,10 + iNumCivs); + iTotalDiploScore /= 10 + iNumCivs; iScore += iTotalDiploScore; } }