From 51929acba1f1d829f9acd7dee784165bc3a1589f Mon Sep 17 00:00:00 2001 From: Robbe Bryssinck Date: Thu, 26 May 2022 01:01:26 +0200 Subject: [PATCH] feat: cool death fade --- Code/client/Games/References.cpp | 7 +++++++ Code/client/Games/References.h | 2 ++ Code/client/Services/Debug/DebugService.cpp | 6 ++++++ Code/client/Services/Generic/PlayerService.cpp | 5 ++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Code/client/Games/References.cpp b/Code/client/Games/References.cpp index ee737652c..cb69096c1 100644 --- a/Code/client/Games/References.cpp +++ b/Code/client/Games/References.cpp @@ -74,6 +74,13 @@ float CalculateRealDamage(Actor* apHittee, float aDamage) noexcept } +void FadeOutGame(bool aFadingOut, bool aBlackFade, float aFadeDuration, bool aRemainVisible, float aSecondsToFade) noexcept +{ + using TFadeOutGame = void(bool, bool, float, bool, float); + POINTER_SKYRIMSE(TFadeOutGame, fadeOutGame, 52847); + fadeOutGame.Get()(aFadingOut, aBlackFade, aFadeDuration, aRemainVisible, aSecondsToFade); +} + TESObjectREFR* TESObjectREFR::GetByHandle(uint32_t aHandle) noexcept { TESObjectREFR* pResult = nullptr; diff --git a/Code/client/Games/References.h b/Code/client/Games/References.h index 69bf6aa16..8d4e2b933 100644 --- a/Code/client/Games/References.h +++ b/Code/client/Games/References.h @@ -27,6 +27,8 @@ float* GetGreetDistance() noexcept } +void FadeOutGame(bool aFadingOut, bool aBlackFade, float aFadeDuration, bool aRemainVisible, float aSecondsToFade) noexcept; + struct ExActor : Actor, ActorExtension { }; diff --git a/Code/client/Services/Debug/DebugService.cpp b/Code/client/Services/Debug/DebugService.cpp index 42e97d376..c40536aa0 100644 --- a/Code/client/Services/Debug/DebugService.cpp +++ b/Code/client/Services/Debug/DebugService.cpp @@ -167,6 +167,12 @@ void DebugService::OnUpdate(const UpdateEvent& acUpdateEvent) noexcept { s_f8Pressed = true; + static bool s_enabled = true; + + FadeOutGame(s_enabled, true, 1.f, true, 0.f); + + s_enabled = !s_enabled; + #if 0 static bool s_enabled = true; static bool s_firstPerson = false; diff --git a/Code/client/Services/Generic/PlayerService.cpp b/Code/client/Services/Generic/PlayerService.cpp index 58a17e835..a696d4bf9 100644 --- a/Code/client/Services/Generic/PlayerService.cpp +++ b/Code/client/Services/Generic/PlayerService.cpp @@ -146,6 +146,7 @@ void PlayerService::RunRespawnUpdates(const double acDeltaTime) noexcept { s_startTimer = true; m_respawnTimer = 5.0; + FadeOutGame(true, true, 2.5f, true, 2.5f); // If a player dies not by its health reaching 0, getting it up from its bleedout state isn't possible // just by setting its health back to max. Therefore, put it to 0. @@ -161,7 +162,7 @@ void PlayerService::RunRespawnUpdates(const double acDeltaTime) noexcept { pPlayer->RespawnPlayer(); - knockdownTimer = 1.0; + knockdownTimer = 1.5; knockdownStart = true; m_transport.Send(PlayerRespawnRequest()); @@ -187,6 +188,8 @@ void PlayerService::RunPostDeathUpdates(const double acDeltaTime) noexcept PlayerCharacter* pPlayer = PlayerCharacter::Get(); pPlayer->currentProcess->KnockExplosion(pPlayer, &pPlayer->position, 0.f); + FadeOutGame(false, true, 0.5f, true, 2.f); + knockdownStart = false; } }