Skip to content

Singleplayer Overview

eezstreet edited this page Apr 7, 2013 · 3 revisions

This page will serve as an overview for the singleplayer portion of the game, which is encapsulated in jasp.exe, jk2gamex86.dll, and jagamex86.dll. This is not by any means a tutorial on how to make a mod, it's rather just a general overview of how the game works.

The singleplayer game is separated into three portions on OpenJK: JK2 Modbase (jk2gamex86.dll), JKA Modbase (jagamex86.dll), and Shared Executable (jasp.exe). You can switch between using the JK2 Modbase and JKA Modbase by changing the value of com_jk2 in the commandline. There are some slight differences between JK2 and JKA, aside from gameplay:

  • JK2 uses the StriP string system (.sp files) while JKA uses the StringEd string system (.str files).
  • JK2 has no support for Ghoul 2 models in the UI [FIXME] . Also, there are some slight lighting changes as well.

The rest of the engine enhancements that were added from JKA (ie, weather effects) should still be supported, with the exception of acid rain.

In OpenJK, you can use fs_game to switch between which modbases you want to use. There MUST be a base dll in your Gamedata folder for each game, otherwise those games will not work properly on base. To use a different modbase, place the modbase binary file (the .dll) in a new folder in Gamedata - for instance, MD2 - and set your fs_game to match the folder. Do not place the binary in a PK3, as the game is not capable of extracting them.

Networking

SP has a very limited level of networking, which is primarily used for delta-ing the playerstate, among other things. It's fully capable of sending and receiving packets from outside connections, however the Modbases are not able to network properly without some extreme modifications to support this, due to how they're set up.

Trap Calls

SP has no trap_ calls like MP does, whatsoever. These are replaced by the game_import_t and cgi_ functions for Serverside and Clientside, respectively. game_import_t is filled upon GetGameAPI, which serves as the entry point for the serverside, and the contents of it can be accessed in gi.*, for instance, gi.Print("Hello!");

vmMain

SP has two VMs - cgame and UI. UI is entirely within the engine, unlike multiplayer. cgame has some specific access to UI for the datapad, but that's about it. This is handled within vmMain for cgame (cg_main.cpp)

Serverside does not have a vmMain. This role is fulfilled by game_export_t, which is sent to the executable as part of GetGameAPI.

AI

AI is a bit tricky. It's fairly extensive in SP, more so than in MP. Each AI class (ie, CLASS_TAVION) has its own properties which set it as unique. However, not all AI classes have their own file! Most of the Jedi classes are kept in AI_Jedi.cpp, while most shooter types are kept in AI_Stormtrooper.cpp. The more unique AIs (ie, Galak's Mech Suit, Howlers, and Rancors) are kept aside in their own files.

The savegame

Most of the savegame's loading, parsing, saving, etc is all done within jasp.exe, in sv_savegame.cpp. But you can however pass in new values which are able to be saved, through the use of game_import_t calls.