Mod Component Requests Thread

I have something in onDoCityTurn already (it prevents unhappiness from defying a UN resolution while running the Police State civic), so is this how I'd add the first bit of code? (the code you added is in red)

Code:
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
[COLOR="Red"]        ###from here
        pPlayer = gc.getPlayer(iPlayer)
        if not pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY")):
                        iSlaveSpecialist = gc.getInfoTypeForString("SPECIALIST_SLAVE")
                        iSlaveSpecialistInCity = pCity.getSpecialistCount(iSlaveSpecialist)
                        pCity.alterSpecialistCount(iSlaveSpecialist,-iSlaveSpecialistInCity)
                ###to here[/COLOR]
		
# no anger defying UN resolutions start #
		iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
		iPoliceState = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_POLICE_STATE')
		pPlayer = gc.getPlayer(iPlayer)
		iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)

		if (iGovernmentCivic == iPoliceState):
			pCity.changeDefyResolutionAngerTimer(pCity.getDefyResolutionAngerTimer())
# no anger defying UN resolutions end #

You have again spaces instead of tabs! :nono: :trouble:
It seems to look right.
 
Okay, is this tabbed correctly?

Code:
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		###from here
		pPlayer = gc.getPlayer(iPlayer)
		if not pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY")):
						iSlaveSpecialist = gc.getInfoTypeForString("SPECIALIST_SLAVE")
						iSlaveSpecialistInCity = pCity.getSpecialistCount(iSlaveSpecialist)
						pCity.alterSpecialistCount(iSlaveSpecialist,-iSlaveSpecialistInCity)
				###to here
 
Okay, is this tabbed correctly?
Too many tabs after the "if not" line.
Code:
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		###from here
		pPlayer = gc.getPlayer(iPlayer)
		if not pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY")):
			iSlaveSpecialist = gc.getInfoTypeForString("SPECIALIST_SLAVE")
			iSlaveSpecialistInCity = pCity.getSpecialistCount(iSlaveSpecialist)
			pCity.alterSpecialistCount(iSlaveSpecialist,-iSlaveSpecialistInCity)
			###to here
 
Oh, will that cause it not to work? Because it didn't, here's a screen AFTER I changed my civic from Slavery back to Tribalism, see how the slaves remain?

Spoiler :
attachment.php


So, do you think it is something in the code or do you think it was just the indentations? I fixed it now so I'll test it again:

Code:
		###from here
		pPlayer = gc.getPlayer(iPlayer)
		if not pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY")):
			iSlaveSpecialist = gc.getInfoTypeForString("SPECIALIST_SLAVE")
			iSlaveSpecialistInCity = pCity.getSpecialistCount(iSlaveSpecialist)
			pCity.alterSpecialistCount(iSlaveSpecialist,-iSlaveSpecialistInCity)
				###to here
 
Hmm, that didn't appear to work either. I am running Serfdom and the Slave Specialists still work in the city. The Slave Specialists are ONLY supposed to work while running the Slavery civic. I am not sure exactly what The_J intended this code to do, but ideally I want the slave specialists to disapear when you change out of the slavery civic. Or they could at least give no bonus during that time. But here is a screenshot:

Spoiler :
attachment.php
 

Attachments

  • SlavesInRome.jpg
    SlavesInRome.jpg
    201.2 KB · Views: 220
And I might as well double-check that this code is correct (it if for the Flavian Amphitheatre wonder, i.e. the one where you get to build your enemy's UU):

Code:
class DiplomacyGameUtils:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
[COLOR="Red"]		###from here on
		pPlayer = gc.getPlayer(pCity.getOwner())
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_FLAVIAN"))>0:
			iObsoleteTech = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_FLAVIAN")).getObsoleteTech()
			if (iObsoleteTech ==-1) or ( gc.getTeam(pPlayer.getTeam()).isHasTech(iObsoleteTech) == false ):
				iPreviousOwner = pCity.getPreviousOwner ()
				if iPreviousOwner>-1 and iPreviousOwner <=gc.getMAX_CIV_PLAYERS ():
					pPreviousOwner = gc.getPlayer(iPreviousOwner)
					iUniqueUnit = gc.getCivilizationInfo(pPreviousOwner.getCivilizationType ()).getCivilizationUnits(eUnit)
					iDefaultUnit = gc.getUnitClassInfo(eUnit).getDefaultUnitIndex()
					if (iDefaultUnit > -1) and (iUniqueUnit > -1) and (iDefaultUnit != iUniqueUnit):
						return True
                ### to here    [/COLOR]                          
        
		return False

So, does that look right (indentation-wise and everything)?
 
Intendation (and everything else) looks right :).


@slaves:
Seems, that i missinterpreted the use of the command "alterSpecialistCount". I thought, it would set the total amount of specialists in the city. It doesn't, so i guess, it just sets the maximum amount of specialists which you can have as normal specialist in a city :/.
-> now i can't see a way to do it :/.
 
The problem is also that the slave is great person that joined the city, not just a normal or a free specialist. Works best that way for the adding part no doubt but how do you remove settled great people from a city with python? If I had to guess, my bet goes towards
int changeForceSpecialistCount(SpecialistType eIndex, INT iChange)
or in this case changeForceSpecialistCount(iSlaveSpecialist , -getForceSpecialistCount(iSlaveSpecialist))

if you want to keep Slaves in some scenarios, just not let them produce anything outside slavery civic, that's even easier: just give the slavery civic a +1 :hammers: bonus to slave specialists and make the slave specialist produce nothing by default.
 
Intendation (and everything else) looks right :).


@slaves:
Seems, that i missinterpreted the use of the command "alterSpecialistCount". I thought, it would set the total amount of specialists in the city. It doesn't, so i guess, it just sets the maximum amount of specialists which you can have as normal specialist in a city :/.
-> now i can't see a way to do it :/.

Hmm, is there a way to change the slave specialist into a different type of specialist? So at least aesthetically you don't have slaves in your city if you have emancipation?
 
Since I posted almost simultaniously and I edited afterwards, I post again to tell you I think I have the solution. You'll need to test it yourself though.
 
if you want to keep Slaves in some scenarios, just not let them produce anything outside slavery civic, that's even easier: just give the slavery civic a +1 :hammers: bonus to slave specialists and make the slave specialist produce nothing by default.

I didn't see this until after my last post, I think this is ultimately the best way to go about doing this. You'll obviously still have the slaves in the screen, which I guess in a way is a method of saying "hey :):):):):):):), remember when you enslaved people!!!" so really this is the best way I've seen to get around this issue. :goodjob:
 
Anyway, The_J, I tried out the Flavian Amphitheatre code and it still didn't work, but this time it didn't go haywire like last time. I got an assert failure and a python pop-up and couldn't build the Phalanx (I conquered a Greek city) in the captured city. Here is the assert failure I got when I took the city:

attachment.php

Here is the python pop-up I got when it opened the build-select screen:

attachment.php

And for good measure here is the code in the GameUtils file:

Code:
class DiplomacyGameUtils:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
[COLOR="Red"]		###from here on
		pPlayer = gc.getPlayer(pCity.getOwner())
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_FLAVIAN"))>0:
			iObsoleteTech = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_FLAVIAN")).getObsoleteTech()
			if (iObsoleteTech ==-1) or ( gc.getTeam(pPlayer.getTeam()).isHasTech(iObsoleteTech) == false ):
				iPreviousOwner = pCity.getPreviousOwner ()
				if iPreviousOwner>-1 and iPreviousOwner <=gc.getMAX_CIV_PLAYERS ():
					pPreviousOwner = gc.getPlayer(iPreviousOwner)
					iUniqueUnit = gc.getCivilizationInfo(pPreviousOwner.getCivilizationType ()).getCivilizationUnits(eUnit)
					iDefaultUnit = gc.getUnitClassInfo(eUnit).getDefaultUnitIndex()
					if (iDefaultUnit > -1) and (iUniqueUnit > -1) and (iDefaultUnit != iUniqueUnit):
						return True
                ### to here [/COLOR]                             
        
		return False

I'm hoping I just did something stuipd like put in the wrong indentation or something. Do you see anything wrong with this?
 

Attachments

  • FlavianAssertFailure.jpg
    FlavianAssertFailure.jpg
    21.2 KB · Views: 210
  • FlavianPythonPopUp.jpg
    FlavianPythonPopUp.jpg
    31.7 KB · Views: 211
I'm not sure, what is wrong. The problem is in the code which i've stolen from tsentom, and i'm not completly sure, what he did, but it looks like it should work.

Okay, another try: Replace this line:
PHP:
iDefaultUnit = gc.getUnitClassInfo(eUnit).getDefaultUnitIndex()

With

PHP:
iDefaultUnit = gc.getCivilizationInfo(pPlayer.getCivilizationType ()).getCivilizationUnits(eUnit)



:think: thinking about the assert a bit more...is the civ you've played maybe a modular civ?
 
Thanks, I'll give that a shot. I think the Assimilation mod also does a similar thing (except you can't train your UU in the city as well) so you might want to take a look at that code too if this doesn't work.

:think: thinking about the assert a bit more...is the civ you've played maybe a modular civ?

No, I'm Rome.
 
Well, I didn't get a python pop-up, but I got the same assert failure. Just in case something is wrong here's the code:

Code:
class DiplomacyGameUtils:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
[COLOR="Red"]		###from here on
		pPlayer = gc.getPlayer(pCity.getOwner())
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_FLAVIAN"))>0:
			iObsoleteTech = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_FLAVIAN")).getObsoleteTech()
			if (iObsoleteTech ==-1) or ( gc.getTeam(pPlayer.getTeam()).isHasTech(iObsoleteTech) == false ):
				iPreviousOwner = pCity.getPreviousOwner ()
				if iPreviousOwner>-1 and iPreviousOwner <=gc.getMAX_CIV_PLAYERS ():
					pPreviousOwner = gc.getPlayer(iPreviousOwner)
					iUniqueUnit = gc.getCivilizationInfo(pPreviousOwner.getCivilizationType ()).getCivilizationUnits(eUnit)
					iDefaultUnit = gc.getCivilizationInfo(pPlayer.getCivilizationType ()).getCivilizationUnits(eUnit)
					if (iDefaultUnit > -1) and (iUniqueUnit > -1) and (iDefaultUnit != iUniqueUnit):
						return True
                ### to here[/COLOR]                              
        
		return False

And here is a screen. I captured a Viking city and could not build a Beserker (I had all the prereqs, and I put a red square around the Maceman).
 

Attachments

  • FlavianScreenShot.jpg
    FlavianScreenShot.jpg
    196.4 KB · Views: 73
:crazyeye: i have no real idea.

You could try to replace
PHP:
iDefaultUnit = gc.getCivilizationInfo(pPlayer.getCivilizationType ()).getCivilizationUnits(eUnit)

with just
PHP:
iDefaultUnit = eUnit

(or just kick the whole line, and replace iDefaultUnit with eUnit everywhere).
Maybe this will work :/.
 
Well, neither of those solutions worked. On the first one nothing really happened, but I got the same assert failure. On the second one it allowed me to build every possible unit in the game, even those with a -1 cost. So I could build great Engineers and Stealth Bombers and Clones etc. in 875 B.C. I'm not sure if you have anymore solutions, I'll probably scrap the wonder at this point, but if you think you can come up with something else that would be appreciated.
 
I've tested it today, and it's not doable :(.
You've said, that the second attempt last time did allow you to build every unit in the game right?
No, it didn't, you couldn't build all the UUs.
Seems, that the check, which unit is an UU, comes before this function, so i can't changy anything there :(.
Too said :(.
 
Back
Top Bottom