bot: some tweaks for zombie mode (ref #664)
This commit is contained in:
parent
e09d75f245
commit
d965d7677f
6 changed files with 45 additions and 5 deletions
|
|
@ -288,6 +288,7 @@ private:
|
||||||
float m_timeDebugUpdateTime {}; // time to update last debug timestamp
|
float m_timeDebugUpdateTime {}; // time to update last debug timestamp
|
||||||
float m_lastVictimTime {}; // time when bot killed an enemy
|
float m_lastVictimTime {}; // time when bot killed an enemy
|
||||||
float m_killsInterval {}; // interval between kills
|
float m_killsInterval {}; // interval between kills
|
||||||
|
float m_lastDamageTimestamp {}; // last damage from take damage fn
|
||||||
|
|
||||||
bool m_moveToGoal {}; // bot currently moving to goal??
|
bool m_moveToGoal {}; // bot currently moving to goal??
|
||||||
bool m_isStuck {}; // bot is stuck
|
bool m_isStuck {}; // bot is stuck
|
||||||
|
|
|
||||||
|
|
@ -1722,7 +1722,11 @@ void Bot::overrideConditions () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (distanceSq2d <= kReachEnemyWikKnifeDistanceSq && (m_states & Sense::SeeingEnemy) && tid == Task::MoveToPosition) {
|
if (!m_isCreature
|
||||||
|
&& distanceSq2d <= kReachEnemyWikKnifeDistanceSq
|
||||||
|
&& (m_states & Sense::SeeingEnemy)
|
||||||
|
&& tid == Task::MoveToPosition) {
|
||||||
|
|
||||||
clearTask (Task::MoveToPosition); // remove any move tasks
|
clearTask (Task::MoveToPosition); // remove any move tasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1828,6 +1832,10 @@ void Bot::updatePredictedIndex () {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::refreshEnemyPredict () {
|
void Bot::refreshEnemyPredict () {
|
||||||
|
if (m_isCreature) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (game.isNullEntity (m_enemy) && !game.isNullEntity (m_lastEnemy) && !m_lastEnemyOrigin.empty ()) {
|
if (game.isNullEntity (m_enemy) && !game.isNullEntity (m_lastEnemy) && !m_lastEnemyOrigin.empty ()) {
|
||||||
const auto distanceToLastEnemySq = m_lastEnemyOrigin.distanceSq (pev->origin);
|
const auto distanceToLastEnemySq = m_lastEnemyOrigin.distanceSq (pev->origin);
|
||||||
|
|
||||||
|
|
@ -2130,7 +2138,7 @@ void Bot::filterTasks () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// zombie bots has more hunt desire
|
// zombie bots has more hunt desire
|
||||||
if (m_isCreature && huntEnemyDesire > 25.0f) {
|
if (m_isCreature && huntEnemyDesire > 16.0f) {
|
||||||
huntEnemyDesire = TaskPri::Attack;
|
huntEnemyDesire = TaskPri::Attack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2352,6 +2360,17 @@ bool Bot::reactOnEnemy () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special case for creatures
|
||||||
|
if (m_isCreature && !game.isNullEntity (m_enemy)) {
|
||||||
|
m_isEnemyReachable = false;
|
||||||
|
|
||||||
|
if (pev->origin.distanceSq (m_enemy->v.origin) < cr::sqrf (128.0f)) {
|
||||||
|
m_navTimeset = game.time ();
|
||||||
|
m_isEnemyReachable = true;
|
||||||
|
}
|
||||||
|
return m_isEnemyReachable;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_enemyReachableTimer < game.time ()) {
|
if (m_enemyReachableTimer < game.time ()) {
|
||||||
const auto lineDist = m_enemy->v.origin.distance (pev->origin);
|
const auto lineDist = m_enemy->v.origin.distance (pev->origin);
|
||||||
|
|
||||||
|
|
@ -3588,9 +3607,20 @@ void Bot::takeDamage (edict_t *inflictor, int damage, int armor, int bits) {
|
||||||
|
|
||||||
m_lastDamageType = bits;
|
m_lastDamageType = bits;
|
||||||
|
|
||||||
|
if (m_isCreature) {
|
||||||
|
if (util.isPlayer (inflictor) && game.isNullEntity (m_enemy)) {
|
||||||
|
if (seesEnemy (inflictor)) {
|
||||||
|
m_enemy = inflictor;
|
||||||
|
m_enemyOrigin = inflictor->v.origin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!game.is (GameFlags::CSDM)) {
|
if (!game.is (GameFlags::CSDM)) {
|
||||||
updatePracticeValue (damage);
|
updatePracticeValue (damage);
|
||||||
}
|
}
|
||||||
|
m_lastDamageTimestamp = game.time ();
|
||||||
|
|
||||||
if (util.isPlayer (inflictor) || (cv_attack_monsters && util.isMonster (inflictor))) {
|
if (util.isPlayer (inflictor) || (cv_attack_monsters && util.isMonster (inflictor))) {
|
||||||
const auto inflictorTeam = game.getTeam (inflictor);
|
const auto inflictorTeam = game.getTeam (inflictor);
|
||||||
|
|
|
||||||
|
|
@ -1243,7 +1243,9 @@ void Bot::fireWeapons () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// use knife if near and good difficulty (l33t dude!)
|
// use knife if near and good difficulty (l33t dude!)
|
||||||
if (cv_stab_close_enemies && m_difficulty >= Difficulty::Normal
|
if (!game.is (GameFlags::ZombieMod)
|
||||||
|
&& cv_stab_close_enemies
|
||||||
|
&& m_difficulty >= Difficulty::Normal
|
||||||
&& m_healthValue > 80.0f
|
&& m_healthValue > 80.0f
|
||||||
&& !game.isNullEntity (m_enemy)
|
&& !game.isNullEntity (m_enemy)
|
||||||
&& distance < 100.0f
|
&& distance < 100.0f
|
||||||
|
|
|
||||||
|
|
@ -1456,6 +1456,7 @@ void Bot::newRound () {
|
||||||
m_duckDefuse = false;
|
m_duckDefuse = false;
|
||||||
m_duckDefuseCheckTime = 0.0f;
|
m_duckDefuseCheckTime = 0.0f;
|
||||||
m_timeDebugUpdateTime = 0.0f;
|
m_timeDebugUpdateTime = 0.0f;
|
||||||
|
m_lastDamageTimestamp = 0.0f;
|
||||||
|
|
||||||
m_numFriendsLeft = 0;
|
m_numFriendsLeft = 0;
|
||||||
m_numEnemiesLeft = 0;
|
m_numEnemiesLeft = 0;
|
||||||
|
|
|
||||||
|
|
@ -581,8 +581,14 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
&& m_lastCollTime < game.time ()
|
&& m_lastCollTime < game.time ()
|
||||||
&& tid != Task::Attack
|
&& tid != Task::Attack
|
||||||
&& tid != Task::Camp) {
|
&& tid != Task::Camp) {
|
||||||
|
|
||||||
|
// special case for creatures
|
||||||
|
if (m_lastDamageTimestamp >= game.time () && m_isCreature) {
|
||||||
|
m_lastCollTime = m_lastDamageTimestamp + 0.2f;
|
||||||
|
m_firstCollideTime = 0.0f;
|
||||||
|
}
|
||||||
// didn't we move enough previously?
|
// didn't we move enough previously?
|
||||||
if (movedDistance < kMinMovedDistance && m_prevSpeed > 20.0f) {
|
else if (movedDistance < kMinMovedDistance && m_prevSpeed > 20.0f) {
|
||||||
m_prevTime = game.time (); // then consider being stuck
|
m_prevTime = game.time (); // then consider being stuck
|
||||||
m_isStuck = true;
|
m_isStuck = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -828,7 +828,7 @@ void Bot::moveToPos_ () {
|
||||||
getTask ()->data = destIndex;
|
getTask ()->data = destIndex;
|
||||||
|
|
||||||
ensureCurrentNodeIndex ();
|
ensureCurrentNodeIndex ();
|
||||||
findPath (m_currentNodeIndex, destIndex, m_pathType);
|
findPath (m_currentNodeIndex, destIndex, m_isCreature ? FindPath::Fast : m_pathType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
completeTask ();
|
completeTask ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue