Fix zombie bug (#1014)

This commit is contained in:
David Markowitz 2023-03-08 05:32:03 -08:00 committed by GitHub
parent ff0336793c
commit a532bc15d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -915,15 +915,23 @@ void GameMessages::SendSetJetPackMode(Entity* entity, bool use, bool bypassCheck
} }
void GameMessages::SendResurrect(Entity* entity) { void GameMessages::SendResurrect(Entity* entity) {
DestroyableComponent* dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); // Restore the players health after the animation for respawning has finished.
// This is when the health appered back in live, not immediately upon requesting respawn
// Add a half second in case someone decides to cheat and move during the death animation
// and just make sure the client has time to be ready.
constexpr float respawnTime = 3.66700005531311f + 0.5f;
entity->AddCallbackTimer(respawnTime, [=]() {
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
if (dest != nullptr && entity->GetLOT() == 1) { if (destroyableComponent != nullptr && entity->GetLOT() == 1) {
auto* levelComponent = entity->GetComponent<LevelProgressionComponent>(); auto* levelComponent = entity->GetComponent<LevelProgressionComponent>();
if (levelComponent) { if (levelComponent) {
dest->SetHealth(levelComponent->GetLevel() >= 45 ? 8 : 4); destroyableComponent->SetHealth(levelComponent->GetLevel() >= 45 ? 8 : 4);
dest->SetImagination(levelComponent->GetLevel() >= 45 ? 20 : 6); destroyableComponent->SetImagination(levelComponent->GetLevel() >= 45 ? 20 : 6);
}
} }
} });
auto cont = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS)); auto cont = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
if (cont && entity->GetLOT() == 1) { if (cont && entity->GetLOT() == 1) {

View File

@ -1,5 +1,7 @@
#include "ActPlayerDeathTrigger.h" #include "ActPlayerDeathTrigger.h"
#include "Entity.h"
void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target->IsPlayer() || target->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready if (!target->IsPlayer() || target->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready