fix: crash bug introduced in latest commit (resolves #630)
fix: unnecessary assignments here and there
This commit is contained in:
parent
3d0bb4d7da
commit
3d84b96534
3 changed files with 7 additions and 12 deletions
|
|
@ -135,7 +135,7 @@ bool Bot::isEnemyInDarkArea (edict_t *enemy) {
|
||||||
const auto scolor = illum.getSkyColor ();
|
const auto scolor = illum.getSkyColor ();
|
||||||
|
|
||||||
// check if node near the enemy have a degraded light level
|
// check if node near the enemy have a degraded light level
|
||||||
const auto enemyNodeIndex = graph.getNearest (m_enemy->v.origin);
|
const auto enemyNodeIndex = graph.getNearest (enemy->v.origin);
|
||||||
|
|
||||||
if (!graph.exists (enemyNodeIndex)) {
|
if (!graph.exists (enemyNodeIndex)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -273,12 +273,12 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) {
|
||||||
const auto hitsTarget = [&] () -> bool {
|
const auto hitsTarget = [&] () -> bool {
|
||||||
return result.flFraction >= 1.0f || result.pHit == target;
|
return result.flFraction >= 1.0f || result.pHit == target;
|
||||||
};
|
};
|
||||||
|
m_enemyParts = Visibility::None;
|
||||||
|
|
||||||
// creatures can't hurt behind anything
|
// creatures can't hurt behind anything
|
||||||
const auto ignoreFlags = m_isCreature ? TraceIgnore::None : TraceIgnore::Everything;
|
const auto ignoreFlags = m_isCreature ? TraceIgnore::None : TraceIgnore::Everything;
|
||||||
|
|
||||||
// get the stomach hitbox
|
// get the stomach hitbox
|
||||||
m_enemyParts = Visibility::None;
|
|
||||||
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Stomach, refresh), ignoreFlags, self, &result);
|
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Stomach, refresh), ignoreFlags, self, &result);
|
||||||
|
|
||||||
if (hitsTarget ()) {
|
if (hitsTarget ()) {
|
||||||
|
|
@ -287,7 +287,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the stomach hitbox
|
// get the stomach hitbox
|
||||||
m_enemyParts = Visibility::None;
|
|
||||||
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Head, refresh), ignoreFlags, self, &result);
|
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Head, refresh), ignoreFlags, self, &result);
|
||||||
|
|
||||||
if (hitsTarget ()) {
|
if (hitsTarget ()) {
|
||||||
|
|
@ -300,7 +299,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the left hitbox
|
// get the left hitbox
|
||||||
m_enemyParts = Visibility::None;
|
|
||||||
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::LeftArm, refresh), ignoreFlags, self, &result);
|
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::LeftArm, refresh), ignoreFlags, self, &result);
|
||||||
|
|
||||||
if (hitsTarget ()) {
|
if (hitsTarget ()) {
|
||||||
|
|
@ -311,7 +309,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the right hitbox
|
// get the right hitbox
|
||||||
m_enemyParts = Visibility::None;
|
|
||||||
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::RightArm, refresh), ignoreFlags, self, &result);
|
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::RightArm, refresh), ignoreFlags, self, &result);
|
||||||
|
|
||||||
if (hitsTarget ()) {
|
if (hitsTarget ()) {
|
||||||
|
|
@ -322,7 +319,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the feet spot
|
// get the feet spot
|
||||||
m_enemyParts = Visibility::None;
|
|
||||||
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Feet, refresh), ignoreFlags, self, &result);
|
game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Feet, refresh), ignoreFlags, self, &result);
|
||||||
|
|
||||||
if (hitsTarget ()) {
|
if (hitsTarget ()) {
|
||||||
|
|
|
||||||
|
|
@ -1496,27 +1496,25 @@ void PlayerHitboxEnumerator::update (edict_t *ent) {
|
||||||
parts->head.z += bboxset[hitbox].bbmax.z;
|
parts->head.z += bboxset[hitbox].bbmax.z;
|
||||||
parts->head = { ent->v.origin.x, ent->v.origin.y, parts->head.z };
|
parts->head = { ent->v.origin.x, ent->v.origin.y, parts->head.z };
|
||||||
}
|
}
|
||||||
hitbox = kInvalidHitbox;
|
|
||||||
|
|
||||||
// get the body (stomach)
|
// get the body (stomach)
|
||||||
hitbox = getHitbox (studiohdr, bboxset, PlayerPart::Stomach);
|
hitbox = getHitbox (studiohdr, bboxset, PlayerPart::Stomach);
|
||||||
|
|
||||||
if (hitbox != kInfiniteDistance) {
|
if (hitbox != kInvalidHitbox) {
|
||||||
engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->stomach, nullptr);
|
engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->stomach, nullptr);
|
||||||
}
|
}
|
||||||
hitbox = kInvalidHitbox;
|
|
||||||
|
|
||||||
// get the left (arm)
|
// get the left (arm)
|
||||||
hitbox = getHitbox (studiohdr, bboxset, PlayerPart::LeftArm);
|
hitbox = getHitbox (studiohdr, bboxset, PlayerPart::LeftArm);
|
||||||
|
|
||||||
if (hitbox != kInfiniteDistance) {
|
if (hitbox != kInvalidHitbox) {
|
||||||
engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->left, nullptr);
|
engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->left, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the right (arm)
|
// get the right (arm)
|
||||||
hitbox = getHitbox (studiohdr, bboxset, PlayerPart::RightArm);
|
hitbox = getHitbox (studiohdr, bboxset, PlayerPart::RightArm);
|
||||||
|
|
||||||
if (hitbox != kInfiniteDistance) {
|
if (hitbox != kInvalidHitbox) {
|
||||||
engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->right, nullptr);
|
engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->right, nullptr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,6 @@ void Bot::updateLookAnglesNewbie (const Vector &direction, float delta) {
|
||||||
const float offsetDelay = 1.2f;
|
const float offsetDelay = 1.2f;
|
||||||
|
|
||||||
Vector stiffness {};
|
Vector stiffness {};
|
||||||
Vector randomize {};
|
|
||||||
|
|
||||||
m_idealAngles = direction.get2d ();
|
m_idealAngles = direction.get2d ();
|
||||||
m_idealAngles.clampAngles ();
|
m_idealAngles.clampAngles ();
|
||||||
|
|
@ -303,6 +302,8 @@ void Bot::updateLookAnglesNewbie (const Vector &direction, float delta) {
|
||||||
&& ((pev->velocity.length () > 1.0f
|
&& ((pev->velocity.length () > 1.0f
|
||||||
&& m_angularDeviation.length () < 5.0f) || m_angularDeviation.length () < 1.0f)) {
|
&& m_angularDeviation.length () < 5.0f) || m_angularDeviation.length () < 1.0f)) {
|
||||||
|
|
||||||
|
Vector randomize {};
|
||||||
|
|
||||||
// is the bot standing still ?
|
// is the bot standing still ?
|
||||||
if (pev->velocity.length () < 1.0f) {
|
if (pev->velocity.length () < 1.0f) {
|
||||||
randomize = randomization * 0.2f; // randomize less
|
randomize = randomization * 0.2f; // randomize less
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue