diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 6bca2239..f440d6de 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -6442,4 +6442,18 @@ namespace GameMessages { missionComponent->Progress(eMissionTaskType::TALK_TO_NPC, interactedObject->GetLOT(), interactedObject->GetObjectID()); missionComponent->Progress(eMissionTaskType::INTERACT, interactedObject->GetLOT(), interactedObject->GetObjectID()); } + + void Smash::Serialize(RakNet::BitStream& stream) const { + stream.Write(bIgnoreObjectVisibility); + stream.Write(force); + stream.Write(ghostCapacity); + stream.Write(killerID); + } + + void UnSmash::Serialize(RakNet::BitStream& stream) const { + stream.Write(builderID != LWOOBJID_EMPTY); + if (builderID != LWOOBJID_EMPTY) stream.Write(builderID); + stream.Write(duration != 3.0f); + if (builderID != 3.0f) stream.Write(duration); + } } diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 97c92ae4..10c22ce5 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -801,6 +801,26 @@ namespace GameMessages { // Used only for multi-interaction, is of the enum type InteractionType int multiInteractType{}; }; + + struct Smash : public GameMsg { + Smash() : GameMsg(MessageType::Game::SMASH) {} + + void Serialize(RakNet::BitStream& stream) const; + + bool bIgnoreObjectVisibility{}; + bool force{}; + float ghostCapacity{}; + LWOOBJID killerID{}; + }; + + struct UnSmash : public GameMsg { + UnSmash() : GameMsg(MessageType::Game::UN_SMASH) {} + + void Serialize(RakNet::BitStream& stream) const; + + LWOOBJID builderID{ LWOOBJID_EMPTY }; + float duration{ 3.0f }; + }; }; #endif // GAMEMESSAGES_H diff --git a/dGame/dPropertyBehaviors/Strip.cpp b/dGame/dPropertyBehaviors/Strip.cpp index 18648996..3877b618 100644 --- a/dGame/dPropertyBehaviors/Strip.cpp +++ b/dGame/dPropertyBehaviors/Strip.cpp @@ -98,7 +98,6 @@ void Strip::Spawn(LOT lot, Entity& entity) { info.rot = NiQuaternionConstant::IDENTITY; info.spawnerID = entity.GetObjectID(); Game::entityManager->ConstructEntity(Game::entityManager->CreateEntity(info, nullptr, &entity)); - IncrementAction(); } // Spawns a specific drop for all @@ -106,12 +105,17 @@ void Strip::SpawnDrop(LOT dropLOT, Entity& entity) { for (auto* const player : PlayerManager::GetAllPlayers()) { GameMessages::SendDropClientLoot(player, entity.GetObjectID(), dropLOT, 0, entity.GetPosition()); } - IncrementAction(); } void Strip::Update(float deltaTime, ModelComponent& modelComponent) { + m_PausedTime -= deltaTime; + if (m_PausedTime > 0.0f) return; + m_PausedTime = 0.0f; auto& entity = *modelComponent.GetParent(); - auto number = static_cast(GetNextAction().GetValueParameterDouble()); + auto& nextAction = GetNextAction(); + auto number = nextAction.GetValueParameterDouble(); + auto numberAsInt = static_cast(number); + if (GetNextAction().GetType() == "SpawnStromling") { Spawn(10495, entity); } else if (GetNextAction().GetType() == "SpawnPirate") { @@ -119,12 +123,29 @@ void Strip::Update(float deltaTime, ModelComponent& modelComponent) { } else if (GetNextAction().GetType() == "SpawnRonin") { Spawn(10498, entity); } else if (GetNextAction().GetType() == "DropImagination") { - for (; number > 0; number--) SpawnDrop(935, entity); + for (; numberAsInt > 0; numberAsInt--) SpawnDrop(935, entity); } else if (GetNextAction().GetType() == "DropHealth") { - for (; number > 0; number--) SpawnDrop(177, entity); + for (; numberAsInt > 0; numberAsInt--) SpawnDrop(177, entity); } else if (GetNextAction().GetType() == "DropArmor") { - for (; number > 0; number--) SpawnDrop(6431, entity); + for (; numberAsInt > 0; numberAsInt--) SpawnDrop(6431, entity); + } else if (GetNextAction().GetType() == "Smash") { + GameMessages::Smash smash{}; + smash.target = entity.GetObjectID(); + smash.killerID = entity.GetObjectID(); + smash.Send(UNASSIGNED_SYSTEM_ADDRESS); + } else if (GetNextAction().GetType() == "UnSmash") { + GameMessages::UnSmash unsmash{}; + unsmash.target = entity.GetObjectID(); + unsmash.duration = number; + unsmash.builderID = LWOOBJID_EMPTY; + unsmash.Send(UNASSIGNED_SYSTEM_ADDRESS); + } else if (nextAction.GetType() == "Wait") { + m_PausedTime = number; + } else { + return; } + + IncrementAction(); } void Strip::SendBehaviorBlocksToClient(AMFArrayValue& args) const { diff --git a/dGame/dPropertyBehaviors/Strip.h b/dGame/dPropertyBehaviors/Strip.h index a93665f5..511d2b6c 100644 --- a/dGame/dPropertyBehaviors/Strip.h +++ b/dGame/dPropertyBehaviors/Strip.h @@ -34,6 +34,7 @@ public: void Update(float deltaTime, ModelComponent& modelComponent); void SpawnDrop(LOT dropLOT, Entity& entity); private: + float m_PausedTime{ 0.0f }; size_t m_NextActionIndex{ 0 }; std::vector m_Actions; StripUiPosition m_Position;