Liberating, trading and gifting cities

I've fixed it!! :D

God-Emperor was spot on with his guess. The solution is actually quite simple - I've moved the code from CvTeam and into CvTeamAI. It's now inserted as part of AI_doTurnPost() function and it works a perfectly!

In fact this is even better than hoped, as now the code perfroms the check every turn and picks up all AI's - not just those who have a newly conquered vassal. This givs me much more options in terms of performing checks to ensure the ai makes good strategic decisions.

Magic! Thanks to Red_Key, Tholal and God-Emperror for all your help with this one. :goodjob:
I'm glad its working, would you post the finished code for me, :blush: not sure I've followed the process properly.
 
Code below. I've added another check to see what the culture is of the city in question. Hopefully this should prevent the ai from accidentally releasing distant colonies. The whole thing is not fully tested, but so far it seems to work.

Code:
	CvCity* pLoopCity;
	CvCity* pCapital;
	int iLoop;
	PlayerTypes ePlayer = NO_PLAYER;
	ePlayer = getLeaderID();

	pCapital = GET_PLAYER(ePlayer).getCapitalCity();
	
	for (pLoopCity = GET_PLAYER(ePlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iLoop))
	{
		if (100 * plotDistance(pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE(), pCapital->getX_INLINE(), pCapital->getY_INLINE()) / GC.getMapINLINE().maxPlotDistance() > 30)
		{
			FAssert(pLoopCity->getOwnerINLINE() != getID());
			if(pLoopCity->plot()->calculateCulturePercent(pLoopCity->getOwnerINLINE()) < 25)			
			{
				pLoopCity->liberate(false);
			}
		}
	}

The whole thing is inserted in CvTeamAI, at the end of void CvTeamAI::AI_doTurnPost().
 
Top Bottom