mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-25 14:36:22 +00:00
topN GetMixedGearScore
This commit is contained in:
@@ -3514,7 +3514,7 @@ uint32 PlayerbotAI::GetEquipGearScore(Player* player, bool withBags, bool withBa
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBank)
|
uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBank, uint32 topN)
|
||||||
{
|
{
|
||||||
std::vector<uint32> gearScore(EQUIPMENT_SLOT_END);
|
std::vector<uint32> gearScore(EQUIPMENT_SLOT_END);
|
||||||
uint32 twoHandScore = 0;
|
uint32 twoHandScore = 0;
|
||||||
@@ -3572,30 +3572,50 @@ uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!topN) {
|
||||||
|
uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots
|
||||||
|
uint32 sum = 0;
|
||||||
|
|
||||||
uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots
|
// check if 2h hand is higher level than main hand + off hand
|
||||||
uint32 sum = 0;
|
if (gearScore[EQUIPMENT_SLOT_MAINHAND] + gearScore[EQUIPMENT_SLOT_OFFHAND] < twoHandScore * 2)
|
||||||
|
{
|
||||||
|
gearScore[EQUIPMENT_SLOT_OFFHAND] = 0; // off hand is ignored in calculations if 2h weapon has higher score
|
||||||
|
--count;
|
||||||
|
gearScore[EQUIPMENT_SLOT_MAINHAND] = twoHandScore;
|
||||||
|
}
|
||||||
|
|
||||||
// check if 2h hand is higher level than main hand + off hand
|
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
|
||||||
|
{
|
||||||
|
sum += gearScore[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
uint32 res = uint32(sum / count);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// topN != 0
|
||||||
if (gearScore[EQUIPMENT_SLOT_MAINHAND] + gearScore[EQUIPMENT_SLOT_OFFHAND] < twoHandScore * 2)
|
if (gearScore[EQUIPMENT_SLOT_MAINHAND] + gearScore[EQUIPMENT_SLOT_OFFHAND] < twoHandScore * 2)
|
||||||
{
|
{
|
||||||
gearScore[EQUIPMENT_SLOT_OFFHAND] = 0; // off hand is ignored in calculations if 2h weapon has higher score
|
gearScore[EQUIPMENT_SLOT_OFFHAND] = twoHandScore;
|
||||||
--count;
|
|
||||||
gearScore[EQUIPMENT_SLOT_MAINHAND] = twoHandScore;
|
gearScore[EQUIPMENT_SLOT_MAINHAND] = twoHandScore;
|
||||||
}
|
}
|
||||||
|
std::vector<uint32> topGearScore;
|
||||||
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
|
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
|
||||||
{
|
{
|
||||||
sum += gearScore[i];
|
topGearScore.push_back(gearScore[i]);
|
||||||
}
|
}
|
||||||
|
std::sort(topGearScore.begin(), topGearScore.end(), [&](const uint32 lhs, const uint32 rhs) {
|
||||||
if (count)
|
return lhs > rhs;
|
||||||
{
|
});
|
||||||
uint32 res = uint32(sum / count);
|
uint32 sum = 0;
|
||||||
return res;
|
for (int i = 0; i < std::min((uint32)topGearScore.size(), topN); i++) {
|
||||||
|
sum += topGearScore[i];
|
||||||
}
|
}
|
||||||
|
return sum / topN;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore, bool mixed)
|
void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore, bool mixed)
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ class PlayerbotAI : public PlayerbotAIBase
|
|||||||
bool IsInVehicle(bool canControl = false, bool canCast = false, bool canAttack = false, bool canTurn = false, bool fixed = false);
|
bool IsInVehicle(bool canControl = false, bool canCast = false, bool canAttack = false, bool canTurn = false, bool fixed = false);
|
||||||
|
|
||||||
uint32 GetEquipGearScore(Player* player, bool withBags, bool withBank);
|
uint32 GetEquipGearScore(Player* player, bool withBags, bool withBank);
|
||||||
static uint32 GetMixedGearScore(Player* player, bool withBags, bool withBank);
|
static uint32 GetMixedGearScore(Player* player, bool withBags, bool withBank, uint32 topN = 0);
|
||||||
bool HasSkill(SkillType skill);
|
bool HasSkill(SkillType skill);
|
||||||
bool IsAllowedCommand(std::string const text);
|
bool IsAllowedCommand(std::string const text);
|
||||||
float GetRange(std::string const type);
|
float GetRange(std::string const type);
|
||||||
|
|||||||
@@ -573,10 +573,10 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje
|
|||||||
}
|
}
|
||||||
else if (cmd == "init=auto")
|
else if (cmd == "init=auto")
|
||||||
{
|
{
|
||||||
uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(master, true, true) * 1.1f;
|
uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(master, false, false, 10) * 1.1f;
|
||||||
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_LEGENDARY, mixedGearScore);
|
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_LEGENDARY, mixedGearScore);
|
||||||
factory.Randomize(false);
|
factory.Randomize(false);
|
||||||
return "ok, gear score limit: " + std::to_string(mixedGearScore);
|
return "ok, gear score limit: " + std::to_string(mixedGearScore / 5) + "(for epic)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user