Beginner Tutorial: Editing Your First Weapon - KCreator/Earth-Defence-Force-Documentation GitHub Wiki

Intro

The goal of this guide is to serve as an introduction to how a lot of EDF modding works. You're going to learn how to edit .SGO files, which is the file format a significant amount of the game files are in, and adjust the values of an existing weapon to create your very own custom gun. The author of this guide (hi im kacey) only has experience in modding EDF5, so this guide will be focused on that game, however there's a significant amount of overlap between EDF4.1 and EDF5, so you should still be able to follow along. If you have any questions, please join us in the #edf-modding channel on the official EDF Discord server, we'd love to help out.

Tools

Before we start, please follow the instructions on the Getting Started page to install BlueAmulet's ModLoader. After you've downloaded and installed the ModLoader, head to the Tools page and download SGOTT and CriPakTools.

Because EDF is a japanese developed game, you may have issues displaying japanese characters in your text editor. On Windows this is resolved by installing the japanese language pack on your system. The microsoft page found here should have everything you need for getting that set up.

Optionally, if you do not have a decent text editor and don't want to look into finding one you like, you can download Aelbannan's Direct SGO Editor from the Tools page, which functions as a text editor while also skipping needing SGOTT. The author of this guide doesn't have personal experience with the direct editor however so this guide will not be using it, but it is there and seems easy to use for those interested.

Extraction

In order to edit an existing weapon in the game, we're going to need access to the game files. That's where CriPakTools comes in. Navigate to your EDF5 root directory. This can be quickly accessed by going to your Steam library, right clicking on EDF5, selecting Manage, then Browse Local Files.

screenshot of steam, visually detailing where to find Browse Local Files

The file you're looking for is Root.cpk, this is where most of the files that are relevant for editing are stored, packed into a single file. We want to extract it, which is what we'll use CriPakTools for.

Launch CriPakGUI.exe, click File, Open CPK, navigate to and select Root.cpk. Note, if you don't mind using the hard drive space you can make a copy of Root.cpk and move it somewhere convenient for this step, but using the one in your Steam root directory is totally fine.

Now that you've loaded the CPK file into CriPak, it will display a list of all the files it found. Above the list, click "Extract Files", and choose a convenient place to save the extracted files. The resulting folder should look like this.

screenshot of windows explorer, showing the results of extracting Root.cpk

This directory will serve two key purposes. First off, it will be where you will copy files from for editing purposes. Second, it will serve as a guide for how you will install your mods.

Explaining the ModLoader

The way the ModLoader works for the user is relatively simple. The ModLoader replaces the game's files with anything that matches it in the Mods folder. For example, if you put a folder named WEAPON in your Mods folder, and inside that WEAPON folder you had a file named ASSULTRIFLE01.SGO, the ModLoader tells the game to use the ASSULTRIFLE01.SGO found in the Mods/WEAPON folder as opposed to the one in Root.cpk that it would load otherwise. Now, if you were to modify the ASSULTRIFLE01.SGO in your Mods/WEAPON folder, you'd have successfully modded the game! So let's go over how to do that now.

Editing SGO Files

In your extracted Root.cpk directory, open the WEAPON folder. This folder is going to look extremely intimidating but don't worry! There will be helpful links at the end of the guide for finding specific weapons. For now, find the aforementioned ASSULTRIFLE01.SGO (no that is not a typo) and copy it to somewhere convenient for you. This is the .SGO file for the assault rifle that rangers start with, the PA-11.

Next, move sgott.exe to that same convenient folder. To start, you can simply drag the .SGO file onto sgott.exe and a blank window should appear briefly before closing itself, spitting out ASSULTRIFLE01.json. json files are, at the most basic of understanding, a list of values. Right click the file and open it in your text editor or programming tool of choice. (i personally use visual studio code)

Now you have near full control over what the gun can do. There's a lot of values here that you can play around with, however some are much more intuitive than others. Fortunately, SGO files are well documented and, once you get the hang of it, easy to read! We'll start right near the top here, under the section that says "AmmoColor".

AmmoColor has the benefit of being right at the top, easy to explain, and very fun to have control over. Projectiles in EDF5 are often shapes of light as opposed to traditional metal bullets, so changing the color of the projectiles can be very visually striking. Color is controlled through a traditional RGB approach, one number determining how red the bullet is, one for green, one for blue. We also get a fourth number for how opaque the bullet it.

A common trend you'll notice when working with .SGO files is the term "float" usually followed by a very long number. A float value is, basically, a value that accepts numbers with decimals. They can be used for extremely precise values, however since you're not creating a AAA commercial product you don't have to sweat being as precise as Sandlot have been. For our example here we're going to set the gun's bullets to be cyan. We'll accomplish this by setting the first number to 0, the second to 1, and the third to 1. We'll also make the bullets a little see-through by setting the fourth number to 0.7.

We'll change more values soon, but first we're going to learn how to apply our changes to the game.

Installing Our Mod

Great news, installing our modified gun is really easy! Make sure to save your changes to the .json file. Now you have a few options for how to convert the .json file back into .SGO, and the approach you go with will depend on your personal preferences and how you want your general workflow to be. You can simply drag the .json file back onto sgott.exe and it will overwrite the existing .SGO file with our changes. If you'd like to avoid overwriting the original .SGO file for convenience sake, you can rename the original .SGO file to something indicating it's the vanilla version.

You can also run sgott.exe in a command line window of your choice if you know what you're doing, using the command ./sgott.exe [input filename here] [output filename here] As an example, ./sgott.exe ASSULTRIFLE01.JSON MODDEDASSULTRIFLE01.SGO

Once you've got your new .SGO, navigate to your EDF5 root directory, open your Mods folder, and create a folder named WEAPON. Inside your Mods/WEAPON folder, place your modified .SGO and, if you've renamed it, for the sake of this example name it back to ASSULTRIFLE01.SGO. Now, assuming your ModLoader is installed correctly and you followed the steps up to this point correctly, you just need to launch the game, select the PA-11, and load into a mission. Empty your clip and you should see some very pretty blue bullets! Congrats, that's more or less the full process for SGO editing existing weapons. We'll make some more meaningful changes next, as well as go over useful resources for more involved SGO editing.

To Go Even Further Beyond

Okay so changing the projectile colors is fun, but it's unlikely you looked up a guide for modding EDF5 just to change the colors. So let's do something a little dumb and change our boring assault rifle into a weird crowd control weapon.

Back in the .json file, we're going to make a quick change at the very top, AmmoAlive. This is the number of frames that a bullet travels for before disappearing. Set this to 200.

Continuing from AmmoColor, the next section is AmmoCount. This is the weapon stat that dictates the weapon's clip size. Weapon stats are significantly more complicated than the ammo color is, due to the level up system, however luckily the bulk of the values can be ignored and even outright removed. When you're looking at AmmoCount you'll see 6 values, 4 ints (integers) and two floats. The first value is the base stat (the most important one) before any level-ups. The remainder values primarily impact the scaling of the level-up system. For simplicities sake we're going to remove the level-up functionality from this weapon's stats.

At the top of the AmmoCount section you'll see "type": "ptr". You'll actually see this at the top of most sections of this file. When you see ptr like this, it means that the values listed afterwards are packaged together, basically. If you're familiar with arrays or dicts, it's a similar concept. If you change the ptr for AmmoCount to "int", you can then delete everything between the [] brackets, then enter whatever int value you want, and now that stat will be static.

Do note that for other stats the base value may be a "float" instead of an int. It's critical that you take note of the base stat's value "type" before you change "ptr", and that value type you convert "ptr" to matches the base stat.

With that important information out of the way, we're going to be editing the clip size, we're going to take the original clip of 120 and lower it down to 12, a more fitting clip size for the new shape our gun is taking.

Next is AmmoDamage, controlling the damage our gun does. Yes, this can be a very exciting stat, but control yourself just for the sake of this example. We're going to this time set the ptr "type" to "float", remove the unneeded lines, and change the remaining line from 15 to 8.

We're going to skip over AmmoDamageReduce, but for reference that is the handling for damage falloff, for when you're using a gun outside of its effective range. We're going to be skipping over a lot of values, but if you're curious about what they do please feel free to check out the SGO Node Documentation.

Now we have a bunch of single line values. These are the fun gimmicky stats. AmmoExplosion impacts blast radius. We're going to add a small amount of splash to our bullets, changing the value to 5.

Skip to AmmoHitImpulseAdjust, this is the force behind our bullets, or the knockback of them. This, however, only effects physics objects like enemy giblets. We're going to crank this value up to 200 just for fun even though it won't impact enemies.

Skip to AmmoHitSizeAdjust, this changes the bullet's hitbox size. We'll be changing this to 1.5.

Skip to AmmoSize, this changes the size of the projectile visual (not the hitbox). We'll set this to 1.5.

AmmoSpeed impacts the speed the bullet travels. This is a return to the ptr format, however the relevant value we want to edit is a float, so just like before we'll be converting it but this time replace "ptr" with "float", setting it to 1.

Skip to FireAccuracy, this is the accuracy of the bullets in radians, with 0 being perfect accuracy. Change this from a ptr to a float and set it to 0.

Skip to FireCount, this determines the number of projectiles per shot. Set this to 5.

FireInterval is the fire rate, specifically the number of frames it takes before the gun can shoot again. Convert this into an int, and set it to 25.

Skip to FireRecoil, this is undocumented but, predictably, governs your recoil. We're gonna set this to 0 for this example.

The last values we'll be editing are FireSpreadType and FireSpreadWidth. Depending on the value you input in FireSpreadType, you get a different firing spread. We'll be using value 2, which is "Narrow Horizontal Spread". You can see the other options on the SGO Node Documentation.

FireSpreadWidth determines the distance horizontally between your bullets. Set this to 0.2.

Closing

And we're done! Install the updated .sgo file into your Mods/WEAPON folder and test it out. Is the weapon good? Not really! But there's of course plenty more you can do, and I encourage you once again to browse the SGO Node Documentation, as well as join the Discord server and ask any questions you may have, we'd love to help.