fix: bots shoot at dead timer is ignored (bots should shoot some spare bullets toward just dead player).

fix: once again fixed chatter cycling.
add: prevent saving old format waypoint when more than 1024 nodes added.
ci: updated to gcc & mingw 10.2.
This commit is contained in:
ds 2020-10-22 14:40:24 +03:00
commit 27d12d0bbb
4 changed files with 46 additions and 36 deletions

View file

@ -26,29 +26,29 @@
// simple class for bot internal information
class Product final : public Singleton <Product> {
public:
const struct Build {
const StringRef hash { MODULE_BUILD_HASH };
const StringRef author { MODULE_BUILD_AUTHOR };
const StringRef count { MODULE_BUILD_COUNT };
const StringRef machine { MODULE_BUILD_MACHINE };
const StringRef compiler { MODULE_BUILD_COMPILER };
const StringRef id { MODULE_BOT_BUILD_ID };
struct Build {
StringRef hash { MODULE_BUILD_HASH };
StringRef author { MODULE_BUILD_AUTHOR };
StringRef count { MODULE_BUILD_COUNT };
StringRef machine { MODULE_BUILD_MACHINE };
StringRef compiler { MODULE_BUILD_COMPILER };
StringRef id { MODULE_BOT_BUILD_ID };
} build { };
public:
const StringRef name { "YaPB" };
const StringRef year { __DATE__ + 7 };
const StringRef author { "YaPB Development Team" };
const StringRef email { "team@yapb.ru" };
const StringRef url { "https://yapb.ru/" };
const StringRef download { "yapb.ru" };
const StringRef folder { "yapb" };
const StringRef logtag { "YB" };
const StringRef dtime { __DATE__ " " __TIME__ };
const StringRef date { __DATE__ };
const StringRef version { MODULE_BOT_VERSION "." MODULE_BUILD_COUNT };
const StringRef cmdPri { "yb" };
const StringRef cmdSec { "yapb" };
StringRef name { "YaPB" };
StringRef year { __DATE__ + 7 };
StringRef author { "YaPB Development Team" };
StringRef email { "team@yapb.ru" };
StringRef url { "https://yapb.ru/" };
StringRef download { "yapb.ru" };
StringRef folder { "yapb" };
StringRef logtag { "YB" };
StringRef dtime { __DATE__ " " __TIME__ };
StringRef date { __DATE__ };
StringRef version { MODULE_BOT_VERSION "." MODULE_BUILD_COUNT };
StringRef cmdPri { "yb" };
StringRef cmdSec { "yapb" };
};
// expose product info

View file

@ -982,11 +982,11 @@ void Bot::pushChatterMessage (int message) {
}
bool sendMessage = false;
const float messageRepeat = conf.getChatterMessageRepeatInterval (message);
float &messageTimer = m_chatterTimes[message];
auto messageRepeat = conf.getChatterMessageRepeatInterval (message);
auto &messageTimer = m_chatterTimes[message];
if (messageTimer < game.time () || cr::fequal (messageTimer, kMaxChatterRepeatInteval)) {
if (!cr::fequal (messageTimer, kMaxChatterRepeatInteval) && !cr::fequal (messageRepeat, kMaxChatterRepeatInteval)) {
if (!cr::fequal (messageRepeat, kMaxChatterRepeatInteval)) {
messageTimer = game.time () + messageRepeat;
}
sendMessage = true;
@ -1830,16 +1830,19 @@ void Bot::setConditions () {
m_lastVictim = nullptr;
}
auto clearLastEnemy = [&] () {
m_lastEnemyOrigin = nullptr;
m_lastEnemy = nullptr;
};
// check if our current enemy is still valid
if (!game.isNullEntity (m_lastEnemy)) {
if (!util.isAlive (m_lastEnemy) && m_shootAtDeadTime < game.time ()) {
m_lastEnemyOrigin = nullptr;
m_lastEnemy = nullptr;
clearLastEnemy ();
}
}
else {
m_lastEnemyOrigin = nullptr;
m_lastEnemy = nullptr;
clearLastEnemy ();
}
// don't listen if seeing enemy, just checked for sounds or being blinded (because its inhuman)
@ -4800,7 +4803,7 @@ void Bot::logic () {
updateLookAngles (); // and turn to chosen aim direction
// the bots wants to fire at something?
if (m_wantsToFire && !m_isUsingGrenade && m_shootTime <= game.time ()) {
if (m_shootAtDeadTime > game.time () || (m_wantsToFire && !m_isUsingGrenade && m_shootTime <= game.time ())) {
fireWeapons (); // if bot didn't fire a bullet try again next frame
}

View file

@ -359,9 +359,9 @@ bool Bot::lookupEnemies () {
m_enemy = nullptr;
// shoot at dying players if no new enemy to give some more human-like illusion
if (m_seeEnemyTime + 0.3f > game.time ()) {
if (m_seeEnemyTime + 0.1f > game.time ()) {
if (!usesSniper ()) {
m_shootAtDeadTime = game.time () + 0.4f;
m_shootAtDeadTime = game.time () + cr::clamp (m_agressionLevel * 1.25f, 0.45f, 1.05f);
m_actualReactionTime = 0.0f;
m_states |= Sense::SuspectEnemy;
@ -369,6 +369,7 @@ bool Bot::lookupEnemies () {
}
return false;
}
else if (m_shootAtDeadTime > game.time ()) {
m_actualReactionTime = 0.0f;
m_states |= Sense::SuspectEnemy;
@ -422,7 +423,7 @@ Vector Bot::getBodyOffsetError (float distance) {
Vector &maxs = m_enemy->v.maxs, &mins = m_enemy->v.mins;
m_aimLastError = Vector (rg.get (mins.x * error, maxs.x * error), rg.get (mins.y * error, maxs.y * error), rg.get (mins.z * error, maxs.z * error));
m_aimErrorTime = game.time () + rg.get (0.5f, 1.0f);
m_aimErrorTime = game.time () + rg.get (1.0f, 1.2f);
}
return m_aimLastError;
}
@ -461,6 +462,7 @@ const Vector &Bot::getEnemyBodyOffset () {
aimPos += getBodyOffsetError (distance);
}
else {
const float highOffset = m_difficulty > Difficulty::Normal ? 3.5f : 0.0f;
// now take in account different parts of enemy body
if (m_enemyParts & (Visibility::Head | Visibility::Body)) {
@ -470,11 +472,11 @@ const Vector &Bot::getEnemyBodyOffset () {
aimPos.z = headOffset (m_enemy) + getEnemyBodyOffsetCorrection (distance);
}
else {
aimPos.z += 3.5f;
aimPos.z += highOffset;
}
}
else if (m_enemyParts & Visibility::Body) {
aimPos.z += 3.5f;
aimPos.z += highOffset;
}
else if (m_enemyParts & Visibility::Other) {
aimPos = m_enemyOrigin;
@ -502,7 +504,7 @@ float Bot::getEnemyBodyOffsetCorrection (float distance) {
static float offsetRanges[9][3] = {
{ 0.0f, 0.0f, 0.0f }, // none
{ 0.0f, 0.0f, 0.0f }, // melee
{ 6.5f, 6.5f, 4.5f }, // pistol
{ 6.5f, 6.5f, 1.5f }, // pistol
{ 9.5f, 9.0f, -5.0f }, // shotgun
{ 4.5f, 3.5f, -5.0f }, // zoomrifle
{ 4.5f, 1.0f, -4.5f }, // rifle
@ -780,7 +782,7 @@ void Bot::selectWeapons (float distance, int index, int id, int choosen) {
}
// we're should stand still before firing sniper weapons, else sniping is useless..
if (usesSniper () && (m_aimFlags & (AimFlags::Enemy | AimFlags::LastEnemy)) && !m_isReloading && pev->velocity.lengthSq () > 0.0f) {
if (usesSniper () && (m_aimFlags & (AimFlags::Enemy | AimFlags::LastEnemy)) && !m_isReloading && pev->velocity.lengthSq () > 0.0f && getCurrentTaskId () != Task::SeekCover) {
m_moveSpeed = 0.0f;
m_strafeSpeed = 0.0f;
m_navTimeset = game.time ();

View file

@ -474,6 +474,11 @@ int BotControl::cmdNodeSave () {
msg ("All nodes has been saved and written to disk (IGNORING QUALITY CONTROL).");
}
else if (strValue (option) == "old") {
if (graph.length () >= 1024) {
msg ("Unable to save POD-Bot Format waypoint file. Number of nodes exceeds 1024.");
return BotCommandResult::Handled;
}
graph.saveOldFormat ();
msg ("All nodes has been saved and written to disk (POD-Bot Format (.pwf)).");