Can you please teach me/us how to "steal" some mods from the truly amazing megamods out there? For example, I would just like sniper rifles addes to the vanilla, or maybe a gym.
Below I have attached an example mod containing the .308 Sniper Rifle from The X-Com Files total conversion mod. Download it, install it, and pop open the ruleset in notepad++ so you can follow along as I explain how I built it.
You can just copy the code into a separate ruleset file and place it in its own mod directory. To figure out how to do that, look at other small mods as examples. Then just copy the relevant data from the large mod into your mod in the same format as it is in the small mod. Lastly, make sure you test it thoroughly!
Here's an example for the sniper rifle, which I copied from the items ruleset in X-Com Files. You want to take out some unnecessary elements. The original sniper rifle code from X-Com Files has a lot of excess data that we don't need. The simpler it is, the easier it is to handle. I removed the categories and research requirement, because our mod doesn't have the category list or research projects from X-Com Files. The rest of the fluff I'll just leave in place, but most of it could be removed without problem. To know which to leave and which to take out, check the
OXC ruleset reference. Anything not listed there you can do without and it won't break the mod, though it might detract from the quality of the mod.
The next part is to figure out all the extra parts we need. The most generic components other than the item entry are the graphics, sounds, and language entries. All of the lines which call for a sprite or sound file you'll notice have a number next to them, for example: bigSprite: 609. This means that the Sniper Rifle is calling for #609 from the bigSprite list. We'll want to grab these things from the extraSprites and extraSounds files. The bigSprite, floorSprite, handSprite, bulletSprite, and hitAnimation come from the BIGOBS.PCK, FLOOROB.PCK, HANDOB.PCK, Projectiles, and SMOKE.PCK sections of the extraSprites ruleset, respectively. (sic) We will not need entries from Projectiles or SMOKE.PCK because the numbers given for those on our Sniper Rifle (2, 26) are vanilla numbers which do not need resources. Usually when the number is very small, it is a vanilla resource. Mods typically use numbers that are 3 digits and up.
I copied the BIGOBS.PCK, FLOOROB.PCK, and HANDOBS.PCK sections over, carrying only one or two entries each (one for the rifle, one for the clip). Note the following data in the HANDOB.PCK entry:
height: 40
width: 256
subX: 32
subY: 40
This indicates that the entire image is 256x40 pixels and is subdivided into units of 32x40 pixels. All entries in HANDOBS.PCK should use the same value, but it is important to match the dimensions to the image file you're using. If you call the wrong size image, the game will crash on loading. If you call the right size, but the subdivisions are wrong, the textures will be fragmented and out of place. But we are just copying data from a different mod which presumably got the numbers correct so we should be fine.
Next we need the actual graphics files. The data we just copied over lists the file path, starting in your mod's main folder. For example, the bigObs #609 is to be found in {mod folder}/Resources/Weapons_Compilation/ClassicWeapons/bigob_SniperRifle.gif. Since we don't have those folders, we must either create them or change the file path. I choose to make a resources folder and delete all other folders from all file paths. So our final path is changed to Resources/bigob_SniperRifle.gif. So I created a folder called [Resources] and then searched for each graphics file we need in X-Com Files and copied them into my [Resources] folder, then I removed the extraneous folders from the file paths in extraSprites.
Now we need the sound files in extraSounds, from the BATTLE.CAT section. It's fireSound: 76 and hitSound:77 so we find those entries and copy them over just like with extraSprites. Then we copy the sound file over (and repair the file path).
Now we just want the language file and we should be done. We don't need to do anything more than copy it over. The game automatically reads all string values (such as STR_SNIPER_RIFLE) and checks your current language file for a corresponding entry. And it's also okay to not have the language file. If it doesn't find it, it'll just call the weapon STR_SNIPER_RIFLE instead of calling it Sniper Rifle. We get the language file from the extraStrings section corresponding to our chosen language--I'll go with en-US. Now if you've found STR_SNIPER_RIFLE in the language file, you'll notice there is a language entry for a UFOPedia topic on the rifle included in there as well. We can use that to add the UFOPedia project, but I'm not going to cover that at this stage. You can search X-Com Files and try to add it yourself if you like. You will need to find its entry in the ufopaedia section, and make sure you remove the research requirement from the ufopedia entry like we did with the item, unless you intend to instead copy the research project into the mod.
- - - - -
If you wish to try your hand at adding a gym from a big mod:
find one in the facilities section of its ruleset and copy it over. You'll want to get the spriteFacility from BASEBITS.PCK in the extraSprites section. You will also want to copy over the corresponding map file from the MAPS folder, the routes file from the ROUTES folder, and any terrain files it uses from the TERRAIN folder. Make sure your mod has these folders just like this. The entry in facilities tells its MAPS/ROUTES/TERRAIN data at mapName, where it links to an entry in the terrains section. You'll probably find the facility map in the section called XBASE or something similar. You'll need to copy over the full mapDataSets entry, any mapBlocks that are used in your facilities, and all terrain files (from the TERRAIN folder) that are listed in the mapDataSets entry. If the mod doesn't contain one of the terrain files, it's probably a vanilla file which you won't need, such as BLANKS.- - - - -
Once you feel like you're done, or at a good stopping point, you should test everything you added to your mod. We just added a sniper rifle, so we want to run the mod, start up a random battle, load the sniper rifle and ammo onto our ship, and try using and firing the weapon at an alien or two. If everything works out, then we have probably copied the mod correctly. If there are any unexpected errors, you can ask for help from the community either here on the forums (ideally in a new post in the Work in Progress subsection) or on our
Discord channel. Please don't post any replies to this message here in this thread. If you make a new thread in Work in Progress, I will see it and visit it.