Fixed shaky nav aiming.

For the graph files that have many close-placed nodes bots will switch his view constantly to new one when going on path, making it too shaky while moving.

This fix makes bots to look at next node instead of currently reaching one, so aiming is a bit clearer now.
This commit is contained in:
jeefo 2019-08-30 17:23:28 +03:00
commit affa64808d
2 changed files with 11 additions and 6 deletions

View file

@ -2777,13 +2777,18 @@ void Bot::updateAimDir () {
m_lookAt = m_camp;
}
else if (flags & AimFlags::Nav) {
if (m_moveToGoal && !m_isStuck && m_currentNodeIndex != kInvalidNodeIndex && !(m_path->flags & NodeFlag::Ladder) && m_pathWalk.hasNext () && (pev->origin - m_destOrigin).lengthSq () < cr::square (52.0f)) {
m_lookAt = graph[m_pathWalk.next ()].origin + pev->view_ofs;
}
else {
m_lookAt = m_destOrigin;
}
if (m_canChooseAimDirection && m_currentNodeIndex != kInvalidNodeIndex && !(m_path->flags & NodeFlag::Ladder)) {
int dangerIndex = graph.getDangerIndex (m_team, m_currentNodeIndex, m_currentNodeIndex);
if (graph.exists (dangerIndex) && graph.isVisible (m_currentNodeIndex, dangerIndex)) {
m_lookAt = graph[dangerIndex].origin;
m_lookAt = graph[dangerIndex].origin + pev->view_ofs;
}
}
}

View file

@ -918,12 +918,12 @@ int BotControl::cmdNodeIterateCamp () {
// go to next
m_campIterator.shift ();
}
else {
m_campIterator.clear ();
if (m_campIterator.empty ()) {
msg ("Finished iterating camp spots.");
}
}
}
else if (op == "begin") {
for (int i = 0; i < graph.length (); ++i) {
if (graph[i].flags & NodeFlag::Camp) {