SWAT: Elite Force has its code distributed in the hopes that other people will use it as a base. I've cleanly organized as much as possible and made as much stuff configurable in the .ini files as I can, so that your modifications will be as painless as possible.
This tutorial is NOT necessary if you intend to create maps or skins. This is only for creating a derivative mod.
Creating your workspace
Generally, it is not advisable to modify your SEF folder directly. Doing so may present problems when playing in multiplayer. The preferred option is to create a copy of the SEF folder, with your mod name. I will use "MyMod" for the sake of this tutorial, but you can customize it as you please.
Optional: Download the source code
At this point, you can download the source code and copy it into your workspace folder (MyMod) if you want. This is completely optional, and only needed for more complex edits. Here is a link to the GitHub page. You have two options as to how you want to download it:
- Download as zip file: Recommended for most people. Download the zip and copy the contents to your MyMod folder, replacing anything necessary.
- Clone from git: You can make a fork of the Git and pull updates upstream. This is for advanced users.
Customize your workspace
After you have copied your SEF folder, you will need to edit MyMod/System/Version.ini. You will want to change this file almost completely:[quote]
BuildTime="Sat Oct 28 2017"
ModName="[b]SWAT: Elite Force[\\b]"
The section titled [Version] is what your mod will use on the server list, to determine if your mod is compatible. You should change ModName here to be a 2-5 character string. You can go higher but it's not recommended. Other mods have this as "SSF", "SAS", etc. ChangeNumber is your version number.
The section titled [SwatGui.ModInfo] is what your mod's long name is. The long name appears on the main menu above the Discord and Wiki widgets, and on the top of the Join Game menu. Give the full name of your mod here, along with any color codes you want.
Lastly, you need to modify the LaunchSEF.bat so that it can detect your mod's folder properly. Rename it to LaunchMyMod.bat, and find this line in the file:[quote]
IF NOT EXIST ../SEF/NUL[/quote]
And change it to read:[quote]
IF NOT EXIST ../MyMod/NUL[/quote]
Getting familiar with the game
In the Vengeance (Unreal 2.5) engine, everything is treated as a "class". For instance, each type of ammo is a class. Each weapon is a class. When you spawn an enemy, they are an instance of the SwatEnemy class. There are two types of classes which I will talk about for the sake of this tutorial: UnrealScript classes and designer classes.
- UnrealScript classes are created in .uc files, compiled, and saved in MyMod/System/.u files. They are configured in .ini files in MyMod/System.
- Designer classes are created and configured in .u files. They can be edited with SwatEd.
- On top of these, you have localization files. These are based on the language that the game is running in, and used for translation. For the default, International language, these are in .int files, in MyMod/System.
Editing an UnrealScript class's default properties - a weapon
First off, let's edit an UnrealScript class: SwatEquipment.Arwen37GL, also known as the ARWEN 37 grenade launcher ingame. Open up SwatEquipment.ini, and look for the section pertaining to the ARWEN:quote]
; Arwen 37
;; Weight and Bulk FIXME
;; Firing FIXME
;; GUI FIXME
Weap />AllowedSlots WeaponEquip_PrimaryOnly
;; Viewmodel and Zoom
FirstPers />ThirdPersonModelClass class'SwatEquipmentModels2.Arwen37_ThirdPerson'
IdleWeap />IronSightLocationOffset (X=1,Y=-6.5,Z=4)
FlashlightPositi />FlashlightRotation 1stPerson=(Pitch=0,Yaw=0,Roll=0)
FlashlightPositi />FlashlightRotati />
;; Aim information
; Aim error penalties
; Aim error modifiers
; Aim error recovery rates
Here we can edit almost everything about the weapon. Let's go ahead and make the ARWEN37 usable as a secondary weapon as well as a primary. From the above section, change AllowedSlots=WeaponEquip_PrimaryOnly - this field can be WeaponEquip_PrimaryOnly, WeaponEquip_SecondaryOnly, or WeaponEquip_Either. Let's go ahead and change it to be WeaponEquip_Either.
Hold on though - that's not everything we need to do here! We also need to modify the section which states which equipment is valid for the secondary weapon. Look for this section in the same file:[quote]
You'll see sections for each weapon. Let's go ahead and add one, just underneath the HK69 grenade launcher:[quote]
EquipmentClassName is the equipment class (in this case, SwatEquipment.ARWEN37GL), Validity is in what modes this weapon is valid in (some equipment is only available in MP/All Missions, but we can also make some equipment usable only in singleplayer too), TeamValidity is unused, and bSelectable states whether this weapon is selectable in the interface.
Note that if our weapon uses ammo which isn't selectable as a secondary ammo, we will need to edit the [Pocket_SecondaryAmmo] in a similar way.
Now we're ready to go! Run the LaunchMyMod.bat and you should notice that the ARWEN37 is selectable as both a primary and secondary weapon.
Editing a designer class - ammo
INI files are just one way we can configure the game. Another way is through the designer classes - .U files.
Run the LaunchSwatEd.bat. This tool can be used for editing sounds, maps, textures, but also designer classes. Click on View > View Class Browser. You can edit all of the designer classes here, but also look at the class hierarchy as a whole for the game and see how everything is connected.
Now, let's edit some ammo. In the class browser, click File > Open, and open MyMod/Content/Classes/SwatAmmo.u. Now we can see some of the ammo in the game. Note: Be sure that the "ALL" button is not clicked, and that the three bubbles at the top are clicked, so you can see all of the classes! By double clicking an ammo, we can edit some fields about it, including ballistic properties like ricochet, how heavy it is, etc. Let's go ahead and make beanbags ricochet. Double click on the LessLethalAmmo class, to open the default properties window. Then, expand the section "Ricochet", and change "CanRicochet" to True.
There are lots of properties in this window. If you're ever curious about what a field does, select it, and click the "?" icon next to it. (Some fields don't have it, some do) A small description will show which will help explain what that field does. Save this file (Make sure to not overwrite your original game files!), and now you will see that beanbags will sometimes bounce on hard surfaces like metal, stone, concrete, etc. The materials that cause a ricochet can also be changed in the .U file!
Distributing your mod
You have two options to distribute your mod - as an expansion pack to SEF, or as a wholesale mod. I will briefly explain the differences:
- As an expansion pack: The person must have SEF installed, and your modifications (Version.ini, as well as any modified .u/.ini/textures) will be placed in a ZIP file, in an SEF folder. Ideally all the person should have to do is copy the SEF folder and it will replace any files.
- When doing this, you will want to "install" your expansion pack, just to make sure it works, and then run the GenerateMD5.bat, and include the SEF/System/Packages.md5 and SEF/System/Packages.txt in your expansion files.
- As a whole mod: The person does not need SEF to be installed. Run GenerateMD5.bat first, and then place the entire MyMod folder into a zip. All the user needs to do is copy the MyMod folder into their SWAT4 folder, and run the LaunchMyMod.bat. Make sure to remove any generated content, like DynamicLoadout.ini, SwatGuiState.ini, Swat4x.ini, and Campaign.ini, or the user might have weird default settings!
Note that if you decide to base your mod on the SEF source code, you must be able to provide the source code in some capacity, as per the license of the code.