From 87e8c05b203d47cf3f4256ff024c54c85ce278b6 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 3 Dec 2024 22:57:39 +0800 Subject: [PATCH] Innkeeper position and windows compile error --- conf/playerbots.conf.dist | 4 +- src/PlayerbotAIConfig.cpp | 2 +- src/RandomPlayerbotMgr.cpp | 62 +++++++++++++++++++-------- src/strategy/actions/NewRpgAction.cpp | 3 +- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 00fa3a4c..6186e5dc 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -714,10 +714,10 @@ AiPlayerbot.RandomBotArenaTeamMinRating = 1000 AiPlayerbot.DeleteRandomBotArenaTeams = 0 # PvP Restricted Zones (bots don't pvp) -AiPlayerbot.PvpProhibitedZoneIds = "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395,3703,4298" +AiPlayerbot.PvpProhibitedZoneIds = "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395,3703,4298,139" # PvP Restricted Areas (bots don't pvp) -AiPlayerbot.PvpProhibitedAreaIds = "976,35,392" +AiPlayerbot.PvpProhibitedAreaIds = "976,35,392,2268" # Improve react speed in battleground and arena (may cause lag) AiPlayerbot.FastReactInBG = 1 diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 871a3213..cb26477a 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -560,7 +560,7 @@ bool PlayerbotAIConfig::IsInRandomQuestItemList(uint32 id) bool PlayerbotAIConfig::IsPvpProhibited(uint32 zoneId, uint32 areaId) { - return IsInPvpProhibitedZone(zoneId) || IsInPvpProhibitedArea(areaId); + return IsInPvpProhibitedZone(zoneId) || IsInPvpProhibitedArea(areaId) || IsInPvpProhibitedZone(areaId); } bool PlayerbotAIConfig::IsInPvpProhibitedZone(uint32 id) diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 1c5ef029..a0827092 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -39,9 +39,11 @@ #include "PlayerbotCommandServer.h" #include "PlayerbotFactory.h" #include "Playerbots.h" +#include "Position.h" #include "Random.h" #include "ServerFacade.h" #include "SharedDefines.h" +#include "TravelMgr.h" #include "Unit.h" #include "UpdateTime.h" #include "World.h" @@ -1420,7 +1422,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache() "position_x, " "position_y, " "position_z, " - "t.minlevel " + "t.maxlevel " "FROM " "(SELECT " "map, " @@ -1431,12 +1433,15 @@ void RandomPlayerbotMgr::PrepareTeleportCache() "WHERE " "t.npcflag = 0 " "AND t.lootid != 0 " - "AND t.unit_flags != 768 " "AND t.maxlevel - t.minlevel < 3 " "AND map IN ({}) " - "AND c.id1 != 32820 " + "AND t.entry != 32820 " + "AND t.entry != 24196 " "AND c.spawntimesecs < 1000 " - "AND t.faction != 188 " + "AND t.faction not in (11, 71, 79, 85, 188) " + "AND (t.unit_flags & 256) = 0 " + "AND (t.unit_flags & 4096) = 0 " + // "AND (t.flags_extra & 32768) = 0 " "GROUP BY " "map, " "ROUND(position_x / 50), " @@ -1516,23 +1521,42 @@ void RandomPlayerbotMgr::PrepareTeleportCache() continue; const AreaTableEntry* area = sAreaTableStore.LookupEntry(map->GetAreaId(1, x, y, z)); uint32 level = area->area_level; - // LOG_INFO("playerbots", "Area: {} Level: {} creature_entry: {}", area->ID, level, c_entry); - int range = level <= 10 ? 6 : 8; - for (int32 l = (int32)level; l <= (int32)level + range; l++) + for (int i = 2; i<= 80; i++) { - if (l < 1 || l > maxLevel) + std::vector &locs = locsPerLevelCache[i - 1]; + for (auto &levelLoc : locs) { - continue; - } - if (!(entry->hostileMask & 4)) - { - hordeInnkeeperPerLevelCache[(uint8)l].push_back(loc); - } - if (!(entry->hostileMask & 2)) - { - allianceInnkeeperPerLevelCache[(uint8)l].push_back(loc); + if (loc.GetMapId() == levelLoc.GetMapId() && loc.GetExactDist(levelLoc) <= 500.0f) + { + if (!(entry->hostileMask & 4)) + { + hordeInnkeeperPerLevelCache[i].push_back(loc); + } + if (!(entry->hostileMask & 2)) + { + allianceInnkeeperPerLevelCache[i].push_back(loc); + } + // LOG_INFO("playerbots", "Area: {} Level: {} creature_entry: {} add to: {} ({},{},{},{})", area->ID, level, c_entry, i, levelLoc.GetPositionX(), levelLoc.GetPositionY(), levelLoc.GetPositionZ(), levelLoc.GetMapId()); + break; + } } } + // int range = level <= 10 ? 6 : 8; + // for (int32 l = (int32)level; l <= (int32)level + range; l++) + // { + // if (l < 1 || l > maxLevel) + // { + // continue; + // } + // if (!(entry->hostileMask & 4)) + // { + // hordeInnkeeperPerLevelCache[(uint8)l].push_back(loc); + // } + // if (!(entry->hostileMask & 2)) + // { + // allianceInnkeeperPerLevelCache[(uint8)l].push_back(loc); + // } + // } } while (results->NextRow()); } // add all initial position @@ -1547,7 +1571,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache() WorldPosition pos(info->mapId, info->positionX, info->positionY, info->positionZ, info->orientation); - for (int32 l = 1; l <= 6; l++) + for (int32 l = 1; l <= 5; l++) { if ((1 << (i - 1)) & RACEMASK_ALLIANCE) allianceInnkeeperPerLevelCache[(uint8)l].push_back(pos); @@ -1676,7 +1700,7 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot) locs = &locsPerLevelCache[level]; LOG_DEBUG("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), bot->GetLevel(), locs->size()); - if (level >= 5 && urand(0, 100) < sPlayerbotAIConfig->probTeleToBankers * 100) + if (level >= 10 && urand(0, 100) < sPlayerbotAIConfig->probTeleToBankers * 100) { RandomTeleport(bot, bankerLocsPerLevelCache[level], true); } diff --git a/src/strategy/actions/NewRpgAction.cpp b/src/strategy/actions/NewRpgAction.cpp index f637b784..906af1da 100644 --- a/src/strategy/actions/NewRpgAction.cpp +++ b/src/strategy/actions/NewRpgAction.cpp @@ -1,6 +1,7 @@ #include "NewRpgAction.h" #include +#include #include "NewRpgStrategy.h" #include "ObjectDefines.h" @@ -217,7 +218,7 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest) } int attempt = 10; - float minDelta = MAXFLOAT; + float minDelta = M_PI; const float x = bot->GetPositionX(); const float y = bot->GetPositionY(); const float z = bot->GetPositionZ();