Skip to content

Conversation

@sunzenshen
Copy link
Contributor

Description

Minimum viable bot detection for smoke.

Toolchain

  • Windows MSVC VS2022

Linked Issues

@sunzenshen sunzenshen requested a review from a team July 29, 2025 10:09
@AdamTadeusz AdamTadeusz self-requested a review July 29, 2025 14:07
@AdamTadeusz
Copy link
Contributor

untitled.mp4

Something's wrong

@DESTROYGIRL
Copy link
Contributor

Wonder if this will make jeff blind in smoke since CNEO_NPCTargetSystem tests for MASK_BLOCKLOS?

@sunzenshen sunzenshen force-pushed the bot-smoke-line-of-sight-blocker branch 3 times, most recently from df71957 to e51958f Compare July 30, 2025 04:22
@sunzenshen
Copy link
Contributor Author

sunzenshen commented Jul 30, 2025

Diagnosed the issue as hitbox tracelines colliding with the LOS Blocker entity, which prevented damage.

Added a ShouldCollide that filters UTIL_TraceLines with CONTENTS_HITBOX, that skips the LOS Blocker and evaluates as normal.

bot_smoke_hitbox_fix_1.mp4
bot_smoke_hitbox_fix_2.mp4

@sunzenshen
Copy link
Contributor Author

sunzenshen commented Jul 30, 2025

Wonder if this will make jeff blind in smoke since CNEO_NPCTargetSystem tests for MASK_BLOCKLOS?

Not with the current commits right now after some more testing, but I could take a look if that's something players are interested in.

@sunzenshen
Copy link
Contributor Author

sunzenshen commented Jul 30, 2025

With the current approach, you'll need to add NPC and CONTENTS_DEBRIS masks to your NPC Tank code. Let me know how we feel about this approach in general.

bot_smoke_detection_jeff_2.mp4

@sunzenshen sunzenshen requested review from DESTROYGIRL and removed request for a team July 30, 2025 06:25
@sunzenshen sunzenshen force-pushed the bot-smoke-line-of-sight-blocker branch from 3770971 to 4bac8df Compare July 30, 2025 06:47
@Rainyan Rainyan self-requested a review July 30, 2025 10:19
@AdamTadeusz
Copy link
Contributor

AdamTadeusz commented Jul 30, 2025

I'm not too fond of adding CONTENTS_DEBRIS to neo_npc_targetsystem and nextbotvisioninterface. I would personally revert the changes to those files, and do this in neo_smokelineofsightblocker.h instead

#ifndef NEO_SMOKELOSBLOCKER_NEO_H
#define NEO_SMOKELOSBLOCKER_NEO_H
#ifdef _WIN32
#pragma once
#endif

#include "cbase.h"

#define SMOKELINEOFSIGHTBLOCKER_ENTITYNAME	"env_smokelineofsightblocker"


class CNEOSmokeLineOfSightBlocker : public CBaseEntity {
public:
	DECLARE_CLASS(CNEOSmokeLineOfSightBlocker, CBaseEntity);
	DECLARE_DATADESC();

	void Spawn() override {
		BaseClass::Spawn();
		SetSolid(SOLID_BBOX);
		SetCollisionBounds(m_mins, m_maxs);
		SetSolidFlags(FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST);
	}

	static bool m_bNextEntitySeesThroughSmoke;
	bool TestCollision(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr) override
	{
		if (fContentsMask & CONTENTS_BLOCKLOS)
		{
			if (m_bNextEntitySeesThroughSmoke)
			{
				return false;
			}

			tr.fraction = 0.f; // NEO NOTE (Adam) Shouldn't returning true be enough? Should we calculate correct value for the fraction?
			return true;
		}
		return false;
	}

	bool TestHitboxes(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr) override
	{ // NEO NOTE (Adam) Shotguns used to use hulls for half of their pellets, not sure if this los blocker would have affected that, check if/when any weapons do again
		return false;
	}

	void SetBounds(const Vector& mins, const Vector& maxs) { m_mins = mins; m_maxs = maxs; }

private:
	Vector m_mins, m_maxs;
};

bool CNEOSmokeLineOfSightBlocker::m_bNextEntitySeesThroughSmoke = false;

#endif // NEO_SMOKELOSBLOCKER_NEO_H

Not sure if this is the correct way to do it, but it seems to me to be at least slightly better than what you have now

