Need help merging

Well, good. It seems to run past that part now, so it should be OK.
OK.

What it is saying is correct. The class PyCity, as defined in the file PyHelpers.py, does not have as an attribute a function called "setHasRealBuildingIdx".

What it does have is the function setNumRealBuildingIdx.

The difference is that instead of having a true/false value for the second parameter it takes a number. I would guess that originally you could only have one of any specific building in a city and at some point they changed it so that you could have more than one and this mod predates the change (the Final Frontier mod that comes with BtS can have more than one, so any such change happened in BtS or earlier - the GlobalDefines.xml or GlabalDefinesAlt.xml file has a value CITY_MAX_NUM_BUILDINGS which is normally set to 1, but can be higher as Final Frontier sets it to 8).

I would say that changing any occurrence of something like this:
Code:
city.setHasRealBuildingIdx([COLOR="Red"]iThingy[/COLOR],True)
to be something like this:
Code:
city.setNumRealBuildingIdx([COLOR="Red"]iThingy[/COLOR],1)

The reason iThingy is red is that it isn't really iThingy, it will be something different each time.

There are 5 occurances of city.setHasRealBuildingIdx in the file on lines 540, 544, 547, 550, and 569.

There are also 3 occurances of capital.setHasRealBuildingIdx which need the same fix (but to capital.* rather than city.*) on lines 563, 566, and 580.

Fixing all 8 of those should get rid of this problem. Then you get to see what the next problem will be. I figure there is about a 50% chance that you won't be done with this file yet - it would be higher but this is getting close to the end of the file.

OK i did this.;)

Interesting thing (maybe). I was skimming the file to see what was ahead and noticed something.

I'm pretty sure the original BarbarianCiv.py file has a bug in it on line 609.
Code:
                for i in range(0, gc.getMAX_CIV_PLAYERS()) :
                    [B]if( newPlayer.canContact( 9 ) ) :[/B]
                        contactList.append( i )

The "9" should almost certainly be an "i".

As it is, if the new barbarian civ can contact player 9 then every player in the game is added to the list of players they can contact. If they can not contact player 9 then nobody is added to the list. This list is later used to pick a target for a "military type" barbarian to attack (it picks one off the list and declares war immediately if there is at least 1 player in the list).

Changing it to an "i" would hopefully make the list be the actual players that they could contact, which should be those that are close.

So even the original apparently didn't work quite the way it was supposed to.

Did this also. ;)

There apepars to be another bug in the original:

Line 651 is nto indented as far as it should be. I ought to have 1 more tab level of indentation.
As it is, the lack of indentation should casue the definition of the function to end:
Code:
    def onFirstContact( self, argsList ) :
        'Contact'
	iTeamX,iHasMetTeamY = argsList
So the onFirstContact function is likely to do nothing and there is a bunch of loose code floating around in the end of class BarbarianCiv.

This can't be a good thing.

Edit: Well, after posting it here I discovered something. The line that starts with "iTeam" is indented with a single tab, the others use spaces. Mixing tabs and spaces is never a good idea. All (hopefully) of the other lines in the file use spaces. That one line ought to be indented with spaces as far as the next line with text on it.

Tried this and it didnt work, i got a syntax error that said something was wrong with: iTeamX,iHasMetTeamY = argsList :confused: SO i changed it back.


Now after the first two above i get this error message:

Traceback (most recent call last):

File "CvEventInterface", line 25, in onEvent

File "CvCustomEventManager", line 162, in handleEvent

File "CvCustomEventManager", line 173, in _handleDefaultEvent

File "BarbarianCiv", line 104, in onEndGameTurn

File "BarbarianCiv", line 207, in checkBarbCities

File "BarbarianCiv", line 552, in createBarbCiv

AttributeError: 'CyCity' object has no attribute 'countTotalCulture'
ERR: Python function onEvent failed, module CvEventInterface
 
Look back up in this thread. There were two places that used countTotalCulture that needed to be changed. You fixed one of them, but you still need to fix the second one.

I also agree that you need to avoid mixing tabs and spaces. You most certainly need to fix that line that you tried fixing.
 
Look back up in this thread. There were two places that used countTotalCulture that needed to be changed. You fixed one of them, but you still need to fix the second one.

I also agree that you need to avoid mixing tabs and spaces. You most certainly need to fix that line that you tried fixing.

OK i put in the other totalculture and tried again to fix that line and got a ton of errors??:blush:



syntax error?

Spoiler :
Code:
     else :
            #if( self.LOG_DEBUG ) : CyInterface().addImmediateMessage("Game is full ...","")
            if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Game is full ...")


    [B]def onFirstContact( self, argsList ) :
	'Contact'
	iTeamX,iHasMetTeamY = argsList[/B]

	if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - %d has just met %d"%(iTeamX,iHasMetTeamY))

        teamX = gc.getTeam(iTeamX)
        if( teamX.getNumMembers() > 1 ) :
            #if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Team %d has too many members: %d"%(iTeamX,teamX.getNumMembers()))          
            return

Total what i changed.

Spoiler :
Code:
                    elif( barbSettleType == 2 ) : # Builder
                        if( city.canConstruct( iLibrary ) ) :
                            if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iLibrary).getDescription(),city.getName()))
                            city.setNumRealBuildingIdx(iLibrary,1)
                        if( city.canConstruct( iLighthouse ) ) :
                            if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iLighthouse).getDescription(),city.getName()))
                            city.setNumRealBuildingIdx(iLighthouse,1)
                        if( city.canConstruct( iGranary ) ) :
                            if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iGranary).getDescription(),city.getName()))
                            city.setNumRealBuildingIdx(iGranary,1)
                    iTotCul = city.[B]GetCy().countTotalCultureTimes100()/100)/10.0 )[/B]
                    if( iTotCul > 0 ) :
                        city.setCulture( int(iTotCul/2.0) )
                        if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Culture of %s set to %d"%(city.getName(),city.getCulture()))
 
Ignore all the lines that say

ERR: Call function onEvent failed. Can't find module CvEventInterface​

and you find the error:

Code:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 52, in load_module
File "CvCustomEventManager", line 25, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "BarbarianCiv", line 552
iTotCul = city.GetCy().countTotalCultureTimes100()/100)/10.0 )
                                                      ^
SyntaxError: invalid syntax

Failed to load python module CvEventInterface.

You messed up editing line 552, writing this:

Code:
iTotCul = city.GetCy().countTotalCultureTimes100()/100[B])/10.0 )[/B]

You have two extra closing parentheses. What is the original line 552?
 
Ignore all the lines that say

ERR: Call function onEvent failed. Can't find module CvEventInterface​

and you find the error:

Code:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 52, in load_module
File "CvCustomEventManager", line 25, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "BarbarianCiv", line 552
iTotCul = city.GetCy().countTotalCultureTimes100()/100)/10.0 )
                                                      ^
SyntaxError: invalid syntax

Failed to load python module CvEventInterface.

You messed up editing line 552, writing this:

Code:
iTotCul = city.GetCy().countTotalCultureTimes100()/100[B])/10.0 )[/B]

You have two extra closing parentheses. What is the original line 552?

Code:
if( city.canConstruct( iGranary ) ) :
                            if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iGranary).getDescription(),city.getName()))
                            city.setHasRealBuildingIdx(iGranary,True)
                    [B][B]iTotCul = city.GetCy().countTotalCulture()[/B][/B]
                    if( iTotCul > 0 ) :
                        city.setCulture( int(iTotCul/2.0) )
                        if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Culture of %s set to %d"%(city.getName(),city.getCulture()))
 
OK tried it again and still get this? I wrote it exactly like jojoweb said?? So what should it be then?

Traceback (most recent call last):
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "<string>", line 1, in ?

File "<string>", line 52, in load_module

File "CvEventInterface", line 13, in ?

File "<string>", line 52, in load_module

File "CvCustomEventManager", line 25, in ?

File "<string>", line 35, in load_module

File "<string>", line 13, in _get_code

File "

BarbarianCiv

", line

552

:

invalid syntax


Failed to load python module CvEventInterface.
 
Remove the part that I bolded above to get this:

Code:
iTotCul = city.GetCy().countTotalCultureTimes100()/100
 
Remove the part that I bolded above to get this:

Code:
iTotCul = city.GetCy().countTotalCultureTimes100()/100

OK, do you want me to do that to BOTH of them or just this one??


