bot: some reverts and fixes to the pr
This commit is contained in:
parent
3b4c72b051
commit
dca15519b7
5 changed files with 47 additions and 3 deletions
|
|
@ -362,6 +362,7 @@ private:
|
||||||
private:
|
private:
|
||||||
int pickBestWeapon (Array <int> &vec, int moneySave);
|
int pickBestWeapon (Array <int> &vec, int moneySave);
|
||||||
int getRandomCampDir ();
|
int getRandomCampDir ();
|
||||||
|
int findAimingNode (const Vector &to, int &pathLength);
|
||||||
int findNearestNode ();
|
int findNearestNode ();
|
||||||
int findBombNode ();
|
int findBombNode ();
|
||||||
int findCoverNode (float maxDistance);
|
int findCoverNode (float maxDistance);
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ void Bot::avoidGrenades () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if visible to the bot
|
// check if visible to the bot
|
||||||
if (!seesEntity (pent->v.origin) && isInFOV (pent->v.origin - getEyesPos ()) > pev->fov * 0.5f) {
|
if (isInFOV (pent->v.origin - getEyesPos ()) > pev->fov * 0.5f && !seesEntity (pent->v.origin)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto model = pent->v.model.str (9);
|
auto model = pent->v.model.str (9);
|
||||||
|
|
@ -3219,7 +3219,7 @@ void Bot::logic () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure we're not stuck destroying/picking something
|
// ensure we're not stuck destroying/picking something
|
||||||
if (m_navTimeset + getEstimatedNodeReachTime () < game.time () && !(m_states & Sense::SeeingEnemy) && m_moveToGoal) {
|
if (m_navTimeset + getEstimatedNodeReachTime () + 1.0f < game.time () && !(m_states & Sense::SeeingEnemy) && m_moveToGoal) {
|
||||||
ensureEntitiesClear ();
|
ensureEntitiesClear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1437,7 +1437,7 @@ void Bot::attackMovement () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_fightStyle == Fight::Stay) {
|
else if (m_fightStyle == Fight::Stay) {
|
||||||
const bool alreadyDucking = m_duckTime < game.time () || isDucking ();
|
const bool alreadyDucking = m_duckTime >= game.time () || isDucking () || ((pev->button | pev->oldbuttons) & IN_DUCK);
|
||||||
|
|
||||||
if (alreadyDucking) {
|
if (alreadyDucking) {
|
||||||
m_duckTime = game.time () + m_frameInterval * 3.0f;
|
m_duckTime = game.time () + m_frameInterval * 3.0f;
|
||||||
|
|
@ -1458,6 +1458,14 @@ void Bot::attackMovement () {
|
||||||
m_strafeSpeed = 0.0f;
|
m_strafeSpeed = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_difficulty >= Difficulty::Normal && isOnFloor () && m_duckTime < game.time ()) {
|
||||||
|
if (distance < kSprayDistanceX2) {
|
||||||
|
if (rg (0, 1000) < rg (5, 10) && pev->velocity.length2d () > 150.0f && isInViewCone (m_enemy->v.origin)) {
|
||||||
|
pev->button |= IN_JUMP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_isReloading) {
|
if (m_isReloading) {
|
||||||
m_moveSpeed = -pev->maxspeed;
|
m_moveSpeed = -pev->maxspeed;
|
||||||
m_duckTime = game.time () - 1.0f;
|
m_duckTime = game.time () - 1.0f;
|
||||||
|
|
|
||||||
|
|
@ -1670,6 +1670,33 @@ void Bot::clearSearchNodes () {
|
||||||
m_chosenGoalIndex = kInvalidNodeIndex;
|
m_chosenGoalIndex = kInvalidNodeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Bot::findAimingNode (const Vector &to, int &pathLength) {
|
||||||
|
// return the most distant node which is seen from the bot to the target and is within count
|
||||||
|
ensureCurrentNodeIndex ();
|
||||||
|
|
||||||
|
const int destIndex = graph.getNearest (to);
|
||||||
|
int bestIndex = m_currentNodeIndex;
|
||||||
|
|
||||||
|
if (destIndex == kInvalidNodeIndex) {
|
||||||
|
return kInvalidNodeIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = planner.find (destIndex, m_currentNodeIndex, [&] (int index) {
|
||||||
|
++pathLength;
|
||||||
|
|
||||||
|
if (vistab.visible (m_currentNodeIndex, index)) {
|
||||||
|
bestIndex = index;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result && bestIndex == m_currentNodeIndex) {
|
||||||
|
return kInvalidNodeIndex;
|
||||||
|
}
|
||||||
|
return bestIndex;
|
||||||
|
}
|
||||||
|
|
||||||
bool Bot::findNextBestNode () {
|
bool Bot::findNextBestNode () {
|
||||||
// this function find a node in the near of the bot if bot had lost his path of pathfinder needs
|
// this function find a node in the near of the bot if bot had lost his path of pathfinder needs
|
||||||
// to be restarted over again.
|
// to be restarted over again.
|
||||||
|
|
|
||||||
|
|
@ -631,6 +631,14 @@ void Bot::camp_ () {
|
||||||
if (pathLength > 1 && graph.exists (predictNode)) {
|
if (pathLength > 1 && graph.exists (predictNode)) {
|
||||||
m_lookAtSafe = graph[predictNode].origin + pev->view_ofs;
|
m_lookAtSafe = graph[predictNode].origin + pev->view_ofs;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
pathLength = 0;
|
||||||
|
predictNode = findAimingNode (m_lastEnemyOrigin, pathLength);
|
||||||
|
|
||||||
|
if (pathLength > 1 && graph.exists (predictNode)) {
|
||||||
|
m_lookAtSafe = graph[predictNode].origin + pev->view_ofs;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_lookAtSafe = graph[getRandomCampDir ()].origin + pev->view_ofs;
|
m_lookAtSafe = graph[getRandomCampDir ()].origin + pev->view_ofs;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue