I'd like to make that building add +15% production, +3 production and +1 prod on every oil field that lies in the borders of the city. I guess it will have something to do with YIELD_PRODUCTION, right?
The
Building_YieldModifiers table adds +X% to a yield in a city.
The
Building_YieldChanges table adds +X to a yield in a city.
The
Building_ResourceYieldChanges table gives +X to a yield on every instance of a resource. Note that it's not by improvement type, so you can't boost land-based Oil without boosting water-based Oil as well.
Basically, a "Change" is a +X or -X, while a "Modifier" is a percentage increase; that naming scheme is used throughout the game. Note that the Changes are always applied first, so if you have a building that gives +3 and +15%, it'll add the 3 BEFORE adding the 15%. And note that Modifiers stack linearly; that is, if two buildings each add +15%, then the final result is 1.3 times the base value, not 1.15*1.15.
So what you should do is look at the existing Buildings files, find those tables I mentioned, and mimic what you see. For instance, the first one would be
Code:
<GameData>
<Building_YieldModifiers>
<Row>
<BuildingType>BUILDING_REFINERY</BuildingType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>15</Yield>
</Row>
</Building_YieldModifiers>
</GameData>
That's all it takes to have a Refinery add +15% to Production. There are quite a few tables in the buildings file that let you make this more complex, like +X% if a certain resource is nearby, or +X to all river tiles in the area.
I'd also like to make that building cost 1 oil and to be available with Plastics technology (is <PrereqTech>TECH_PLASTICS</PrereqTech> ok?)
Not quite. The name of the tech is TECH_PLASTIC, not plural. There are a few techs like this, where they misspelled something internally. For instance, the Penicillin tech is spelled TECH_PENICILIN (only one L). You have to be careful and use the right name, but your logfiles will tell you if you've got something wrong.
As for costing 1 oil, that's the
Building_ResourceQuantityRequirements table, which is what's used to make Factories cost coal, Nuclear plants cost uranium, and so on. Again, just mimic what you see there in a new entry for your new building.
ArtDefineTag defines what 3D model the game should use when placing this building on the terrain near your city. It's completely optional, and is generally only used for Wonders; most buildings don't use a custom 3D graphic. It does NOT control the icon used; that's what IconAtlas and PortraitIndex are for. (Specifically, IconAtlas says which atlas to use, and Portrait Index is the position within that atlas, from 0 to 63.)
Adding a new art definition requires modifying one of the game's artdefines files, which are NOT GameData and so require you to replace the entirety of the game's file with a new one. Adding icons is much, much easier, but still requires you to create a series of DDS files, which have to be loaded through the Virtual File System (VFS).
MinAreaSize is almost never used, and basically just says that you can't build this building unless your city controls enough area of a certain type to make it worthwhile. In the vanilla game, this is set to -1 for everything other than the Lighthouse, Harbor, Seaport, Great Lighthouse, Colossus, and Sydney Opera House, which have it at 10. These are all the coastal buildings, so unless you want to make your new building have a similar restriction, leave it at -1.
HurryCostModifier affects how expensive this building is to purchase with gold if you want to just buy it instead of producing it normally. By default, a building costs X gold per hammer, where X scales with a few factors (difficulty, map size, and so on). A 25 means, add another +25% on top of that value. So the Courthouse has a 50, which makes it quite a bit harder for you to just buy one in each city you conquer.
The reason nearly every building has a value of 25 for this, instead of just changing the base conversion rate and having every building be zero, is that unlike many other fields, HurryCostModifier cannot accept a negative number. So, the only way to make a building CHEAPER to rush is to have it be zero, while everyone else is 25. Many UBs (like the Wat or Satrap's Court) have a 15 instead of their counterparts' 25, to make them slightly cheaper to purchase, and some late-era buildings (like the Solar Plant) have a 0.
Setting this value to -1 means that the building cannot be purchased at all. Wonders have this -1, for obvious reasons. (This -1 is why it can't accept a negative cost modifier.)
This should go to other file than the above one, am I right?
XML modding
does not care about filenames. You could take your entire mod, put it in a single file named Bob.xml, and it'd still work as long as you remembered to load it through an OnModActivated command. As long as you're only creating new GameData entries (or updating existing ones), file name does not matter at all.
When you're making a huge mod, then yes, it's easier to split your mod up into many files. Some people lump by type, like the core game does (i.e. all Building definitions go in one file, all BuildingClass in another, and so on), but others lump by content (all Refinery-related entries go in one file, and so on). The reason splitting it up is good is that if you have any bugs in an XML file, the
entire file is thrown out. The logfiles will tell you what went wrong, of course, but it's still handy to have an easy way to see which parts of your mod are working fine and which aren't. If you split by content, then a mistake in your Refinery code will only stop the Refinery from loading, and won't affect any other buildings you've added, whereas if you split by type then depending on how wrong your new buildings look you'll know which part it failed in. It's a personal choice thing.
Once you start getting into UI modding, or altering art definitions, then those files DO need to keep their original names. But that's a whole other discussion about the VFS.
I'm not using ModBuddy, but should I?
Yes. Writing the XML isn't enough, you need to BUILD the xml, which (among other things) creates a .modinfo file the game needs; besides listing all of the files in the mod, the modinfo file also contains the OnModActivated command that tells the game to load the XML. (The game doesn't actually read XML directly, it translates it to SQL internally and then uses that. So you need to tell it which files should be converted to SQL.)
You can't fake a modinfo file easily because it includes a checksum for each of the mod's files to ensure they don't get corrupted. So learn to use ModBuddy.