Now i got to re-start a new game and see what happens??

EDIT
: OK now i get this error:

Traceback (most recent call last):

File "CvEventInterface", line 25, in onEvent

File "CvCustomEventManager", line 162, in handleEvent

File "CvCustomEventManager", line 173, in _handleDefaultEvent

File "BarbarianCiv", line 104, in onEndGameTurn

File "BarbarianCiv", line 207, in checkBarbCities

File "BarbarianCiv", line 622, in createBarbCiv

ArgumentError: Python argument types in
CyTeam.declareWar(CyTeam, int, bool)
did not match C++ signature:
declareWar(class CyTeam {lvalue}, int, bool, int)
ERR: Python function onEvent failed, module CvEventInterface

104:
Code:
self.checkBarbCities()

207:
Code:
 if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Current modifiers are: mod %f, ncm %d, gsm %f"%(mod,numCitiesMod,gsm))
                [B]self.createBarbCiv( barbCityTree[maxListIdx] )[/B]
                return

622:
Code:
else :
                        vr = game.getSorenRandNum(len(closePlayers),'BarbarianCiv: pick who to declare war on')
                        victimIdx = closePlayers[vr]
                    [B]pyNewPlayer.getTeam().declareWar(victimIdx,True)[/B]
                    if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - New civ declared war on %s"%(PyPlayer(victimIdx).getCivilizationName()))
 
Try instead

PHP:
pyNewPlayer.getTeam().declareWar(victimIdx,True,WarPlanTypes.WARPLAN_LIMITED)


Haven't looked at the function, i just guess, that it shouldn't be a bigger war.

OK thx, that seems to work!;) Now i can find the next error :blush::(
 
OK ran into a NEW error:

Traceback (most recent call last):

File "CvEventInterface", line 25, in onEvent

File "CvCustomEventManager", line 155, in handleEvent

File "CvCustomEventManager", line 166, in _handleDefaultEvent

File "BarbarianCiv", line 104, in onEndGameTurn

File "BarbarianCiv", line 207, in checkBarbCities

File "BarbarianCiv", line 628, in createBarbCiv

ArgumentError: Python argument types in
CyCity.isCoastal(CyCity)
did not match C++ signature:
isCoastal(class CyCity {lvalue}, int)
ERR: Python function onEvent failed, module CvEventInterface

Line 628:

Code:
for i in range(0,gc.getMAX_CIV_PLAYERS()) :
            player = gc.getPlayer(i)
            if( player.isAlive() ):
                if( player.getTeam() == iTeamX ) :
                    playerX = player
                [B]elif( player.getTeam() == iHasMetTeamY ) :[/B]
                    playerY = player
 
Here, the game is asking what the minimum size of a lake/ocean is for the city to be considered coastal.

You want to add a 10, so if it currently reads:

pCity.isCoastal()

Then it should become:

pCity.isCoastal(10)


I dont see "pCity.isCoastal" anyplace in the pyhton file, sorry.

btw, is there anyway to reduce the number of units that are given to the civ in the start when they first arrive? Darn thing gives around 25 units?

Just the file attached.
 
In this file it's:

city.GetCy().isCoastal()

on line 628. Just add the 10.

To adjust the number of units, edit lines 531 to 538. Perhaps to something like:
Code:
                        extraUnits = int( (newPlayer.getCurrentEra()+1) - 2*i )
                        if( len(closePlayers) == 0 ) : # Viking style, no horsies (but still allows elephants ... )
                            if( not iCounter == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iCounter,cityX,cityY,2+game.getSorenRandNum(4+extraUnits,'BarbarianCiv: give military infantry'))
                            if( not iAttack == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iAttack,cityX,cityY,2+game.getSorenRandNum(4+extraUnits,'BarbarianCiv: give military mobile'))
                        else :
                            if( not iCounter == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iCounter,cityX,cityY,1+game.getSorenRandNum(3+extraUnits,'BarbarianCiv: give military infantry'))
                            if( not iMobile == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iMobile,cityX,cityY,1+game.getSorenRandNum(3+extraUnits,'BarbarianCiv: give military mobile'))
                            if( not iAttack == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iAttack,cityX,cityY,1+game.getSorenRandNum(3+extraUnits,'BarbarianCiv: give military mobile'))
 
OK,NOT related to anything above, i just didnt want to start another thread is all, but i got this error, what happened was i was playing late game, it looked like it went into the usual RunTime error and the desktop appeared, but then the game came back on (i was surprised:eek:) then it had this error??

Traceback (most recent call last):

File "CvScreensInterface", line 719, in forceScreenRedraw

File "CvMainInterface", line 967, in redraw

File "CvMainInterface", line 1692, in updateSelectionButtons

RuntimeError: unidentifiable C++ exception
ERR: Python function forceScreenRedraw failed, module CvScreensInterface

CvScreen 719:

Code:
# Main Interface Screen
	if ( argsList[0] == MAIN_INTERFACE ):
		m[B]ainInterface.redraw()[/B]
	elif ( argsList[0] == WORLDBUILDER_SCREEN ):
		worldBuilderScreen.redraw()
	elif ( argsList[0] == WORLDBUILDER_DIPLOMACY_SCREEN ):
		worldBuilderDiplomacyScreen.redraw()
	elif ( argsList[0] == TECH_CHOOSER ):
		techChooser.updateTechRecords(true)

CvMainInterface line 967:

Code:
if ( CyInterface().isDirty(InterfaceDirtyBits.SelectionButtons_DIRTY_BIT) == True ):
			# Selection Buttons Dirty
			[B]self.updateSelectionButtons()[/B]
			CyInterface().setDirty(InterfaceDirtyBits.SelectionButtons_DIRTY_BIT, False)
		if ( CyInterface().isDirty(InterfaceDirtyBits.ResearchButtons_DIRTY_BIT) == True ):

CvMainInterface line 1692:

Code:
if (pHeadSelectedCity.canTrain(eLoopUnit, False, True)):
						szButton = gc.getPlayer(pHeadSelectedCity.getOwner()).getUnitButton(eLoopUnit)
						[B]screen.appendMultiListButton( "BottomButtonContainer", szButton, iRow, WidgetTypes.WIDGET_TRAIN, i, -1, False )[/B]
						screen.show( "BottomButtonContainer" )
 
I know this error with a little difference (in line 1061, in updatePlotListButtons).
Seems not to be reproducable, doesn't occur often (1:50 games, i guess).
Wouldn't really worry about it, but if someone knows a solution for it, i would also be happy to hear it.
 
I know this error with a little difference (in line 1061, in updatePlotListButtons).
Seems not to be reproducable, doesn't occur often (1:50 games, i guess).
Wouldn't really worry about it, but if someone knows a solution for it, i would also be happy to hear it.


ANyone know what he's talking about?
 
Back to the BarbarianMod, is there anyway to REDUCE the number of units that the Barb's produce, i think i asked this earlier and took the advise but it still produces WAY to many units?? Heck i didnt even get started.:(
 
Sure, you can mess with the numbers in lines 531 to 538 ... my suggestions are in bold, but you can try changing the numbers:

Code:
                        extraUnits = [B]int( (3*(newPlayer.getCurrentEra()+1))/2 - 2*i )[/B]
                        if( len(closePlayers) == 0 ) : # Viking style, no horsies (but still allows elephants ... )
                            if( not iCounter == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iCounter,cityX,cityY,2+game.getSorenRandNum([B]2[/B]+extraUnits,'BarbarianCiv: give military infantry'))
                            if( not iAttack == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iAttack,cityX,cityY,2+game.getSorenRandNum([B]2[/B]+extraUnits,'BarbarianCiv: give military mobile'))
                        else :
                            if( not iCounter == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iCounter,cityX,cityY,1+game.getSorenRandNum([B]1[/B]+extraUnits,'BarbarianCiv: give military infantry'))
                            if( not iMobile == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iMobile,cityX,cityY,1+game.getSorenRandNum([B]1[/B]+extraUnits,'BarbarianCiv: give military mobile'))
                            if( not iAttack == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iAttack,cityX,cityY,1+game.getSorenRandNum([B]1[/B]+extraUnits,'BarbarianCiv: give military mobile'))

Explanation:

The first line is now set up to give more units for later eras, while keeping things constant for the first two eras. The constant factors on the subsequent lines were reduced so that there would be fewer units.
 
Top Bottom