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
    I put these codes in CvGameUtils.py and don't work,
    Spoiler :
    Code:
    	def cannotConstruct(self,argsList):
    		pCity = argsList[0]
    		eBuilding = argsList[1]
    		bContinue = argsList[2]
    		bTestVisible = argsList[3]
    		bIgnoreCost = argsList[4]
    		
    		# Slave Cage 
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) != gc.getInfoTypeForString('CIVIC_SLAVERY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_SLAVE_CAGE'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_COMMON_LAW'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_SLAVE_CAGE'):
    				return True
    				
    		# End Slave Cage
    		
    		# Slave Market
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) != gc.getInfoTypeForString('CIVIC_SLAVERY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_SLAVE_MARKET'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_COMMON_LAW'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_SLAVE_MARKET'):
    				return True
    				
    		# End Slave Market		
    		
    		# Slave Auction National Wonder
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) != gc.getInfoTypeForString('CIVIC_SLAVERY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_NATIONAL_SLAVE_AUCTION'):				
    				return True	
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_COMMON_LAW'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_NATIONAL_SLAVE_AUCTION'):
    				return True	
    				
    		# END Slave Auction National Wonder
    		
    		# FEUDAL MONARCHY 
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LEGAL')) != gc.getInfoTypeForString('CIVIC_ARISTOCRACY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_FEUDAL_MONARCHY'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LEGAL')) == gc.getInfoTypeForString('CIVIC_LIBERTY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_FEUDAL_MONARCHY'):
    				return True
    				
    		# End FEUDAL MONARCHY
    		
    		# ABSOLUTE MONARCHY 
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LEGAL')) != gc.getInfoTypeForString('CIVIC_BUREAUCRACY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_ABSOLUTE_MONARCHY'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LEGAL')) == gc.getInfoTypeForString('CIVIC_LIBERTY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_ABSOLUTE_MONARCHY'):
    				return True
    				
    		# End ABSOLUTE MONARCHY
    		
    		# GHALL 
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) != gc.getInfoTypeForString('CIVIC_GUILD'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_GHALL'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_STATE_PROPERTY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_GHALL'):
    				return True
    				
    		# End GHALL
    		
    		# HANSA
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) != gc.getInfoTypeForString('CIVIC_GUILD'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_HANSA'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_STATE_PROPERTY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_HANSA'):
    				return True
    				
    		# End HANSA
    		
    		# Import Tariffs
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) != gc.getInfoTypeForString('CIVIC_MERCANTILISM'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_TARIFF'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_STATE_PROPERTY'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_TARIFF'):
    				return True
    				
    		# End Import Tariffs
    		
    		# Grand Arsenal
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) != gc.getInfoTypeForString('CIVIC_MERCHANT_PRINCES'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_GRAND_ARSENAL'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_ECONOMY')) == gc.getInfoTypeForString('CIVIC_CORPORATISM'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_GRAND_ARSENAL'):
    				return True
    				
    		# End Grand Arsenal
    		
    		# King's Vassal
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_GOVERNMENT')) != gc.getInfoTypeForString('CIVIC_HEREDITARY_RULE'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_KINGS_VASSAL'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_GOVERNMENT')) == gc.getInfoTypeForString('CIVIC_REPUBLIC'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_KINGS_VASSAL'):
    				return True
    				
    		# End King's Vassal
    		
    		# Royal Bureaucracy
    		ePlayer = pCity.getOwner()
    		pPlayer = gc.getPlayer(ePlayer)
    				
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_GOVERNMENT')) != gc.getInfoTypeForString('CIVIC_HEREDITARY_RULE'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_ROYAL_BUREAUCRACY'):				
    				return True
    		
    		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_GOVERNMENT')) == gc.getInfoTypeForString('CIVIC_REPUBLIC'):
    			if eBuilding == gc.getInfoTypeForString('BUILDING_ROYAL_BUREAUCRACY'):
    				return True
    				
    		# End Royal Bureaucracy
    		
    		# 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
    

    and this is my PythonCallbackDefines.xml file:
    Spoiler :
    Code:
    <?xml version="1.0"?>
    <!-- Sid Meier's Civilization 4 -->
    <!-- Copyright Firaxis Games 2005 -->
    <!-- -->
    <!-- Global Defines -->
    <Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
    	<Define>
    		<DefineName>USE_CANNOT_FOUND_CITY_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_FOUND_CITIES_ON_WATER_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_IS_PLAYER_RESEARCH_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_RESEARCH_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CANNOT_DO_CIVIC_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_DO_CIVIC_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CANNOT_CONSTRUCT_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_CONSTRUCT_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_DECLARE_WAR_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CANNOT_RESEARCH_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_GET_UNIT_COST_MOD_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_GET_BUILDING_COST_MOD_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_GET_CITY_FOUND_VALUE_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CANNOT_HANDLE_ACTION_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_BUILD_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CANNOT_TRAIN_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CAN_TRAIN_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_UNIT_CANNOT_MOVE_INTO_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_CANNOT_SPREAD_RELIGION_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_FINISH_TEXT_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_ON_UNIT_SET_XY_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_ON_UNIT_SELECTED_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_ON_UPDATE_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_ON_UNIT_CREATED_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    	<Define>
    		<DefineName>USE_ON_UNIT_LOST_CALLBACK</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    </Civ4Defines>
    

    What i must to do, that this work? I think that i am not something activate in PythonCallbackDefines.xml but i am not sure.
     
  2. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,872
    Location:
    DE/NL/FR
    Set the value for USE_CANNOT_CONSTRUCT_CALLBACK to 1, that should do it.
     
  3. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
  4. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    Hi guys, I am wondering if anyone has any ideas how I could achieve this:

    Basically I am changing floodpains to only produce unhealthiness, but I want one civ to have a special improvement that makes floodplains great again. What I need to know is how can I make this civ gravitate towards settling near them, when they start out as a 'bad' terrain? Is it possible to set a civ trait to make a specific terrain have a bonus for them?
    I know it can be done with the 'boost' to already high producing terrains. Anyway your thoughts and ideas would be appreciated for a good way to implement this.
     
  5. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,872
    Location:
    DE/NL/FR
    Don't see a way without recoding the AI.
     
  6. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    037DE940 mov eax,dword ptr [ecx+300h]

    hey guys, I am debugging my mod and i got this CTD exception in Debug on VS studio, i don't get any indication of files that were being run, anyone have any idea what this means?? I understand it is quite a specilist qustion, I am also going to try dropping it in google to see if it sheds any light.
     
  7. Ekolite

    Ekolite Deity

    Joined:
    Sep 15, 2007
    Messages:
    5,451
    How do I mod the effects of leader traits? Specifically what I hope to achieve is making the industrious trait provide +1 hammers from workshops in my version of FFH for Civ 4 bts.
     
  8. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,872
    Location:
    DE/NL/FR
    Are bonuses from improvements possible in FfH?
    Because it's not possible in BtS, so it has to be a custom effect.
    I'd suggest that you take a look at FfH's versions of either Civilizations\TraitInfos or Terrain\ImprovementInfos
     
  9. platyping

    platyping Sleeping Dragon

    Joined:
    Oct 22, 2010
    Messages:
    4,626
    Location:
    Emerald Dreams
    Possible with python, but that will affect whole team, so unless it is only for specific scenarios where team forming is not possible, not a good solution.
     
  10. Ekolite

    Ekolite Deity

    Joined:
    Sep 15, 2007
    Messages:
    5,451
    Hmm.. Okay I will have a go at that at some point, although it is probably beyond my modding capabilities at the moment.

    Second question: Is there any way to change the pre-required tech for an improvement. Again this is for FFH, at the moment camps become available at Hunting, but I want to bring it forward to an earlier tech or even have them available from the very beginning.

    Does anyone have any ideas?
     
  11. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
  12. Imp. Knoedel

    Imp. Knoedel Simperator Knoedel

    Joined:
    Nov 11, 2011
    Messages:
    8,791
    Location:
    The cooler Germany
    Hey there modding community!

    I recently began to create a mod-mod for Legends of Revolution, and after reading through several tutorials I think I understood most what I need for it, but there are still some things that aren´t clear to me which is why I´m here:

    Now I am aware that there is a way to keep a mod compact by only putting the files I actually change into the mod´s folder, copy the BtS shortcut and change its properties so that it loads the mod when I click on it, but I haven´t found a way to do the same with my modmod, seeing as there is no LoR.exe. So if someone here could tell me if there is an easier way than just copy-pasting the whole content of the LoR-mod folder and going from there, I would be most grateful.
    Some of the things I want to include in my modmod require coding in the DLL, would that be even possible with that approach? I figure since many files are cross-referencing each other and everything has to be compiled to actually work, I might as well copy the whole CvGameCoreDLL folder from LoR into my modmod, no?

    Any help is appreciated!
     
  13. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,872
    Location:
    DE/NL/FR
    Is it just about the loading of your mod?
    In that case you should just use one of the different mod starter utilities from the utilities subforum ;).
     
  14. Imp. Knoedel

    Imp. Knoedel Simperator Knoedel

    Joined:
    Nov 11, 2011
    Messages:
    8,791
    Location:
    The cooler Germany
    Mkay I´ll take a look at it, thanks.
     
  15. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    Hey guys, wondering if anyone has knowledge of how ranged bombardment damage works?

    Specifically i mean the 'air attack' ranged bombardment effect that allows units to do damage from a distance. I used it with a unit and it did 33% damage, is this a hard wired thing or can it be changed to allow different units to inflict different amounts of damage with a single shot?
     
  16. God-Emperor

    God-Emperor Deity

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    The ranged damage is based on the strength of the unit specified in the iAirCombat tag vs. the regular strength of the defender, with the attackers strength modified by damage (so if it has only 70% of its hit points left its strength is only 70% of the specified value).

    The exact formula is in the CvUnit.cpp file, in the rangeCombatDamage function.

    If the current air attack strength of the attacker is equal to the strength of the defender it will do the amount of damage defined by the RANGE_COMBAT_DAMAGE in the file GlobalDefines.xml, which is set to 30 in BtS.

    Due to the way it works, in your test which did 33 damage the strength use by the attacker must have been around 25% higher than the strength used by the defender.
     
  17. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,708
    Location:
    UK
    ok brilliant, thans for laying that out for me, now I know where to go to play around with stuff :D
     
  18. kiwitt

    kiwitt Road to War Modder

    Joined:
    Jan 11, 2006
    Messages:
    5,568
    Location:
    Auckland, NZ (GMT+12)
    A bit of a "noobie" observation ... I noticed when I went into worldbuilder that when I added a Mall and a Supermarket into the same city I got both bonuses. I was thinking that when I did this one would cancel out the other (i.e. one being a unique version of the other).

    This is quite a revelation as it is going to make my Modern World scenario quite interesting. As I can pre-populate the cities with standard buildings and then add unique buildings based on the relevant cultures that had influenced the city in it total history.

    Some cities are 1,000's of years old and have had multiple cultures pass through it.
     
  19. Imp. Knoedel

    Imp. Knoedel Simperator Knoedel

    Joined:
    Nov 11, 2011
    Messages:
    8,791
    Location:
    The cooler Germany
    What would I have to change to make Military Police bonus available for buildings? i.e. If I want to give a Wonder the same effect Hereditary Rule has now.
     
  20. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    32,872
    Location:
    DE/NL/FR
    This is not doable with XML and not easily doable with Python, so SDK is the way to go.
     

Share This Page