diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index e605908f..6b10dccf 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -263,29 +263,12 @@ void PetComponent::OnUse(Entity* originator) auto position = originatorPosition; - NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector(); //m_Parent->GetRotation().GetForwardVector(); + NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector(); forward.y = 0; if (dpWorld::Instance().IsLoaded()) { - /* - if (interactionDistance > 2) - { - interactionDistance -= 1; - } - */ - NiPoint3 attempt = petPosition + forward * interactionDistance; - - /* - float deg = std::atan2(petPosition.z - originatorPosition.z, petPosition.x - originatorPosition.x); //* 180 / M_PI; - - auto position = NiPoint3( - petPosition.x + interactionDistance * std::cos(-deg), - petPosition.y, - petPosition.z + interactionDistance * std::sin(-deg) - ); - */ float y = dpWorld::Instance().GetHeightAtPoint(attempt); @@ -309,8 +292,6 @@ void PetComponent::OnUse(Entity* originator) auto rotation = NiQuaternion::LookAt(position, petPosition); - - //GameMessages::SendTeleport(originator->GetObjectID(), position, rotation, originator->GetSystemAddress(), true); GameMessages::SendNotifyPetTamingMinigame( originator->GetObjectID(), @@ -532,14 +513,12 @@ void PetComponent::Update(float deltaTime) m_Timer = 1; } -void PetComponent::TryBuild(std::vector& bricks, bool clientFailed) -{ +void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) { if (m_Tamer == LWOOBJID_EMPTY) return; auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer); - if (tamer == nullptr) - { + if (tamer == nullptr) { m_Tamer = LWOOBJID_EMPTY; return; @@ -547,19 +526,11 @@ void PetComponent::TryBuild(std::vector& bricks, bool clientFailed) const auto& cached = buildCache.find(m_Parent->GetLOT()); - if (cached == buildCache.end()) - { - GameMessages::SendPetTamingTryBuildResult(m_Tamer, false, 0, tamer->GetSystemAddress()); - - return; - } + if (cached == buildCache.end()) return; auto* destroyableComponent = tamer->GetComponent(); - - if (destroyableComponent == nullptr) - { - return; - } + + if (destroyableComponent == nullptr) return; auto imagination = destroyableComponent->GetImagination(); @@ -569,59 +540,17 @@ void PetComponent::TryBuild(std::vector& bricks, bool clientFailed) EntityManager::Instance()->SerializeEntity(tamer); - const auto& trueBricks = BrickDatabase::Instance()->GetBricks(cached->second.buildFile); - - if (trueBricks.empty() || bricks.empty()) - { - GameMessages::SendPetTamingTryBuildResult(m_Tamer, false, 0, tamer->GetSystemAddress()); - - return; - } - - auto* brickIDTable = CDClientManager::Instance()->GetTable("BrickIDTable"); - - int32_t correct = 0; - - for (const auto& brick : bricks) - { - const auto brickEntries = brickIDTable->Query([brick](const CDBrickIDTable& entry) - { - return entry.NDObjectID == brick.designerID; - }); - - if (brickEntries.empty()) - { - continue; - } - - const auto designerID = brickEntries[0].LEGOBrickID; - - for (const auto& trueBrick : trueBricks) - { - if (designerID == trueBrick.designerID && brick.materialID == trueBrick.materialID) - { - correct++; - - break; - } - } - } - - const auto success = correct >= cached->second.numValidPieces; - - GameMessages::SendPetTamingTryBuildResult(m_Tamer, success, correct, tamer->GetSystemAddress()); - - if (!success) - { - if (imagination < cached->second.imaginationCost) - { + if (clientFailed) { + if (imagination < cached->second.imaginationCost) { ClientFailTamingMinigame(); } - } - else - { + } else { m_Timer = 0; } + + if (numBricks == 0) return; + + GameMessages::SendPetTamingTryBuildResult(m_Tamer, !clientFailed, numBricks, tamer->GetSystemAddress()); } void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) @@ -727,7 +656,6 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) if (missionComponent != nullptr) { - //missionComponent->ForceProgress(506, 768, 1, false); missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PET_TAMING, m_Parent->GetLOT()); }