Python please :)

Okay, I added it to the events file in the appropriate place, and I get no errors... but nothings asleep. Bummer. Its like the ability to set units to sleep is not there. I am working with 1.61, not Warlords, btw, is the CvSelectGroup available for 1.61?
 
Are you sure the code is firing?

I've just had a thought - it may be that onBeginGameTurn will actually fire at the end of turn 0, not neccessarily at the start of the game. Maybe onStartGame would be a better trigger... though I don't know if all the units are alive then.
 
You are right TGA, OnBeginGameTurn will be run at the beginning of the END of each game turn. You want onBeginPlayerTurn wich will run at the begining of each player's turn.

And just another note, instead of checking if the gameturn is 0, check if the human turns active is equal to 1 (I think the method is somthing like CyGame().getHumanTurnActive() or something similar). This way the code will work even if the starting era isn't ancient. :)
 
I'm pretty sure onBeginPlayerTurn runs at the end of every player's turn as well. I'll check.

EDIT: Yup, I was unfortunetly correct.
 
That confuses me TGA as I have several mods that set values at the begining of a players turn and things wouldn't work right during the turn if those values wern't set first. I have noticed no problems on the very first turn of players so it couldn't be setting them at the end and then just be working on subsaquent turns. When I look at the event manager the onBeginPlayerTurn says this
Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList

Am I missing something? You have me curious as I've done several things at the beginning of players turns and I've never noticed any problems and I would like to know if isn't working the way I thought it was. :)


EDIT: There is also a onEndPlayer event handler..
 
Hmm. I'll check.

Here we go. As all research and stuff is done at the end of the turn. So I'm assuming that all this stuff is as well. I can't track down where this function is called ATM, which is a bit of a pain, so I can't say for certain. I would do some debugs on the code, but I'm running some other tests which I can't really disrupt.
Code:
void CvPlayer::doTurn()
{
	PROFILE_FUNC();

	CvCity* pLoopCity;
	int iLoop;

	FAssertMsg(isAlive(), "isAlive is expected to be true");
	FAssertMsg(!hasBusyUnit() || GC.getGameINLINE().isMPOption(MPOPTION_SIMULTANEOUS_TURNS), "End of turn with busy units in a sequential-turn game");

	gDLL->getEventReporterIFace()->beginPlayerTurn( GC.getGameINLINE().getGameTurn(),  getID());

	GC.getGameINLINE().verifyDeals();

	AI_doTurnPre();

	if (getRevolutionTimer() > 0)
	{
		changeRevolutionTimer(-1);
	}

	if (getConversionTimer() > 0)
	{
		changeConversionTimer(-1);
	}

	setConscriptCount(0);

	verifyGoldCommercePercent();

	doGold();

	doResearch();

	for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
	{
		pLoopCity->doTurn();
	}

	if (getGoldenAgeTurns() > 0)
	{
		changeGoldenAgeTurns(-1);
	}

	if (getAnarchyTurns() > 0)
	{
		changeAnarchyTurns(-1);
	}

	verifyCivics();

	updateTradeRoutes();

	updateWarWearinessPercentAnger();

	updateEconomyHistory(GC.getGameINLINE().getGameTurn(), calculateTotalYield(YIELD_COMMERCE) - calculateInflatedCosts());
	updateIndustryHistory(GC.getGameINLINE().getGameTurn(), calculateTotalYield(YIELD_PRODUCTION));
	updateAgricultureHistory(GC.getGameINLINE().getGameTurn(), calculateTotalYield(YIELD_FOOD));
	updatePowerHistory(GC.getGameINLINE().getGameTurn(), getPower());
	updateCultureHistory(GC.getGameINLINE().getGameTurn(), countTotalCulture());
	expireMessages();  // turn log

	gDLL->getInterfaceIFace()->setDirty(CityInfo_DIRTY_BIT, true);

	AI_doTurnPost();

	gDLL->getEventReporterIFace()->endPlayerTurn( GC.getGameINLINE().getGameTurn(),  getID());
}
 
Not quite sure what you're asking.

IIRC CvGameInterface.py is the callback interface. The SDK calls the python commands on certain events and you can return true or false from python depending on whether you want the action to continue.
 
The Great Apple said:
Not quite sure what you're asking.

IIRC CvGameInterface.py is the callback interface. The SDK calls the python commands on certain events and you can return true or false from python depending on whether you want the action to continue.

Thanks TGA. Thats what I was asking. So pretty much an SDK modification needs to be made in order to return a true or false based on the cvGameInterface coding.
 
Back
Top Bottom