Quick Modding Questions Thread

Hello again. I'm trying to use platyping's python component "Leaning Tower" in my mod. However, there is no Leaning Tower in my mod. I would like to use it for another wonder "Jetavanaramaya". So I tried replacing the python code.
This is part 1 of the original.
Code:
## Leaning Tower Start ##
		pPlayer = gc.getPlayer(iPlayer)
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_LEANING_TOWER")) == 1:
			sScript = pPlayer.getScriptData()
			for i in xrange(sScript.count("Pisa")):
				iCityIDLength = int(sScript[sScript.find("Pisa") +4])
				iCityID = int(sScript[sScript.find("Pisa") +5: sScript.find("Pisa") +5 + iCityIDLength])
				pPlayer.getCity(iCityID).changeGreatPeopleProgress(pPlayer.greatPeopleThreshold(false)/4)
				pPlayer.setScriptData(pPlayer.getScriptData().replace("Pisa", "", 1))
				pPlayer.setScriptData(pPlayer.getScriptData().replace(str(iCityIDLength), "", 1))
				pPlayer.setScriptData(pPlayer.getScriptData().replace(str(iCityID), "", 1))
## Leaning Tower End ##
This is what I tried replacing it with.
Code:
## Leaning Tower Start ##
		pPlayer = gc.getPlayer(iPlayer)
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_JETAVANARAMAYA")) == 1:
			sScript = pPlayer.getScriptData()
			for i in xrange(sScript.count("Jetavanaramaya")):
				iCityIDLength = int(sScript[sScript.find("Jetavanaramaya") +4])
				iCityID = int(sScript[sScript.find("Jetavanaramaya") +5: sScript.find("Jetavanaramaya") +5 + iCityIDLength])
				pPlayer.getCity(iCityID).changeGreatPeopleProgress(pPlayer.greatPeopleThreshold(false)/2)
				pPlayer.setScriptData(pPlayer.getScriptData().replace("Jetavanaramaya", "", 1))
				pPlayer.setScriptData(pPlayer.getScriptData().replace(str(iCityIDLength), "", 1))
				pPlayer.setScriptData(pPlayer.getScriptData().replace(str(iCityID), "", 1))
## Leaning Tower End ##
And this is part 2 of the original code.
Code:
## Leaning Tower Start ##
			pPlayer = gc.getPlayer(iPlayer)
			if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_LEANING_TOWER")) == 1:
				if pUnit.getUnitType() != gc.getInfoTypeForString("UNIT_GREAT_GENERAL"):
					iGreatPeopleThresholdIncrease = gc.getDefineINT("GREAT_PEOPLE_THRESHOLD") * gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getGreatPeoplePercent() /100
					if pCity.getGreatPeopleProgress() >= pPlayer.greatPeopleThreshold(True) - iGreatPeopleThresholdIncrease:
						pPlayer.setScriptData(pPlayer.getScriptData() + "Pisa" + str(len(str(pCity.getID()))) + str(pCity.getID()))
## Leaning Tower End ##
And I tried to replace it with this.
Code:
## Leaning Tower Start ##
			pPlayer = gc.getPlayer(iPlayer)
			if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_LEANING_TOWER")) == 1:
				if pUnit.getUnitType() != gc.getInfoTypeForString("UNIT_GREAT_GENERAL"):
					iGreatPeopleThresholdIncrease = gc.getDefineINT("GREAT_PEOPLE_THRESHOLD") * gc.getGameSpeedInfo(CyGame().getGameSpeedType()).getGreatPeoplePercent() /100
					if pCity.getGreatPeopleProgress() >= pPlayer.greatPeopleThreshold(True) - iGreatPeopleThresholdIncrease:
						pPlayer.setScriptData(pPlayer.getScriptData() + "Pisa" + str(len(str(pCity.getID()))) + str(pCity.getID()))
## Leaning Tower End ##
But apparently that doesn't work. Any idea how I could fix this?
 
That sounds very likely, if you want to verify I suggest changing the Hindu missionary sound and test if it affects your new missionary as well.

Ok I have replaced the sound my new missionary is making in the kf file, but now I getting this error when the music suppose to play:

Audio System: Could not setup 3D sample with ID 4

Any ideas what this means?


Looking more into activate kf file I found these entries for expected effect:

Effect:EFFECT_MISSIONARY_ACTIVE_HINDU:EFFECT_MISSIONARY_ACTIVE_HIDNU

Maybe I should alter these as well. But I have no idea what "EFFECTS" are or where to look for then to edit.

Thanks! ;)
 
In the file XML/Misc/CIV4EffectInfos.xml ( :D ).

It is for the glowing light effect when the missionary spreads the religion in a city.
 
