Quick Modding Questions Thread

Is it possible to add the <ImprovementYieldChanges> tag from CivicsInfo to BuildingsInfo? Will it be necessary to make changes to the dll?
 
Is it possible to add the <ImprovementYieldChanges> tag from CivicsInfo to BuildingsInfo? Will it be necessary to make changes to the dll?
Yes, that would require a DLL change. Among other things, something like this loop would need to be added to CvPlayer::processBuilding. That is, if it's supposed to affect all cities (wonder effect), might get more complicated if it's supposed to work at a per-city level. Maybe some mod already does this. I thought perhaps Rise of Mankind (AND), but it looks like that mod has only added such a tag to leader traits (and it does so by adding a tag TraitYieldChanges to ImprovementInfo).

Is there a way to hide technology from Civilopedia?:mischief:
Looks like the bGraphicalOnly tag is supported by the DLL for all CvInfo types that the Pedia displays, and the Pedia will exclude CvInfo instances with that tag. The tag would have to be added to the Civ4TechnologiesSchema.xml, however:
Spoiler :
Code:
	<ElementType name="TechInfo" content="eltOnly">
		<element type="Type"/>
		 ...
		<element type="SoundMP"/>
		<element type="Button"/>
		<element type="bGraphicalOnly" minOccurs="0"/>
	</ElementType>
The minOccurs means that the tag will default to 0 and won't have to be added explicitly to every tech. And higher up in the same file:
Code:
	<ElementType name="Button" content="textOnly"/>
	<ElementType name="bGraphicalOnly" content="textOnly" dt:type="boolean"/>
	<ElementType name="TechInfo" content="eltOnly">
Just the one in the middle, the element types above and below should already exist. In Civ4TechInfos.xml, bGraphicalOnly would then go at the end of your TechInfo element:
Code:
			<Button>,Art/Interface/Buttons/TechTree/Mysticism.dds,Art/Interface/Buttons/TechTree_Atlas.dds,4,11</Button>
			<bGraphicalOnly>1</bGraphicalOnly>
		</TechInfo>
I've only tried it for Mysticism. This made it disappear from the Pedia, hopefully, there are no undesirable side-effects.

Is this the correct code? Maybe I forgot something?
This code supports the wonder that gives (or removes) dummy "bonus tech". Wonder may become obsolete.
Add the tech upon building construction, remove upon building obsolescence, city raze or foreign city acquisition. That sounds reasonable. Won't cover the WorldBuilder, but I guess that can't be helped. Could only add a periodic check, e.g. once per turn. Such a check could also verify that the other cases are handled correctly. (But maybe more trouble to implement than it's worth.)
 
Looks like the bGraphicalOnly tag is supported by the DLL for all CvInfo types that the Pedia displays, and the Pedia will exclude CvInfo instances with that tag. The tag would have to be added to the Civ4TechnologiesSchema.xml, however:
Thanks, this works well!
But what about hiding a technology from the tech tree?
I'm using <iGridX>0</iGridX> <iGridY>0</iGridY>, but perhaps there is a better way?
 
Thanks, this works well!
But what about hiding a technology from the tech tree?
I'm using <iGridX>0</iGridX> <iGridY>0</iGridY>, but perhaps there is a better way?

Have you tried -1 as x and y coordinates? Iirc other mods use that value to hide non-researchable techs from the tree.
 
Yes, that would require a DLL change. Among other things, something like this loop would need to be added to CvPlayer::processBuilding. That is, if it's supposed to affect all cities (wonder effect), might get more complicated if it's supposed to work at a per-city level. Maybe some mod already does this. I thought perhaps Rise of Mankind (AND), but it looks like that mod has only added such a tag to leader traits (and it does so by adding a tag TraitYieldChanges to ImprovementInfo).

Looks like the bGraphicalOnly tag is supported by the DLL for all CvInfo types that the Pedia displays, and the Pedia will exclude CvInfo instances with that tag. The tag would have to be added to the Civ4TechnologiesSchema.xml, however:
Spoiler :
Code:
    <ElementType name="TechInfo" content="eltOnly">
        <element type="Type"/>
         ...
        <element type="SoundMP"/>
        <element type="Button"/>
        <element type="bGraphicalOnly" minOccurs="0"/>
    </ElementType>
The minOccurs means that the tag will default to 0 and won't have to be added explicitly to every tech. And higher up in the same file:
Code:
    <ElementType name="Button" content="textOnly"/>
    <ElementType name="bGraphicalOnly" content="textOnly" dt:type="boolean"/>
    <ElementType name="TechInfo" content="eltOnly">
Just the one in the middle, the element types above and below should already exist. In Civ4TechInfos.xml, bGraphicalOnly would then go at the end of your TechInfo element:
Code:
            <Button>,Art/Interface/Buttons/TechTree/Mysticism.dds,Art/Interface/Buttons/TechTree_Atlas.dds,4,11</Button>
            <bGraphicalOnly>1</bGraphicalOnly>
        </TechInfo>
I've only tried it for Mysticism. This made it disappear from the Pedia, hopefully, there are no undesirable side-effects.
It's strange, but using <bGraphicalOnly>1</bGraphicalOnly> makes my code not work.:crazyeye:
Only the initial acquisition of technology works, but when the owner of the city changes, the bonus technology is not removed from the old owner and is not given to the new one. If I set <bGraphicalOnly>0</bGraphicalOnly> the code works again.
 
Difficult to see what impact graphical-only could have on the game logic. No Python exception occurring? Maybe you could verify through print statements that your setHasTech calls are reached. One could also modify the Pedia Python code so that techs are excluded e.g. based on bDisabled instead. The tech tree could, on that note, also skip disabled techs – if the coordinate-based approach isn't satisfactory.
 
Difficult to see what impact graphical-only could have on the game logic. No Python exception occurring? Maybe you could verify through print statements that your setHasTech calls are reached. One could also modify the Pedia Python code so that techs are excluded e.g. based on bDisabled instead. The tech tree could, on that note, also skip disabled techs – if the coordinate-based approach isn't satisfactory.
Mysterious! The code works again.:goodjob:
 
How can I get a link to an instance of a city with a specific wonder? Is this possible without a loop?
 
I think you'll need to write your own loop. A loop like that may already exist somewhere in Python, but, since CyCity.getNumBuildings gets called in a lot of places, such code would be difficult to find. Even with BUG, which has added some utility modules, I doubt that there is already a function that does just what you want. No global list of cities either, so you'd need an outer loop over all players.
 
I tried changing the vedic aryans event to require priesthood instead of polytheism; just replaced with 'TECH_PRIESTHOOD' in CvRandomEventInterface and started a new game. It occurred after one civ had researched polytheism anyway. I made sure nobody had priesthood, then I changed the # of archers that spawned in the event code and reloaded the turn before and that change was reflected. Then I tried removing polytheism and the event didn't happen. So it is reading the changed file but it's still going off of polytheism regardless. Why?
 
I tried changing the vedic aryans event to require priesthood instead of polytheism; just replaced with 'TECH_PRIESTHOOD' in CvRandomEventInterface and started a new game. It occurred after one civ had researched polytheism anyway. I made sure nobody had priesthood, then I changed the # of archers that spawned in the event code and reloaded the turn before and that change was reflected. Then I tried removing polytheism and the event didn't happen. So it is reading the changed file but it's still going off of polytheism regardless. Why?
Did you change the tech in Events XML too?
 
How to use CvGameUtils.py file? I made a small addition, but it doesn't affect anything.
Code:
    def getExtraCost(self, argsList):
        ePlayer = argsList[0]
    ## Ishtar Gate Start ##
        pPlayer = gc.getPlayer(ePlayer)
        if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_ISHTAR_GATE")) == 1:
            return  -10
    ## Ishtar Gate End ##
        return 0
 
I tried changing the vedic aryans event to require priesthood instead of polytheism; just replaced with 'TECH_PRIESTHOOD' in CvRandomEventInterface and started a new game. It occurred after one civ had researched polytheism anyway. I made sure nobody had priesthood, then I changed the # of archers that spawned in the event code and reloaded the turn before and that change was reflected. Then I tried removing polytheism and the event didn't happen. So it is reading the changed file but it's still going off of polytheism regardless. Why?
I figured this out; it's due to the way Taurus is set for BUFFY compatibility. Changing the else polytheism to else priesthood in Buffy.py made it work.
 
How to use CvGameUtils.py file? I made a small addition, but it doesn't affect anything.
If your mod includes BUG, then this thread might help. Or, for a quicker solution, you could try placing your code in Python\EntryPoints\CvGameInterface.py instead. If BUG is not involved, then it seems that the DLL should call the function you've modified; no change needed in PythonCallbackDefines.xml either.
 
Any method to get all the player's world wonders?
I find only getNumWorldWonders () for city.
 
I'm trying to block the ability to build a building through CyUtils, but it doesn't work.
Code:
    def cannotConstruct(self,argsList):
        pCity = argsList[0]
        eBuilding = argsList[1]
        bContinue = argsList[2]
        bTestVisible = argsList[3]
        bIgnoreCost = argsList[4]
## Petra Start ##
        if eBuilding == gc.getInfoTypeForString("BUILDING_PETRA"):
            if pCity.getPlotCity().getTerrainType()!= gc.getInfoTypeForString("TERRAIN_DESERT"):
                return True
## Petra End ##
        return False
 
That should throw an exception - I don't think CyCity has a method getPlotCity. Maybe it'll work with pCity.plot() instead. USE_CANNOT_CONSTRUCT_CALLBACK also needs to be enabled in XML, and the BUG mod, if involved, could interfere. print statements would show whether cannotConstruct is getting called and which of the conditions are true.
 
Top Bottom