OPL2 uses the Panda3D library. Panda3D is an open-source game engine with full Python support. http://www.panda3d.org/
Panda3D has official wrappers for many 3rd party libraries like OpenAL, FMOD, ODE, Bullet, PhysX, libRocket, etc.
OPL2 is completely written in Python. There are C++ versions of some performance-critical functions, which are only used when available (running on the same CPU architecture, same OS the module was compiled for). So you should be able to run OPL2 on any platform which Panda3D runs on, even though you might experience slowdowns because the pure Python versions of the functions are used, if we haven't compiled the module for that platform.
OPL2's sourcecode is pretty small: it consists of 13 Python modules and 2 “faster version” C++
modules.
Main script. Runs the GUI Launcher or directly starts the game (by importing “PL2Start.py”)
depending if the launcher is enabled or not in the configuration file (opl2_data/config.txt).
Generally useless for modders.
A launcher which shows up at startup and allows you to change some game settings before starting
the actual game. Can be disabled. If you'll want to reenable, either edit the config file yourself or
delete the config file and let OPL2 generate a default one next time. Generally useless for modders.
Similar to Panda3D's DirectStart module, which simply creates an instance of ShowBase (which
itself initializes many default Panda3D stuff). PL2Start imports DirectStart, creates an instance of
PL2Base, starts the PL2 interpreter by telling it to run the script "script.txt" and also starts
Panda3D's game loop. Generally useless for modders.
This class is meant to mimic C's random number generator. Is used by the game to encrypt and
decrypt *.dat files, which are used for saving characters and game progress. Generally useless for
modders.
A 3rd party open source parser library-module, used for parsing PL2's *.txt scripts. Generally
useless for modders.
Provides functions for scanning the game's “add-ons” folder for add-ons, extracting the entries from
pl2 archives, and “attribute” files from the add-ons, parsing them and generating Python
dictionaries which are used in the game by PL2 scripts and the “CharacterCreationScreen” class.
Used by the PL2Base class.
A class for loading PL2's native file formats (PL2, TMB, TSB, TCM, BIN, PSD). Similar to
Panda3D's Loader class. The functions accept file paths or data strings.
An instance is created in the PL2Base class (like an instance of “Loader” is created when you make
an instance of Panda3D's “Loader” class, for example by importing “DirectStart”).
A parser/interpreter for PL2's TXT scripts. Parser uses the “pyparsing.py” library-module.
Interpreter implemented as a Panda3D “Task” object.
A module containing all the Python functions which correspond to PL2 TXT commands.
Can be called directly from Python code or assigned to the PL2 *.txt script commands by using the
“commandsDict” dictionary of the PL2Interpreter class. Very interesting for modders.
Similar to Panda3D's ShowBase class (which is instantiated automatically when you import
DirectStart module). Sets up some default objects and functions used by other OPL2 modules. Very
interesting for modders.
The Clothing Selection Screen from PL2 which is usually accessed with the “%Z” command. Very
interesting for modders.
Provides camera controls very similar to the original game.
An instance is created in the PL2Base class.
Functions/classes for making modding the game simpler and more powerful.
Contains faster C++ version of the function “_decompressPL2” from the PL2loader class. Used for
decompressing LZSS compressed *.pl2 files. Generally useless for modders.
Contains faster C++ versions of the functions “_mold” and “_decompressRLE” from the
“PL2Loader” class. Used for decompressing RLE compressed *.psd image layers and rearranging
pixel data. Generally useless for modders.
(note: wanted to create a table, but Sourceforge sucks at rendering tables)
There is an automatically generated html documentation of the sourcecode, generated with Doxygen, which can be found in the folder “engine/src/doc” (or “src/doc” for the sourcecode distribution).
Binary version of OPL2 comes as an archive. The archive contains the following folders:
engine/ add-ons/ opl2_data/
"add-ons" folder is empty, copy your files from the original game here.
"engine" folder contains these subfolders:
/panda3d/ /game/
"panda3d" contains the Panda3D engine (which includes a full copy of Python).
"game" contains OPL2's sourcecode and html docs.
“opl2_data” contains the game's configuration file and the folders "cache" and "plugins":
/cache/ /plugins/
"cache" folder is Panda3D's cache folder (not used by default).
"plugins" folder where your Python/C++ add-ons/mods are placed.
"panda3d" contains the following subfolders:
/bin/ /etc/ /direct/ /pandac/ /python/
All these folders should be known to you as a Pana3D user.
If you want to distribute OPL2 with your own version of Panda3D, you'll need to copy the folders from the SDK like this, or distribute it like any other Python application, by using something like py2exe or cx_Freeze and not using our exe launcher and folder structure.
For developing the suggested way is to download the Panda3D SDK and the sourcecode version of OPL2.
Please use the Panda3D docs and forum for Panda3D questions. Same goes to general Python/C++ questions, use Google.