mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
init=auto
This commit is contained in:
@@ -581,13 +581,13 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const
|
||||
// nonCombatEngine->addStrategy("group");
|
||||
// nonCombatEngine->addStrategy("guild");
|
||||
|
||||
if (sPlayerbotAIConfig->autoDoQuests)
|
||||
{
|
||||
// nonCombatEngine->addStrategy("travel");
|
||||
nonCombatEngine->addStrategy("rpg");
|
||||
} else {
|
||||
nonCombatEngine->addStrategy("move random");
|
||||
}
|
||||
// if (sPlayerbotAIConfig->autoDoQuests)
|
||||
// {
|
||||
// // nonCombatEngine->addStrategy("travel");
|
||||
// nonCombatEngine->addStrategy("rpg");
|
||||
// } else {
|
||||
// nonCombatEngine->addStrategy("move random");
|
||||
// }
|
||||
|
||||
// if (masterBotAI)
|
||||
// nonCombatEngine->addStrategy("maintenance");
|
||||
|
||||
@@ -3514,7 +3514,91 @@ uint32 PlayerbotAI::GetEquipGearScore(Player* player, bool withBags, bool withBa
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore)
|
||||
uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBank)
|
||||
{
|
||||
std::vector<uint32> gearScore(EQUIPMENT_SLOT_END);
|
||||
uint32 twoHandScore = 0;
|
||||
|
||||
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
|
||||
{
|
||||
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
_fillGearScoreData(player, item, &gearScore, twoHandScore, true);
|
||||
}
|
||||
|
||||
if (withBags)
|
||||
{
|
||||
// check inventory
|
||||
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
_fillGearScoreData(player, item, &gearScore, twoHandScore, true);
|
||||
}
|
||||
|
||||
// check bags
|
||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (Bag* pBag = (Bag*)player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
{
|
||||
if (Item* item2 = pBag->GetItemByPos(j))
|
||||
_fillGearScoreData(player, item2, &gearScore, twoHandScore, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (withBank)
|
||||
{
|
||||
for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
_fillGearScoreData(player, item, &gearScore, twoHandScore, true);
|
||||
}
|
||||
|
||||
for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
if (item->IsBag())
|
||||
{
|
||||
Bag* bag = (Bag*)item;
|
||||
for (uint8 j = 0; j < bag->GetBagSize(); ++j)
|
||||
{
|
||||
if (Item* item2 = bag->GetItemByPos(j))
|
||||
_fillGearScoreData(player, item2, &gearScore, twoHandScore, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots
|
||||
uint32 sum = 0;
|
||||
|
||||
// check if 2h hand is higher level than main hand + off hand
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore, bool mixed)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
@@ -3524,7 +3608,7 @@ void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector<uin
|
||||
return;
|
||||
|
||||
uint8 type = proto->InventoryType;
|
||||
uint32 level = proto->ItemLevel;
|
||||
uint32 level = mixed ? proto->ItemLevel * (1 + proto->Quality) : proto->ItemLevel;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
||||
@@ -400,6 +400,7 @@ class PlayerbotAI : public PlayerbotAIBase
|
||||
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);
|
||||
static uint32 GetMixedGearScore(Player* player, bool withBags, bool withBank);
|
||||
bool HasSkill(SkillType skill);
|
||||
bool IsAllowedCommand(std::string const text);
|
||||
float GetRange(std::string const type);
|
||||
@@ -447,7 +448,7 @@ class PlayerbotAI : public PlayerbotAIBase
|
||||
static std::vector<std::string> dispel_whitelist;
|
||||
bool EqualLowercaseName(std::string s1, std::string s2);
|
||||
private:
|
||||
void _fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore);
|
||||
static void _fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore, bool mixed = false);
|
||||
bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||
protected:
|
||||
Player* bot;
|
||||
|
||||
@@ -52,7 +52,7 @@ uint32 PlayerbotFactory::tradeSkills[] =
|
||||
std::list<uint32> PlayerbotFactory::classQuestIds;
|
||||
std::list<uint32> PlayerbotFactory::specialQuestIds;
|
||||
|
||||
PlayerbotFactory::PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality) : level(level), itemQuality(itemQuality), InventoryAction(GET_PLAYERBOT_AI(bot), "factory")
|
||||
PlayerbotFactory::PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality, uint32 gearScoreLimit) : level(level), itemQuality(itemQuality), gearScoreLimit(gearScoreLimit), InventoryAction(GET_PLAYERBOT_AI(bot), "factory")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -984,7 +984,7 @@ bool PlayerbotFactory::CanEquipItem(ItemTemplate const* proto, uint32 desiredQua
|
||||
if (proto->Quality != desiredQuality)
|
||||
return false;
|
||||
|
||||
if (proto->Bonding == BIND_QUEST_ITEM || proto->Bonding == BIND_WHEN_USE)
|
||||
if (proto->Bonding == BIND_QUEST_ITEM /*|| proto->Bonding == BIND_WHEN_USE*/)
|
||||
return false;
|
||||
|
||||
if (proto->Class == ITEM_CLASS_CONTAINER)
|
||||
@@ -1201,6 +1201,9 @@ void PlayerbotFactory::InitEquipment(bool incremental)
|
||||
if (!proto)
|
||||
continue;
|
||||
|
||||
if (gearScoreLimit != 0 && CalcMixedGearScore(proto->ItemLevel, proto->Quality) > gearScoreLimit) {
|
||||
continue;
|
||||
}
|
||||
if (proto->Class != ITEM_CLASS_WEAPON &&
|
||||
proto->Class != ITEM_CLASS_ARMOR)
|
||||
continue;
|
||||
@@ -2253,6 +2256,11 @@ void PlayerbotFactory::InitAmmo()
|
||||
bot->SetAmmo(entry);
|
||||
}
|
||||
|
||||
uint32 PlayerbotFactory::CalcMixedGearScore(uint32 gs, uint32 quality)
|
||||
{
|
||||
return gs * (quality + 1);
|
||||
}
|
||||
|
||||
void PlayerbotFactory::InitMounts()
|
||||
{
|
||||
uint32 firstmount = 20;
|
||||
|
||||
@@ -103,7 +103,7 @@ enum PriorizedConsumables
|
||||
class PlayerbotFactory : public InventoryAction
|
||||
{
|
||||
public:
|
||||
PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality = 0);
|
||||
PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality = 0, uint32 gearScoreLimit = 0);
|
||||
|
||||
static ObjectGuid GetRandomBot();
|
||||
static void Init();
|
||||
@@ -121,7 +121,7 @@ class PlayerbotFactory : public InventoryAction
|
||||
void InitEquipment(bool incremental);
|
||||
void InitPet();
|
||||
void InitAmmo();
|
||||
|
||||
static uint32 CalcMixedGearScore(uint32 gs, uint32 quality);
|
||||
private:
|
||||
void Prepare();
|
||||
// void InitSecondEquipmentSet();
|
||||
@@ -175,6 +175,7 @@ class PlayerbotFactory : public InventoryAction
|
||||
EnchantContainer::const_iterator GetEnchantContainerEnd() { return m_EnchantContainer.end(); }
|
||||
uint32 level;
|
||||
uint32 itemQuality;
|
||||
uint32 gearScoreLimit;
|
||||
static std::list<uint32> specialQuestIds;
|
||||
std::vector<uint32> trainerIdCache;
|
||||
protected:
|
||||
|
||||
@@ -571,6 +571,13 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje
|
||||
factory.Randomize(false);
|
||||
return "ok";
|
||||
}
|
||||
else if (cmd == "init=auto")
|
||||
{
|
||||
uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(master, true, true) * 1.1f;
|
||||
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_LEGENDARY, mixedGearScore);
|
||||
factory.Randomize(false);
|
||||
return "ok, gear score limit: " + std::to_string(mixedGearScore);
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd == "levelup" || cmd == "level")
|
||||
|
||||
@@ -160,12 +160,12 @@ bool CheckMountStateAction::Mount()
|
||||
{
|
||||
uint32 secondmount = 40;
|
||||
|
||||
// if (bot->isMoving())
|
||||
// {
|
||||
// bot->StopMoving();
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
// // bot->GetMotionMaster()->MoveIdle();
|
||||
// }
|
||||
if (bot->isMoving())
|
||||
{
|
||||
bot->StopMoving();
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
// bot->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
|
||||
Player* master = GetMaster();
|
||||
botAI->RemoveShapeshift();
|
||||
|
||||
Reference in New Issue
Block a user