#include "skse64/PluginAPI.h" // super #include "skse64_common/skse_version.h" // What version of SKSE is running? #include // CSIDL_MYCODUMENTS #include "PhasmalistInventoryFunctions.h" #include "CreatePotion.h" static SKSEPapyrusInterface * g_papyrus = NULL; static SInt32 g_NewGameStarted = 0; #define SKYRIMAE constexpr true #ifndef SKYRIMAE #define RUNTIME_VERSION_1_6_353 MAKE_EXE_VERSION(1, 6, 353) struct SKSEPluginVersionData { enum { kVersion = 1, }; enum { // set this if you are using a (potential at this time of writing) post-AE version of the Address Library kVersionIndependent_AddressLibraryPostAE = 1 << 0, // set this if you exclusively use signature matching to find your addresses and have NO HARDCODED ADDRESSES kVersionIndependent_Signatures = 1 << 1, }; UInt32 dataVersion; // set to kVersion UInt32 pluginVersion; // version number of your plugin char name[256]; // null-terminated ASCII plugin name char author[256]; // null-terminated ASCII plugin author name (can be empty) char supportEmail[256]; // null-terminated ASCII support email address (can be empty) // this is not for showing to users, it's in case I need to contact you about // a compatibility problem with your plugin // version compatibility UInt32 versionIndependence; // set to one of the kVersionIndependent_ enums or zero UInt32 compatibleVersions[16]; // zero-terminated list of RUNTIME_VERSION_ defines your plugin is compatible with UInt32 seVersionRequired; // minimum version of the script extender required, compared against PACKED_SKSE_VERSION // you probably should just set this to 0 unless you know what you are doing }; #endif void SKSEMessageHandler(SKSEMessagingInterface::Message* msg) { if (msg->type == SKSEMessagingInterface::kMessage_PostLoadGame || msg->type == SKSEMessagingInterface::kMessage_NewGame) { if (g_NewGameStarted < 2) { g_NewGameStarted++; } } } extern "C" { __declspec(dllexport) SKSEPluginVersionData SKSEPlugin_Version = { SKSEPluginVersionData::kVersion, 1, #ifdef SKYRIMAE "fs_skse_functions", #else "fs_skse_functions_disabled", #endif "Eddoursul", "enderal@eddoursul.win", 0, // not version independent { RUNTIME_VERSION_1_6_353, 0 }, // compatible with 1.6.353 0, // works with any version of the script extender. you probably do not need to put anything here }; bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info) { // Called by SKSE to learn about this plugin and check that it's safe to load it #ifndef SKYRIMAE gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Enderal Special Edition\\SKSE\\Enderal_SE.log"); gLog.SetPrintLevel(IDebugLog::kLevel_Error); gLog.SetLogLevel(IDebugLog::kLevel_DebugMessage); _MESSAGE("EnderalSE"); #endif // populate info structure info->infoVersion = PluginInfo::kInfoVersion; #ifdef SKYRIMAE info->name = "fs_skse_functions_disabled"; #else info->name = skse->runtimeVersion == RUNTIME_VERSION_1_5_97 ? "fs_skse_functions" : "fs_skse_functions_disabled"; #endif info->version = 1; if (skse->isEditor) { return false; } // ### do not do anything else in this callback // ### only fill out PluginInfo and return true/false // supported runtime version return true; } bool SKSEPlugin_Load(const SKSEInterface * skse) { // Called by SKSE to load this plugin #ifdef SKYRIMAE gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Enderal Special Edition\\SKSE\\Enderal_AE.log"); gLog.SetPrintLevel(IDebugLog::kLevel_Error); gLog.SetLogLevel(IDebugLog::kLevel_DebugMessage); if (skse->runtimeVersion != RUNTIME_VERSION_1_6_353) { _MESSAGE("skipping initialization of the non-AE library"); return true; } #else if (skse->runtimeVersion != RUNTIME_VERSION_1_5_97) { _MESSAGE("skipping initialization of the non-SE library"); return true; } #endif _MESSAGE("EnderalSE loaded"); auto messaging = (SKSEMessagingInterface*)skse->QueryInterface(kInterface_Messaging); messaging->RegisterListener(skse->GetPluginHandle(), "SKSE", SKSEMessageHandler); g_papyrus = (SKSEPapyrusInterface *)skse->QueryInterface(kInterface_Papyrus); //Check if the function registration was a success... bool btest = g_papyrus->Register(PhasmalistScripts::RegisterFuncs); if (btest) { _MESSAGE("Register Succeeded: Phasmalist functions"); } btest = g_papyrus->Register(CreatePotion::RegisterFuncs); if (btest) { _MESSAGE("Register Succeeded: CreatePotion functions"); } g_papyrus->Register([](VMClassRegistry* registry) { registry->RegisterFunction(new NativeFunction0("NewGameCount", "EnderalLib", [](StaticFunctionTag* tag) { return g_NewGameStarted; }, registry)); _MESSAGE("Register Succeeded: NewGameCount"); return true; }); return true; } };