Quick Modding Questions Thread

Hello! I have a problem for including next war archeology in my private mod. The different arcologies don't stack correctly and i don't find the solution. Could anyone help me please? Here is a screen shot. Thanks!

Hi Bullist, as i understand you want arcologies like in Next War, if you want that, you must do next:

Use this code from CvGameUtils.py:
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		
		[B][COLOR="Red"]# player can't build an arcology if they have shielding or advanced shielding
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True
		
		# player can't build shielding if they have advanced
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True

		return False[/COLOR][/B]

and from CvEventManager.py:
Code:
	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
			# If this is a wonder...
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())

		CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)
		
		[B][COLOR="Red"]if iBuildingType == CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), "BUILDING_ARCOLOGY_SHIELDING"):
			pCity.setNumRealBuilding(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), "BUILDING_ARCOLOGY"), False)
		elif iBuildingType == CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), "BUILDING_DEFLECTOR_SHIELDING"):
			pCity.setNumRealBuilding(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), "BUILDING_ARCOLOGY_SHIELDING"), False)[/COLOR][/B]

		if (not self.__LOG_BUILDING):
			return
		CvUtil.pyPrint('%s was finished by Player %d Civilization %s' 
			%(PyInfo.BuildingInfo(iBuildingType).getDescription(), pCity.getOwner(), gc.getPlayer(pCity.getOwner()).getCivilizationDescription(0)))

and you must in PythonCallbackDefines.xml do this:
Code:
[B][COLOR="Red"]	<Define>
		<DefineName>USE_CANNOT_CONSTRUCT_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>[/COLOR][/B]

and can you upload your cottage/town texture from image it's look very nice, thanks :)
 
How do I make the AI value some improvements more or less than others? I added the ability to build hamlets but sacrifice the worker for it to solve the problem of unemployed workers sitting around doing nothing once you run out of tiles to improve. The idea is that once everything is improved you can sacrifice your workers to replace farms or workshops or whatever with instant hamlets, but now the AI just doesn't build cottages at all anymore and instead of bulldozing already present improvements it often throws away early workers for a single hamlet on one tile while leaving the rest of the BFC unimproved until it has trained another worker.
 
I havent looked at the improvement building code yet, but it have always been a pita to see how they would : farm->cottage->(building to town)->farm, so its high on my todo list. Will try to look at it in the weekend.

That kind of was one of the reasons for granting the ability to sacrifice a worker for an improvement in the first place, so that AIs wouldn't have any workers left to bulldoze towns because they have turned them into instant hamlets.
 
Question about Naval Barbarians.

Do they spawn following same rules as land barbarians?
I understand that on land, as more and more land is settled, there is less and less room for barbs to spawn.
But seas are pretty huge. So I was wondering do barbs only allowed to spawn along the coast?
I understand that early ships are coast bound, but later ships are not, but I still don't see them spawning in the sea.
 
