parent
31482f145d
commit
85c1cc1b0c
6 changed files with 55 additions and 10 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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; |
||||
}; |
Loading…
Reference in new issue