Debugging further issues with the NPC split

Thunderbrd

C2C War Dog
Joined
Jan 2, 2010
Messages
30,015
Location
Las Vegas
There are still a number of bugs in the NPC split project that I have yet to sort out. Some of them, I really need help from a Python expert (@DH!)

I'm doing a review and finding many of the issues I'm seeing in the python may require work in the dll to setup the fix in the python. Some of them I think I can functionally see what needs to change in the python but I have no idea how to actually program them in python.

In both cases, I need some help at least talking it out and if I can get some direct help with reprogramming, it would be awesome.

I THINK we can fix all these issues without anything happening to break saves but there are some other ways I can go about things here that would require that and would inadvertently take care of some of the problems.

Anyhow, I started a new thread on this so that the posts could be considered a ticket item and we could make sure each individual area is taken care of in order. I'll include my first item of discovery and discussion in the next post.
 
Item #1:
RevUtils.py
Code:
def changePersonality( playerIdx, newPersonality = -1 ) :
	# Changes leader personality of this civ

	player = gc.getPlayer(playerIdx)

	if( newPersonality < 0 ) :
		iBestValue = 0
		newPersonality = -1

		for iI in range(0,gc.getNumLeaderHeadInfos()) :
			if (not iI == gc.getDefineINT("BARBARIAN_LEADER")) :
				iValue = (1 + game.getSorenRandNum(10000, "Choosing Personality"))

				for iJ in range(0,gc.getMAX_CIV_PLAYERS()) :
					if (gc.getPlayer(iJ).isEverAlive()) :
						if (gc.getPlayer(iJ).getPersonalityType() == iI) :
							iValue /= 2

				if (iValue > iBestValue) :
					iBestValue = iValue
					newPersonality = iI

	if (newPersonality >= 0 and newPersonality < gc.getNumLeaderHeadInfos()) :
		player.setPersonalityType(newPersonality)
The problem is specifically here:
if (not iI == gc.getDefineINT("BARBARIAN_LEADER")) :

We now have more than one leader for NPCs and we need to include a solution for this that can tie into the xml so that this doesn't keep having to be a hardcoded check. There is currently no tag for a leader to designate that leader an NPC leader only, but if there were, and I reported the tag through to python, would we be able to easily capture that tag data and use it here to say basically:
if leader is not an npc

rather than
if leader is not barbarian
?

Seems to be the fix to me and while I can easily program the boolean for the leaderheadinfos.xml, capturing that data into a correct syntax filter statement here in this bit of python would be past my skills.

Still, I don't see how to do this without that tag so it seems obvious I need to take that step at least ;) Tag will be bNPC and is called 'isNPC()'.
 
What the code is checking for is a possible new leader for a nation. Up until now that has meant every leader except the barbarian one.

The minimum we need is a boolean indicating that this leader is not suitable for any playable nation, since elsewhere you may change the nation you play. This is not quite the same as NPC but includes them.

I would go for a tag bPlayable with the call isPlayable().
 
What the code is checking for is a possible new leader for a nation. Up until now that has meant every leader except the barbarian one.

The minimum we need is a boolean indicating that this leader is not suitable for any playable nation, since elsewhere you may change the nation you play. This is not quite the same as NPC but includes them.

I would go for a tag bPlayable with the call isPlayable().

Thanks for the confirming diagnosis. It's also nice to see you feel you can properly operate on a bool tag reported to python to resolve this.

Do you see any reason we would want to define a leader as unplayable other than being NPCs? I already built the tag is all...
 
About the issue with the neanderthal cities.

Did you try to give them a lower index before the barbarian player. Or maybe increase MAX_CIV_PLAYERS to 41 and give the neanderthal player index 41.

Those bars are done in the exe so there isn't alot we could try to fix it.
 
Not really, I just thought it would give us more flexibility in the future eg transitioning from nations to cultures.
Ok... will change it later if it seems necessary. For now, the tag is in place as isNPC()

About the issue with the neanderthal cities.

Did you try to give them a lower index before the barbarian player. Or maybe increase MAX_CIV_PLAYERS to 41 and give the neanderthal player index 41.

Those bars are done in the exe so there isn't alot we could try to fix it.

Changing around the indexes is what will mess up save games so it's the last debugging option and the last thing I'll do when many other reported bugs have been caught up to.

I was hoping for another answer... sigh. So in short, the theory stands now that the EXE has the same basic systematic error as much of what I just fixed in python, where the assumption that the barbarian player is the last player is set in stone there. If that's the case, this gets much more difficult. I'll have to redefine much of the entire process. Ugh...
 
Back
Top Bottom