Hello again. I'm trying to use platyping's python component "Leaning Tower" in my mod. However, there is no Leaning Tower in my mod. I would like to use it for another wonder "Jetavanaramaya". So I tried replacing the python code.
But apparently that doesn't work. Any idea how I could fix this?

Honestly, I can't even figure what Platy was up to when he wrote this piece of code :D.

But I would say: just replace the BUILDINGCLASS_LEANING_TOWER with yours, do not bother about "Pisa"...
 
Honestly, I can't even figure what Platy was up to when he wrote this piece of code :D.

But I would say: just replace the BUILDINGCLASS_LEANING_TOWER with yours, do not bother about "Pisa"...

It is a troublesome effect which is not worth the effort.
 
i have a bts mod ive been working on, and im trying to take a couple of techs from FFH2 and insert them into the tech tree. i have all the dependencies working, but im running into 2 problems:
1) when view the tech tree "EXPLORATION" is sitting on top of "HUNTING" when its a prereq for "HUNTING" & FORESTRY is sitting on top of BRONZE WORKING
2) i wanted to use the WAY_OF_THE_FORESTS picture for FORESTRY in the tech tree. in the TechInfos.XML it says the button for WAY_OF_THE_FORESTS is here: Art/Interface/Buttons/TechTree/Leaves.dds, but when i go to the "Buttons" folder there is no TechTree folder, so i cant find that Leaves.dds to import it into my mod. If i go all the way up to
the Beyond the Sword folder and search for "Leaves.dds" it doesnt exist at all. i cant figure out how FFH2 has a picture of a leaf in the tech tree for WAY_OF_THE_FORESTS when i cant find the .dds where the XML says it should be.

Any help someone could provide would be very much appreciated.
 
I've attached a screenshot of my new tech tree with EXPLORATION and FORESTRY sitting on top of THE WHEEL and BRONZE WORKING respectively.
 

Attachments

  • TechTreeIssues.jpg
    TechTreeIssues.jpg
    46.9 KB · Views: 66
The tech tree places techs according to whatever grid x and y values stated in the xml. It does not automatically spaces them out like those pedia upgrade trees.

Thus, you have to adjust the x and values manually.
 
... and Art/Interface/Buttons/TechTree/Leaves.dds is probably packed in an FfH2 .fpk file.

Get Firaxis's PakBuild program to unpack the art.
 
Thank you isen, I got the .fpk file unpacked and found the .dds files and got those working.....now on to the tech tree...thank you for the input platy...do you know the x,y system? i looked at all the x,y's for everything through the medieval era and i cant understand it...the numbers in the XML dont make any sense to me compared to how they look in the tech tree......im looking at the following line in the XML to get the x,y's......is that the right spot because 4,11 doesnt make any sense

<Button>,Art/Interface/Buttons/TechTree/Mysticism.dds,Art/Interface/Buttons/TechTree_Atlas.dds,4,11</Button>


UPDATE: im an idiot! just took another look at the TechInfos.XML and saw the iGridX & iGridY values.....
 
Good that you figured it out.

Just in case, techtree_atlas.dds is a collection of buttons and Mysticism is in the 4th column, 11th row.
 
How exactly do global defines work? When the game loads, does it just read GlobalDefines.xml or all files at the right locations containing the civ4defines tag?

And which files at which locations pertain to the AI?
 
On game start, the game reads a predefined list of xml files. If it isn't present in the mod, it will use the vanilla file of that name. Reading an xml file means copying the content into memory and the file will no longer be needed. The memory storage is formatted entirely differently and is much faster than searching xml files. The list is hardcoded in the DLL, but DLL modders can mod the list if needed.

Global defines works the same way. However you aren't supposed to use the global define xml file in a mod. Instead use globalDefineALT.xml. It loads the regular one first and then overwrites with the ALT values afterwards. This way you get standard settings for every value not present in your mod and you can get a file, which only contains the values your mod alters.

How the global defines are used in the game can't really be answered in general. Any code in exe, DLL or python can request the value connected to a specific string. Where and when each value is called and how it's used then depends on the implementation for each value. This mean to answer how a specific value is used, you should ask the modder, who implemented that specific value.

I'm not sure if this is such a perfect answer, but it is tricky to be more specific to such a broad question. How the XML loading system works is kind of a big topic if you start to be specific. It's also fairly technical and would likely go over the head of most people here. This is why I will not be more specific unless I'm asked.

As for where the AI code is located, the answer is the DLL code. More specifically the AI files. For instance there is CvCity.cpp for city related code and then there is CvCityAI.cpp for code on how the AI should handle the city code. The same goes for CvPlayerAI, CvUnitAI and so on. This too will not be more specific unless asked about something more specific.

In theory it is possible to use python to implement some AI actions. However I wouldn't recommend it as you would likely not like the resulting performance, or lack hereof. The wait time for next turn will grow significantly. Also the DLL can do lots of stuff for the AI, which python can't.
 
Thanks.

Re global defines, I'm asking in relation to Better Bug AI and the various mods that use it. These have a number of global defines files like GlobalDefines.xml and GlobalDefinesAlt.xml, but also BBAI_AI_Variables_GlobalDefines.xml, TechDiffusion_GlobalDefines.xml etc. I've been wanting to know if the game reads all of these files.

Re the AI, well, it's also regarding BBAI-based mods actually. I only see python and XML files in these though, aside of CvGameCoreDLL.dll.
 
Thanks.

Re global defines, I'm asking in relation to Better Bug AI and the various mods that use it. These have a number of global defines files like GlobalDefines.xml and GlobalDefinesAlt.xml, but also BBAI_AI_Variables_GlobalDefines.xml, TechDiffusion_GlobalDefines.xml etc. I've been wanting to know if the game reads all of these files.

Re the AI, well, it's also regarding BBAI-based mods actually. I only see python and XML files in these though, aside of CvGameCoreDLL.dll.

The game reads all of those files.

As for the AI in the BBAI based mods, most of the AI coding is contained in the dll. Python and XML are used for the interface, Civilopedia, screens and other mod components. If you want to work with the AI, you need to learn C++, I'm afraid.
 
I am having problems with a bonus/resource appearing far to often. See picture. I have tried a number of things but no matter how small the percentages all my deserts are filled with sacred ruins.

Spoiler :
Code:
	       <BonusInfo>
		      <Type>BONUS_SACRED_RUINS</Type>
		      <Description>TXT_KEY_BONUS_SACRED_RUINS</Description>
		      <Civilopedia>TXT_KEY_BONUS_SACRED_RUINS_PEDIA</Civilopedia>
		      <BonusClassType>BONUSCLASS_GENERAL</BonusClassType>
		      <ArtDefineTag>ART_DEF_BONUS_SACRED_RUINS</ArtDefineTag>
		      <TechReveal>NONE</TechReveal>
		      <TechCityTrade>NONE</TechCityTrade>
			<TechObsolete>NONE</TechObsolete>
		      <YieldChanges>
			     <iYieldChange>0</iYieldChange>
			     <iYieldChange>0</iYieldChange>
			     <iYieldChange>1</iYieldChange>
		      </YieldChanges>
			<iAITradeModifier>0</iAITradeModifier>
			<iAIObjective>0</iAIObjective>
			<iHealth>0</iHealth>
			<iHappiness>0</iHappiness>
		      <iPlacementOrder>5</iPlacementOrder>
		      <iConstAppearance>100</iConstAppearance>
		      <iMinAreaSize>3</iMinAreaSize>
		      <iMinLatitude>0</iMinLatitude>
		      <iMaxLatitude>80</iMaxLatitude>
		      <Rands>
		          	<iRandApp1>25</iRandApp1>
	       		<iRandApp2>25</iRandApp2>
        			<iRandApp3/>
			     <iRandApp4/>
		      </Rands>
		      <iPlayer>10</iPlayer>
		      <iTilesPer>1024</iTilesPer>
		      <iMinLandPercent>0</iMinLandPercent>
		      <iUnique>0</iUnique>
			<iGroupRange>3</iGroupRange>
			<iGroupRand>1</iGroupRand>
		      <bArea>0</bArea>
		      <bHills>1</bHills>
		      <bFlatlands>1</bFlatlands>
		      <bNoRiverSide>1</bNoRiverSide>
			<bNormalize>0</bNormalize>
		      <TerrainBooleans>
			     <TerrainBoolean>
				        <TerrainType>TERRAIN_DESERT</TerrainType>
				        <bTerrain>1</bTerrain>
			     </TerrainBoolean>
		      </TerrainBooleans>
		      <FeatureBooleans>
			     <FeatureBoolean>
				        <FeatureType>FEATURE_JUNGLE</FeatureType>
				        <bFeature>1</bFeature>
			     </FeatureBoolean>
			     <FeatureBoolean>
				        <FeatureType>FEATURE_SWAMP</FeatureType>
				        <bFeature>1</bFeature>
			     </FeatureBoolean>
		      </FeatureBooleans>
		      <FeatureTerrainBooleans>
			     <FeatureTerrainBoolean>
				        <TerrainType>TERRAIN_GRASS</TerrainType>
				        <bFeatureTerrain>1</bFeatureTerrain>
			     </FeatureTerrainBoolean>
		      </FeatureTerrainBooleans>
	       </BonusInfo>

Note: duck is because I have lost the button and I don't know why the obelisk is pink as I got the file from the downloads just to be sure I had it all.
 

Attachments

  • sacred ruins.jpg
    sacred ruins.jpg
    349.4 KB · Views: 135
Back
Top Bottom