mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-21 16:09:26 +02:00
Compare commits
No commits in common. "f989976c9392fe750a4e823341dd6bf7d0db1ae5" and "62ef4b63b1d8f66eccfc920a3b0c19649ec8b757" have entirely different histories.
f989976c93
...
62ef4b63b1
@ -23,20 +23,12 @@ namespace ai::gbless
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
constexpr uint32 GREATER_BLESSING_ASSIGNMENT_CACHE_MS = 4 * 1000;
|
constexpr uint32 GREATER_BLESSING_ASSIGNMENT_CACHE_MS = 4 * 1000;
|
||||||
constexpr uint32 GREATER_BLESSING_PENDING_ASSIGNMENT_CACHE_MS = 500;
|
constexpr uint32 GREATER_BLESSING_PENDING_ASSIGNMENT_CACHE_MS = 100;
|
||||||
constexpr uint8 MAX_BLESSING_SLOTS = 4;
|
constexpr uint8 MAX_BLESSING_SLOTS = 4;
|
||||||
constexpr uint8 MAX_CLASS_ID = 12;
|
constexpr uint8 MAX_CLASS_ID = 12;
|
||||||
|
|
||||||
constexpr size_t BaseBlessingCategoryCount = MAX_BLESSING_SLOTS;
|
constexpr size_t BaseBlessingCategoryCount = MAX_BLESSING_SLOTS;
|
||||||
|
|
||||||
enum PaladinBlessingCapability : uint8
|
|
||||||
{
|
|
||||||
PALADIN_BLESSING_CAPABILITY_NONE = 0,
|
|
||||||
PALADIN_BLESSING_CAPABILITY_IMPROVED_WISDOM = 1 << 0,
|
|
||||||
PALADIN_BLESSING_CAPABILITY_IMPROVED_MIGHT = 1 << 1,
|
|
||||||
PALADIN_BLESSING_CAPABILITY_SANCTUARY = 1 << 2
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr size_t BaseBlessingIndex(BaseBlessingCategory category)
|
constexpr size_t BaseBlessingIndex(BaseBlessingCategory category)
|
||||||
{
|
{
|
||||||
return static_cast<size_t>(static_cast<uint8>(category) - static_cast<uint8>(BASE_MIGHT));
|
return static_cast<size_t>(static_cast<uint8>(category) - static_cast<uint8>(BASE_MIGHT));
|
||||||
@ -66,38 +58,22 @@ namespace
|
|||||||
(!left.byRole || left.role == right.role);
|
(!left.byRole || left.role == right.role);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 GetPaladinBlessingCapabilities(Player* player)
|
int TalentScore(Player* player)
|
||||||
{
|
{
|
||||||
if (!player)
|
if (!player)
|
||||||
return PALADIN_BLESSING_CAPABILITY_NONE;
|
return 0;
|
||||||
|
|
||||||
uint8 capabilities = PALADIN_BLESSING_CAPABILITY_NONE;
|
int score = 0;
|
||||||
if (player->HasAura(SPELL_IMPROVED_MIGHT_R1) ||
|
if (player->HasAura(SPELL_IMPROVED_MIGHT_R1) ||
|
||||||
player->HasAura(SPELL_IMPROVED_MIGHT_R2))
|
player->HasAura(SPELL_IMPROVED_MIGHT_R2))
|
||||||
{
|
{
|
||||||
capabilities |= PALADIN_BLESSING_CAPABILITY_IMPROVED_MIGHT;
|
score += 2;
|
||||||
}
|
}
|
||||||
if (player->HasAura(SPELL_IMPROVED_WISDOM_R1) ||
|
if (player->HasAura(SPELL_IMPROVED_WISDOM_R1) ||
|
||||||
player->HasAura(SPELL_IMPROVED_WISDOM_R2))
|
player->HasAura(SPELL_IMPROVED_WISDOM_R2))
|
||||||
{
|
{
|
||||||
capabilities |= PALADIN_BLESSING_CAPABILITY_IMPROVED_WISDOM;
|
|
||||||
}
|
|
||||||
if (player->HasSpell(ai::paladin::SPELL_BLESSING_OF_SANCTUARY))
|
|
||||||
capabilities |= PALADIN_BLESSING_CAPABILITY_SANCTUARY;
|
|
||||||
|
|
||||||
return capabilities;
|
|
||||||
}
|
|
||||||
|
|
||||||
int TalentScore(Player* player)
|
|
||||||
{
|
|
||||||
uint8 const capabilities = GetPaladinBlessingCapabilities(player);
|
|
||||||
int score = 0;
|
|
||||||
|
|
||||||
if (capabilities & PALADIN_BLESSING_CAPABILITY_IMPROVED_MIGHT)
|
|
||||||
score += 2;
|
|
||||||
|
|
||||||
if (capabilities & PALADIN_BLESSING_CAPABILITY_IMPROVED_WISDOM)
|
|
||||||
score += 1;
|
score += 1;
|
||||||
|
}
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
@ -107,23 +83,23 @@ namespace
|
|||||||
if (!player)
|
if (!player)
|
||||||
return std::numeric_limits<int>::min() / 4;
|
return std::numeric_limits<int>::min() / 4;
|
||||||
|
|
||||||
uint8 const capabilities = GetPaladinBlessingCapabilities(player);
|
|
||||||
|
|
||||||
if (category == BASE_SANCTUARY)
|
if (category == BASE_SANCTUARY)
|
||||||
{
|
{
|
||||||
if (!(capabilities & PALADIN_BLESSING_CAPABILITY_SANCTUARY))
|
if (!player->HasSpell(ai::paladin::SPELL_BLESSING_OF_SANCTUARY))
|
||||||
return std::numeric_limits<int>::min() / 4;
|
return std::numeric_limits<int>::min() / 4;
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category == BASE_MIGHT &&
|
if (category == BASE_MIGHT &&
|
||||||
(capabilities & PALADIN_BLESSING_CAPABILITY_IMPROVED_MIGHT))
|
(player->HasAura(SPELL_IMPROVED_MIGHT_R1) ||
|
||||||
|
player->HasAura(SPELL_IMPROVED_MIGHT_R2)))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (category == BASE_WISDOM &&
|
if (category == BASE_WISDOM &&
|
||||||
(capabilities & PALADIN_BLESSING_CAPABILITY_IMPROVED_WISDOM))
|
(player->HasAura(SPELL_IMPROVED_WISDOM_R1) ||
|
||||||
|
player->HasAura(SPELL_IMPROVED_WISDOM_R2)))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -131,50 +107,6 @@ namespace
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectActivePaladinPool(
|
|
||||||
std::vector<Player*>& botPaladins)
|
|
||||||
{
|
|
||||||
std::sort(botPaladins.begin(), botPaladins.end(),
|
|
||||||
[](Player* left, Player* right)
|
|
||||||
{
|
|
||||||
return left->GetGUID() < right->GetGUID();
|
|
||||||
});
|
|
||||||
|
|
||||||
std::vector<Player*> selectedPaladins;
|
|
||||||
selectedPaladins.reserve(botPaladins.size());
|
|
||||||
std::vector<bool> selected(botPaladins.size(), false);
|
|
||||||
|
|
||||||
auto const selectFirstWithCapability = [&](uint8 capability)
|
|
||||||
{
|
|
||||||
for (size_t index = 0; index < botPaladins.size(); ++index)
|
|
||||||
{
|
|
||||||
if (selected[index])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!(GetPaladinBlessingCapabilities(botPaladins[index]) & capability))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
selected[index] = true;
|
|
||||||
selectedPaladins.push_back(botPaladins[index]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
selectFirstWithCapability(PALADIN_BLESSING_CAPABILITY_SANCTUARY);
|
|
||||||
selectFirstWithCapability(PALADIN_BLESSING_CAPABILITY_IMPROVED_MIGHT);
|
|
||||||
selectFirstWithCapability(PALADIN_BLESSING_CAPABILITY_IMPROVED_WISDOM);
|
|
||||||
|
|
||||||
for (size_t index = 0; index < botPaladins.size(); ++index)
|
|
||||||
{
|
|
||||||
if (selected[index])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
selectedPaladins.push_back(botPaladins[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
botPaladins = std::move(selectedPaladins);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DesiredBlessingSet
|
struct DesiredBlessingSet
|
||||||
{
|
{
|
||||||
std::array<BaseBlessingCategory, MAX_BLESSING_SLOTS> ordered = {};
|
std::array<BaseBlessingCategory, MAX_BLESSING_SLOTS> ordered = {};
|
||||||
@ -661,22 +593,29 @@ namespace
|
|||||||
if (botPaladins.empty())
|
if (botPaladins.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SelectActivePaladinPool(botPaladins);
|
|
||||||
|
|
||||||
uint8 activePaladinCount =
|
|
||||||
std::min<uint8>(static_cast<uint8>(botPaladins.size()), MAX_BLESSING_SLOTS);
|
|
||||||
|
|
||||||
bool anySanctuaryAvailable = false;
|
bool anySanctuaryAvailable = false;
|
||||||
for (uint8 paladinIndex = 0; paladinIndex < activePaladinCount; ++paladinIndex)
|
for (Player* paladin : botPaladins)
|
||||||
{
|
{
|
||||||
if (GetPaladinBlessingCapabilities(botPaladins[paladinIndex]) &
|
if (paladin && paladin->HasSpell(ai::paladin::SPELL_BLESSING_OF_SANCTUARY))
|
||||||
PALADIN_BLESSING_CAPABILITY_SANCTUARY)
|
|
||||||
{
|
{
|
||||||
anySanctuaryAvailable = true;
|
anySanctuaryAvailable = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::sort(botPaladins.begin(), botPaladins.end(),
|
||||||
|
[](Player* a, Player* b)
|
||||||
|
{
|
||||||
|
int sa = TalentScore(a);
|
||||||
|
int sb = TalentScore(b);
|
||||||
|
if (sa != sb)
|
||||||
|
return sa > sb;
|
||||||
|
return a->GetGUID() < b->GetGUID();
|
||||||
|
});
|
||||||
|
|
||||||
|
uint8 activePaladinCount =
|
||||||
|
std::min<uint8>(static_cast<uint8>(botPaladins.size()), MAX_BLESSING_SLOTS);
|
||||||
|
|
||||||
int mySlot = -1;
|
int mySlot = -1;
|
||||||
for (size_t i = 0; i < botPaladins.size(); ++i)
|
for (size_t i = 0; i < botPaladins.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -756,9 +695,7 @@ namespace
|
|||||||
classBuckets, botPaladins, allPaladins,
|
classBuckets, botPaladins, allPaladins,
|
||||||
classWideOwners, exclusiveOwnersByBucket, classWideBases,
|
classWideOwners, exclusiveOwnersByBucket, classWideBases,
|
||||||
exclusiveBasesByBucket))
|
exclusiveBasesByBucket))
|
||||||
{
|
return false;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < classWideBases.size(); ++index)
|
for (size_t index = 0; index < classWideBases.size(); ++index)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user