Adding a HasMet check to Trade Penalty

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
One thing that has always irked me was meeting a new civ and getting the

-4 "You have Traded with Our Worst Enemy"

Penalty. When you haven't even met this civ yet, it's just irritating and doesn't make the game more fun in any way. So I'm on a mission to fix this. Tracking it from the XML text, and into GameTextMgr.cpp we get this little function:

RivalTradeAttitude

searching for RivalTradeAttitude leads into CvPlayerAI.cpp with this function:
Code:
int CvPlayerAI::AI_getRivalTradeAttitude(PlayerTypes ePlayer) const
{
	// XXX human only?
	return -(range(((GET_TEAM(getTeam()).AI_getEnemyPeacetimeGrantValue(GET_PLAYER(ePlayer).getTeam()) + (GET_TEAM(getTeam()).AI_getEnemyPeacetimeTradeValue(GET_PLAYER(ePlayer).getTeam()) / 3)) / ((GET_TEAM(getTeam()).AI_getHasMetCounter(GET_PLAYER(ePlayer).getTeam()) + 1) * 10)), 0, 4));
}

Anyone know how to make it so this function only applies to players that have been met?
 
how about this? (and similar tweak for the peacetimetradevalue)
Code:
void CvPlayerAI::AI_changePeacetimeGrantValue(PlayerTypes eIndex, int iChange)
{
	PROFILE_FUNC();

	int iI;

	FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
	FAssertMsg(eIndex < MAX_PLAYERS, "eIndex is expected to be within maximum bounds (invalid Index)");

	if (iChange != 0)
	{
		m_aiPeacetimeGrantValue[eIndex] = (m_aiPeacetimeGrantValue[eIndex] + iChange);
		FAssert(AI_getPeacetimeGrantValue(eIndex) >= 0);

		FAssert(iChange > 0);

		if (iChange > 0)
		{
			if (GET_PLAYER(eIndex).getTeam() != getTeam())
			{
				for (iI = 0; iI < MAX_CIV_TEAMS; iI++)
				{
					if (GET_TEAM((TeamTypes)iI).isAlive())
					{
						if (GET_TEAM((TeamTypes)iI).AI_getWorstEnemy() == getTeam())
						{
/*************************************************************************************************/
/** BETTER AI (Better Diplomatics) Sephi		                	    						**/
/*************************************************************************************************/
/** orig
							GET_TEAM((TeamTypes)iI).AI_changeEnemyPeacetimeGrantValue(GET_PLAYER(eIndex).getTeam(), iChange);
**/
                            //make sure that if A trades with B and A is C's worst enemy, C is only mad at B if C has met B before
                            //A = this
                            //B = eIndex
                            //C = (TeamTypes)iI
                            if (GET_TEAM((TeamTypes)iI).isHasMet(GET_PLAYER(eIndex).getTeam()))
                            {
                                GET_TEAM((TeamTypes)iI).AI_changeEnemyPeacetimeGrantValue(GET_PLAYER(eIndex).getTeam(), iChange);
                            }
/*************************************************************************************************/
/** End															    							**/
/*************************************************************************************************/
						}
					}
				}
			}
		}
	}
}
 
Awesome, that works perfectly, thanks! :goodjob:
 
So wait, if I just copied the 2nd code instead of the 1st one into the Python file that is it?
 
No, it's SDK not python.

It's kind of difficult to explain if it's not immediately apparent. I'll try though, but Sephi laid out the code in it's entirety, so if you're having problems understanding what to do, it's a problem with not recognizing the format and structure of the language, and that's difficult to explain because you really need to figure it out using common sense.

Anyway In CvPlayerAI.cpp find this:
Code:
void CvPlayerAI::AI_changePeacetimeGrantValue(PlayerTypes eIndex, int iChange)
Now I'm not programmer, so I don't really know what this is per se, but I know it begins my function I want to change, so follow the function until where sephi adds the comments, then insert the code sephi adds. Then recompile. Anyway try to figure it out, and if it doesn't work or it fails to compile post your code and I'll try to see where you're going wrong and help you fix it.
 
Back
Top Bottom