bot: more correct clearance for lost hostages
fix: bot sometime stuck in shoot breakable task (ref #606) refactor: fix task names in debug mode
This commit is contained in:
parent
68993aa434
commit
d8ed0e565c
3 changed files with 19 additions and 28 deletions
|
|
@ -478,7 +478,7 @@ private:
|
||||||
void updateHearing ();
|
void updateHearing ();
|
||||||
void postProcessGoals (const IntArray &goals, int result[]);
|
void postProcessGoals (const IntArray &goals, int result[]);
|
||||||
void updatePickups ();
|
void updatePickups ();
|
||||||
void ensureEntitiesClear ();
|
void ensurePickupEntitiesClear ();
|
||||||
void checkTerrain (float movedDistance, const Vector &dirNormal);
|
void checkTerrain (float movedDistance, const Vector &dirNormal);
|
||||||
void checkFall ();
|
void checkFall ();
|
||||||
void checkDarkness ();
|
void checkDarkness ();
|
||||||
|
|
|
||||||
|
|
@ -751,7 +751,7 @@ void Bot::updatePickups () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::ensureEntitiesClear () {
|
void Bot::ensurePickupEntitiesClear () {
|
||||||
const auto tid = getCurrentTaskId ();
|
const auto tid = getCurrentTaskId ();
|
||||||
|
|
||||||
if (tid == Task::PickupItem || (m_states & Sense::PickupItem)) {
|
if (tid == Task::PickupItem || (m_states & Sense::PickupItem)) {
|
||||||
|
|
@ -766,21 +766,10 @@ void Bot::ensureEntitiesClear () {
|
||||||
if (tid == Task::PickupItem) {
|
if (tid == Task::PickupItem) {
|
||||||
completeTask ();
|
completeTask ();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (tid == Task::ShootBreakable) {
|
|
||||||
if (!game.isNullEntity (m_breakableEntity)) {
|
|
||||||
m_ignoredBreakable.emplace (m_breakableEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_breakableTime = game.time () + 5.0f;
|
|
||||||
m_breakableOrigin = nullptr;
|
|
||||||
m_lastBreakable = nullptr;
|
|
||||||
m_breakableEntity = nullptr;
|
|
||||||
|
|
||||||
completeTask ();
|
|
||||||
}
|
|
||||||
findValidNode ();
|
findValidNode ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Bot::isIgnoredItem (edict_t *ent) {
|
bool Bot::isIgnoredItem (edict_t *ent) {
|
||||||
for (const auto &ignored : m_ignoredItems) {
|
for (const auto &ignored : m_ignoredItems) {
|
||||||
|
|
@ -3341,7 +3330,7 @@ void Bot::logic () {
|
||||||
// ensure we're not stuck destroying/picking something
|
// ensure we're not stuck destroying/picking something
|
||||||
if (m_moveToGoal && m_moveSpeed > 0.0f && rg (2.5f, 3.5f) + m_navTimeset + m_destOrigin.distanceSq2d (pev->origin) / cr::sqrf (m_moveSpeed) < game.time ()
|
if (m_moveToGoal && m_moveSpeed > 0.0f && rg (2.5f, 3.5f) + m_navTimeset + m_destOrigin.distanceSq2d (pev->origin) / cr::sqrf (m_moveSpeed) < game.time ()
|
||||||
&& !(m_states & Sense::SeeingEnemy)) {
|
&& !(m_states & Sense::SeeingEnemy)) {
|
||||||
ensureEntitiesClear ();
|
ensurePickupEntitiesClear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if need to use parachute
|
// check if need to use parachute
|
||||||
|
|
@ -3393,24 +3382,24 @@ void Bot::showDebugOverlay () {
|
||||||
static HashMap <int32_t, StringRef> tasks {
|
static HashMap <int32_t, StringRef> tasks {
|
||||||
{ Task::Normal, "Normal" },
|
{ Task::Normal, "Normal" },
|
||||||
{ Task::Pause, "Pause" },
|
{ Task::Pause, "Pause" },
|
||||||
{ Task::MoveToPosition, "Move" },
|
{ Task::MoveToPosition, "MoveToPosition" },
|
||||||
{ Task::FollowUser, "Follow" },
|
{ Task::FollowUser, "FollowUser" },
|
||||||
{ Task::PickupItem, "Pickup" },
|
{ Task::PickupItem, "PickupItem" },
|
||||||
{ Task::Camp, "Camp" },
|
{ Task::Camp, "Camp" },
|
||||||
{ Task::PlantBomb, "PlantBomb" },
|
{ Task::PlantBomb, "PlantBomb" },
|
||||||
{ Task::DefuseBomb, "DefuseBomb" },
|
{ Task::DefuseBomb, "DefuseBomb" },
|
||||||
{ Task::Attack, "Attack" },
|
{ Task::Attack, "Attack" },
|
||||||
{ Task::Hunt, "Hunt" },
|
{ Task::Hunt, "Hunt" },
|
||||||
{ Task::SeekCover, "SeekCover" },
|
{ Task::SeekCover, "SeekCover" },
|
||||||
{ Task::ThrowExplosive, "ThrowHE" },
|
{ Task::ThrowExplosive, "ThrowExplosive" },
|
||||||
{ Task::ThrowFlashbang, "ThrowFL" },
|
{ Task::ThrowFlashbang, "ThrowFlashbang" },
|
||||||
{ Task::ThrowSmoke, "ThrowSG" },
|
{ Task::ThrowSmoke, "ThrowSmoke" },
|
||||||
{ Task::DoubleJump, "DoubleJump" },
|
{ Task::DoubleJump, "DoubleJump" },
|
||||||
{ Task::EscapeFromBomb, "EscapeFromBomb" },
|
{ Task::EscapeFromBomb, "EscapeFromBomb" },
|
||||||
{ Task::ShootBreakable, "DestroyBreakable" },
|
{ Task::ShootBreakable, "ShootBreakable" },
|
||||||
{ Task::Hide, "Hide" },
|
{ Task::Hide, "Hide" },
|
||||||
{ Task::Blind, "Blind" },
|
{ Task::Blind, "Blind" },
|
||||||
{ Task::Spraypaint, "Spray" }
|
{ Task::Spraypaint, "Spraypaint" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static HashMap <int32_t, StringRef> personalities {
|
static HashMap <int32_t, StringRef> personalities {
|
||||||
|
|
@ -3524,12 +3513,14 @@ bool Bot::hasHostage () {
|
||||||
if (!game.isNullEntity (hostage)) {
|
if (!game.isNullEntity (hostage)) {
|
||||||
|
|
||||||
// don't care about dead hostages
|
// don't care about dead hostages
|
||||||
if (hostage->v.health <= 0.0f || pev->origin.distanceSq (hostage->v.origin) > cr::sqrf (600.0f)) {
|
if (hostage->v.health > 0.0f || pev->origin.distanceSq (hostage->v.origin) < cr::sqrf (600.0f)) {
|
||||||
hostage = nullptr;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
m_hostages.remove (hostage);
|
||||||
|
hostage = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1451,7 +1451,7 @@ void Bot::shootBreakable_ () {
|
||||||
m_lookAtSafe = m_breakableOrigin;
|
m_lookAtSafe = m_breakableOrigin;
|
||||||
|
|
||||||
// is bot facing the breakable?
|
// is bot facing the breakable?
|
||||||
if (util.getConeDeviation (ent (), m_breakableOrigin) >= 0.90f) {
|
if (util.getConeDeviation (ent (), m_breakableOrigin) >= 0.95f && util.isVisible (m_breakableOrigin, ent ())) {
|
||||||
m_moveSpeed = 0.0f;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0f;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue