JK2JA Coding Getting Started

I've written this tutorial for people who can understand the JK2/JA code, but can't seem to get what they want ingame.
Sure, you've seen mods out there that rely heavily on the code to run their features...but how does one get the code to work?
In this two part tutorial, I'll explain how to get the code up, running, and compiled into your base folder.
Part I - Jedi Knight 2
You will need:
SDK v1
SDK v2
PakScape
Install both parts of the SDK.
Go into your JK2/Gamedata folder. Inside you should notice four new folders - bin, code, Tools, and ui. Ignore bin, Tools and ui for now, all we want to focus on is the code folder. Inside the code folder lies the source code of the game, ready to be compiled into a .qvm/.vm.
Let's make sure the code compiles fine first. Run buildvms.bat inside the code folder. If all goes well, you should have these files in a new folder called 'base' in your code folder:
- cgame.qvm
- jk2mpgame.qvm
- ui.qvm
- cgame.map (optional)
- jk2mpgame.map (optional)
- ui.map (optional)
Note: the .map files may not be there if you do not have Microsoft Visual C++ installed on your computer. It's okay. You don't need these.
Okay, so let's get cracking! Make a new folder within Gamedata called MyMod. Open up PakScape and go to File>New. Next, make a new folder within PakScape (in the archive you are working on) called "vm" (without quotes). Copy and Paste your .qvms here. Now go to File > Save As... "zzMyMod.pk3" (without quotes) in your MyMod folder, within Gamedata. Note: Make sure your Save As Type is set to "Quake 3 Pak (*.pk3)".
Why not just call the .pk3 - MyMod.pk3? Well, the game loads the PK3s reverse alphabetically. So, zzMyMod.pk3 will be loaded first (provided there are no other .pk3s in your Base or MyMod folder that are called zzzz_myskin.pk3 for instance).
The game will not load the PK3 because it isn't in your base folder. That is a good thing. You need to keep all .qvms out of your base folder at all times, or else your game may have conflicts, and you won't be able to join Pure Servers. But how do we get it to load the .pk3? We need to create a .bat file to load the game with our new .qvm.
Open up NotePad, and type this line:
jk2mp.exe +set fs_game MyMod
Then save it as MyMod.bat in your Gamedata folder. Congratulations! If you run the .bat, then the game will be running your mod. You can also place new skins, models, levels, etc. in your new folder to have mod-specific content.
But of course, there won't be any new content! That's where your effort comes in. You need to go out there and code the game as you wish. Edit anything in the code folder and it will probably have an effect. But you will need a good grasp on C/C++ before you can edit a good portion of the code. It's best to buy a book or two on the subject, and give that a good read.
For example, you can edit the weapon firing speeds in game/g_weapon.c, edit the damages in game/bg_weapons.c, and create new CVARs in game/g_main.c.
Part II - Jedi Academy
Jedi Academy is different than JK2 because JA relies solely on .dlls (Direct Link Libraries) to run.
For this tutorial, you will need:
Microsoft Visual C++ 2008 Express Edition
The Jedi Academy SDK
A decent understanding of C
PakScape
Open your hard drive (Local Disc (C:) by default). If you installed the SDK correctly, then a new folder called 'Projects' should appear here. Open this folder and navigate to the solution file (JEDI_Academy_SDK/codemp/JKA_mp(sdk).sln by default). Double-click on the solution file.
If you have Visual C++ installed right, a window should pop up that says "Visual Studio Conversion Wizard". Just hit Finish and then Close. You don't need to worry about the Conversion Report.
The game will not compile as-is, so we need to make some adjustments.
The first file we need to change is game/q_math.c. Comment out this function:
float powf ( float x, int y )
{
float r = x;
for ( y--; y>0; y-- )
r = r * r;
return r;
}
Now open game/q_shared.h. Comment out this line:
float powf ( float x, int y );
Why do we need to comment out this powf() function? Well, in
Compile using a Final configuration. Inside your Final Folder, within codemp, there should be three .dll files. Open a new file in PakScape and paste these three .dll files inside the new file. Create a new folder inside your Jedi Academy's Gamedata folder called MyMod. Save your file in PakScape as zzzmymod.pk3 (And make sure the file type is set to Quake 3 Pak (*.pk3).) inside the MyMod folder.
The game won't load MyMod by default, it will load base. So what we need to do is make a .bat that will change the game from base to MyMod. Open Notepad and type:
jamp.exe +set fs_game MyMod
And save it as MyMod.bat within the GameData folder.
All set! Your game will now run MyMod correctly. You can also place maps, skins, models, sounds, music, etc. inside your MyMod folder for Mod-Specific content.
That's all for the day. Now get out there and make the next big mod to hit Jedi Outcast or Jedi Academy!

