Quick Modding Questions Thread

If you want to disable buildings without a specific civic, you either have to mess with SDK to make a new tag, or to use this python function.

Without the codes, of course nothing is going to work
 
Thank you platyping :) but i have some new question about python.
Code:
		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)
		
		[COLOR="DarkOrange"]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]

		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)))
This orange core is from Next War mod, from CvEventManager.py.
This code replace some building with some other building. I have two buildings "BUILDINGCLASS_ANCIENT_SHIPS" and "BUILDINGCLASS_SHIPYARD". I want when i build "BUILDINGCLASS_SHIPYARD" that this building replace "BUILDINGCLASS_ANCIENT_SHIPS" i am put this in my py file:

if iBuildingType == CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), "BUILDING_SHIPYARD"):
pCity.setNumRealBuilding(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), "BUILDING_ANCIENT_SHIPS"), False)


without this elif tag and the result was this:
When i build "BUILDING_SHIPYARD" this building replace "BUILDING_ANCIENT_SHIPS" (i forget to say that i already build "BUILDING_ANCIENT_SHIPS" because "BUILDING_SHIPYARD" prereq "BUILDING_ANCIENT_SHIPS" in city) and i can again build "BUILDING_ANCIENT_SHIPS" but i don't want that, i want similar with ARCOLOGY in Next War mod. I hope you understand me. :)

Can someone rewrite this part of code i really don't know what to do here. Thanks.
 
The answer is in cannotConstruct in CvGameUtils in Next War mod
 
Can one AI be set to VALUE AN AREA like a land bridge crossing the Water?
and force another AI to fight and/or take a particular city?

I'm just getting started in modding and I was given this list

These files you might want to edit:
CIV4BuildingInfos
CIV4UnitInfos
CIV4CivilizationInfos
CIV4ArtDefines_Bonus
CIV4ArtDefines_Unit
CIV4ArtDefines_Building

But none of those seem right for an AREA:confused:
 
Can one AI be set to VALUE AN AREA like a land bridge crossing the Water?
and force another AI to fight and/or take a particular city?

That would require C++ coding, and can't be done via XML :sad:.

Hi,

I want to modify NextWar mod. Can anyone teach me how to add futuristic city sets (to replace modern era city sets when future arrives)?
Thanks to those who'll respond.:)

Faye.

Just a bit below there's this thread ;).
 
Is it possible to send a city into a turn of disorder/resistance using python? I searched the API but couldn't find any functions that would appear to do this.
 
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		
		# 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

The orange codes you posted under onBuildingBuilt will remove Arcology when Shielding is built in the same city.
But it will still allows user to build a new Arcology since it has been removed.

The codes that restricted users from building a new Arcology when Shielding is present in the city is under cannotConstruct in CvGameUtils.

1) When City is checking whether it cannot build Arcology,
If City has Arcology Shielding or Deflector Shielding present, then yeah, cannot build Arcology

2) When City is checking about Arcology Shielding,
If City has Deflector Shielding present, then again cannot building Arcology Shielding.

Thus, just adjust the variables to what you need to work.

Notes:
This only works provided no UB involved.
If UB involved, extra codes necessary
 
Hi guys, I am running debugger on my mod to try and fix some CTD issues, (Debug in VS studio) I have got this code error causing the CTD when I click on one of my units in the pop up build list of my city (after completing its prior job.) but I have no idea what exactly it is trying to tell me is the issue.
here are the statements.
Spoiler :

Code:
CvGameCoreDLL.dll!CvArtFileMgr::ltstr::operator()(const char * s1=0x0012fbe0, const char * s2=0x2a4c6260)  Line 90 + 0xd bytes	C++

>	CvGameCoreDLL.dll!std::_Tree<std::_Tmap_traits<char const *,CvArtInfoUnit *,CvArtFileMgr::ltstr,std::allocator<std::pair<char const * const,CvArtInfoUnit *> >,0> >::iterator::iterator(std::_Tree_nod<std::_Tmap_traits<char const *,CvArtInfoUnit *,CvArtFileMgr::ltstr,std::allocator<std::pair<char const * const,CvArtInfoUnit *> >,0> >::_Node * _Pnode=0x00000001)  Line 313	C++

+		this	(0x00432eb0 "V‹ñVè",0x005fdb30 {m_szShaderNIF={...} m_szShadowNIF={...} m_szShadowAttach={...} ...})	std::_Tree<std::_Tmap_traits<char const *,CvArtInfoUnit *,CvArtFileMgr::ltstr,std::allocator<std::pair<char const * const,CvArtInfoUnit *> >,0> >::iterator * const

+		this	(0x00432eb0 "V‹ñVè",0x005fdb30 {m_szShaderNIF={...} m_szShadowNIF={...} m_szShadowAttach={...} ...})	std::_Tree<std::_Tmap_traits<char const *,CvArtInfoUnit *,CvArtFileMgr::ltstr,std::allocator<std::pair<char const * const,CvArtInfoUnit *> >,0> >::iterator * const

+		_Pnode	0x00000001 {_Left=??? _Parent=??? _Right=??? ...}	std::_Tree_nod<std::_Tmap_traits<char const *,CvArtInfoUnit *,CvArtFileMgr::ltstr,std::allocator<std::pair<char const * const,CvArtInfoUnit *> >,0> >::_Node *


If anyone has any idea of what any of this is actually saying that would be great to know.

I get the sense that it is something to do with the units art reference, but what exactly and why this would cause a CTD I have no idea.

The mod is running with K-mod as a base.
 
This looks vaguely familiar...

In the case I dealt with I think it was associated with using the value "None" instead of "NONE" in an art reference: a movie definition for a building. It turned out that in the CvBuildingInfo::getMovieInfo() there is specific handling for the "NONE" value and it is case sensitive, so "None" was a problem.

In this case, it appears to be referring to a CvArtInfoUnit. So somewhere there is a unit with art problems. It might be an early/late/middle art define tag itself, or it could be relating to unit art style type stuff (in the file in the XML\Civilizations folder), or it might be the contents of an art info.

Anyhow, by looking at the contents of the variables in the debugger you should be able to figure out what it is referring to. Also, by looking at the thing (or things, you might need to go back more than one step) before this in the call stack you should be able to see what it was supposed to be doing. The specific thing you posted relates to a "less than" operator used by a map type variable in art info stuff. It's what was triggering that operation that you want to know. If you click on an item in the call stack it will take you to that location to see what it was doing there (and you can inspect the variables there too, which might tell you which specific unit type has the problem).
 
This looks vaguely familiar...

In the case I dealt with I think it was associated with using the value "None" instead of "NONE" in an art reference: a movie definition for a building. It turned out that in the CvBuildingInfo::getMovieInfo() there is specific handling for the "NONE" value and it is case sensitive, so "None" was a problem.
It turns out that it was a ',' at the start of the units button reference, I thinki this was an issue because I removed the original atlas reference, so I thik it was seeing the ',' trying to run an atlas reference, finding none and crashing...

Fingers crossed the issue is now resolved.

New Q:
How would I go about defining how many civs are played in a 'Play now' game. Basically it is creating multiples of the same civ in my game as there are a limited number, where as what I want is one of each without duplicates.

Cheers guys
 
Top Bottom