From ca0da9d3bfc5fad6f39a4e8209fbbaf1e583a108 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Mon, 8 Jun 2026 22:45:24 -0500 Subject: [PATCH] feat: preconditions improvements (#1983) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: implement missing precondition types (20, 21, 23) and pet checks Add DoesNotHaveFlag (23), NotFreeTrial (20), and MissionActive (21) to PreconditionType and implement their checks. Also implement PetDeployed and IsPetTaming using PetComponent static helpers, matching client behavior — both are simple boolean checks with no LOT comparison. LegoClubMember is set to always pass as DLU has no membership concept. * fix: update TODO comments for team check and racing licence preconditions * type Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- dGame/dUtilities/Preconditions.cpp | 27 ++++++++++++++++++++------- dGame/dUtilities/Preconditions.h | 5 ++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/dGame/dUtilities/Preconditions.cpp b/dGame/dUtilities/Preconditions.cpp index da18c81c..26f1f7bd 100644 --- a/dGame/dUtilities/Preconditions.cpp +++ b/dGame/dUtilities/Preconditions.cpp @@ -13,6 +13,7 @@ #include "DestroyableComponent.h" #include "GameMessages.h" #include "eMissionState.h" +#include "PetComponent.h" std::map Preconditions::cache = {}; @@ -79,6 +80,9 @@ bool Precondition::Check(Entity* player, bool evaluateCosts) const { case PreconditionType::DoesNotHaveRacingLicence: case PreconditionType::LegoClubMember: case PreconditionType::NoInteraction: + case PreconditionType::NotFreeTrial: + case PreconditionType::MissionActive: + case PreconditionType::DoesNotHaveFlag: any = true; break; case PreconditionType::DoesNotHaveItem: @@ -154,7 +158,7 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat if (missionComponent == nullptr) return false; return missionComponent->GetMissionState(value) >= eMissionState::COMPLETE; case PreconditionType::PetDeployed: - return false; // TODO + return PetComponent::GetActivePet(player->GetObjectID()) != nullptr; case PreconditionType::HasFlag: return character->GetPlayerFlag(value); case PreconditionType::WithinShape: @@ -162,9 +166,9 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat case PreconditionType::InBuild: return character->GetBuildMode(); case PreconditionType::TeamCheck: - return false; // TODO + return false; // TODO: requires knowing the player's minigame team assignment (red/blue etc.); DLU does not track this per-player case PreconditionType::IsPetTaming: - return false; // TODO + return PetComponent::GetTamingPet(player->GetObjectID()) != nullptr; case PreconditionType::HasFaction: for (const auto faction : destroyableComponent->GetFactionIDs()) { if (faction == static_cast(value)) { @@ -182,15 +186,24 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat return true; case PreconditionType::HasRacingLicence: - return false; // TODO + return false; // TODO: requires a racing licence level on the player; DLU does not track this case PreconditionType::DoesNotHaveRacingLicence: - return false; // TODO + return false; // TODO: requires a racing licence level on the player; DLU does not track this case PreconditionType::LegoClubMember: - return false; // TODO + return true; // Live LU opened LEGO CLUB to All players at some point, so always return true case PreconditionType::NoInteraction: - return false; // TODO + return false; // TODO: requires tracking the player's currently active interaction object; DLU does not track this case PreconditionType::HasLevel: return levelComponent->GetLevel() >= value; + case PreconditionType::NotFreeTrial: + return true; // DLU does not support free trial accounts; all players pass this check + case PreconditionType::MissionActive: { + if (missionComponent == nullptr) return false; + const auto state = missionComponent->GetMissionState(value); + return state == eMissionState::ACTIVE || state == eMissionState::COMPLETE_ACTIVE; + } + case PreconditionType::DoesNotHaveFlag: + return !character->GetPlayerFlag(value); default: return true; // There are a couple more unknown preconditions. Always return true in this case. } diff --git a/dGame/dUtilities/Preconditions.h b/dGame/dUtilities/Preconditions.h index 2b6e1216..0a1ac70b 100644 --- a/dGame/dUtilities/Preconditions.h +++ b/dGame/dUtilities/Preconditions.h @@ -26,7 +26,10 @@ enum class PreconditionType DoesNotHaveRacingLicence, LegoClubMember, NoInteraction, - HasLevel = 22 + NotFreeTrial, + MissionActive, + HasLevel, + DoesNotHaveFlag = 23 };