api: allow getting current bot goal.

api: do not use buckets for nearest node search.
This commit is contained in:
ds 2020-11-06 10:27:19 +03:00
commit a0202efc40
5 changed files with 26 additions and 9 deletions

View file

@ -5309,14 +5309,12 @@ void Bot::startDoubleJump (edict_t *ent) {
}
void Bot::sendBotToOrigin (const Vector &origin) {
clearSearchNodes ();
clearTask (Task::MoveToPosition); // remove any move tasks
m_position = origin;
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, kInvalidNodeIndex, 0.0f, true);
m_chosenGoalIndex = graph.getNearestNoBuckets (origin);
m_chosenGoalIndex = graph.getNearest (origin);
getTask ()->data = m_chosenGoalIndex;
startTask (Task::MoveToPosition, TaskPri::Hide, m_chosenGoalIndex, 0.0f, true);
}
void Bot::resetDoubleJump () {

View file

@ -12,6 +12,9 @@ class YaPBModule : public IYaPBModule {
public:
virtual ~YaPBModule () override = default;
public:
CR_DECLARE_DESTRUCTOR ();
private:
Bot *getBot (int index) {
if (index < 1) {
@ -39,7 +42,7 @@ public:
// gets the node nearest to origin
virtual int getNearestNode (float *origin) override {
if (graph.length () > 0) {
return graph.getNearest (origin);
return graph.getNearestNoBuckets (origin);
}
return kInvalidNodeIndex;
}
@ -79,6 +82,15 @@ public:
}
}
virtual int getBotGoal (int entity) override {
auto bot = getBot (entity);
if (bot) {
return bot->m_chosenGoalIndex == kInvalidNodeIndex ? bot->getTask ()->data : bot->m_chosenGoalIndex;
}
return kInvalidNodeIndex;
}
// force bot to go to selected origin
virtual void setBotGoalOrigin (int entity, float *origin) override {
auto bot = getBot (entity);