diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index f440d6de..1f60017b 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -6456,4 +6456,9 @@ namespace GameMessages { stream.Write(duration != 3.0f); if (builderID != 3.0f) stream.Write(duration); } + + void PlayBehaviorSound::Serialize(RakNet::BitStream& stream) const { + stream.Write(soundID != -1); + if (soundID != -1) stream.Write(soundID); + } } diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 10c22ce5..4cb3950e 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -821,6 +821,14 @@ namespace GameMessages { LWOOBJID builderID{ LWOOBJID_EMPTY }; float duration{ 3.0f }; }; + + struct PlayBehaviorSound : public GameMsg { + PlayBehaviorSound() : GameMsg(MessageType::Game::PLAY_BEHAVIOR_SOUND) {} + + void Serialize(RakNet::BitStream& stream) const; + + int32_t soundID{ -1 }; + }; }; #endif // GAMEMESSAGES_H diff --git a/dGame/dPropertyBehaviors/Strip.cpp b/dGame/dPropertyBehaviors/Strip.cpp index ea56dfa0..d6fef642 100644 --- a/dGame/dPropertyBehaviors/Strip.cpp +++ b/dGame/dPropertyBehaviors/Strip.cpp @@ -115,34 +115,44 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) { auto& nextAction = GetNextAction(); auto number = nextAction.GetValueParameterDouble(); auto numberAsInt = static_cast(number); - if (GetNextAction().GetType() == "SpawnStromling") { + auto nextActionType = GetNextAction().GetType(); + if (nextActionType == "SpawnStromling") { Spawn(10495, entity); - } else if (GetNextAction().GetType() == "SpawnPirate") { + } else if (nextActionType == "SpawnPirate") { Spawn(10497, entity); - } else if (GetNextAction().GetType() == "SpawnRonin") { + } else if (nextActionType == "SpawnRonin") { Spawn(10498, entity); - } else if (GetNextAction().GetType() == "DropImagination") { + } else if (nextActionType == "DropImagination") { for (; numberAsInt > 0; numberAsInt--) SpawnDrop(935, entity); - } else if (GetNextAction().GetType() == "DropHealth") { + } else if (nextActionType == "DropHealth") { for (; numberAsInt > 0; numberAsInt--) SpawnDrop(177, entity); - } else if (GetNextAction().GetType() == "DropArmor") { + } else if (nextActionType == "DropArmor") { for (; numberAsInt > 0; numberAsInt--) SpawnDrop(6431, entity); - } else if (GetNextAction().GetType() == "Smash") { + } else if (nextActionType == "Smash") { GameMessages::Smash smash{}; smash.target = entity.GetObjectID(); smash.killerID = entity.GetObjectID(); smash.Send(UNASSIGNED_SYSTEM_ADDRESS); - } else if (GetNextAction().GetType() == "UnSmash") { + } else if (nextActionType == "UnSmash") { GameMessages::UnSmash unsmash{}; unsmash.target = entity.GetObjectID(); unsmash.duration = number; unsmash.builderID = LWOOBJID_EMPTY; unsmash.Send(UNASSIGNED_SYSTEM_ADDRESS); m_PausedTime = number; - } else if (nextAction.GetType() == "Wait") { + } else if (nextActionType == "Wait") { m_PausedTime = number; + } else if (nextActionType == "PlaySound") { + GameMessages::PlayBehaviorSound sound; + sound.target = modelComponent.GetParent()->GetObjectID(); + sound.soundID = numberAsInt; + sound.Send(UNASSIGNED_SYSTEM_ADDRESS); } else { - LOG("Tried to play action (%s) which is not supported.", nextAction.GetType().data()); + static std::set g_PlayedSounds; + if (!g_PlayedSounds.contains(nextActionType.data())) { + LOG("Tried to play action (%s) which is not supported.", nextActionType.data()); + g_PlayedSounds.insert(nextActionType.data()); + } return; } @@ -174,10 +184,13 @@ void Strip::Update(float deltaTime, ModelComponent& modelComponent) { RemoveStates(modelComponent); // Check for starting blocks and if not a starting block proc this blocks action - if (nextAction.GetType() == "OnInteract") { - modelComponent.AddInteract(); - Game::entityManager->SerializeEntity(entity); - m_WaitingForAction = true; + if (m_NextActionIndex == 0) { + if (nextAction.GetType() == "OnInteract") { + modelComponent.AddInteract(); + Game::entityManager->SerializeEntity(entity); + m_WaitingForAction = true; + + } } else { // should be a normal block ProcNormalAction(deltaTime, modelComponent); }