1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Quick Modding Questions Thread

Discussion in 'Civ4 - Creation & Customization' started by kiwitt, Jan 27, 2010.

  1. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
  2. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    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
     
  3. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
    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.
     
  4. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    The answer is in cannotConstruct in CvGameUtils in Next War mod
     
  5. Eclipse4449

    Eclipse4449 Deity

    Joined:
    Dec 19, 2006
    Messages:
    6,815
    Location:
    Ohio (-5 GMT)
    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:
     
  6. jarhead_leif

    jarhead_leif Civ2ToT Modder

    Joined:
    Feb 1, 2012
    Messages:
    713
    Location:
    Philippines
    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.
     
  7. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,876
    Location:
    DE/NL/FR
    That would require C++ coding, and can't be done via XML :sad:.

    Just a bit below there's this thread ;).
     
  8. jarhead_leif

    jarhead_leif Civ2ToT Modder

    Joined:
    Feb 1, 2012
    Messages:
    713
    Location:
    Philippines
  9. Barbarian King

    Barbarian King Prince

    Joined:
    May 4, 2010
    Messages:
    346
    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.
     
  10. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,876
    Location:
    DE/NL/FR
    I'd try setOccupationTimer in the CyCity class.
     
  11. Barbarian King

    Barbarian King Prince

    Joined:
    May 4, 2010
    Messages:
    346
    Thanks! That worked and was just what I needed.
     
  12. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
    Yes i can see there is three buildings (orange codes), but i want two how to do that? :\
     
  13. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    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
     
  14. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    Hey guys, I am having trouble finding where the Building Wealth, Science, Culture in cities is defined. Is it in the BtS folder, or do I need to find it in vanilla? and of course where?

    Thanks for help :)
     
  15. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,876
    Location:
    DE/NL/FR
    GameInfo\ProcessInfo.xml (Warlords file)
     
  16. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
  17. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    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.
     
  18. God-Emperor

    God-Emperor Deity

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    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).
     
  19. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    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
     
  20. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,876
    Location:
    DE/NL/FR
    That's defined in GameInfo\WorldInfos.xml.
     

Share This Page