From b35b8ad99763674b4120af27974fdbf0d8c976b1 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 2 Aug 2023 01:52:26 +0800 Subject: [PATCH] miscs: refresh & moveto --- src/PlayerbotFactory.cpp | 2 +- src/RandomPlayerbotMgr.cpp | 6 ++++-- src/strategy/actions/MovementActions.cpp | 12 ++++++++---- src/strategy/values/LootStrategyValue.cpp | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index 1b7d0e47..840f34d7 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -347,7 +347,7 @@ void PlayerbotFactory::Randomize(bool incremental) void PlayerbotFactory::Refresh() { Prepare(); - InitEquipment(true); + // InitEquipment(true); InitAmmo(); InitFood(); InitReagents(); diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index f448e6ea..f5239185 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -1144,7 +1144,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache() "GroupedData g " "INNER JOIN creature c ON g.guid = c.guid " "INNER JOIN creature_template t on c.id1 = t.entry;", sPlayerbotAIConfig->randomBotMapsAsString.c_str()); - + uint32 collected_locs = 0; if (results) { do @@ -1156,7 +1156,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache() float z = fields[3].Get(); uint32 avg_level = fields[4].Get(); WorldLocation loc(mapId, x, y, z, 0); - LOG_INFO("playerbots", "get location {} {} {} {}, level: {}", mapId, x, y, z, avg_level); + collected_locs++; for (int32 level = (int32)avg_level - (int32)sPlayerbotAIConfig->randomBotTeleHigerLevel; level <= (int32)avg_level + (int32)sPlayerbotAIConfig->randomBotTeleLowerLevel; level++) { if (level < 1 || level > maxLevel) { continue; @@ -1165,6 +1165,8 @@ void RandomPlayerbotMgr::PrepareTeleportCache() } } while (results->NextRow()); } + LOG_INFO("playerbots", "{} locations for level collected.", collected_locs); + LOG_INFO("playerbots", "Preparing RPG teleport caches for {} factions...", sFactionTemplateStore.GetNumRows()); results = WorldDatabase.Query("SELECT map, position_x, position_y, position_z, r.race, r.minl, r.maxl FROM creature c INNER JOIN playerbots_rpg_races r ON c.id1 = r.entry " "WHERE r.race < 15"); diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 59482805..41e13f78 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -4,6 +4,7 @@ #include "MovementActions.h" #include "MovementGenerator.h" +#include "ObjectDefines.h" #include "ObjectGuid.h" #include "PlayerbotAIConfig.h" #include "SharedDefines.h" @@ -139,9 +140,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // return false; // } // bot->UpdateGroundPositionZ(x, y, z); - z += 15.0f; + z += 2.0f; bot->UpdateAllowedPositionZ(x, y, z); - z += 0.5f; + // z += 0.5f; float distance = bot->GetDistance2d(x, y); if (distance > sPlayerbotAIConfig->contactDistance) { @@ -673,8 +674,11 @@ bool MovementAction::MoveTo(Unit* target, float distance) float dx = cos(angle) * needToGo + bx; float dy = sin(angle) * needToGo + by; - float dz = bz + (tz - bz) * (needToGo / distanceToTarget); // calc accurate z postion to avoid stuck - return MoveTo(target->GetMapId(), dx, dy, tz); + float dz = std::max(bz, tz); // calc accurate z position to avoid stuck + if (distanceToTarget > CONTACT_DISTANCE) { + dz = std::max(dz, bz + (tz - bz) * (needToGo / distanceToTarget)); + } + return MoveTo(target->GetMapId(), dx, dy, dz); } float MovementAction::GetFollowAngle() diff --git a/src/strategy/values/LootStrategyValue.cpp b/src/strategy/values/LootStrategyValue.cpp index 9eb5a632..87dfc089 100644 --- a/src/strategy/values/LootStrategyValue.cpp +++ b/src/strategy/values/LootStrategyValue.cpp @@ -70,7 +70,7 @@ class AllLootStrategy : public LootStrategy LootStrategyValue::~LootStrategyValue() { - delete defaultValue; + // delete defaultValue; } LootStrategy* LootStrategyValue::normal = new NormalLootStrategy();