miscs: engine

This commit is contained in:
Yunfan Li
2023-08-03 21:27:59 +08:00
parent 1c47108c23
commit 09566cb664
7 changed files with 62 additions and 29 deletions

View File

@@ -87,7 +87,7 @@ AiPlayerbot.RandomBotShowCloak = 1
AiPlayerbot.DisableRandomLevels = 0
# Set randombots starting level here if "AiPlayerbot.DisableRandomLevels" enabled
AiPlayerbot.RandombotStartingLevel = 1
AiPlayerbot.RandombotStartingLevel = 5
# Set kill XP rate for bots (default: 1)
# Server XP Rate * AiPlayerbot.KillXPRate

View File

@@ -305,8 +305,10 @@ void PlayerbotFactory::Randomize(bool incremental)
pmo->finish();
}
bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT, true);
bot->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
if (!incremental) {
bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT, true);
bot->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
}
if (bot->getLevel() >= 10)
{
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet");
@@ -1147,6 +1149,7 @@ void PlayerbotFactory::InitEquipmentNew(bool incremental)
void PlayerbotFactory::InitEquipment(bool incremental)
{
// todo(yunfan): to be refactored, too much time overhead
DestroyItemsVisitor visitor(bot);
IterateItems(&visitor, ITERATE_ALL_ITEMS);
@@ -1215,13 +1218,11 @@ void PlayerbotFactory::InitEquipment(bool incremental)
std::vector<uint32>& ids = items[slot];
if (ids.empty())
{
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "%s: no items to equip for slot %d", bot->GetName().c_str(), slot);
continue;
}
Item* oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
if (incremental && !IsDesiredReplacement(oldItem)) {
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "%s: doesn't desire to replace current slot %d", bot->GetName().c_str(), slot);
continue;
}
@@ -1243,7 +1244,6 @@ void PlayerbotFactory::InitEquipment(bool incremental)
}
}
if (bestItemForSlot == 0) {
// sLog->outMessage("playerbot", LOG_LEVEL_INFO, "%s: equip failed for slot %d(bestItemForSlot == 0))", bot->GetName().c_str(), slot);
continue;
}
if (oldItem)
@@ -1253,7 +1253,6 @@ void PlayerbotFactory::InitEquipment(bool incremental)
}
uint16 dest;
if (!CanEquipUnseenItem(slot, dest, bestItemForSlot)) {
sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "%s: equip failed for slot %d", bot->GetName().c_str(), slot);
continue;
}
Item* newItem = bot->EquipNewItem(dest, bestItemForSlot, true);

View File

@@ -1275,7 +1275,10 @@ void RandomPlayerbotMgr::IncreaseLevel(Player* bot)
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "IncreaseLevel");
uint32 lastLevel = GetValue(bot, "level");
uint32 level = bot->getLevel();
uint8 level = bot->getLevel() + 1;
if (level > maxLevel) {
level = maxLevel;
}
if (lastLevel != level)
{
PlayerbotFactory factory(bot, level);

View File

@@ -261,8 +261,8 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal)
lastRelevance = 0.0f;
PushDefaultActions();
if (queue.Peek() && depth < 1 && !minimal)
return DoNextAction(unit, depth + 1, minimal);
// if (queue.Peek() && depth < 1 && !minimal)
// return DoNextAction(unit, depth + 1, minimal);
}
// MEMORY FIX TEST

View File

@@ -26,21 +26,53 @@ bool LootRollAction::Execute(Event event)
p >> rollType; //need,greed or pass on roll
RollVote vote = PASS;
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(guid.GetEntry()))
{
switch (proto->Class)
{
case ITEM_CLASS_WEAPON:
case ITEM_CLASS_ARMOR:
if (!QueryItemUsage(proto).empty())
vote = NEED;
break;
default:
if (StoreLootAction::IsLootAllowed(guid.GetEntry(), botAI))
vote = NEED;
break;
}
}
// std::vector<Roll*> rolls = group->GetRolls();
// bot->Say("guid:" + std::to_string(guid.GetCounter()) +
// "item entry:" + std::to_string(guid.GetEntry()), LANG_UNIVERSAL);
// for (std::vector<Roll*>::iterator i = rolls.begin(); i != rolls.end(); ++i)
// {
// if ((*i)->isValid() && (*i)->itemGUID == guid && (*i)->itemSlot == slot)
// {
// uint32 itemId = (*i)->itemid;
// bot->Say("item entry2:" + std::to_string(itemId), LANG_UNIVERSAL);
// ItemTemplate const *proto = sObjectMgr->GetItemTemplate(itemId);
// if (!proto)
// continue;
// switch (proto->Class)
// {
// case ITEM_CLASS_WEAPON:
// case ITEM_CLASS_ARMOR:
// if (!QueryItemUsage(proto).empty())
// vote = NEED;
// else if (bot->HasSkill(SKILL_ENCHANTING))
// vote = DISENCHANT;
// break;
// default:
// if (StoreLootAction::IsLootAllowed(itemId, botAI))
// vote = NEED;
// break;
// }
// break;
// }
// }
// if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(guid.GetEntry()))
// {
// switch (proto->Class)
// {
// case ITEM_CLASS_WEAPON:
// case ITEM_CLASS_ARMOR:
// if (!QueryItemUsage(proto).empty())
// vote = NEED;
// break;
// default:
// if (StoreLootAction::IsLootAllowed(guid.GetEntry(), botAI))
// vote = NEED;
// break;
// }
// }
switch (group->GetLootMethod())
{

View File

@@ -135,11 +135,10 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
if (!IsMovingAllowed(mapId, x, y, z)) {
return false;
}
// if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR)) {
// bot->Yell("I'm falling!", LANG_UNIVERSAL);
// if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_FALLING_FAR)) {
// bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL);
// return false;
// }
// bot->UpdateGroundPositionZ(x, y, z);
z += 2.0f;
bot->UpdateAllowedPositionZ(x, y, z);
// z += 0.5f;

View File

@@ -43,7 +43,7 @@ WorldLocation ArrowFormation::GetLocationInternal()
float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
float z = master->GetPositionZ();
float z = master->GetPositionZ() + 5.0f;
float ground = master->GetMap()->GetHeight(x, y, z + 0.5f);
if (ground <= INVALID_HEIGHT)