XML questions for my mod

Hugh Heggen

Chieftain
Joined
Aug 31, 2014
Messages
7
Location
Australia
Hello everyone

I just recently published a mod on steam workshop for Civ V and it is going very well, but I wasn't able to implement every thing I wanted to in my mod before I uploaded it.
I had a few problems trying to get some specific building functions to work so in the end I just dumped them and went with something easier instead.

I wanted a building to add production to hills but it didn't seem to work with ether the TerrainYieldChanges or FeatureYieldChanges tags.

I tried to get a building to add culture per population but culture and the YieldChangesPerPop tag don't seem to work together.

I made some ancient production and economic buildings and I wanted them to be required before you can build a workshop or market and I also wanted them to be free for cities founded in a later era but the two tags seemed to clash and the workshop/market would not come free with a city built in later eras. I removed the ClassesNeededInCity tag from the workshop/market and then they were given free like normal. Anyone know what I'm doing wrong?

Lastly I made some custom resources that are improved with farms but I wasn't able to figure out were the wheat field dds was and how it was linked to the resource so my rice and maize have a custom appearance until you build a farm on them then they just look like normal farms.
Has anyone successfully modded a wheat farm?

My mod can be found here http://steamcommunity.com/sharedfiles/filedetails/?id=305940312

Any help would be appreciated.
 
I wanted a building to add production to hills but it didn't seem to work with ether the TerrainYieldChanges or FeatureYieldChanges tags.

I tried to get a building to add culture per population but culture and the YieldChangesPerPop tag don't seem to work together.
What you've seen is normal, and not anything you are doing wrong. Hills are not a 'real' terrain as recognized by the game for the <Building_TerrainYieldChanges> table, nor are Hills recognized as a 'Feature' that can be used in the <Building_FeatureYieldChanges> table. WRT to the <Building_FeatureYieldChanges> and <Building_TerrainYieldChanges>, Rivers and Lakes will not work for these tables either. But River and Lake plots have their own tables (<Building_RiverPlotYieldChanges> & <Building_LakePlotYieldChanges>) so it's not so much of a problem with those.

You are also correct in your conclusion that <Building_YieldChangesPerPop> does not work for YIELD_CULTURE. It never has. It also does not work for YIELD_FAITH. At least one mod-author wrote a work-around lua program for the culture issue. That was Poukai in his India Civilizations Pack mod. You might look there because I don't remember exactly what he did code-wise in his lua. He's a forum member, but I don't know if he has a mod page for that civilization pack posted to the forum or not.
I made some ancient production and economic buildings and I wanted them to be required before you can build a workshop or market and I also wanted them to be free for cities founded in a later era but the two tags seemed to clash and the workshop/market would not come free with a city built in later eras. I removed the ClassesNeededInCity tag from the workshop/market and then they were given free like normal. Anyone know what I'm doing wrong?
I have some suspicions but without looking at the code you were trying they'd just be guesses based on suppositions based on not much of anything concrete.

For the rest of it, map resources and improvements modding is something I've not done any of as yet.

[edit] sorry, my bad. The lua program in the India Civilizations Pack is for allowing YIELD_FAITH to work in the <Building_YieldChangesPerPop> table. I remembered that wrong -- I could have sworn it was written for culture per pop.
 
Here is an example of some XML i use
<Building_ClassesNeededInCity>
<Row>
<BuildingType>BUILDING_WINDMILL</BuildingType>
<BuildingClassType>BUILDINGCLASS_GRANARY</BuildingClassType>
</Row>
</Building_ClassesNeededInCity>
Its quoted out at the moment but if I activate it it stops the FreeStartEra tag from working.
Is there a particular order these tags are supposed to be in or is there another tag I'm missing to make them both work?
 
Here is an example of some XML i use

Its quoted out at the moment but if I activate it it stops the FreeStartEra tag from working.
Is there a particular order these tags are supposed to be in or is there another tag I'm missing to make them both work?
No, there's no tag you'd be missing that I can see. I am seeing the same results when I try this, which for the moment is confusing me since the Monument & Amphitheater pairing work just fine for the <FreeStartEra>.
 
It's because you can't guarantee the order the buildings will be processed. If the attempt to add the windmill comes BEFORE the addition of the granary, it will fail.

It so happens that the ID of the Windmill is 16 and for the Granary it's 40, whereas for the Amphitheater(sic) it's 121 and for the Monument it's 28

SQLite has a tendency (although NOT guaranteed) to return rows in ascending ID order - hence why the Monument/Amphitheater pair works but the Granary/Windmill pair doesn't
 
So, would doing a <Delete> on the Granary and the Windmill followed by a re-creation in order where Granary appears before Windmill work without making too much of a hash with missing references, or would all the other tables that referenced the original Granary and Windmill make proper use of the re-created versions.

Doing complete deletes on Buildings is getting into territory I've not much experimented with. Not sure if it would also be necessary to Delete all the <Rows> in other tables that reference the deleted building, and then follow that up with re-creating those <Row> entries in those tables. Scary in the sense of all the follow-up issues that might need to be dealt with. Also not sure how this would affect other mods that make changes to Windmill or Granary. All of these are concerns that usually result in me concluding it just isn't "cost-effective" to do a delete on a building.

[edit]and also the bit about "But NOT guaranteed"
 
Just use (some messy) SQL to swap the IDs over
Code:
INSERT INTO Buildings(Type, GoldMaintenance) SELECT 'BUILDING_TEMP_GRANARY', ID FROM Buildings WHERE Type='BUILDING_WINDMILL';
INSERT INTO Buildings(Type, GoldMaintenance) SELECT 'BUILDING_TEMP_WINDMILL', ID FROM Buildings WHERE Type='BUILDING_GRANARY';
UPDATE Buildings SET ID=-1 WHERE Type='BUILDING_WINDMILL';
UPDATE Buildings SET ID=(SELECT GoldMaintenance FROM Buildings WHERE Type='BUILDING_TEMP_GRANARY') WHERE Type='BUILDING_GRANARY';
UPDATE Buildings SET ID=(SELECT GoldMaintenance FROM Buildings WHERE Type='BUILDING_TEMP_WINDMILL') WHERE Type='BUILDING_WINDMILL';
DELETE FROM Buildings WHERE Type IN ('BUILDING_TEMP_GRANARY', 'BUILDING_TEMP_WINDMILL');
 
Hello everyone

I just recently published a mod on steam workshop for Civ V and it is going very well, but I wasn't able to implement every thing I wanted to in my mod before I uploaded it.
I had a few problems trying to get some specific building functions to work so in the end I just dumped them and went with something easier instead.

I wanted a building to add production to hills but it didn't seem to work with ether the TerrainYieldChanges or FeatureYieldChanges tags.

I tried to get a building to add culture per population but culture and the YieldChangesPerPop tag don't seem to work together.

I made some ancient production and economic buildings and I wanted them to be required before you can build a workshop or market and I also wanted them to be free for cities founded in a later era but the two tags seemed to clash and the workshop/market would not come free with a city built in later eras. I removed the ClassesNeededInCity tag from the workshop/market and then they were given free like normal. Anyone know what I'm doing wrong?

Lastly I made some custom resources that are improved with farms but I wasn't able to figure out were the wheat field dds was and how it was linked to the resource so my rice and maize have a custom appearance until you build a farm on them then they just look like normal farms.
Has anyone successfully modded a wheat farm?

My mod can be found here http://steamcommunity.com/sharedfiles/filedetails/?id=305940312

Any help would be appreciated.

You want culture per pop?

First you need some dummy buildings. Add this to your XML:
Spoiler :
<BuildingClasses>
<Row>
<Type>BUILDINGCLASS_CULTURE_PER_POP</Type>
<DefaultBuilding>BUILDING_CULTURE_PER_POP</DefaultBuilding>
<NoLimit>true</NoLimit>
<Description>TXT_KEY_CULTURE_PER_POP</Description>
</Row>
</BuildingClasses>
<Buildings>
<Row>
<Type>BUILDING_CULTURE_PER_POP</Type>
<Cost>-1</Cost>
<GreatWorkCount>-1</GreatWorkCount>
<NeverCapture>true</NeverCapture>
<NukeImmune>true</NukeImmune>
<IconAtlas>BW_ATLAS_1</IconAtlas>
<PortraitIndex>19</PortraitIndex>
<Description>TXT_KEY_CULTURE_PER_POP</Description>
<Help>TXT_KEY_CULTURE_PER_POP</Help>
</Row>
</Buildings>
<Building_YieldChanges>
<Row>
<BuildingType>BUILDING_CULTURE_PER_POP</BuildingType>
<YieldType>YIELD_CULTURE</YieldType>
<Yield>2</Yield>
</Row>
</Building_YieldChanges>


I'm assuming you have BNW and can use the GreatWorks = -1 trick to keep the building invisible. I am told it exploits a bug in the game, I don't care, it works. You may also want to set the TX_KEYs to actually reference something. It'll probably work anyway, but it'll throw a pile of errors into your log and you don't want that.

Next, use this Lua:
Spoiler :

function CulturePerPop(PlayerID, cityID)
local pPlayer = Players[PlayerID];
local pBuilding = GameInfoTypes["BUILDING_YOURBUILDING"];
for pCity in pPlayer:Cities() do
if (pPlayer:IsAlive()) then
if (pCity:GetNumBuilding(pBuilding) > 0) then
local pPop = pCity:GetPopulation();
local CultureBonus = math.floor(pPop / 5);
if CultureBonus > 0 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_CULTURE_PER_POP"], CultureBonus);
else pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_CULTURE_PER_POP"], 0);
end
end
end
end
end
GameEvents.PlayerDoTurn.Add(CulturePerPop);


I'm sure you noticed on line 3 it says "BUILDING_YOURBUILDING". Slap the name of your building in there. Also, this is designed to give a culture bonus for every 5 citizens. That is in line 8. Mathfloor means round down, so no bonus for a population less than 5. Tweak that number to whatever divisor suits your purposes. Also note that in the previous XML, the culture yield change is set at 2. Make that whatever you want.

In my limited experience, copy/pasting code from the forums often causes little syntax breaks. So try this out, I give 80/20 odds it won't work the first time. I'll be back around to help you if there's an issue.
 
I'm assuming you have BNW and can use the GreatWorks = -1 trick to keep the building invisible. I am told it exploits a bug in the game, I don't care, it works. You may also want to set the TX_KEYs to actually reference something. It'll probably work anyway, but it'll throw a pile of errors into your log and you don't want that.

You dont need to add the text strings to this building, unless you want to see them show up in the pedia.
There isnt any exploit at all, we use nearly 100 of the hidden buildings in CCTP.
The only thing that is important when you use that hidden mechanic, be aware that buildings that grants f.e spies need also a ui change, otherwise you will encouter some problems with the vanilla ui.
 
You dont need to add the text strings to this building, unless you want to see them show up in the pedia.
There isnt any exploit at all, we use nearly 100 of the hidden buildings in CCTP.
The only thing that is important when you use that hidden mechanic, be aware that buildings that grants f.e spies need also a ui change, otherwise you will encouter some problems with the vanilla ui.
The simplest solution for that is to give the hidden building a <Description> tag and define the tag in the <Language_en_US> table. The description won't cause the building to show in the civilopedia but it will cure the game-break issue related to Espionage Modifiers within the definition of the hidden building, where a hidden building without a <Description> tag and an <EspionageModifier> causes the espionage overview to lock-up and not allow the assignment of spies to a city to do counter-espionage, for example.

I always advise folks to throw a <Description> tag into a building hidden by <GreatWorkCount>-1</GreatWorkCount>, regardless of whether they're planning to use any of the espionage commands, since this habit pre-actively addresses those issues when adopted as a habit.
 
Sorry for the late reply.
I couldn't get the SQL script that whoward69 gave me to work but LeeS's suggestion of deleting the building entries worked.
I just deleted the BUILDINGCLASS entries then re entered them in the order I wanted, really quick and simple actually.
The culture per pop scripts Bingles gave me crashed the game on startup but then I entered a BuildingClass tag in the Buildings entry and that fixed it.
The building does show up in the pedia though which is a bit annoying.
I tried deleting the Description and help tags but that just f###ed up the entire pedia so I left it as is. Not really a problem anyway.
Anybody know how to get a building to add production on hills?
You guys have been a huge help and it's greatly appreciated, thank you all.
 
Top Bottom