From db5ee491405ccd019f6c4cccd49c4a00c6748197 Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Wed, 1 Nov 2023 07:27:34 +0600 Subject: [PATCH] fix(skymp5-server): setting isDead to false via gamemode makes actor invulnerable (#1727) --- skymp5-server/cpp/server_guest_lib/MpActor.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/skymp5-server/cpp/server_guest_lib/MpActor.cpp b/skymp5-server/cpp/server_guest_lib/MpActor.cpp index 5ab9072c8e..ec21a4f928 100644 --- a/skymp5-server/cpp/server_guest_lib/MpActor.cpp +++ b/skymp5-server/cpp/server_guest_lib/MpActor.cpp @@ -691,7 +691,16 @@ void MpActor::SetRespawnTime(float time) void MpActor::SetIsDead(bool isDead) { - SendAndSetDeathState(isDead, false); + constexpr bool kShouldTeleport = false; + + if (isDead) { + if (IsDead() == false) { + SendAndSetDeathState(isDead, kShouldTeleport); + } + } else { + // same as SendAndSetDeathState but resets isRespawning flag + Respawn(kShouldTeleport); + } } void MpActor::RestoreActorValue(espm::ActorValue av, float value)