Bazaar developer reference

CvDiplomacyAI::DoUpdateMinorCivDisputeLevels()

Defined in
CvDiplomacyAI.cpp, line 8899
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoUpdateMinorCivDisputeLevels

Hooks

static bool BeforeCvDiplomacyAI_DoUpdateMinorCivDisputeLevels(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoUpdateMinorCivDisputeLevels(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoUpdateMinorCivDisputeLevels(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdateMinorCivDisputeLevels>(host, &BeforeCvDiplomacyAI_DoUpdateMinorCivDisputeLevels);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdateMinorCivDisputeLevels>(host, &AfterCvDiplomacyAI_DoUpdateMinorCivDisputeLevels);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdateMinorCivDisputeLevels>(host, &ReplaceCvDiplomacyAI_DoUpdateMinorCivDisputeLevels);

Code

8898/// Updates what is our level of Dispute with a player is over Minor Civ Friendship8899void CvDiplomacyAI::DoUpdateMinorCivDisputeLevels()8900{8901	PlayerTypes ePlayer;89028903	DisputeLevelTypes eDisputeLevel;89048905	int iMinorCivDisputeWeight;89068907	// Personality factors in quite a bit here, which is why we square the value8908	int iPersonalityMod = GetMinorCivCompetitiveness() * GetMinorCivCompetitiveness();	// Ranges from 0 to 10089098910	int iMinorCivLoop;8911	PlayerTypes eMinor;89128913	// Loop through all (known) Players8914	for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)8915	{8916		ePlayer = (PlayerTypes) iPlayerLoop;89178918		if(IsPlayerValid(ePlayer))8919		{8920			eDisputeLevel = DISPUTE_LEVEL_NONE;8921			iMinorCivDisputeWeight = 0;89228923			// Loop through all minors to check our relationship with them8924			for(iMinorCivLoop = MAX_MAJOR_CIVS; iMinorCivLoop < MAX_CIV_PLAYERS; iMinorCivLoop++)8925			{8926				eMinor = (PlayerTypes) iMinorCivLoop;89278928				// We have a PtP with this minor8929				if(GET_PLAYER(eMinor).GetMinorCivAI()->IsProtectedByMajor(GetPlayer()->GetID()))8930				{8931					// Player is Allies with this minor8932					if(GET_PLAYER(eMinor).GetMinorCivAI()->IsAllies(ePlayer))8933						iMinorCivDisputeWeight += iPersonalityMod* /*10*/ GC.getMINOR_CIV_DISPUTE_ALLIES_WEIGHT();8934					// Player is Friends with this minor8935					else if(GET_PLAYER(eMinor).GetMinorCivAI()->IsAllies(ePlayer))8936						iMinorCivDisputeWeight += iPersonalityMod* /*5*/ GC.getMINOR_CIV_DISPUTE_FRIENDS_WEIGHT();8937				}8938			}89398940			// Now See what our new Dispute Level should be8941			if(iMinorCivDisputeWeight >= /*700*/ GC.getMINOR_CIV_DISPUTE_FIERCE_THRESHOLD())8942				eDisputeLevel = DISPUTE_LEVEL_FIERCE;8943			else if(iMinorCivDisputeWeight >= /*400*/ GC.getMINOR_CIV_DISPUTE_STRONG_THRESHOLD())8944				eDisputeLevel = DISPUTE_LEVEL_STRONG;8945			else if(iMinorCivDisputeWeight >= /*200*/ GC.getMINOR_CIV_DISPUTE_WEAK_THRESHOLD())8946				eDisputeLevel = DISPUTE_LEVEL_WEAK;89478948			// Actually set the Level8949			SetMinorCivDisputeLevel(ePlayer, eDisputeLevel);8950		}8951	}8952}

Calls

Called by