SQGLib is a C++ lib powered by SKSE to add runtime quest generation capabilities to Skyrim.
- CMake
- Add this to your
PATH
- Add this to your
- The Elder Scrolls V: Skyrim Special Edition
- Add the environment variable
Skyrim64Pathto point to the root installation of your game directory (the one containingSkyrimSE.exe).
- Add the environment variable
- Vcpkg
- Add the environment variable
VCPKG_ROOTwith the value as the path to the folder containing vcpkg
- Add the environment variable
- Visual Studio Community 2022
- Desktop development with C++
git clone https://github.com/ZeCroque/SQGLib.git
cd SQGLib
git submodule init
git submodule update
cmake --preset vs2022-windows
cmake --build build --config Release
- As the quest logs are normally read from localized string, I had to hook the UI method that searches for them on mouse hover.
- The response text for dialog topics are read from the
.espusing thefileOffsetattribute. I wasn't able to locate/trigger the method that would create and store the responses for my runtime-generated dialog topics and thus I went on a workaround that dynamically changes the strings of pre-defined template topics fromSQGLib.espusing an event sink and a hook. To make it work seemlessly I also had to hook another method to manually set/unset the "yet said" flag on theses template topics. This comes with the annoying limitation of only 4 dialog topics at a given level of the custom dialog tree (I could have added more but I chose to be on-par with FO4). There's also support for hello topics and one single force greet topic by NPC. - I added a runtime-compiled script system for quest, topic and package fragments, as well as aliases script. It uses a forked version of Orvid's Caprica compiler and does unfortunately a lot of memory leaks (AFAIK it's the case even on the release version of Caprica, so I'll reach out to Orvid about that). It tries to read unzipped vanilla scripts and flags (from either
Scripts/SourceorSource/Scripts) and then is able to compile source strings and store them into a custom script store that will provide vanilla callbacks the compiled scripts when needed. Currently in the sample project these scripts are read fromData/SKSE/SQGLibSamplebut the goal is obviously to generate them on the go with the procedural engine. - I implemented a custom "fragment" system using event sinks and it is currently expecting to find :
- A script named equally to the quest editorId for quest stages "fragments"
- A script named
"TF_" + quest editorIdfor dialog topics "fragments" - A script named equally to what's been given to
AddAliasPackagesfor package "fragments"
- The generated quests, dialogs, packages and scripts are serialized using a forked version of Dynamic Persistent Form (by Thiago099) into a new co-save with the
.sqgextension to be restored when you load a savegame. I had to create a new co-save instead of using the.skseone because the SKSE'sLoadCallbacktriggers too late in the savegame loading process and therefore the generated quest weren't inialized properly and didn't appear in the quest log. The savegame folder is found using a function copied fromSKSEthat is not visible fromCommonLibSSE, so that's not ideal as I will have to update it wheneverSKSEgets updated.
- You can add the environment variable
MO2Pathto automatically add a debug target that will launch MO2 from Visual Studio. The debug target runs DebugWithMO2.ps1, which starts MO2, waits forSkyrimSE.exeto have SKSE injected, then attaches Visual Studio to it (attaching earlier makes the SKSE loader fail with "Couldn't inject DLL"). Stopping the debugger ("Stop Debugging") also closes the game, while "Detach All" leaves it running. Child process debugging is not needed. Since the attach happens after SKSE starts, early breakpoints (e.g. inSKSEPluginLoad) may be missed: wait for the debugger there (while (!IsDebuggerPresent()) Sleep(100);) if needed- Set
MO2_INSTANCEto the name of the instance you want MO2 to manage (default isSkyrim Special Edition) - Set
MO2_TARGETto the name of the target you want MO2 to run (default isSkyrim Special Edition). It can point to the SKSE loader - Set
MO2_PROFILEto the name of the MO2 profile you want to use (useful to have MO2 write to a mod folder instead of the overwrite in the chosen profile)
- Set
- Set
LEGACY_SCRIPT_PATHtoONto use the old Scripts/Source path instead of the new (and stupid) Source/Scripts path - Set
NOTES_FOLDER_PATHif you are versionning notes/TODOs etc.. outside git and want to have them appear in VSC - Build the
packagetarget to automatically build and zip up your dll in a ready-to-distribute format.