Someone looked in the SDK of vanilla Civ IV (sorry, I don't know exactly where; he didn't specify) and found this:
http://forums.civfanatics.com/threa...ow-exactly-wfyabta-works.188183/#post-4602558
Code:
DenialTypes CvTeamAI::AI_techTrade(TechTypes eTech, TeamTypes eTeam)
{
...
if (eAttitude < ATTITUDE_FRIENDLY)
{
if ((GC.getGameINLINE().getTeamRank(getID()) < (GC.getGameINLINE().countCivTeamsEverAlive() / 2)) ||
(GC.getGameINLINE().getTeamRank(eTeam) < (GC.getGameINLINE().countCivTeamsEverAlive() / 2)))
{
iNoTechTradeThreshold = AI_noTechTradeThreshold();
iNoTechTradeThreshold *= max(0, (GC.getHandicapInfo(GET_TEAM(eTeam).getHandicapType()).getNoTechTradeModifier() + 100));
iNoTechTradeThreshold /= 100;
if (AI_getMemoryCount(eTeam, MEMORY_RECEIVED_TECH_FROM_ANY) > iNoTechTradeThreshold)
{
return DENIAL_TECH_WHORE;
}
}
....
}
....
}
...
int CvTeamAI::AI_noTechTradeThreshold()
{
int iRand;
int iCount;
int iI;
iRand = 0;
iCount = 0;
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
{
iRand += GC.getLeaderHeadInfo(GET_PLAYER((PlayerTypes)iI).getPersonalityType()).getNoTechTradeThreshold();
iCount++;
}
}
}
if (iCount > 0)
{
iRand /= iCount;
}
return iRand;
}
As I understand it, it is the "CvTeamAI" instead of "CvPlayerAI" that makes the AI use the average of its diplomatic attitude towards you and your vassals when determining whether it should trade with you (I don't have other examples, but I suspect CvTeamAI also affects other things like peace vassaling, defensive pacts, and of course war declarations). The most dangerous aspect of this is, obviously, that Friendly AIs are not truly Friendly if they are not also Friendly towards every single one of your vassals.
I hope this section of code is enough to help you pinpoint its location.