Help with ModModMod(ules)

WarKirby

Arty person
Joined
Jul 13, 2006
Messages
5,317
Location
Glasgow, Scotland
I've decided to take a shot at putting my xml tweaks into modules, that can be loaded without replacing files. Inspired by tarq's post here: http://forums.civfanatics.com/showpost.php?p=7870299&postcount=14

Some things, I don't understand though.

Firstly, the schema. What is it? what does it do? Do I need one for each module? Or can I create several modules all referencing that one file?

I'd like to make some individual modules for my Radiant Guard changes, one for tweaks to ranged combat, one for the Dragon adjustments, etc.

Also, he mentions:

3) Add "WarKirbys_" to the beginning of each file.

So that I would end up with "WarKirbys_Civ4UnitInfos.xml"
But I don't see any potential there for more than one file. Is that naming scheme necessary, or just a suggestion? Can I just call it dragons.xml, or radiantguard.xml ?
 
You need the schema for each file you edit. Take my mod for example. One of the files I use is Civ4TraitInfos.xml, so I rename it MalakimPlus_Civ4TraitInfos.xml. It uses Civ4CivilizationsSchema.xml, so I rename that file under the same format, to MalakimPlus_Civ4CivilizationsSchema.xml.

Each file you use will reference it's Schema at the top of the document. Change the name of the schema to the name of your Module's schema, as in <Civ4TraitInfos xmlns="x-schema:MalakimPlus_CIV4CivilizationsSchema.xml">.

For every module you make, you must have the schema included. It's what the game uses to tell it how to read the xml.

The naming scheme he used is just a suggestion. So long as whatever name you use is at the front, and does not replace the original file name, it should work. As in, use dragons_Civ4UnitInfos.xml, not dragons.xml.

Hopefully this helps. :goodjob:
 
You need the schema for each file you edit. Take my mod for example. One of the files I use is Civ4TraitInfos.xml, so I rename it MalakimPlus_Civ4TraitInfos.xml. It uses Civ4CivilizationsSchema.xml, so I rename that file under the same format, to MalakimPlus_Civ4CivilizationsSchema.xml.

I understand this.
But what if I'm making several modules from the same file?

My radiant guard changes are all in Civ4UnitInfos.xml
And my change to make moroi not obsolete, is also in the same file.

So could I use one schema for both of these? and any others that came from the same xml?


The naming scheme he used is just a suggestion. So long as whatever name you use is at the front, and does not replace the original file name, it should work. As in, use dragons_Civ4UnitInfos.xml, not dragons.xml.


Are you saying that I cannot replace the original filename? That it won't work if I do ?

so dragons.xml won't work?
 
I understand this.
But what if I'm making several modules from the same file?

My radiant guard changes are all in Civ4UnitInfos.xml
And my change to make moroi not obsolete, is also in the same file.

So could I use one schema for both of these? and any others that came from the same xml?



If you keep them in the same module, yes. If you split the changes out into their own modules, no. Since modules only need to contain what's been changed rather than the entire file, it is VERY easy to split changes out into their own modules.


Are you saying that I cannot replace the original filename? That it won't work if I do ?

so dragons.xml won't work?

Right.
 
Firstly, the schema. What is it? what does it do? Do I need one for each module? Or can I create several modules all referencing that one file?

I'm not sure what the technical role of the schema files is. What they mean to us is that the XML files have to match the format/order given by the schema, and that a module's XML file

1) Needs a schema file if the original XML file needed a schema. (Text files don't.)

2) Needs that schema to be present in the module, and needs that schema file to be renamed to match the reference near the top of your XML file.

So that I would end up with "WarKirbys_Civ4UnitInfos.xml"
But I don't see any potential there for more than one file. Is that naming scheme necessary, or just a suggestion? Can I just call it dragons.xml, or radiantguard.xml ?

There's a tutorial around here somewhere that gives the full naming rules for modular files. What I put into long-term memory is "modulename_".

You could have a dragons_Civ4UnitInfos.xml and a radiantguard_Civ4UnitInfos.xml. They could both be in the same directory and use the same schema. You could call it "dragons_" or "radiantguard_", or something else. It just needs to match the schema file you refer to in your XML.
 
You could have a dragons_Civ4UnitInfos.xml and a radiantguard_Civ4UnitInfos.xml. They could both be in the same directory and use the same schema. You could call it "dragons_" or "radiantguard_", or something else. It just needs to match the schema file you refer to in your XML.

Thank you. This is what I've been looking for. Maybe Valkrionn interpreted my question wrongly, or I misinterpreted his answer, but I got the impression that this wasn't possible.


Another question, then. Will subdirectories work?

Can I make a subfolder named Archery, and put all my archery related tweaks in there, along with the appropriate schemas, and put that folder within the modules folder to make it work?

Also, I just did my first sucessful test run of a module. yaay.
I'm adding some free promos to priest units. Woodsman for FoL priests, Guerilla for Kilmorph, etc..
 
Can I make a subfolder named Archery, and put all my archery related tweaks in there, along with the appropriate schemas, and put that folder within the modules folder to make it work?
I did that. Fall Further 050/Assets/Modules/OperaLeaderHeads/Emer/Art, for example, Emer being the name of a leader. It works.
 
You can subdirectory to your heart's content. The only rule for folders is that the Schema associated with any XML file must be in the same folder as that XML file. This is also the reason you wind up needing multiple copies of the Schema if you create multiple modules. There is usually no need to edit the Schema. It tells the XML loader what tags exist in an XML file, and how they exist there. Since adding new tags is pointless without DLL work, and most of our Schema already list all fields as optional, you are pretty nicely covered to just use the default. VERY few Module makers ever open the schema files or understand what they are for actually.
 
More questions are coming to mind.

Is there any way to do multiple edits to one entry (a single unit, building, etc) over several modules?
Or is one always going to completely overwrite the other and apply only it's own changes?

For example, I'm looking to put my dragon changes in one module, which included taking away drifa's extraneous crap. And a seperate module, which will add a new promotion to several units, including drifa. Is it possible to have both of these, without having to merge them into one module?
 
As XML has to be loaded in a certain order, the last module would likely overwrite anything else that was loaded before. Example:

file A (base file)
value 1=A
value 2=A
value 3=A

file B (module 1)
value 1=A
value 2=B
value 3=A

file C (module 2)
value 1=B
value 2=A
value 3=B

When only applying file B to file A, you'd have:
1=A
2=B
3=A

When only applying file C to file A, you'd have:
1=B
2=A
3=B

But when applying both to file A, it'd be like applying file C to file B:
1=B
2=A
3=B

I think it would work that way. I may be wrong.
 
Yes, the last module loaded completely overwrites all others which attempted to modify the same <Type> entry.

World of Civilization has corrected this, making it possible to ONLY modify a single XML field within a pre-existing item, but I haven't had the time to pick that particular bit of code improvement from them in the past year. I do hope to get this working sometime, as it will make modules FAR more friendly.
 
World of Civilization has corrected this, making it possible to ONLY modify a single XML field within a pre-existing item, but I haven't had the time to pick that particular bit of code improvement from them in the past year. I do hope to get this working sometime, as it will make modules FAR more friendly.

yaay

Even just the ability to add free promotions to a unit with a module, without touching anything else, would suit my needs perfectly


I hope sometime comes soon. In the meantime, I guess I'll just cut the changes to drifa within the dragon module. They were hardly important anyway.
 
Another question.

I know I can put custom names on the files. But do I have to?
I've started doing seperate modules inside their own uniquely named subfolders, so is there any need to change names of the xml files within? or can I just leave the default names ?
 
I believe it is allowed to not rename them, but by renaming them people can place all the files which they like into a single folder to more easily seperate those they have "given their seal of approval to" from those they are testing out for the first time. Though the same could be done by just placing all of them in a "Modules/Approved" folder instead of just "Modules."


There COULD be an issue with the DLL not wanting to load a filename it has already seen, and ignoring the folder aspect of the name, but that would be a little unusual, and you would expect some warnings to avoid sharing the name of 2 modules to have popped up by now.
 
Ok. halp

With a little testing, it seems that renaming the files IS required. When transferring my modules to the new version of FF, I found that some worked, and others did not. The ones that didn't work, were the ones I didn't rename.

But, I have a problem. One of my modules seems to have broken the civilopedia, and by extension, probably the game.

I called it Sighting and Archery. It basically just carries over a few changes from my last bout of xml editing. The summary of them is as follows:

Sighting and Archery
----------------------------------------
Wall Defender gives +1 Ranged Combat
Perfect Sight now gives +3 visibility range
Ljosalfar archers get +1 ranged combat from Dextrous trait
Wall Defender promo now gives +1 visibility

Boywers cost lowered from 2400 - 1500
Precision reduced 6400 - 3200

None of these effects were happening, until I went in and renamed the files properly. Once I did, well...

The ENTIRE technologies section of the civilopedia, is wiped clean. Nothing is there at all.
Moreover, when I try to hover over any tech mentioned in other pedia entries, the game crashes instantly.

What could I have done to cause this? Two of the changes there do affect techs.

The "archery_CIV4TechInfos.xml" file, reads as follows.
The schema is unchanged aside from the filename

Spoiler :
Code:
<?xml version="1.0"?>
<!-- Created with the FfH editor by Kael -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Tech Infos -->
<Civ4TechInfos xmlns="x-schema:archery_CIV4TechnologiesSchema.xml">
	<TechInfos>
		<TechInfo>		<!-- Bowyers -->
			<Type>TECH_BOWYERS</Type>
			<Description>TXT_KEY_TECH_BOWYERS</Description>
			<Civilopedia>TXT_KEY_TECH_PLACEHOLDER_PEDIA</Civilopedia>
			<Advisor>ADVISOR_MILITARY</Advisor>
			<iAIWeight>10</iAIWeight>
			<iAITradeModifier>10</iAITradeModifier>
			<iCost>1500</iCost>
			<iAdvancedStartCost>100</iAdvancedStartCost>
			<Era>ERA_CLASSICAL</Era>
			<iAsset>48</iAsset>
			<bTrade>1</bTrade>
			<bGoodyTech>1</bGoodyTech>
			<iGridX>5</iGridX>
			<iGridY>12</iGridY>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_CULTURE</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_MILITARY</FlavorType>
					<iFlavor>40</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_PRODUCTION</FlavorType>
					<iFlavor>50</iFlavor>
				</Flavor>
			</Flavors>
			<OrPreReqs>
					<PrereqTech>TECH_ARCHERY</PrereqTech>
			</OrPreReqs>
			<AndPreReqs>
					<PrereqTech>TECH_BRONZE_WORKING</PrereqTech>
			</AndPreReqs>
			<Quote>TXT_KEY_TECH_BOWYERS_PEDIA</Quote>
			<Sound>AS2D_TECH_DING</Sound>
			<SoundMP>AS2D_TECH_DING</SoundMP>
			<Button>Art/Interface/Buttons/TechTree/Bowyers.dds</Button>
		</TechInfo>		
		<TechInfo>		<!-- Precision -->
			<Type>TECH_PRECISION</Type>
			<Description>TXT_KEY_TECH_PRECISION</Description>
			<Civilopedia>TXT_KEY_TECH_PLACEHOLDER_PEDIA</Civilopedia>
			<Advisor>ADVISOR_MILITARY</Advisor>
			<iCost>3200</iCost>
			<iAdvancedStartCost>100</iAdvancedStartCost>
			<Era>ERA_MEDIEVAL</Era>
			<iAsset>56</iAsset>
			<iPower>8</iPower>
			<bTrade>1</bTrade>
			<bGoodyTech>1</bGoodyTech>
			<iGridX>6</iGridX>
			<iGridY>12</iGridY>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_GOLD</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_GROWTH</FlavorType>
					<iFlavor>20</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_MILITARY</FlavorType>
					<iFlavor>60</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_PRODUCTION</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
			</Flavors>
			<OrPreReqs>
					<PrereqTech>TECH_BOWYERS</PrereqTech>
			</OrPreReqs>
			<AndPreReqs>
					<PrereqTech>TECH_MILITARY_STRATEGY</PrereqTech>
			</AndPreReqs>
			<Quote>TXT_KEY_TECH_PRECISION_PEDIA</Quote>
			<Sound>AS2D_TECH_DING</Sound>
			<SoundMP>AS2D_TECH_DING</SoundMP>
			<Button>Art/Interface/Buttons/TechTree/Precision.dds</Button>
		</TechInfo>	
	</TechInfos>
</Civ4TechInfos>
 
Back
Top Bottom