miscs: refresh & moveto

This commit is contained in:
Yunfan Li
2023-08-02 01:52:26 +08:00
parent 0969db4c89
commit b35b8ad997
4 changed files with 14 additions and 8 deletions

View File

@@ -347,7 +347,7 @@ void PlayerbotFactory::Randomize(bool incremental)
void PlayerbotFactory::Refresh()
{
Prepare();
InitEquipment(true);
// InitEquipment(true);
InitAmmo();
InitFood();
InitReagents();

View File

@@ -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<float>();
uint32 avg_level = fields[4].Get<uint32>();
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");

View File

@@ -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()

View File

@@ -70,7 +70,7 @@ class AllLootStrategy : public LootStrategy
LootStrategyValue::~LootStrategyValue()
{
delete defaultValue;
// delete defaultValue;
}
LootStrategy* LootStrategyValue::normal = new NormalLootStrategy();