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 "GameMessages.h"
#include "eMissionState.h"
#include "PetComponent.h"
std::map<uint32_t, Precondition*> 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<int>(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.
}

View File

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