Python Error in CvWBDesc.py

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
In BTS 3.19, I get the following python error in the CvWBDesc.py file:

Code:
Python Exception

Traceback (most recent call last):

File "CvWBInterface", line 18, in writeDesc

File "CvWBDesc", line 1545 in write

File "CvWBDesc", line 1193 in write

File "CvWBDesc", line 827 in write

AttributeError: 'NoneType' object has no attribute 'GetType'


line 827 in the CvWBDesc.py file reads:
Code:
f.write("\t\tUnitAIType=%s\n" %(gc.getUnitAIInfo(unit.getUnitAIType()).getType()))

Could this have something to do with the CIV4UnitAIInfos.xml file, which has these add on entries?

Code:
<UnitAIInfo>
	<Type>UNITAI_INQUISITOR</Type>
	<Description>UNITAI_INQUISITOR</Description>
</UnitAIInfo>
<UnitAIInfo>
	<Type>UNITAI_INQUISITOR_SEA</Type>
	<Description>UNITAI_INQUISITOR_SEA</Description>
</UnitAIInfo>

I can't seem to clear up this error. Any ideas on what may be wrong?

Respectfully,

Orion Veteran :cool:
 
I had a similar issue and it was caused by one of the units having a AI type of no AI, so that unit.getUnitAIType() is null.
 
In my code I was spawning using the player.initunit function and setting the AI to UnitAITypes.NO_UNITAI. Since the python class reference encourages you to use that setting I afterward used the unit.setUnitAIType(UnitAITypes.UNITAI_UNKNOWN) to fix the error.

Also you could have it run a check to see if unit.getUnitAIType() is NO_UNITAI and if it is just plug the UNITAI_UNKNOWN in even though the AI type will not be accurate for thoes 2 in the world builder.

I suggest just making sure that every unit has an AI. It causes some annoying side effects if not when debugging.
 
In my code I was spawning using the player.initunit function and setting the AI to UnitAITypes.NO_UNITAI. Since the python class reference encourages you to use that setting I afterward used the unit.setUnitAIType(UnitAITypes.UNITAI_UNKNOWN) to fix the error.

Also you could have it run a check to see if unit.getUnitAIType() is NO_UNITAI and if it is just plug the UNITAI_UNKNOWN in even though the AI type will not be accurate for thoes 2 in the world builder.

I suggest just making sure that every unit has an AI. It causes some annoying side effects if not when debugging.

This error is strange. I can start Civ4 and resume play on a saved game and the error will come up. Immediately closing and reopening the same game -- and no error at all! :crazyeye:

I don't believe I want to choose the work around, but rather, as you say make sure every unit has an AI. Is there a specific way to do this in XML or python? Is there a post that I can use as good example to follow?

Orion Veteran :cool:
 
Back
Top Bottom