sunzenshen added a commit to sunzenshen/neo that referenced this pull request Jul 31, 2025
Removes debris collision property in favor of a custom entity type with manually defined collision and hit handling.

Credit: @AdamTadeusz

NeotokyoRebuild#1247 (comment)

Also reverts changes related to debris-based collision properties.
@sunzenshen
Copy link
Contributor Author

I would personally revert the changes to those files, and do this in neo_smokelineofsightblocker.h instead

Those changes work well on my setup, though one thing to point out is that this also blocks the NPC tank vision on nt_rogue_ctg. As discussed on Discord, there's arguments for not blocking smoke LOS for that situation. Do we want to address that edge case in this PR or a different PR?

@sunzenshen
Copy link
Contributor Author

  if (fContentsMask &= CONTENTS_BLOCKLOS)

The = is probably a typo, which was affecting collisions with physics objects. Tweaked this line to avoid overwriting fContentsMask.

smoke_phys_collision.mp4

@AdamTadeusz
Copy link
Contributor

AdamTadeusz commented Jul 31, 2025

@sunzenshen I've updated the code snippet above to include a static bool m_bNextEntitySeesThroughSmoke. Assuming the vision checks are NOT done in parallel, this can then be set to true before the tracelines are done to ignore smokes. In the case of nextbots, I add the following to IsLineOfSightClearToEntity before the trace lines (and an import for neo_player.h and neo_smokelineofsightblocker.h)

#ifdef NEO
	auto neoPlayer = static_cast<CNEO_Player*>(GetBot()->GetEntity());
	CNEOSmokeLineOfSightBlocker::m_bNextEntitySeesThroughSmoke = neoPlayer ? neoPlayer->GetClass() == NEO_CLASS_SUPPORT : false;
#endif // NEO

For jeff, before the loop through all clients in CNEO_NPCTargetSystem::Think (and also the import neo_smokelineofsightblocker.h)

	CNEOSmokeLineOfSightBlocker::m_bNextEntitySeesThroughSmoke = true;

As long as every entity that checks for smokes updates the value before the traceline, it shouldn't be necessary to update the value again after the traceline, but maybe you want to set it to false afterwards just in case anyway

sunzenshen added a commit to sunzenshen/neo that referenced this pull request Aug 1, 2025
Removes debris collision property in favor of a custom entity type with manually defined collision and hit handling.

Credit: @AdamTadeusz

NeotokyoRebuild#1247 (comment)

Also reverts changes related to debris-based collision properties.
@sunzenshen sunzenshen force-pushed the bot-smoke-line-of-sight-blocker branch 2 times, most recently from c33416e to ee57001 Compare August 1, 2025 06:34
@Rainyan
Copy link
Collaborator

Rainyan commented Aug 1, 2025

@sunzenshen Is this ready for review?

@sunzenshen
Copy link
Contributor Author

@sunzenshen Is this ready for review?

Yup, I'm ready for review.

Rainyan
Rainyan previously approved these changes Aug 1, 2025
Copy link
Collaborator

@Rainyan Rainyan left a comment

Choose a reason for hiding this comment

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

LGTM

Removes debris collision property in favor of a custom entity type with manually defined collision and hit handling.

Credit: @AdamTadeusz

NeotokyoRebuild#1247 (comment)

Also reverts changes related to debris-based collision properties.
Typo with extra = mask logic cleared physics masks
Assumes NextBot is single-threaded
@sunzenshen sunzenshen force-pushed the bot-smoke-line-of-sight-blocker branch from ee57001 to 7488d29 Compare August 2, 2025 00:05
@sunzenshen sunzenshen requested a review from Rainyan August 2, 2025 02:29
@sunzenshen sunzenshen merged commit 3958948 into NeotokyoRebuild:master Aug 2, 2025
7 checks passed
sunzenshen added a commit that referenced this pull request Aug 2, 2025
Removes debris collision property in favor of a custom entity type with manually defined collision and hit handling.

Credit: @AdamTadeusz

#1247 (comment)

Also reverts changes related to debris-based collision properties.
@sunzenshen sunzenshen deleted the bot-smoke-line-of-sight-blocker branch September 21, 2025 16:17
@DESTROYGIRL DESTROYGIRL added the Bots Related to bot players label Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bots Related to bot players

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants