Editing JK2 Single Player Game/Engine Code

Guides and how to's on anything related to JK2, whether it's about modding or in-game topics.
Post Reply
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Editing JK2 Single Player Game/Engine Code

Post by Tr!Force » 21 Jan 2016, 00:30

OK, this is a tutorial to modify the JK2 Single Player Game/Engine Code, i will use the OpenJK Source-Code for JK2 SP because it is much more stable than the original JK2 SP Source-Code, and OpenJK already fixed a lot of things.
Tr!Force wrote:Note 1: English is not my main language, so i will try to do my best :lol:
Note 2: If you want know what things can you do with the Source-Code, i will answer: you can change the entire game.
So, Lets Go!

1. Getting all resources:
  • Download the OpenJK Project here (the "Download ZIP" button)
  • Download CMake from here (this is to generate the project files)
  • Download Visual Studio here (2013 version in my case)
2. Install stuff
  • Install CMAKE with Admin Rights (right click -> execute as Admin)
  • Dont forget to check the option "add CMAKE to system PATH (for you or all users)"
  • Install VIsual Studio (2013 version in my case)
3. Create the project files:
  • Go to your OpenJK-master folder
  • Open CMakeLists.txt with an editor (like Notepad++, Vim, etc...)
  • Look for the BuildJK2SPxxx strings, and change all OFF with ON at the end:

    Code: Select all

    option(BuildJK2SPEngine "Whether to create projects for the jk2 SP engine (openjo_sp.exe)" OFF)
    option(BuildJK2SPGame "Whether to create projects for the jk2 sp gamecode mod (jk2gamex86.dll)" OFF)
    option(BuildJK2SPRdVanilla "Whether to create projects for the jk2 sp renderer (rdjosp-vanilla_x86.dll)" OFF)
    
  • Save the file and now open the file CreateVisualStudio2013Projects.bat (in the same folder)
  • OK, now ure ready to work with the project files in with Visual Studio
4. Edit the game:
  • Open the project file OpenJK.sln (in the "build" folder)
  • Now feel free to edity whatever you want. The whole project has the Jedi Academy SP / MP and the Jedi Outcast SP codes
  • The main game features for JK2 SP are in: JK2 SP Game Library Project (in "game" folder, look at the right sidebar)
  • For example, if you want edit the weapon damages i written an easy example here:
    1. Go to the game folder in JK2 SP Game Library
    2. Open weapons.h
    3. Inside use the search tool and look for:

      Code: Select all

      #define BRYAR_PISTOL_DAMAGE 14
      and change the 14 with whatever you want, for example 999:

      Code: Select all

      #define BRYAR_PISTOL_DAMAGE 999
    4. You can write a note or a message in the same line adding // at the beginning of the note, like:

      Code: Select all

      #define BRYAR_PISTOL_DAMAGE 999 //Old value was 14
    5. Now you are ready to compile. :P
    6. Note: There is better ways to manage damages, for example creating a cvar /g_weapon_bryar_dmg 999 to use in the console, but this way is fine to start coding.
  • Finally when you have everything done, and you are ready, save the project and change Debug with Release at the top of the window:
    Image
  • Now you need to generate the 3 main JK2 SP Binaries, so right click on project files (Look at the right sidebar) and press "Build" in:
    1. JK2 SP Client
    2. JK2 SP Game Library
    3. JK2 SP Vanilla renderer
  • After that you will get a "final" message from every build at the bottom, like:

    Code: Select all

     ========== Build All: 3 succeeded, 0 failed, 0 skipped ==========
    
  • If theres 0 failed it means everything is fine.
  • Now go to the Release folder and copy the 3 main JK2 SP files:
    1. openjo_sp.x86.exe
    2. rdjosp-vanilla_x86.dll
    3. jospgamex86.dll
  • Paste these files in GameData folder in your JK2 game folder
  • Now you are ready to play with your own JK2 SP Version! (remember to open the main executable openjo_sp.x86.exe)
  • Note 1: if says SDL2.dll not found, just get from OpenJK Source folder in: OpenJK-master\lib\SDL2\bin
  • Note 2: Remember to click on ReBuild in the project if you want do more tests and compile again, and again...
Any questions, bugs, etc.. you can write here in this topic.
Regards ;)
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@jk2mp.com
  • Discord: TriForce#8785

Tom Arrow
Posts: 91
Joined: 21 Sep 2016, 03:05

Re: Editing JK2 Single Player Game/Engine Code

Post by Tom Arrow » 04 Oct 2016, 16:21

Does it work the same way with JK2MP or JoMME?

User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Editing JK2 Single Player Game/Engine Code

Post by Tr!Force » 18 Oct 2016, 14:19

Tom Arrow wrote:Does it work the same way with JK2MP or JoMME?
u mean, is the same structure? if is that, yes.
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@jk2mp.com
  • Discord: TriForce#8785

Post Reply
Created by Matti from StylesFactory.pl and Warlords of Draenor (modified by jk2.info)
Powered by phpBB® Forum Software © phpBB Limited
GZIP: On
 

 

cron