Quick Modding Questions Thread

Python is a script based language and not a compiler based language like C++. This mean .py files will not need to be compiled (they can't), but since "compiling" happens at runtime, it will be significantly slower than C++. The technical term is that python is an interpreted programming language (in case anybody wants to look it up).

While notepad could do the job, I highly recommend notepad++. Indenting is important and notepad++ is optimized to work with such requirements as well as syntax highlighting while notepad is just meant to write text. Notepad++ is also better than notepad for xml editing.
 
Thank You ;)


And another question.

I wanted to make a special unit that would be very good at suppressing city unhappiness.
I went to unit file and changed value of 1 in <bMilitaryHappiness>1</bMilitaryHappiness> for 2 so unit would add 2 happiness instead of 1.
However the game gave me an error saying that this is a BOOLEAN value, which means its either yes or no, and I can't give it a 2.

Is there a way around this to have unit provide more than 1 point of happiness under Monarchy?

Also, is it possible to give unit higher maintenance cost? (sadly bMilitarySupport is also a Boolean)


Thanks!
 
Also, is it possible to give unit higher maintenance cost? (sadly bMilitarySupport is also a Boolean)

I can't help you with the first point but you can use iExtraCost to make any unit cost however much you like.
 
However the game gave me an error saying that this is a BOOLEAN value, which means its either yes or no, and I can't give it a 2.
The dll handles loading of the xml files and if you are unhappy with how it works, you will have to mod the dll. If you can't mod it, then you really are stuck with a fixed set of options.

Is there a way around this to have unit provide more than 1 point of happiness under Monarchy?
Edit civic xml and change iHappyPerMilitaryUnit to 2. I think that should do it, but it appears that you have one setting to affect all units and you can't have some city guard unit with double happiness effect.
 
I think I'll just give all the individual mounted units a production bonus from stables. So is there a way to disguise it? Basically, I want to remove the description of the bonus from the mounted units themselves, and give the stable a false description stating that it gives mounted units +25% production.

Also, how do I make a shortcut for a mod? Apparently this was done by right-clicking in the folder and selecting New, but that doesn't work for me (because of Windows 8?)
 
I'm not sure that I'm following you on the first one, but there is a hidden tag 'Help' that you can insert in the BuildingInfos in-between the Civilopedia and Strategy tags, as referenced in the schema file:
Code:
<ElementType name="Help" content="textOnly"/>
.

For the Shortcut icon, I find it easier to just copy one and edit its properties (it works with Windows 8 too):

in Start in:
Code:
"C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods"
or appropriate path for you.

in Target:
Code:
"C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Civ4BeyondSword.exe" mod=\WWI_Jon_Shafer_BtS319

Note that it works because of the underscores in the name of the Mod. If not, add quotes like this:
Code:
"C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Civ4BeyondSword.exe" "mod=\History Rewritten"
 
I'm not sure that I'm following you on the first one,

I earlier posted about wanting to make stables give production bonuses to mounted units, but that requires DLL modding. So instead I want to give each individual mounted unit (chariots, knights, etc) a production bonus from stables. But I want the game to pretend that it's doing the former- giving stables a bonus to all mounted units, which is equivalent. How do I affect the descriptions?

but there is a hidden tag 'Help' that you can insert in the BuildingInfos in-between the Civilopedia and Strategy tags, as referenced in the schema file:
Code:
<ElementType name="Help" content="textOnly"/>
.

For the Shortcut icon, I find it easier to just copy one and edit its properties (it works with Windows 8 too):

in Start in:
Code:
"C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods"
or appropriate path for you.

in Target:
Code:
"C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Civ4BeyondSword.exe" mod=\WWI_Jon_Shafer_BtS319

Note that it works because of the underscores in the name of the Mod. If not, add quotes like this:
Code:
"C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Civ4BeyondSword.exe" "mod=\History Rewritten"

:goodjob:
 
The point I'm missing is how you are going to give each individual mounted unit a production bonus from stables. You could decrease their iCost and give them the stable as a PrereqBuilding but just remember that Mongols having a BUILDING_MONGOL_GER would be excluded from the process.

Your last question: create a Help tag. Since you don't care about languages, you can even type what you want directly in it withtout going through a TXT_KEY_BUILDING_STABLE_HELP or similar. Or edit the TXT_KEY_BUILDING_STABLE_STRATEGY.
 
Another question: I want to alter dimensions my Civic screen a bit so it fits 6 civics per type rather than 5.
How/where I could do that?

Thank You!

It is in the Python\Screens folder CvCivicsScreen.py but I can't tell you exactly where because we went past 6 types per civic a long time ago and use one of the civic screen mods. Unfortunately the modder did not put their name in a comment block in the code saying what they did so I can't point you at it. It maybe Johny Smith's. Platyping has one I am sure.
 
Copy Python\Screens\CvCivicsScreen.py to your mod. Note that it is in the original civ4, not warlords or bts (at least in my complete install).

Near the top it sets 15-20 numbers and this is where you want to mod. The code you need to change would be this:
Code:
self.HEADINGS_BOTTOM = 280
self.HELP_TOP = 350
Changing headings should do what you ask while moving the help might be needed in case they overlap. I don't think you need to change any of the other numbers, but I'm not 100% sure.

Looking at the code, the "correct" number would be 280 + (2 * TEXT_MARGIN) = 310. That would be a good place to start and see if it fits what you want it to look like.

However the whole file seems pretty hardcoded and I would prefer a more dynamic approach. Maybe Platyping already did one. At least that would be a good place to start looking.
 
Dawn of Civilization has it.

Question: how do I provide a separate soundtrack for my mod? I know how to alter music, but the soundtrack files themselves are broken up into Civ IV, Warlords and BTS folders. My attempt to create one in my mod resulted in my custom ancient era tracks being played in all eras- even in the base game, and all other mods! How does that even happen?
 
Dawn of Civilization has it.

Question: how do I provide a separate soundtrack for my mod? I know how to alter music, but the soundtrack files themselves are broken up into Civ IV, Warlords and BTS folders. My attempt to create one in my mod resulted in my custom ancient era tracks being played in all eras- even in the base game, and all other mods! How does that even happen?

I think they are defined in CIV4EraInfos in Gameinfo folder

Code:
		<EraInfo>
			<Type>ERA_CLASSICAL</Type>
			<Description>TXT_KEY_ERA_CLASSICAL</Description>
			<Strategy>TXT_KEY_ERA_CLASSICAL_STRATEGY</Strategy>
			<bNoGoodies>0</bNoGoodies>
			<bNoAnimals>1</bNoAnimals>
			<bNoBarbUnits>0</bNoBarbUnits>
			<bNoBarbCities>0</bNoBarbCities>
			<iAdvancedStartPoints>1200</iAdvancedStartPoints>
			<iStartingUnitMultiplier>1</iStartingUnitMultiplier>
			<iStartingDefenseUnits>1</iStartingDefenseUnits>
			<iStartingWorkerUnits>1</iStartingWorkerUnits>
			<iStartingExploreUnits>1</iStartingExploreUnits>
			<iStartingGold>10</iStartingGold>
			<iFreePopulation>0</iFreePopulation>
			<iStartPercent>10</iStartPercent>
			<iGrowthPercent>100</iGrowthPercent>
			<iTrainPercent>100</iTrainPercent>
			<iConstructPercent>100</iConstructPercent>
			<iCreatePercent>100</iCreatePercent>
			<iResearchPercent>90</iResearchPercent>
			<iBuildPercent>100</iBuildPercent>
			<iImprovementPercent>100</iImprovementPercent>
			<iGreatPeoplePercent>100</iGreatPeoplePercent>
			<iCulturePercent>100</iCulturePercent>
			<iAnarchyPercent>50</iAnarchyPercent>
			<iEventChancePerTurn>2</iEventChancePerTurn>
			<iSoundtrackSpace>400</iSoundtrackSpace>
			<bFirstSoundtrackFirst>0</bFirstSoundtrackFirst>
			<EraInfoSoundtracks>
				<EraInfoSoundtrack>AS2D_SONG_ALEXANDER</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_VIKING</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_ROME</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_PELOPONNESIAN</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_MID_ROME</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_ANC_EUROPE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_ANC_ROME</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_MID_EUROPE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_MOD_CELTIC</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CONQUESTS_FANTASY1</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CONQUESTS_FANTASY2</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CONQUESTS_ROMAN</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EC_EARLY_PEACE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EC_EARLY_WAR</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EU_LATE_PEACE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EU_LATE_WAR</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_GR_EARLY_PEACE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_BARBARIAN</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_GR_EARLY_WAR</EraInfoSoundtrack>
			</EraInfoSoundtracks>
			<CitySoundscapes>
				<CitySoundscape>
					<CitySizeType>CITYSIZE_SMALL</CitySizeType>
					<SoundscapeScript>ASSS_CITY_ANCIENT_SMALL_SELECT_AMB</SoundscapeScript>
				</CitySoundscape>
				<CitySoundscape>
					<CitySizeType>CITYSIZE_MEDIUM</CitySizeType>
					<SoundscapeScript>ASSS_CITY_ANCIENT_SMALL_SELECT_AMB</SoundscapeScript>
				</CitySoundscape>
				<CitySoundscape>
					<CitySizeType>CITYSIZE_LARGE</CitySizeType>
					<SoundscapeScript>ASSS_CITY_ANCIENT_LARGE_SELECT_AMB</SoundscapeScript>
				</CitySoundscape>
			</CitySoundscapes>
			<AudioUnitVictoryScript>AS2D_VICTORY_EARLY</AudioUnitVictoryScript>
			<AudioUnitDefeatScript>AS2D_LOSS_EARLY</AudioUnitDefeatScript>
		</EraInfo>

