Improved monsters targeting👾 (#203)
Improved monsters targeting Fixed aim offset for monsters
This commit is contained in:
parent
588715f28e
commit
ed46e3238d
2 changed files with 22 additions and 7 deletions
|
|
@ -765,6 +765,7 @@ private:
|
||||||
float isInFOV (const Vector &dest);
|
float isInFOV (const Vector &dest);
|
||||||
float getShiftSpeed ();
|
float getShiftSpeed ();
|
||||||
float getEnemyBodyOffsetCorrection (float distance);
|
float getEnemyBodyOffsetCorrection (float distance);
|
||||||
|
float calculateScaleFactor (edict_t *ent);
|
||||||
|
|
||||||
bool canReplaceWeapon ();
|
bool canReplaceWeapon ();
|
||||||
bool canDuckUnder (const Vector &normal);
|
bool canDuckUnder (const Vector &normal);
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ bool Bot::checkBodyParts (edict_t *target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check top of head
|
// check top of head
|
||||||
|
if (util.isPlayer (target)) {
|
||||||
spot.z += 25.0f;
|
spot.z += 25.0f;
|
||||||
game.testLine (eyes, spot, TraceIgnore::Everything, self, &result);
|
game.testLine (eyes, spot, TraceIgnore::Everything, self, &result);
|
||||||
|
|
||||||
|
|
@ -140,6 +141,7 @@ bool Bot::checkBodyParts (edict_t *target) {
|
||||||
m_enemyParts |= Visibility::Head;
|
m_enemyParts |= Visibility::Head;
|
||||||
m_enemyOrigin = result.vecEndPos;
|
m_enemyOrigin = result.vecEndPos;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_enemyParts != 0) {
|
if (m_enemyParts != 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -270,7 +272,9 @@ bool Bot::lookupEnemies () {
|
||||||
|
|
||||||
// see if bot can see the monster...
|
// see if bot can see the monster...
|
||||||
if (seesEnemy (intresting)) {
|
if (seesEnemy (intresting)) {
|
||||||
float distance = (intresting->v.origin - pev->origin).lengthSq ();
|
// higher priority for big monsters
|
||||||
|
float scaleFactor = (1.0f / calculateScaleFactor (intresting));
|
||||||
|
float distance = (intresting->v.origin - pev->origin).lengthSq () * scaleFactor;
|
||||||
|
|
||||||
if (distance * 0.7f < nearestDistance) {
|
if (distance * 0.7f < nearestDistance) {
|
||||||
nearestDistance = distance;
|
nearestDistance = distance;
|
||||||
|
|
@ -499,7 +503,7 @@ const Vector &Bot::getEnemyBodyOffset () {
|
||||||
if (!m_enemyParts && (m_states & Sense::SuspectEnemy)) {
|
if (!m_enemyParts && (m_states & Sense::SuspectEnemy)) {
|
||||||
aimPos += getBodyOffsetError (distance);
|
aimPos += getBodyOffsetError (distance);
|
||||||
}
|
}
|
||||||
else {
|
else if (util.isPlayer (m_enemy)) {
|
||||||
const float highOffset = m_difficulty > Difficulty::Normal ? 3.5f : 0.0f;
|
const float highOffset = m_difficulty > Difficulty::Normal ? 3.5f : 0.0f;
|
||||||
|
|
||||||
// now take in account different parts of enemy body
|
// now take in account different parts of enemy body
|
||||||
|
|
@ -1650,3 +1654,13 @@ void Bot::checkReload () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Bot::calculateScaleFactor (edict_t *ent) {
|
||||||
|
Vector entSize = ent->v.maxs - ent->v.mins;
|
||||||
|
float entArea = 2 * (entSize.x * entSize.y + entSize.y * entSize.z + entSize.x * entSize.z);
|
||||||
|
|
||||||
|
Vector botSize = pev->maxs - pev->mins;
|
||||||
|
float botArea = 2 * (botSize.x * botSize.y + botSize.y * botSize.z + botSize.x * botSize.z);
|
||||||
|
|
||||||
|
return entArea / botArea;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue