feat: preconditions improvements (#1983)

* 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>
This commit is contained in:
Aaron Kimbrell
2026-06-08 22:45:24 -05:00
committed by GitHub
parent 1d2de705fb
commit ca0da9d3bf
2 changed files with 24 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
#include "DestroyableComponent.h" #include "DestroyableComponent.h"
#include "GameMessages.h" #include "GameMessages.h"
#include "eMissionState.h" #include "eMissionState.h"
#include "PetComponent.h"
std::map<uint32_t, Precondition*> Preconditions::cache = {}; std::map<uint32_t, Precondition*> Preconditions::cache = {};
@@ -79,6 +80,9 @@ bool Precondition::Check(Entity* player, bool evaluateCosts) const {
case PreconditionType::DoesNotHaveRacingLicence: case PreconditionType::DoesNotHaveRacingLicence:
case PreconditionType::LegoClubMember: case PreconditionType::LegoClubMember:
case PreconditionType::NoInteraction: case PreconditionType::NoInteraction:
case PreconditionType::NotFreeTrial:
case PreconditionType::MissionActive:
case PreconditionType::DoesNotHaveFlag:
any = true; any = true;
break; break;
case PreconditionType::DoesNotHaveItem: case PreconditionType::DoesNotHaveItem:
@@ -154,7 +158,7 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat
if (missionComponent == nullptr) return false; if (missionComponent == nullptr) return false;
return missionComponent->GetMissionState(value) >= eMissionState::COMPLETE; return missionComponent->GetMissionState(value) >= eMissionState::COMPLETE;
case PreconditionType::PetDeployed: case PreconditionType::PetDeployed:
return false; // TODO return PetComponent::GetActivePet(player->GetObjectID()) != nullptr;
case PreconditionType::HasFlag: case PreconditionType::HasFlag:
return character->GetPlayerFlag(value); return character->GetPlayerFlag(value);
case PreconditionType::WithinShape: case PreconditionType::WithinShape:
@@ -162,9 +166,9 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat
case PreconditionType::InBuild: case PreconditionType::InBuild:
return character->GetBuildMode(); return character->GetBuildMode();
case PreconditionType::TeamCheck: 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: case PreconditionType::IsPetTaming:
return false; // TODO return PetComponent::GetTamingPet(player->GetObjectID()) != nullptr;
case PreconditionType::HasFaction: case PreconditionType::HasFaction:
for (const auto faction : destroyableComponent->GetFactionIDs()) { for (const auto faction : destroyableComponent->GetFactionIDs()) {
if (faction == static_cast<int>(value)) { if (faction == static_cast<int>(value)) {
@@ -182,15 +186,24 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat
return true; return true;
case PreconditionType::HasRacingLicence: 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: 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: 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: 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: case PreconditionType::HasLevel:
return levelComponent->GetLevel() >= value; 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: default:
return true; // There are a couple more unknown preconditions. Always return true in this case. return true; // There are a couple more unknown preconditions. Always return true in this case.
} }

View File

@@ -26,7 +26,10 @@ enum class PreconditionType
DoesNotHaveRacingLicence, DoesNotHaveRacingLicence,
LegoClubMember, LegoClubMember,
NoInteraction, NoInteraction,
HasLevel = 22 NotFreeTrial,
MissionActive,
HasLevel,
DoesNotHaveFlag = 23
}; };