rip7114 Posted March 31, 2025 Posted March 31, 2025 I am trying to link the DD system with the basic game behavior, so I need to call Papyrus through SKSE64, which means I have to deal with C++, and I never expected the road to hell to be so deep. I have gone through all the branches of CommonLib on GitHub and tried to deploy any of it, but without exception, I encountered various errors to some degree. I spent a lot of time trying to trace and fix the issues, but the errors are endless. I am completely unsure if the problem lies with my local environment or if the library I’m trying to deploy actually has issues. I need help. I need help. I am not a native English speaker, thank you for your patience in reading this.
traison Posted March 31, 2025 Posted March 31, 2025 Is this a game where we guess the errors you got trying to compile it? I'll go first: you got linking errors, and there was at least one header file missing. I win?
rip7114 Posted March 31, 2025 Author Posted March 31, 2025 3 hours ago, traison said: Is this a game where we guess the errors you got trying to compile it? I'll go first: you got linking errors, and there was at least one header file missing. I win? Thank you for your reply. I guess I was just testing whether anyone reads these types of posts on this forum. I will try to describe the issue in more detail, but right now I feel somewhat stuck as I am unfamiliar with the related terminology. Another reason is that it has been six months since I last opened this project and gave up on it, and my memory has started to fade. When I reopened it, I encountered new issues, such as the cmake toolchain in the cache being different from the current toolchain file. The old problems I had faced seem to no longer appear in the same way, which only doubles my confusion. I am also considering whether to finish the deployment or release the current code in hopes that someone can take over. It is a very brief script for numerical hooking, about 110 lines. Once finished, this functionality can start interacting passively with DD or its upstream functionalities. I would like to know which library I should choose for someone who has no ability to solve any problems, and then restart until I encounter enough issues for I can come back and list them. I hope to get a usable template project. I believe I have solved the issue of including header files correctly, at least in Visual Studio there are looked fine. However, the included files for call papyrus now trigger a large number of build errors when generating. But I cannot reproduce this situation at the moment.
rip7114 Posted March 31, 2025 Author Posted March 31, 2025 The goal is to link the basic damage values of the game with the arousal value and bypass the damage calculation on the health of all creatures with an arousal value. The idea is to later add damage to orgasmic behavior, making orgasm the only action capable of calculating the health of creatures with an arousal value. I know that most of the header file references are meaningless; they are just desperate attempts during the process of encountering problems. #include <RE/Skyrim.h> #include <RE/V/Variable.h> #include <RE/V/VirtualMachine.h> #include <REL/Relocation.h> #include <SKSE/Logger.h> #include <SKSE/SKSE.h> #include <SKSE/Trampoline.h> #include <spdlog/sinks/basic_file_sink.h> #include <string> #include <unordered_map> using namespace RE; using namespace SKSE; using namespace REL; std::unordered_map<std::string, float> damageMap; void Update() { SKSE::log::info("Performing periodic update..."); } // Define custom callback class to receive invocation results class ArousalCallback : public RE::BSScript::IStackCallbackFunctor { public: // Correct callback function signature void operator()(RE::BSScript::Variable a_result) override { if (a_result.IsFloat()) { float arousalValue = a_result.GetFloat(); SKSE::log::info("Received arousal value: {:.2f}", arousalValue); } else { SKSE::log::error("Failed to retrieve a valid arousal value."); } } bool CanSave() const override { return false; // Default behavior: cannot save callback } void SetObject(const RE::BSTSmartPointer<RE::BSScript::Object>& a_object) override { SKSE::log::info("SetObject called."); // If object reference needs to be saved, implement logic here } ~ArousalCallback() override = default; }; void DamageEventCallback(Actor* target, Actor* attacker, float& damage) { if (!target) { SKSE::log::info("Invalid target!"); return; } std::string targetNameStr = target->GetDisplayFullName(); if (targetNameStr.empty()) { SKSE::log::info("Target has no name!"); return; } // Calculate and store adjusted damage value float multiplier = 0.5f; float DmgtoArousal = damage * multiplier; damage = 0.0f; // Prevent damage from being applied to health damageMap[targetNameStr] = DmgtoArousal; // Call Papyrus function auto vm = RE::BSScript::Internal::VirtualMachine::GetSingleton(); if (vm) { SKSE::log::info("Attempting to invoke Papyrus function..."); auto args = RE::MakeFunctionArguments(target); // Explicitly cast to base class pointer type auto callback = RE::BSTSmartPointer<RE::BSScript::IStackCallbackFunctor>(new ArousalCallback()); bool success = vm->DispatchStaticCall("OSLArousedNative", // Script name "GetArousal", // Function name args, // Parameters callback // Callback object ); if (success) { SKSE::log::info("Successfully dispatched Papyrus function."); } else { SKSE::log::error("Failed to dispatch Papyrus function."); } } } void InitializePlugin() { SKSE::log::info("Initializing plugin..."); auto taskInterface = GetTaskInterface(); if (taskInterface) { taskInterface->AddTask(Update); } else { SKSE::log::error("TaskInterface not available!"); } auto& trampoline = SKSE::GetTrampoline(); SKSE::log::info("Trampoline initialized."); } #ifndef DLLEXPORT #define DLLEXPORT __declspec(dllexport) #endif extern "C" DLLEXPORT bool SKSEPlugin_Load(const SKSE::LoadInterface* skse) { SKSE::log::info("SKSE Plugin Loaded!"); SKSE::Init(skse); InitializePlugin(); return true; }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now