From 81d8c187ea5233c88ea396be14195dc296aa7f1d Mon Sep 17 00:00:00 2001 From: jadebenn Date: Tue, 21 Nov 2023 20:16:17 -0600 Subject: [PATCH] mission fix redo --- dGame/dComponents/PetComponent.cpp | 9 ++--- dGame/dGameMessages/GameMessages.cpp | 52 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 1ab06833..f979def4 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -368,15 +368,12 @@ void PetComponent::Update(float deltaTime) { } auto* owner = GetOwner(); - if (owner == nullptr) { m_Parent->Kill(); - return; } m_MovementAI = m_Parent->GetComponent(); - if (m_MovementAI == nullptr) { return; } @@ -390,7 +387,6 @@ void PetComponent::Update(float deltaTime) { NiPoint3 position = m_MovementAI->GetParent()->GetPosition(); float distanceToOwner = Vector3::DistanceSquared(position, destination); - if (distanceToOwner > 50 * 50 || m_TimerAway > 5) { m_MovementAI->Warp(destination); @@ -437,7 +433,6 @@ void PetComponent::Update(float deltaTime) { const bool digUnlocked = missionComponent->GetMissionState(842) == eMissionState::COMPLETE; Entity* closestTresure = PetDigServer::GetClosestTresure(position); - if (closestTresure != nullptr && digUnlocked) { // Skeleton Dragon Pat special case for bone digging if (closestTresure->GetLOT() == 12192 && m_Parent->GetLOT() != 13067) { @@ -449,7 +444,7 @@ void PetComponent::Update(float deltaTime) { if (distance < 5 * 5) { m_Interaction = closestTresure->GetObjectID(); - Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::Bounce , true); // Plays 'bounce' animation + Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::Bounce, true); // Plays 'bounce' animation SetIsReadyToDig(true); @@ -1157,7 +1152,7 @@ void PetComponent::SetPreconditions(std::string& preconditions) { void PetComponent::StartInteractDig() { //m_InInteract = true; m_TresureTime = 2.0f; //TODO: Remove magic number - Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::DigTreasure , true); + Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::DigTreasure, true); } void PetComponent::EndInteractDig() { diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 1a6d112b..4777631d 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -5016,32 +5016,6 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) if (emoteID == 0) return; std::string sAnimationName = "deaded"; //Default name in case we fail to get the emote - MissionComponent* missionComponent = entity->GetComponent(); - if (missionComponent) { - if (targetID != LWOOBJID_EMPTY) { - auto* targetEntity = Game::entityManager->GetEntity(targetID); - - LOG_DEBUG("Emote target found (%d)", targetEntity != nullptr); - - if (targetEntity != nullptr) { - targetEntity->OnEmoteReceived(emoteID, entity); - missionComponent->Progress(eMissionTaskType::EMOTE, emoteID, targetID); - } - } else { - LOG_DEBUG("Target ID is empty, using backup"); - const auto scriptedEntities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT); - - const auto& referencePoint = entity->GetPosition(); - - for (auto* scripted : scriptedEntities) { - if (Vector3::DistanceSquared(scripted->GetPosition(), referencePoint) > 5.0f * 5.0f) continue; - - scripted->OnEmoteReceived(emoteID, entity); - missionComponent->Progress(eMissionTaskType::EMOTE, emoteID, scripted->GetObjectID()); - } - } - } - CDEmoteTableTable* emotes = CDClientManager::Instance().GetTable(); if (emotes) { CDEmoteTable* emote = emotes->GetEmote(emoteID); @@ -5049,6 +5023,32 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) } RenderComponent::PlayAnimation(entity, sAnimationName); + + MissionComponent* missionComponent = entity->GetComponent(); + if (!missionComponent) return; + + if (targetID != LWOOBJID_EMPTY) { + auto* targetEntity = Game::entityManager->GetEntity(targetID); + + LOG_DEBUG("Emote target found (%d)", targetEntity != nullptr); + + if (targetEntity != nullptr) { + targetEntity->OnEmoteReceived(emoteID, entity); + missionComponent->Progress(eMissionTaskType::EMOTE, emoteID, targetID); + } + } else { + LOG_DEBUG("Target ID is empty, using backup"); + const auto scriptedEntities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT); + + const auto& referencePoint = entity->GetPosition(); + + for (auto* scripted : scriptedEntities) { + if (Vector3::DistanceSquared(scripted->GetPosition(), referencePoint) > 5.0f * 5.0f) continue; + + scripted->OnEmoteReceived(emoteID, entity); + missionComponent->Progress(eMissionTaskType::EMOTE, emoteID, scripted->GetObjectID()); + } + } } void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {