graph: reworked buckets so they can handle very large number of nodes

graph: reworked buckets so they can handle very large number of nodes
aim: bots should more respect headshot allow option (needs testing)
aim: incorporated never-finished changes from pr #204
nav: increased reachability timers a bit
nav: ensure buckets has enough nodes before use they
conf: introduced max recoil in difficulty config file
bot: overall fixes to jason mode, treat knife in hands and no weapons as jason mode too
bot: changed default difficulty level for bots to level 3
fix: knife attacks not working since last commit (fixes #429)
fix: hostage rescue not working since last commit (fixes #427)
refactor: use range loops for graph outside graph class when possible
This commit is contained in:
jeefo 2023-04-11 22:32:28 +03:00
commit 1a650c57ce
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
14 changed files with 426 additions and 347 deletions

View file

@ -35,6 +35,8 @@ public:
int32_t headshotPct {};
int32_t seenThruPct {};
int32_t hearThruPct {};
int32_t maxRecoil {};
Vector aimError {};
};
private:

View file

@ -151,6 +151,9 @@ public:
// test line
void testLine (const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult *ptr);
// test model
void testModel (const Vector &start, const Vector &end, int hullNumber, edict_t *entToHit, TraceResult *ptr);
// trace line with channel, but allows us to store last traceline bot has fired, saving us some cpu cycles
bool testLineChannel (TraceChannel channel, const Vector &start, const Vector &end, int ignoreFlags, edict_t *ignoreEntity, TraceResult &result);

View file

@ -259,10 +259,6 @@ public:
friend class Bot;
private:
struct Bucket {
int x, y, z;
};
int m_editFlags {};
int m_loadAttempts {};
int m_cacheNodeIndex {};
@ -297,12 +293,13 @@ private:
IntArray m_rescuePoints {};
IntArray m_visitedGoals {};
SmallArray <int32_t> m_buckets[kMaxBucketsInsidePos][kMaxBucketsInsidePos][kMaxBucketsInsidePos];
SmallArray <Matrix> m_matrix {};
SmallArray <Practice> m_practice {};
SmallArray <Path> m_paths {};
SmallArray <uint8_t> m_vistable {};
HashMap <int32_t, Array <int32_t>, EmptyHash <int32_t>> m_hashTable;
String m_graphAuthor {};
String m_graphModified {};
@ -327,6 +324,7 @@ public:
int getPathDist (int srcIndex, int destIndex);
int clearConnections (int index);
int getBspSize ();
int locateBucket (const Vector &pos);
float calculateTravelTime (float maxSpeed, const Vector &src, const Vector &origin);
@ -394,9 +392,8 @@ public:
const char *getDataDirectory (bool isMemoryFile = false);
const char *getOldFormatGraphName (bool isMemoryFile = false);
Bucket locateBucket (const Vector &pos);
IntArray searchRadius (float radius, const Vector &origin, int maxCount = -1);
const SmallArray <int32_t> &getNodesInBucket (const Vector &pos);
IntArray getNarestInRadius (float radius, const Vector &origin, int maxCount = -1);
const IntArray &getNodesInBucket (const Vector &pos);
public:
size_t getMaxRouteLength () const {
@ -468,6 +465,23 @@ public:
edict_t *getEditor () {
return m_editor;
}
public:
Path *begin () {
return m_paths.begin ();
}
Path *begin () const {
return m_paths.begin ();
}
Path *end () {
return m_paths.end ();
}
Path *end () const {
return m_paths.end ();
}
};
// we're need `bots`

View file

@ -467,10 +467,6 @@ constexpr int kGameMaxPlayers = 32;
constexpr int kGameTeamNum = 2;
constexpr int kInvalidNodeIndex = -1;
constexpr int kMaxBucketSize = static_cast <int> (kMaxNodes * 0.65);
constexpr int kMaxBucketsInsidePos = kMaxNodes * 8 / kMaxBucketSize + 1;
constexpr int kMaxNodesInsideBucket = kMaxBucketSize / kMaxBucketsInsidePos;
// weapon masks
constexpr auto kPrimaryWeaponMask = (cr::bit (Weapon::XM1014) | cr::bit (Weapon::M3) | cr::bit (Weapon::MAC10) | cr::bit (Weapon::UMP45) | cr::bit (Weapon::MP5) | cr::bit (Weapon::TMP) | cr::bit (Weapon::P90) | cr::bit (Weapon::AUG) | cr::bit (Weapon::M4A1) | cr::bit (Weapon::SG552) | cr::bit (Weapon::AK47) | cr::bit (Weapon::Scout) | cr::bit (Weapon::SG550) | cr::bit (Weapon::AWP) | cr::bit (Weapon::G3SG1) | cr::bit (Weapon::M249) | cr::bit (Weapon::Famas) | cr::bit (Weapon::Galil));
constexpr auto kSecondaryWeaponMask = (cr::bit (Weapon::P228) | cr::bit (Weapon::Elite) | cr::bit (Weapon::USP) | cr::bit (Weapon::Glock18) | cr::bit (Weapon::Deagle) | cr::bit (Weapon::FiveSeven));
@ -690,6 +686,7 @@ private:
float m_changeViewTime {}; // timestamp to change look at while at freezetime
float m_breakableTime {}; // breakeble acquired time
float m_jumpDistance {}; // last jump distance
float m_lastBadWeaponSwitchTime {}; // last time we're switched weapon as it's bad
bool m_moveToGoal {}; // bot currently moving to goal??
bool m_isStuck {}; // bot is stuck
@ -709,6 +706,7 @@ private:
bool m_moveToC4 {}; // ct is moving to bomb
bool m_grenadeRequested {}; // bot requested change to grenade
bool m_needToSendWelcomeChat {}; // bot needs to greet people on server?
bool m_switchedToKnifeDuringJump {}; // bot needs to revert weapon after jump?
Pickup m_pickupType {}; // type of entity which needs to be used/picked up
PathWalk m_pathWalk {}; // pointer to current node from path
@ -778,7 +776,6 @@ private:
float getEstimatedNodeReachTime ();
float isInFOV (const Vector &dest);
float getShiftSpeed ();
float getEnemyBodyOffsetCorrection (float distance);
float calculateScaleFactor (edict_t *ent);
bool canReplaceWeapon ();
@ -809,6 +806,7 @@ private:
bool reactOnEnemy ();
bool selectBestNextNode ();
bool hasAnyWeapons ();
bool isKnifeMode ();
bool isDeadlyMove (const Vector &to);
bool isOutOfBombTimer ();
bool isWeaponBadAtDistance (int weaponIndex, float distance);
@ -830,6 +828,7 @@ private:
bool updateLiftHandling ();
bool updateLiftStates ();
bool canRunHeavyWeight ();
bool isEnemyInSight (Vector &endPos);
void doPlayerAvoidance (const Vector &normal);
void selectCampButtons (int index);
@ -920,12 +919,13 @@ private:
edict_t *lookupBreakable ();
edict_t *setCorrectGrenadeVelocity (const char *model);
const Vector &getEnemyBodyOffset ();
Vector getEnemyBodyOffset ();
Vector calcThrow (const Vector &start, const Vector &stop);
Vector calcToss (const Vector &start, const Vector &stop);
Vector isBombAudible ();
Vector getBodyOffsetError (float distance);
Vector getCampDirection (const Vector &dest);
Vector getCustomHeight (float distance);
uint8_t computeMsec ();