mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Conditions: Implement (partially) PlayerCondition LfgValue fields
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "Group.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Item.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "Log.h"
|
||||
#include "LootMgr.h"
|
||||
#include "Map.h"
|
||||
@@ -2493,6 +2494,51 @@ inline bool PlayerConditionLogic(uint32 logic, std::array<bool, N>& results)
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32 ConditionMgr::GetPlayerConditionLfgValue(Player const* player, PlayerConditionLfgStatus status)
|
||||
{
|
||||
Group const* group = player->GetGroup();
|
||||
if (!group)
|
||||
return 0;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case PlayerConditionLfgStatus::InLFGDungeon:
|
||||
return sLFGMgr->inLfgDungeonMap(player->GetGUID(), player->GetMapId(), player->GetMap()->GetDifficultyID()) ? 1 : 0;
|
||||
case PlayerConditionLfgStatus::InLFGRandomDungeon:
|
||||
return sLFGMgr->inLfgDungeonMap(player->GetGUID(), player->GetMapId(), player->GetMap()->GetDifficultyID()) &&
|
||||
sLFGMgr->selectedRandomLfgDungeon(player->GetGUID()) ? 1 : 0;
|
||||
case PlayerConditionLfgStatus::InLFGFirstRandomDungeon:
|
||||
{
|
||||
if (!sLFGMgr->inLfgDungeonMap(player->GetGUID(), player->GetMapId(), player->GetMap()->GetDifficultyID()))
|
||||
return 0;
|
||||
|
||||
uint32 selectedRandomDungeon = sLFGMgr->GetSelectedRandomDungeon(player->GetGUID());
|
||||
if (!selectedRandomDungeon)
|
||||
return 0;
|
||||
|
||||
if (lfg::LfgReward const* reward = sLFGMgr->GetRandomDungeonReward(selectedRandomDungeon, player->getLevel()))
|
||||
if (Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest))
|
||||
if (player->CanRewardQuest(quest, false))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
case PlayerConditionLfgStatus::PartialClear:
|
||||
break;
|
||||
case PlayerConditionLfgStatus::StrangerCount:
|
||||
break;
|
||||
case PlayerConditionLfgStatus::VoteKickCount:
|
||||
break;
|
||||
case PlayerConditionLfgStatus::BootCount:
|
||||
break;
|
||||
case PlayerConditionLfgStatus::GearDiff:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditionEntry const* condition)
|
||||
{
|
||||
if (condition->MinLevel && player->getLevel() < condition->MinLevel)
|
||||
@@ -2807,7 +2853,21 @@ bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditio
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: research lfg status for player conditions
|
||||
if (condition->LfgStatus[0])
|
||||
{
|
||||
using LfgCount = std::extent<decltype(condition->LfgStatus)>;
|
||||
|
||||
std::array<bool, LfgCount::value> results;
|
||||
results.fill(true);
|
||||
for (std::size_t i = 0; i < LfgCount::value; ++i)
|
||||
if (condition->LfgStatus[i])
|
||||
results[i] = PlayerConditionCompare(condition->LfgCompare[i],
|
||||
GetPlayerConditionLfgValue(player, PlayerConditionLfgStatus(condition->LfgStatus[i])),
|
||||
condition->LfgValue[i]);
|
||||
|
||||
if (!PlayerConditionLogic(condition->LfgLogic, results))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (condition->AreaID[0])
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ class LootTemplate;
|
||||
struct Condition;
|
||||
struct PlayerConditionEntry;
|
||||
struct WorldStateExpressionEntry;
|
||||
enum class PlayerConditionLfgStatus : uint8;
|
||||
|
||||
/*! Documentation on implementing a new ConditionType:
|
||||
Step 1: Check for the lowest free ID. Look for CONDITION_UNUSED_XX in the enum.
|
||||
@@ -286,6 +287,7 @@ class TC_GAME_API ConditionMgr
|
||||
bool IsObjectMeetingSmartEventConditions(int64 entryOrGuid, uint32 eventId, uint32 sourceType, Unit* unit, WorldObject* baseObject) const;
|
||||
bool IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player* player, Creature* vendor) const;
|
||||
|
||||
static uint32 GetPlayerConditionLfgValue(Player const* player, PlayerConditionLfgStatus status);
|
||||
static bool IsPlayerMeetingCondition(Player const* player, PlayerConditionEntry const* condition);
|
||||
static bool IsPlayerMeetingExpression(Player const* player, WorldStateExpressionEntry const* expression);
|
||||
|
||||
|
||||
@@ -935,6 +935,18 @@ enum PhaseUseFlagsValues : uint8
|
||||
PHASE_USE_FLAGS_ALL = PHASE_USE_FLAGS_ALWAYS_VISIBLE | PHASE_USE_FLAGS_INVERSE
|
||||
};
|
||||
|
||||
enum class PlayerConditionLfgStatus : uint8
|
||||
{
|
||||
InLFGDungeon = 1,
|
||||
InLFGRandomDungeon = 2,
|
||||
InLFGFirstRandomDungeon = 3,
|
||||
PartialClear = 4,
|
||||
StrangerCount = 5,
|
||||
VoteKickCount = 6,
|
||||
BootCount = 7,
|
||||
GearDiff = 8
|
||||
};
|
||||
|
||||
enum PrestigeLevelInfoFlags : uint8
|
||||
{
|
||||
PRESTIGE_FLAG_DISABLED = 0x01 // Prestige levels with this flag won't be included to calculate max prestigelevel.
|
||||
|
||||
Reference in New Issue
Block a user