Skip to content

Commit

Permalink
convert degrees to radians in fov check, use correct hitbox numbers, …
Browse files Browse the repository at this point in the history
…add random seed to command to give weapons spread
  • Loading branch information
AdamTadeusz committed Nov 9, 2024
1 parent b46431d commit 8b562b8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 10 deletions.
5 changes: 5 additions & 0 deletions mp/src/game/server/neo/bots/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,11 @@ void CBot::MimicThink( int playerIndex )
m_cmd->impulse = playercmd->impulse;
m_cmd->weaponselect = playercmd->weaponselect;
m_cmd->weaponsubtype = playercmd->weaponsubtype;
#ifdef NEO
m_cmd->random_seed = RandomInt(0, 255);
#else
m_cmd->random_seed = playercmd->random_seed;
#endif // NEO
m_cmd->mousedx = playercmd->mousedx;
m_cmd->mousedy = playercmd->mousedy;

Expand Down Expand Up @@ -478,6 +482,7 @@ void CBot::InjectButton( int btn )
if ( !GetUserCommand() )
return;

GetUserCommand()->random_seed = RandomInt(0, 255);
GetUserCommand()->buttons |= btn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ bool CBotDecision::ShouldRun() const
if ( GetLocomotion()->IsUsingLadder() )
return false;

#ifdef NEO
if (IsCombating())
return false;
#endif // NEO

if ( GetLocomotion()->IsRunning() )
return true;

Expand Down Expand Up @@ -1120,6 +1125,8 @@ BCOND CBotDecision::ShouldRangeAttack1()

if ( flDistance > pWeapon->GetWeaponInfo().m_flIdealDistance )
return BCOND_TOO_FAR_TO_ATTACK;
#elif NEO
// NEO TODO (Adam) ideal distances for different weapon types, code to get closer to enemy if enemy out of range
#elif HL2MP
if ( flDistance > 600.0f )
return BCOND_TOO_FAR_TO_ATTACK;
Expand Down
56 changes: 46 additions & 10 deletions mp/src/game/server/neo/bots/in_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,54 @@ bool Utils::GetEntityBones( CBaseEntity *pEntity, HitboxBones &bones )
bones.leftLeg = -1;
bones.rightLeg = -1;

#ifdef NEO
/*
NEOTODO: Something is wack about hitgroups. Hitgroup head helps keep bots shooting center mass, for some reason...
Make sure to update CBotProfile::SetSkill when testing.
*/
if ( pEntity->IsPlayer() ) {
bones.head = HITGROUP_CHEST;
bones.chest = HITGROUP_HEAD;
bones.leftLeg = HITGROUP_LEFTLEG;
bones.rightLeg = HITGROUP_RIGHTLEG;
#ifdef APOCALYPSE
if (pEntity->ClassMatches("npc_infected")) {
bones.head = 16;
bones.chest = 10;
bones.leftLeg = 4;
bones.rightLeg = 7;
return true;
}

if (pEntity->IsPlayer()) {
bones.head = 12;
bones.chest = 9;
bones.leftLeg = 1;
bones.rightLeg = 4;
return true;
}
#elif NEO
if (pEntity->IsPlayer())
{
bones.head = 12;
bones.chest = 10;
bones.leftLeg = 1;
bones.rightLeg = 5;
return true;
}
#elif HL2MP
enum
{
TEAM_COMBINE = 2,
TEAM_REBELS,
};

if (pEntity->IsPlayer()) {
if (pEntity->GetTeamNumber() == TEAM_REBELS) {
bones.head = 0;
bones.chest = 0;
bones.leftLeg = 7;
bones.rightLeg = 11;
return true;
}
else if (pEntity->GetTeamNumber() == TEAM_COMBINE) {
bones.head = 17;
bones.chest = 17;
bones.leftLeg = 8;
bones.rightLeg = 12;
return true;
}
}
#endif

return false;
Expand Down
8 changes: 8 additions & 0 deletions mp/src/game/shared/basecombatcharacter_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,11 @@ bool CBaseCombatCharacter::IsLookingTowards( const Vector &target, float cosTole
bool CBaseCombatCharacter::IsInFieldOfView( CBaseEntity *entity ) const
{
CBasePlayer *pPlayer = ToBasePlayer( const_cast< CBaseCombatCharacter* >( this ) );
#ifdef NEO // NEO NOTE (Adam) Even the default fov values defined in the original sdk provide values that are clearly in degrees, and this function isn't really used by anything else so I think its a safe assumption to assume GetFOV here returns degrees
float flTolerance = pPlayer ? cos(DEG2RAD((float)pPlayer->GetFOV() * 0.5f)) : BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE;
#else
float flTolerance = pPlayer ? cos( (float)pPlayer->GetFOV() * 0.5f ) : BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE;
#endif // NEO

Vector vecForward;
Vector vecEyePosition = EyePosition();
Expand Down Expand Up @@ -662,7 +666,11 @@ bool CBaseCombatCharacter::IsInFieldOfView( const Vector &pos ) const
CBasePlayer *pPlayer = ToBasePlayer( const_cast< CBaseCombatCharacter* >( this ) );

if ( pPlayer )
#ifdef NEO // NEO NOTE (Adam) See above note
return IsLookingTowards(pos, cos(DEG2RAD((float)pPlayer->GetFOV() * 0.5f)));
#else
return IsLookingTowards( pos, cos( (float)pPlayer->GetFOV() * 0.5f ) );
#endif // NEO

return IsLookingTowards( pos );
}
Expand Down

0 comments on commit 8b562b8

Please sign in to comment.