aim: predict: use local copy of last predicted node

This commit is contained in:
jeefo 2023-07-02 19:27:25 +03:00
commit cb11409435
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED

View file

@ -138,19 +138,20 @@ void Bot::updateAimDir () {
m_lookAtPredict = nullptr; m_lookAtPredict = nullptr;
}; };
int pathLength = m_lastPredictLength; auto pathLength = m_lastPredictLength;
int predictNode = m_lastPredictIndex; auto predictNode = m_lastPredictIndex;
auto isPredictedIndexApplicable = [&] () -> bool { auto isPredictedIndexApplicable = [&] () -> bool {
if (!vistab.visible (m_currentNodeIndex, predictNode) || !vistab.visible (m_previousNodes[0], predictNode)) { if (!vistab.visible (m_currentNodeIndex, predictNode) || !vistab.visible (m_previousNodes[0], predictNode)) {
predictNode = kInvalidNodeIndex; predictNode = kInvalidNodeIndex;
pathLength = kInfiniteDistanceLong;
} }
return predictNode != kInvalidNodeIndex && pathLength < cv_max_nodes_for_predict.int_ (); return predictNode != kInvalidNodeIndex && pathLength < cv_max_nodes_for_predict.int_ ();
}; };
if (changePredictedEnemy) { if (changePredictedEnemy) {
if (isPredictedIndexApplicable ()) { if (isPredictedIndexApplicable ()) {
m_lookAtPredict = graph[m_lastPredictIndex].origin; m_lookAtPredict = graph[predictNode].origin;
m_timeNextTracking = game.time () + rg.get (0.5f, 1.0f); m_timeNextTracking = game.time () + rg.get (0.5f, 1.0f);
m_trackingEdict = m_lastEnemy; m_trackingEdict = m_lastEnemy;