and then sound references themselves are defined in AudioDefines in Audio folder.
Note that I haven't actualy tried this myself ;)
 
I think they are defined in CIV4EraInfos in Gameinfo folder

Code:
		<EraInfo>
			<Type>ERA_CLASSICAL</Type>
			<Description>TXT_KEY_ERA_CLASSICAL</Description>
			<Strategy>TXT_KEY_ERA_CLASSICAL_STRATEGY</Strategy>
			<bNoGoodies>0</bNoGoodies>
			<bNoAnimals>1</bNoAnimals>
			<bNoBarbUnits>0</bNoBarbUnits>
			<bNoBarbCities>0</bNoBarbCities>
			<iAdvancedStartPoints>1200</iAdvancedStartPoints>
			<iStartingUnitMultiplier>1</iStartingUnitMultiplier>
			<iStartingDefenseUnits>1</iStartingDefenseUnits>
			<iStartingWorkerUnits>1</iStartingWorkerUnits>
			<iStartingExploreUnits>1</iStartingExploreUnits>
			<iStartingGold>10</iStartingGold>
			<iFreePopulation>0</iFreePopulation>
			<iStartPercent>10</iStartPercent>
			<iGrowthPercent>100</iGrowthPercent>
			<iTrainPercent>100</iTrainPercent>
			<iConstructPercent>100</iConstructPercent>
			<iCreatePercent>100</iCreatePercent>
			<iResearchPercent>90</iResearchPercent>
			<iBuildPercent>100</iBuildPercent>
			<iImprovementPercent>100</iImprovementPercent>
			<iGreatPeoplePercent>100</iGreatPeoplePercent>
			<iCulturePercent>100</iCulturePercent>
			<iAnarchyPercent>50</iAnarchyPercent>
			<iEventChancePerTurn>2</iEventChancePerTurn>
			<iSoundtrackSpace>400</iSoundtrackSpace>
			<bFirstSoundtrackFirst>0</bFirstSoundtrackFirst>
			<EraInfoSoundtracks>
				<EraInfoSoundtrack>AS2D_SONG_ALEXANDER</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_VIKING</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_ROME</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_PELOPONNESIAN</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_MID_ROME</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_ANC_EUROPE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_ANC_ROME</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_MID_EUROPE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CIV_III_MOD_CELTIC</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CONQUESTS_FANTASY1</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CONQUESTS_FANTASY2</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_CONQUESTS_ROMAN</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EC_EARLY_PEACE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EC_EARLY_WAR</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EU_LATE_PEACE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_EU_LATE_WAR</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_GR_EARLY_PEACE</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_BARBARIAN</EraInfoSoundtrack>
				<EraInfoSoundtrack>AS2D_SONG_DIP_GR_EARLY_WAR</EraInfoSoundtrack>
			</EraInfoSoundtracks>
			<CitySoundscapes>
				<CitySoundscape>
					<CitySizeType>CITYSIZE_SMALL</CitySizeType>
					<SoundscapeScript>ASSS_CITY_ANCIENT_SMALL_SELECT_AMB</SoundscapeScript>
				</CitySoundscape>
				<CitySoundscape>
					<CitySizeType>CITYSIZE_MEDIUM</CitySizeType>
					<SoundscapeScript>ASSS_CITY_ANCIENT_SMALL_SELECT_AMB</SoundscapeScript>
				</CitySoundscape>
				<CitySoundscape>
					<CitySizeType>CITYSIZE_LARGE</CitySizeType>
					<SoundscapeScript>ASSS_CITY_ANCIENT_LARGE_SELECT_AMB</SoundscapeScript>
				</CitySoundscape>
			</CitySoundscapes>
			<AudioUnitVictoryScript>AS2D_VICTORY_EARLY</AudioUnitVictoryScript>
			<AudioUnitDefeatScript>AS2D_LOSS_EARLY</AudioUnitDefeatScript>
		</EraInfo>

and then sound references themselves are defined in AudioDefines in Audio folder.
Note that I haven't actualy tried this myself ;)

Yes, I know. That's what I did. Editing the files of one mod shouldn't have an effect on others- but somehow it did.
 
Well, I don't know then... :(

Anyway, I got another very tricky question.

I want to add another Art Style period to the game.
Such as: there is Early, Medieval and Late (Industrial) art styles for some game units, such as Great General.

Now I want to add a Renaissance art for him.
I have the unit model. I added it into unit art file.
I added new tag into unitinfo file - <RenaissanceArtDefineTag>
Obviously game doesn't know such tag, so I added this tag into UnitSchema like this: <ElementType name="RenaissanceArtDefineTag" content="textOnly"/>

Of course there is nothing that tells the game to switch the art style when Renaissance Era starts. So how would I do that?

Thank You!
 
That's defined in the dll. You can't add something to a schema file and expect it to work without appropriate coding in the dll.

But I encountered the same problem than you with my Napoleon scenario. In the dll, there is a calculation for when the Late art style should come, depending upon the number of Eras in your Mod. Since I didn't want to change the dll for a scenario, I "tricked" the game by adding a fake Era after the Future one. Nothing else changed. The result is that I have a Napoleonic GG in Industrial era, not the modern one.

Unfortunately, this only works for a scenario like this since the Napoleonic GG would otherwise appear as from the Middle Ages (MiddleArtDefineTag).
 
PHP:
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(), "UnitMeshGroup"))
{
	for ( k = 0; k < iIndexVal; k++ )
	{
		pXML->GetChildXmlValByName( &m_piUnitGroupRequired[k], "iRequired");
		pXML->GetChildXmlValByName(szTextVal, "EarlyArtDefineTag");
		setEarlyArtDefineTag(k, szTextVal);
		pXML->GetChildXmlValByName(szTextVal, "LateArtDefineTag");
		setLateArtDefineTag(k, szTextVal);
		pXML->GetChildXmlValByName(szTextVal, "MiddleArtDefineTag");
		setMiddleArtDefineTag(k, szTextVal);
		gDLL->getXMLIFace()->NextSibling(pXML->GetXML());
	}
	gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
That's the art reading code in CvUnitInfo::Read (the dll). It has those 3 tags to read and it can only be changed by changing the dll. Personally I would have liked it better if it was based on a list of pairs of (artstyle, starting era), possibly with a mandatory "default" to ensure it would always have an art style. That way adding eras and art styles can be done by modding xml only.

I started wondering how colonization threats this and it does it very simple. It doesn't listen to eras at all for art styles. Now I started wondering if I can make the "xml only" solution as a modcomp, which works for both bts and colo to bring this feature to colo as well as assisting bts modders :think:
However I will not start on it right away because I'm in the middle of something else.
 
Thank you guys! Well I am already running a custom dll, but it does only one small thing.
And i think I have source code for it (someone else created it).
I guess my only thing is to add extra line to it and compile it.

I suppose adding this would be the only thing needed? :

pXML->GetChildXmlValByName(szTextVal, "RenaissanceArtDefineTag");
setMiddleArtDefineTag(k, szTextVal);
 
Back
Top Bottom