aim: added optional hitbox-based aiming for bots (ref #579)

This commit is contained in:
jeefo 2024-06-02 23:03:12 +03:00
commit 8dece62df6
No known key found for this signature in database
GPG key ID: D696786B81B667C8
6 changed files with 264 additions and 3 deletions

View file

@ -48,7 +48,8 @@ CR_DECLARE_SCOPED_ENUM (GameFlags,
HasBotVoice = cr::bit (11), // on that game version we can use chatter
AnniversaryHL25 = cr::bit (12), // half-life 25th anniversary engine
Xash3DLegacy = cr::bit (13), // old xash3d-branch
ZombieMod = cr::bit (14) // zombie mod is active
ZombieMod = cr::bit (14), // zombie mod is active
HasStudioModels = cr::bit (15) // game supports studio models, so we can use hitbox-based aiming
)
// defines map type
@ -70,6 +71,18 @@ CR_DECLARE_SCOPED_ENUM (EntitySearchResult,
Break
)
// player body parts
CR_DECLARE_SCOPED_ENUM (PlayerPart,
Head = 1,
Chest,
Stomach,
LeftArm,
RightArm,
LeftLeg,
RightLeg,
Feet // custom!
)
// variable reg pair
struct ConVarReg {
cvar_t reg;
@ -112,6 +125,29 @@ public:
}
};
// player model part info enumerator
class PlayerHitboxEnumerator final {
public:
struct Info {
float updated {};
Vector head {};
Vector stomach {};
Vector feet {};
Vector right {};
Vector left {};
} m_parts[kGameMaxPlayers] {};
public:
// get's the enemy part based on bone info
Vector get (edict_t *ent, int part, float updateTimestamp);
// update bones positions for given player
void update (edict_t *ent);
// reset all the poisitons
void reset ();
};
// provides utility functions to not call original engine (less call-cost)
class Game final : public Singleton <Game> {
public:
@ -353,6 +389,11 @@ public:
m_gameFlags |= type;
}
// clears game flag
void clearGameFlag (const int type) {
m_gameFlags &= ~type;
}
// gets the map type
bool mapIs (const int type) const {
return !!(m_mapFlags & type);