From 2a0f63c0a1ad7bef842bddbbbf647d934362791f Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:44:22 -0700 Subject: [PATCH] Fix all smashables not playing animations (#1112) Fixes an issue where most smashables did not explode into bricks upon death. This included anything that was spawned or didnt have the flag is_smashable set. Tested that in races, all objects smash into bricks Tested that the player properly explodes in their car if they crash Tested that Shooting Gallery plays the special smash animation when a ship is smashed Tested that all spawned objects play smash animations * Fix warning, Fix modular assembly not smashing * Rename variable to correct name --- dGame/Entity.cpp | 4 ++-- dGame/dComponents/DestroyableComponent.cpp | 4 ++-- dGame/dComponents/DestroyableComponent.h | 4 ++-- dGame/dComponents/InventoryComponent.cpp | 1 - dScripts/EquipmentScripts/BuccaneerValiantShip.cpp | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 907e8e63..bac07713 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -386,8 +386,8 @@ void Entity::Initialize() { comp->SetMaxCoins(currencyValues[0].maxvalue); } - // extraInfo overrides - comp->SetIsSmashable(GetVarAs(u"is_smashable") != 0); + // extraInfo overrides. Client ORs the database smashable and the luz smashable. + comp->SetIsSmashable(comp->GetIsSmashable() | (GetVarAs(u"is_smashable") != 0)); } } else { comp->SetHealth(1); diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 01ebf5c1..db8a2013 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -51,7 +51,7 @@ DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) { m_IsGMImmune = false; m_IsShielded = false; m_DamageToAbsorb = 0; - m_HasBricks = false; + m_IsModuleAssembly = m_Parent->HasComponent(eReplicaComponentType::MODULE_ASSEMBLY); m_DirtyThreatList = false; m_HasThreats = false; m_ExplodeFactor = 1.0f; @@ -163,7 +163,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn outBitStream->Write(m_IsSmashed); if (m_IsSmashable) { - outBitStream->Write(m_HasBricks); + outBitStream->Write(m_IsModuleAssembly); outBitStream->Write(m_ExplodeFactor != 1.0f); if (m_ExplodeFactor != 1.0f) outBitStream->Write(m_ExplodeFactor); } diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 66c8374d..5e5133b7 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -239,7 +239,7 @@ public: * Returns whether or not this entity has bricks flying out when smashed * @return whether or not this entity has bricks flying out when smashed */ - bool GetHasBricks() const { return m_HasBricks; } + bool GetHasBricks() const { return m_IsModuleAssembly; } /** * Sets the multiplier for the explosion that's visible when the bricks fly out when this entity is smashed @@ -546,7 +546,7 @@ private: /** * Whether this entity has bricks flying out when smashed (causes the client to look up the files) */ - bool m_HasBricks; + bool m_IsModuleAssembly; /** * The rate at which bricks fly out when smashed diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 907356ce..618e93b6 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -1002,7 +1002,6 @@ void InventoryComponent::HandlePossession(Item* item) { // Setup the destroyable stats auto* destroyableComponent = mount->GetComponent(); if (destroyableComponent) { - destroyableComponent->SetIsSmashable(false); destroyableComponent->SetIsImmune(true); } diff --git a/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp b/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp index 3db214b5..15954622 100644 --- a/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp +++ b/dScripts/EquipmentScripts/BuccaneerValiantShip.cpp @@ -11,7 +11,7 @@ void BuccaneerValiantShip::OnStartup(Entity* self) { // Kill self if missed self->AddCallbackTimer(1.1F, [self]() { - self->Kill(); + self->Smash(); }); } });