Quick Modding Questions Thread

Thanks for the instruct guys :) I have made the changes so hopefully we are all good now :D

that python error was starting to get irratating :D

Doh... New error

NameError: global name 'Immigration' is not defined

Spoiler :
Code:
		iOwner = pCity.getOwner()
		pPlayer = gc.getPlayer(iOwner)
		UnitType = unit.getUnitType()
		iImmigrant = gc.getInfoTypeForString("UNIT_IMMIGRANT")
		intCity = Immigration.getLeastPopulatedCity(iOwner) [COLOR="Red"]<--this line[/COLOR]
		
		if UnitType == iImmigrant:
			#CyInterface().addImmediateMessage("B", "")
			if pPlayer.isAlive() and not pPlayer.isBarbarian():
				ReducedCityPopulation = pCity.getPopulation() - 2
				pCity.setPopulation(ReducedCityPopulation)				
				if intCity != -1:
					MigrationCity = pPlayer.getCity(intCity)
					Immigration.doImmigrantPlacementAI(unit, MigrationCity)

Now there is also a python file called immigration which is in my mod, so I am not sure if the 2 things are linked or not.. (or if they somehow need to be and they are not properly..)
 
You probably need to import the Immigration file so you can use the functions in it. Up near the beginning of the file, around where the other similar statements are in there already, add a line that just says "import Immigration".

Odds are good that this will fix this problem. Then it is on to the next problem... (Well, with a quick look through the code again it actually like like there won't be another. Besides which, you are running out of lines in the function that have not had a problem fixed already.)
 
Hey guys, was the ability to set a prereq tech for upgradable improvements (like cottage-town, developed in a mod?) I just tried to do it with the existing code but it does not seem to work..

If that already exists it must have been in a mod. You can put prereq techs on the BuildInfos to prevent workers from building an improvement without a tech. AFAIK with XML you can't have a prereq tech for upgrading. This sounds like a good thing to add into Super Forts. ;)
 
I have one new problem.

I work with map scripts and i am put some new map scripts.

You can see "AlphaCentauri"(this is map script from Future Mod), sometimes work, sometimes don't work. I put all terrain and all feature in game, which i see in "AlphaCentauri" map script and i am converted .xml and .py files in .txt because forum don't give to upload this two types of files.

When i am in game, i choose "AlphaCentauri" map script, sometimes work normal, but sometimes i get this:



I really don't know why.

This is my version of Rise from Erebus.

You can see my attached files. I am attach my terrain and feature infos.

Please see and help, i can upload some another map script (for example some map script which work correctly, from "Rise from Erebus").
 

Attachments

  • AlphaCentauri.txt
    19.8 KB · Views: 32
  • CIV4FeatureInfos.txt
    266.6 KB · Views: 51
  • CIV4TerrainInfos.txt
    268.7 KB · Views: 73
this is an odd question but do samurai and gallic swordsman require py. modding to be able to get the crossover promotions?
 
this is an odd question but do samurai and gallic swordsman require py. modding to be able to get the crossover promotions?

No.

Any unit will start with any promotion it is given for free in the Unit XML regardless of normal requirements.

Combine that with the promotion unitcombat requirements and you see how it is done. For example, Drill 1 does not list the melee type so melee units can't take it. But Drill 2 and higher do list melee as being able to take them. So if a melee unit manages to get Drill 1 (like getting it for free in the unitinfo XML, as the Samurai does) it can continue to get the later drill promotions.
 
some civs in my mod are building excessive numbers of workers even when their land is already improved.

I have tried to influence their decision based on the number of workers they already have vs how many cities, but my C++ modding is trial and error and so far, though it compiles and runs fine, they are still building just as many workers.

I have tried this:

Spoiler :

in
Code:
UnitTypes CvCityAI::AI_bestUnit(bool bAsync, AdvisorTypes eIgnoreAdvisor, UnitAITypes* peBestUnitAI)

I added

Code:
// srpt start attempt to curb AI worker spam
	if (kPlayer.AI_getNumAIUnits(UNITAI_WORKER) >= (std::max(kPlayer.getNumCities() / 3, 4)))
	{
		aiUnitAIVal[UNITAI_WORKER] = 0;
	}
	// srpt end

it seemed to have no effect. am I in the wrong place?
 
Hi everyone. I'm not a programmer. I tried to make this code from three parts work of The_J . Code but does not work. Can someone try to find a bug, please?

Spoiler :
PHP:
	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
## Ritual Start ## 
		if iImprovement == gc.getInfoTypeForString("IMPROVEMENT_RITUAL"): 
			iX = pPlot.getX() 
			iY = pPlot.getY() 

			for iXLoop in range(iX - 1, iX + 2):
				for iYLoop in range(iY - 1, iY + 2): 
					pPlot = CyMap().plot(iXLoop, iYLoop) 
					if pPlot.isWater():
						iBonus = pPlot.getBonusType(-1)                                                
						pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True) 
						pPlot.setImprovementType(-1) 
						pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_GRASS" ), 1, 1)                                                              
						if iBonus ==gc.getInfoTypeForString("BONUS_FISH"):                                                                         
							iNewBonus = gc.getInfoTypeForString("BONUS_COW")
						elif iBonus ==gc.getInfoTypeForString("BONUS_CLAM"): 
							iNewBonus = gc.getInfoTypeForString("BONUS_PIG") 
						elif iBonus ==gc.getInfoTypeForString("BONUS_CRAB"): 
							iNewBonus = gc.getInfoTypeForString("BONUS_SHEEP") 
						elif iBonus ==gc.getInfoTypeForString("BONUS_OIL"): 
							iNewBonus = gc.getInfoTypeForString("BONUS_OIL")                                                     
						elif iBonus ==gc.getInfoTypeForString("BONUS_WHALE"): 
							iNewBonus = gc.getInfoTypeForString("BONUS_DEER") 
						else:
							iNewBonus = -1
						pPlot.setBonusType(iNewBonus) 
## Ritual End ##
 
According to the 3rd line, which is unpacking the argsList into separate variables, you already have an iX and iY as they are passed via the argsList. You do not have a pPlot defined anywhere before the loops. So the 6th and 7th lines are a problem and should just be removed.

There may be some other problem, but nothing leapt out at me like that issue.
 
I stole the idea from Voykah, but is there a modcomp that allows me to speed up certain technologies for certain civilizations?
 
I stole the idea from Voykah, but is there a modcomp that allows me to speed up certain technologies for certain civilizations?

Divide the Technology in two (Pre-Tech and Tech) and give Pre-Tech to the Civ for free! Silly, isn't it?
 
Top Bottom