Yes, sea units work almost the same way as land units. The target number of units per sea area is computed as the number of unowned water tiles (including ocean) divided by UnownedWaterTilesPerBarbarianUnit from the Handicap XML. Then, the units are spawned only on unobserved coastal tiles. If a mod allows e.g. barbarian Galleons, I reckon they will also only appear in coastal waters. CvGame::createBarbarianUnits uses the same tile selector for all units:
Code:
pPlot = GC.getMapINLINE().syncRandPlot((
RANDPLOT_NOT_VISIBLE_TO_CIV | 
[color="Blue"]RANDPLOT_ADJACENT_LAND[/color] | 
RANDPLOT_PASSIBLE), ...
The target number remains pretty much constant, whereas the eligible spawn locations become fewer and fewer, which leads to barb Galleys crowding around remote islands.
 
How how HOW do I stop getting contact with everyone when I load up a worldbuilder scenario!?!?!

I've looked at the file and I definitely don't have universal contact there. It's only when I actually play it.
 
How how HOW do I stop getting contact with everyone when I load up a worldbuilder scenario!?!?!

I've looked at the file and I definitely don't have universal contact there. It's only when I actually play it.

Just in case check Revealed Areas for you and the AIs, if they overlap, you automatically will have contact. This happens if you were at some point placing then removing units for different civs next to each other.
 
Just in case check Revealed Areas for you and the AIs, if they overlap, you automatically will have contact. This happens if you were at some point placing then removing units for different civs next to each other.

No, I never did anything with units. I just wanted to change the settings.
 
It apparently isn't possible to have an event that changes an improvement (a Cottage) into another (a Hamlet), it seems - is that correct? Well, I suppose it'd be possible with Python, but...
 
PHP:
	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		###
		iPlayer = city.getOwner()
		pPlayer = gc.getPlayer(iPlayer)
		uNewUnit = gc.getInfoTypeForString("UNIT_SUPREME_LEADER")
		pNewUnit = pPlayer.initUnit( uNewUnit,  city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
		pNewUnit.setName(pPlayer.getName())
		pNewUnit.finishMoves()
		## RECONSTRUCTION Start ##
		#if(gc.getGame().isOption(GameOptionTypes.GAMEOPTION_SPECIAL_PROMOTIONS)):
		#if(city.isCapital() or city.isHasBuilding(gc.getInfoTypeForString("BUILDING_PALACE"))):
		#ReconstructionCustomFunctions.BirthRegicide(city)
		## RECONSTRUCTION End ##
		if (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))

Why this code doesn't work for AI ? It's only work for human player.
 
bool CvUnit::canRangeStrikeAt(const CvPlot* pPlot, int iX, int iY) const
PHP:
	if ((plot()->isCity(true, getTeam())) && (getDomainType() == DOMAIN_LAND))
	{
		changeExtraAirRange(1);
	}

Getting a
1>CvUnit.cpp(12472) : error C2662: 'CvUnit::changeExtraAirRange' : cannot convert 'this' pointer from 'const CvUnit' to 'CvUnit &'
Not really sure what it means/how to fix?
 
Looks like a const correctness issue. canRangeStrikeAt isn't supposed to change any values of the callee (the CvUnit object). Possible solutions:
* Move the changeExtraAirRange call to some other place, i.e. into a function that isn't const. It does seem strange to increase extra air range in a function that checks whether a plot can be range-struck.
* Remove the const qualifier from canRangeStrikeAt both in CvUnit.cpp and CvUnit.h. If canRangeStrikeAt is called by any const functions, you'll get a similar compiler error elsewhere. I don't think that's the case though.
* Not sure if casting to non-const could break something in this case:
((CvUnit*)this)->changeExtraAirRange(1);
 
thanks :D
I'm learning by doing, so I had no idea about what const was. Im guessing const=constant=non changable. Makes sense.
I went a bit around the issue by making a new Int:
PHP:
	int rangestrikeRangechange = 0;
	if ((plot()->isCity(true, getTeam())) && (getDomainType() == DOMAIN_LAND))
	{
	rangestrikeRangechange += 1;
//		changeExtraAirRange(1);
	}

	if (plotDistance(pPlot->getX_INLINE(), pPlot->getY_INLINE(), pTargetPlot->getX_INLINE(), pTargetPlot->getY_INLINE()) > airRange() + rangestrikeRangechange)
	{
		return false;
	}
So when rangestriking landunits are situated in a City or a Fort they'll get an extra range. (to justify they are in a fortified defense position).

I appreciate the c++ lesson :D
 
No, I never did anything with units. I just wanted to change the settings.

As DH said,

Go into the WB save file using Notepad++, find the entries at the top of the file for each Civ:

Change:

BeginTeam
TeamID=0
ContactWithTeam=0
ContactWithTeam=8 (Remove all of these.)
RevealMap=0
EndTeam

To:

BeginTeam
TeamID=0
ContactWithTeam=0
RevealMap=0
EndTeamf
 
How do I change the amount of tiles revealed during airplane scouting missions? I can't figure out where this is stored.

EDIT: I didn't realize that people were still responding to my previous question. There was absolutely no contact made with other civs in the file. Whatever this is, it's something that triggers whenever I try to load the scenario.
 
Top Bottom