nav: tweaked reachability timers
nav: ignore pickup item if stuck fix: bad loading for graphs since last commit
This commit is contained in:
parent
13f4cad6cd
commit
5b7e58d360
6 changed files with 33 additions and 32 deletions
|
|
@ -345,7 +345,7 @@ public:
|
|||
|
||||
template <typename U> bool saveStorage (StringRef name, StorageOption options, StorageVersion version, const SmallArray <U> &data, ExtenHeader *exten);
|
||||
template <typename U> bool loadStorage (StringRef name, StorageOption options, StorageVersion version, SmallArray <U> &data, ExtenHeader *exten, int32_t *outOptions);
|
||||
template <typename ...Args> bool raiseLoadingError (bool isGraph, MemFile &file, const char *fmt, Args &&...args);
|
||||
template <typename ...Args> bool raiseLoadingError (bool isGraph, bool isDebug, MemFile &file, const char *fmt, Args &&...args);
|
||||
|
||||
void saveOldFormat ();
|
||||
void reset ();
|
||||
|
|
@ -485,11 +485,11 @@ public:
|
|||
#include <manager.h>
|
||||
|
||||
// helper for reporting load errors
|
||||
template <typename ...Args> bool BotGraph::raiseLoadingError (bool isGraph, MemFile &file, const char *fmt, Args &&...args) {
|
||||
template <typename ...Args> bool BotGraph::raiseLoadingError (bool isGraph, bool isDebug, MemFile &file, const char *fmt, Args &&...args) {
|
||||
auto result = strings.format (fmt, cr::forward <Args> (args)...);
|
||||
|
||||
// display error only for graph file
|
||||
if (isGraph) {
|
||||
if (isGraph || isDebug) {
|
||||
logger.error (result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -689,6 +689,9 @@ void Bot::updatePickups () {
|
|||
}
|
||||
|
||||
void Bot::ensureEntitiesClear () {
|
||||
if ((!m_isStuck || m_navTimeset + getEstimatedNodeReachTime () + m_frameInterval * 2.0f > game.time ()) && !(m_states & Sense::SeeingEnemy)) {
|
||||
return;
|
||||
}
|
||||
const auto currentTask = getCurrentTaskId ();
|
||||
|
||||
if (currentTask == Task::PickupItem || (m_states & Sense::PickupItem)) {
|
||||
|
|
@ -4795,10 +4798,8 @@ void Bot::logic () {
|
|||
m_strafeSpeed = pev->maxspeed * static_cast <float> (m_needAvoidGrenade);
|
||||
}
|
||||
|
||||
// ensure we're not stuck destroying/picking something
|
||||
if (m_navTimeset + getEstimatedNodeReachTime () + 2.0f < game.time () && !(m_states & Sense::SeeingEnemy)) {
|
||||
|
||||
ensureEntitiesClear ();
|
||||
}
|
||||
translateInput ();
|
||||
|
||||
// check if need to use parachute
|
||||
|
|
|
|||
|
|
@ -555,11 +555,11 @@ Vector Bot::getCustomHeight (float distance) {
|
|||
static constexpr float offsetRanges[9][3] = {
|
||||
{ 0.0f, 0.0f, 0.0f }, // none
|
||||
{ 0.0f, 0.0f, 0.0f }, // melee
|
||||
{ 1.5f, -3.0f, -4.5f }, // pistol
|
||||
{ 0.5f, -3.0f, -4.5f }, // pistol
|
||||
{ 6.5f, 6.0f, -2.0f }, // shotgun
|
||||
{ 2.5f -7.5f, -9.5f }, // zoomrifle
|
||||
{ 2.5f, -7.5f, -9.5f }, // rifle
|
||||
{ 2.5f, -7.5f, -9.5f }, // smg
|
||||
{ 0.5f -7.5f, -9.5f }, // zoomrifle
|
||||
{ 0.5f, -7.5f, -9.5f }, // rifle
|
||||
{ 0.5f, -7.5f, -9.5f }, // smg
|
||||
{ 0.0f, -2.5f, -6.0f }, // sniper
|
||||
{ 1.5f, -4.0f, -9.0f } // heavy
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1683,7 +1683,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
|
||||
// graphs can be downloaded...
|
||||
bool isGraph = !!(options & StorageOption::Graph);
|
||||
bool isGraphOrDebug = isGraph || cv_debug.bool_ ();
|
||||
bool isDebug = cv_debug.bool_ ();
|
||||
|
||||
MemFile file (filename); // open the file
|
||||
|
||||
|
|
@ -1707,7 +1707,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
// if graph & attempted to load multiple times, bail out, we're failed
|
||||
if (isGraph && ++m_loadAttempts > 2) {
|
||||
m_loadAttempts = 0;
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Unable to load %s (filename: '%s'). Download process has failed as well. No nodes has been found.", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Unable to load %s (filename: '%s'). Download process has failed as well. No nodes has been found.", name, filename);
|
||||
}
|
||||
|
||||
// downloader for graph
|
||||
|
|
@ -1754,7 +1754,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
if (tryReload ()) {
|
||||
return true;
|
||||
}
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Unable to open %s file for reading (filename: '%s').", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Unable to open %s file for reading (filename: '%s').", name, filename);
|
||||
}
|
||||
|
||||
// read the header
|
||||
|
|
@ -1766,12 +1766,12 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
if (tryReload ()) {
|
||||
return true;
|
||||
}
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Unable to read magic of %s (filename: '%s').", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Unable to read magic of %s (filename: '%s').", name, filename);
|
||||
}
|
||||
|
||||
// check the path-numbers
|
||||
if (!isGraph && hdr.length != length ()) {
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Damaged %s (filename: '%s'). Mismatch number of nodes (got: '%d', need: '%d').", name, filename, hdr.length, m_paths.length ());
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Damaged %s (filename: '%s'). Mismatch number of nodes (got: '%d', need: '%d').", name, filename, hdr.length, m_paths.length ());
|
||||
}
|
||||
|
||||
// check the count
|
||||
|
|
@ -1779,7 +1779,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
if (tryReload ()) {
|
||||
return true;
|
||||
}
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Damaged %s (filename: '%s'). Paths length is overflowed (got: '%d').", name, filename, hdr.length);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Damaged %s (filename: '%s'). Paths length is overflowed (got: '%d').", name, filename, hdr.length);
|
||||
}
|
||||
|
||||
// check the version
|
||||
|
|
@ -1787,7 +1787,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
ctrl.msg ("Graph version mismatch %s (filename: '%s'). Version number differs (got: '%d', need: '%d') Please, upgrade %s.", name, filename, hdr.version, version, product.name);
|
||||
}
|
||||
else if (hdr.version > version && !isGraph) {
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Damaged %s (filename: '%s'). Version number differs (got: '%d', need: '%d').", name, filename, hdr.version, version);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Damaged %s (filename: '%s'). Version number differs (got: '%d', need: '%d').", name, filename, hdr.version, version);
|
||||
}
|
||||
|
||||
// temporary solution to kill version 1 vistables, which has a bugs
|
||||
|
|
@ -1797,7 +1797,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
if (File::exists (vistablePath)) {
|
||||
plat.removeFile (vistablePath.chars ());
|
||||
}
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Bugged vistable %s (filename: '%s'). Version 1 has a bugs, vistable will be recreated.", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Bugged vistable %s (filename: '%s'). Version 1 has a bugs, vistable will be recreated.", name, filename);
|
||||
}
|
||||
|
||||
// save graph version
|
||||
|
|
@ -1807,7 +1807,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
|
||||
// check the storage type
|
||||
if ((hdr.options & options) != options) {
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Incorrect storage format for %s (filename: '%s').", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Incorrect storage format for %s (filename: '%s').", name, filename);
|
||||
}
|
||||
auto compressedSize = static_cast <size_t> (hdr.compressed);
|
||||
auto numberNodes = static_cast <size_t> (hdr.length);
|
||||
|
|
@ -1824,7 +1824,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
|
||||
// try to uncompress
|
||||
if (ulz.uncompress (compressed.data (), hdr.compressed, reinterpret_cast <uint8_t *> (data.data ()), hdr.uncompressed) == ULZ::UncompressFailure) {
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Unable to decompress ULZ data for %s (filename: '%s').", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Unable to decompress ULZ data for %s (filename: '%s').", name, filename);
|
||||
}
|
||||
else {
|
||||
|
||||
|
|
@ -1859,7 +1859,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef name, StorageOption
|
|||
}
|
||||
}
|
||||
else {
|
||||
return raiseLoadingError (isGraphOrDebug, file, "Unable to read ULZ data for %s (filename: '%s').", name, filename);
|
||||
return raiseLoadingError (isGraph, isDebug, file, "Unable to read ULZ data for %s (filename: '%s').", name, filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1837,17 +1837,17 @@ bool Bot::findNextBestNode () {
|
|||
continue;
|
||||
}
|
||||
|
||||
// ignore non-reacheable nodes...
|
||||
if (!isReachableNode (path.number)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if node is already used by another bot...
|
||||
if (bots.getRoundStartTime () + 5.0f < game.time () && isOccupiedNode (path.number)) {
|
||||
busyIndex = path.number;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore non-reacheable nodes...
|
||||
if (!isReachableNode (path.number)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we're still here, find some close nodes
|
||||
float distance = pev->origin.distanceSq (path.origin);
|
||||
|
||||
|
|
@ -1906,7 +1906,7 @@ bool Bot::findNextBestNode () {
|
|||
}
|
||||
|
||||
float Bot::getEstimatedNodeReachTime () {
|
||||
float estimatedTime = 4.2f;
|
||||
float estimatedTime = 3.5f;
|
||||
|
||||
// if just fired at enemy, increase reachability
|
||||
if (m_shootTime + 0.15f < game.time ()) {
|
||||
|
|
@ -1926,9 +1926,9 @@ float Bot::getEstimatedNodeReachTime () {
|
|||
if (longTermReachability) {
|
||||
estimatedTime *= 2.0f;
|
||||
}
|
||||
estimatedTime = cr::clamp (estimatedTime, 3.0f, longTermReachability ? 8.0f : 4.2f);
|
||||
estimatedTime = cr::clamp (estimatedTime, 3.0f, longTermReachability ? 8.0f : 3.5f);
|
||||
}
|
||||
return estimatedTime + m_frameInterval;
|
||||
return estimatedTime;
|
||||
}
|
||||
|
||||
void Bot::findValidNode () {
|
||||
|
|
@ -3388,7 +3388,7 @@ bool Bot::isReachableNode (int index) {
|
|||
|
||||
// some one seems to camp at this node
|
||||
if (isOccupiedNode (index, true)) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
float ladderDist = dst.distance2d (src);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue