Skip to content

Conversation

@AdamTadeusz
Copy link
Contributor

Description

Previously the bots would always shoot center mass, but IsLineOfSightClearToEntity checks center mass, eye pos and origin. This pr adds a map to NextBotVisionInterface that stores the ideal position for the bot to aim at when shooting at entities.

@AdamTadeusz AdamTadeusz requested a review from a team July 31, 2025 12:19
@AdamTadeusz AdamTadeusz changed the title NeoNextBots shoot at visible parts of other clients NeoNextBots shoot at visible parts of other entities Jul 31, 2025
Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if any of these recommendations don't make sense for the context.

@sunzenshen sunzenshen requested a review from a team August 1, 2025 03:27
@Rainyan Rainyan requested review from Rainyan and removed request for a team August 15, 2025 12:06
@AdamTadeusz AdamTadeusz requested a review from sunzenshen August 15, 2025 13:05
sunzenshen
sunzenshen previously approved these changes Aug 16, 2025
Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better in bot matches now. The way to check this behavior is to load up nt_bullet and verify that the bots don't try to shoot through the seats of the train when they see an enemy behind the obstacle.

@nullsystem
Copy link
Collaborator

This can be changed to give headshot aiming a higher precedence. Somewhere down the line when there's ability to customize bots can be used to differentiate "experts" and "normal" bots for example and add more logics like weapon type and distance.

diff --git a/src/game/server/NextBot/NextBotVisionInterface.cpp b/src/game/server/NextBot/NextBotVisionInterface.cpp
index 5b9474fc..d316e072 100644
--- a/src/game/server/NextBot/NextBotVisionInterface.cpp
+++ b/src/game/server/NextBot/NextBotVisionInterface.cpp
@@ -773,6 +773,18 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
        trace_t result;
        NextBotTraceFilterIgnoreActors filter( subject, COLLISION_GROUP_NONE );

+#ifdef NEO
+       UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->EyePosition(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+       if ( result.DidHit() )
+       {
+               UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->WorldSpaceCenter(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+
+               if ( result.DidHit() )
+               {
+                       UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->GetAbsOrigin(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+               }
+       }
+#else
        UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->WorldSpaceCenter(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
        if ( result.DidHit() )
        {
@@ -783,6 +795,7 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
                        UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->GetAbsOrigin(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
                }
        }
+#endif

        if ( visibleSpot )
        {

@AdamTadeusz
Copy link
Contributor Author

This can be changed to give headshot aiming a higher precedence. Somewhere down the line when there's ability to customize bots can be used to differentiate "experts" and "normal" bots for example and add more logics like weapon type and distance.

diff --git a/src/game/server/NextBot/NextBotVisionInterface.cpp b/src/game/server/NextBot/NextBotVisionInterface.cpp
index 5b9474fc..d316e072 100644
--- a/src/game/server/NextBot/NextBotVisionInterface.cpp
+++ b/src/game/server/NextBot/NextBotVisionInterface.cpp
@@ -773,6 +773,18 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
        trace_t result;
        NextBotTraceFilterIgnoreActors filter( subject, COLLISION_GROUP_NONE );

+#ifdef NEO
+       UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->EyePosition(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+       if ( result.DidHit() )
+       {
+               UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->WorldSpaceCenter(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+
+               if ( result.DidHit() )
+               {
+                       UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->GetAbsOrigin(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+               }
+       }
+#else
        UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->WorldSpaceCenter(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
        if ( result.DidHit() )
        {
@@ -783,6 +795,7 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
                        UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->GetAbsOrigin(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
                }
        }
+#endif

        if ( visibleSpot )
        {

I think shooting center mass should be the default?

@nullsystem
Copy link
Collaborator

This can be changed to give headshot aiming a higher precedence. Somewhere down the line when there's ability to customize bots can be used to differentiate "experts" and "normal" bots for example and add more logics like weapon type and distance.

diff --git a/src/game/server/NextBot/NextBotVisionInterface.cpp b/src/game/server/NextBot/NextBotVisionInterface.cpp
index 5b9474fc..d316e072 100644
--- a/src/game/server/NextBot/NextBotVisionInterface.cpp
+++ b/src/game/server/NextBot/NextBotVisionInterface.cpp
@@ -773,6 +773,18 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
        trace_t result;
        NextBotTraceFilterIgnoreActors filter( subject, COLLISION_GROUP_NONE );

+#ifdef NEO
+       UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->EyePosition(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+       if ( result.DidHit() )
+       {
+               UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->WorldSpaceCenter(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+
+               if ( result.DidHit() )
+               {
+                       UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->GetAbsOrigin(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
+               }
+       }
+#else
        UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->WorldSpaceCenter(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
        if ( result.DidHit() )
        {
@@ -783,6 +795,7 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
                        UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), subject->GetAbsOrigin(), MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
                }
        }
+#endif

        if ( visibleSpot )
        {

I think shooting center mass should be the default?

Regardless of bot difficulty even? Headshots been fairly effective I think at least hard/expert bots should aim more for the head.

sunzenshen
sunzenshen previously approved these changes Aug 19, 2025
Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was curious to know how 4e44af9 would affect the behavior of this PR, since there didn't seem to be a merge conflict.

Locally I rebased this branch on top of upstream/master e80e9b0 and observed some bot matches. Overall the behavior seems smooth, though I'm not sure if there's any redundancies in routines now. Up to you if you'd like to sanity test your expected behavior based on top of the latest master branch.

@Rainyan Rainyan removed their request for review August 24, 2025 22:03
@nullsystem nullsystem requested a review from sunzenshen August 27, 2025 23:29
Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loaded ntre_bullet and verified that bots now/still shoot over the train seats instead of previously trying to shoot through the seats all the time.

@AdamTadeusz AdamTadeusz merged commit b7a727a into NeotokyoRebuild:master Aug 28, 2025
7 checks passed
@AdamTadeusz AdamTadeusz deleted the 259_neoBotsAimAtVisibleLocation branch August 28, 2025 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants