Implemented health bar fix with DLL, removed custom hudmenu.swf and .gfx

This commit is contained in:
Eddoursul 2023-12-20 16:27:06 +01:00
parent 31482f145d
commit 85c1cc1b0c
6 changed files with 55 additions and 10 deletions

BIN
SKSE/Plugins/EnderalSE.dll (Stored with Git LFS)

Binary file not shown.

BIN
interface/exported/hudmenu.gfx (Stored with Git LFS)

Binary file not shown.

BIN
interface/hudmenu.swf (Stored with Git LFS)

Binary file not shown.

View File

@ -9,6 +9,7 @@
#include "DialogueMenuPatch.h"
#include "Patches/TweenMenuPatch.h"
#include "Patches/HeroMenuPatch.h"
#include "Patches/HUDMenuPatch.h"
using namespace SKSE;
@ -173,6 +174,7 @@ SKSEPluginLoad(const LoadInterface* skse) {
DialogueMenuPatch::Install();
HeroMenuPatch::Install();
TweenMenuPatch::Install();
HUDMenuPatch::Install();
if (g_settings.at("VideoInterruptPatch")) {
logger::info("Making videos interruptible...");

View File

@ -0,0 +1,45 @@
#pragma once
inline std::time_t lastUpdate;
class HUDMenuPatch final : public RE::ActorValueMeter
{
public:
static void Install()
{
REL::Relocation<uintptr_t> vtbl(RE::VTABLE_ActorValueMeter[0]);
_ProcessMessage = vtbl.write_vfunc(0x2, &ProcessMessageEx);
}
private:
bool ProcessMessageEx(RE::UIMessage* a_message)
{
if (this->actorValue == RE::ActorValue::kHealth && a_message->type == RE::UI_MESSAGE_TYPE::kScaleformEvent) {
std::time_t currentTime = std::time(nullptr);
if (currentTime > lastUpdate) {
// Ping the health bar every second
lastUpdate = currentTime;
auto playerAV = RE::PlayerCharacter::GetSingleton()->AsActorValueOwner();
auto currentHealth = playerAV->GetActorValue(RE::ActorValue::kHealth);
if (currentHealth < playerAV->GetBaseActorValue(RE::ActorValue::kHealth) && currentHealth > 0) {
auto uiMovie = RE::UI::GetSingleton()->GetMovieView(RE::HUDMenu::MENU_NAME);
if (uiMovie) {
RE::GFxValue va;
uiMovie->GetVariable(&va, "HUDMovieBaseInstance.HealthMeterAnim._currentframe");
RE::GFxValue args[1];
args[0].SetNumber(va.GetNumber());
uiMovie->Invoke("HUDMovieBaseInstance.HealthMeterAnim.PlayForward", nullptr, args, 1);
}
}
}
}
return _ProcessMessage(this, a_message);
}
inline static REL::Relocation<decltype(&ProcessMessageEx)> _ProcessMessage;
};

View File

@ -57,8 +57,12 @@ void HeroMenuPatch::FillMenuValues()
public:
void operator()(RE::BSScript::Variable a_result)
{
auto uiMovie = RE::UI::GetSingleton()->GetMovieView("CustomMenu");
uiMovie->SetVariable("_root.heromenu_mc.stats.playerclass.stat_value.text", a_result.GetString());
if (a_result.IsString()) {
auto uiMovie = RE::UI::GetSingleton()->GetMovieView("CustomMenu");
if (uiMovie) {
uiMovie->SetVariable("_root.heromenu_mc.stats.playerclass.stat_value.text", a_result.GetString());
}
}
}
bool CanSave() { return false; }
void SetObject(const RE::BSTSmartPointer<RE::BSScript::Object>&) {}