Skip to content

[HL2DM] Add missing NPC relationship tables#1840

Open
YourSourceBoiii wants to merge 2 commits intoValveSoftware:masterfrom
YourSourceBoiii:relationshiptables
Open

[HL2DM] Add missing NPC relationship tables#1840
YourSourceBoiii wants to merge 2 commits intoValveSoftware:masterfrom
YourSourceBoiii:relationshiptables

Conversation

@YourSourceBoiii
Copy link
Copy Markdown

ISSUE: NPC relationship tables are missing in Half Life 2 Deathmatch. This makes it so that any spawned NPC will do nothing, as they don't know whether to like / fear / attack any players or other NPCs.

There is still a surprising amount of players in HL2DM who like to play gamemodes where NPCs are vital. Having working relationship tables (and thus working NPCs) by default would be greatly appreciated.

FIX: Copy and paste the InitDefaultAIRelatonships() code over from hl2_gamerules.cpp to hl2mp_gamerules.cpp

@WonderlandWar
Copy link
Copy Markdown

WonderlandWar commented Mar 14, 2026

This shouldn't be pulled, it would break a lot of coop maps because a lot of them were made knowing that certain NPCs are neutral to each other. For instance, a lot of coop maps have both headcrabs and vortigaunts but they don't fight each other because the aliens are meant to be enemies to the players and not to each other. This PR would break a lot of coop maps because NPCs would be fighting each other a lot which is not the intent of the vast majority of coop maps.

@JoriKos
Copy link
Copy Markdown
Contributor

JoriKos commented Mar 14, 2026

Would it be possible to make this functionality console command-based? That would avoid breaking existing maps (as they can simply change the console command), while still being able to use this in future maps/servers.

@YourSourceBoiii
Copy link
Copy Markdown
Author

YourSourceBoiii commented Mar 14, 2026

This shouldn't be pulled, it would break a lot of coop maps because a lot of them were made knowing that certain NPCs are neutral to each other. For instance, a lot of coop maps have both headcrabs and vortigaunts but they don't fight each other because the aliens are meant to be enemies to the players and not to each other. This PR would break a lot of coop maps because NPCs would be fighting each other a lot which is not the intent of the vast majority of coop maps.

Fuck those coop maps. 1st of all the NPCs are not neutral to each other because their relationship isn't defined, if they would be they'd have DT_NU set. 2nd of all the relationship tables I added are the ones from HL2 and that's how it's supposed to be. 3rd of all everybody who hosts a coop server right now easily knows how to compile their own server dll and add in their own relationship tables because NPCs are so broken in HL2DM that you need to know how to do that to even run a coop server. It doesn't even break the classtables so you wouldn't even need to compile a new server dll if it gets in. But all you server owners will act like it's the end of the world like always.

And oh yeah fishing, sv_cheats and RP servers exist too and make use of these NPCs. The people who host those are generally not capable enough to fix this themselves but they would like to play with NPCs too. The benefits of fixing it for everybody and simply outweigh breaking a few coop maps and the opinion of some highly capable coop server owners IMO

@WonderlandWar
Copy link
Copy Markdown

WonderlandWar commented Mar 14, 2026

Replying to #1840 (comment)

  1. I know their relationships aren't defined neutral as far as code is concerned, what I meant by "neutral" is that NPCs aren't fighting each other which is what the vast majority of coop maps intend.
  2. It's true that's what it's supposed to be, but breaking 20 years of coop maps isn't worth the benefit (especially since relationships can be easily setup with map logic anyways).
  3. Some players don't want to host modded servers to make the maps functional, and they shouldn't be expected to because the game has allowed them to for 20 years.

Fishing maps are far more niche nowadays than they were before and RP servers rarely use real NPC AI. RP servers require mods, and if the server has a programmer (which is far more likely than not), then adding relationships wouldn't be a problem.
There is an entire gamebanana page for coop maps for hl2dm: https://gamebanana.com/mods/cats/5331
and this isn't even all of them because most coop maps can be found by downloading them from servers.

The main question I want to ask is how this PR really helps anything. Mappers can easily setup relationships for their maps and it's not difficult to add relationships with server mods. On the other hand, it's only going to ruin the functionality of the many many coop maps that exist.

@YourSourceBoiii
Copy link
Copy Markdown
Author

YourSourceBoiii commented Mar 15, 2026

Replying to #1840 (comment)

"20 years of coop maps". 95% of coop maps have only 1 or 2 enemy types in a room / segment at once, and when they do have 2 enemy types they're literally always from the same "faction" (for example zombie + headcrabs, or combine soldiers + manhacks, etc.) so they wouldn't even be negatively effected. Of the maps that would be negatively effected probably half of them are "exclusive" maps which server owners keep for themselves by serving bsp files without the entity lumps in them. Those wouldn't be negatively effected either because those servers are already running their own custom binaries

I understand that you have strong opinions about this because you make coop maps and did dev work for a coop server, but there's really no need to exaggerate the impacts of this change. Only a few maps would be effected by this and they don't matter because coop is boring anyways. It would be more fun if you can have NPCs functional like in HL2 on any map and any gamemode without having to add a bunch of entities. It would make more sense and greatly lower the barrier of entry for people to play with them

@JoriKos
Copy link
Copy Markdown
Contributor

JoriKos commented Mar 15, 2026

I'd like to re-ask my question, wouldn't it be better to add a ConVar to determine if it should have old or new behaviour? That way you can have the new maps set the console command to the new behaviour, and old co-op maps aren't broken.

Even if you think they are a niche part of the game, seeing as how the game has 280 peak players today (and goes up to ~300 players each day for a really really long time) I think you can consider the entire game niche and arguing that it's okay to break those maps rather than work out a compromise seems like a weird choice.

@WonderlandWar
Copy link
Copy Markdown

WonderlandWar commented Mar 15, 2026

Replying to #1840 (comment)

I'm all for this, so long as the ConVar is off by default.

@henk717
Copy link
Copy Markdown

henk717 commented Mar 19, 2026

Its not just coop maps. Theres a ton of content in the game that relies upon manually defining ai relationships. You don't need this change at all since anyone can already define these even without modding the game.

If you need this for a level just copy the default ones replicate them as ai_relationships in a vmf file and now you have a template.

But frankly if you don't care about the content that actually uses these things you shouldn't be the one trying to decide whats best for the game Leave that to us who actually know and care about keeping the game running.

NPC infighting is not a problem btw compared to the real issue. I happen to have this exact cvar in my codebase that people are suggesting. If this is on by default it will make vortigaunts player allies. The maps however make them enemies. Wanna know what the result is? Immortal hostile vortigaunts. For that reason even though I added it as an experiment hoping it would fix maps that lack the relationships it broke far more than it ever fixed. So I went with different approaches instead.

@vadim-ktnkv
Copy link
Copy Markdown

vadim-ktnkv commented Mar 25, 2026

Replying to #1840 (comment)

You know what, buddy? You're the problem here, not the coop maps. When I was depressed and felt like life had no meaning, I decided to go back to coop servers because of the warm memories I had from the early 2010s. And you know what? Playing coop and having a community to talk to about anything helped me and a few other guys find a ray of hope. It gave me the strength to seek treatment, and now I’ve recovered and can lead a normal life. So don't be so quick to judge coop servers when you have no idea what they mean to people.

@YourSourceBoiii
Copy link
Copy Markdown
Author

Its not just coop maps. Theres a ton of content in the game that relies upon manually defining ai relationships.

Such as?

Leave that to us who actually know and care about keeping the game running.

Wtf did you ever do to keep HL2DM running? You've been hosting your shitty coop server since 2009 and never did you share any of your plugins, maps or server files. You never shared bugfixes, made a PR in this repo, or hosted a mapping contest to get people to make more content for HL2DM. The only thing you know and care about is getting more players on your server, to the point that you made unverifiable claims about a competing community and scared a bunch of people into blocking them

NPC infighting is not a problem btw

Exactly what I already said

Wanna know what the result is? Immortal hostile vortigaunts.

This is probably an issue on only a few maps, half of which are exclusive to your server anyways. Easily fixable by making a plugin or editing the map files

@YourSourceBoiii
Copy link
Copy Markdown
Author

Replying to #1840 (comment)

You know what, buddy? You're the problem here, not the coop maps. When I was depressed and felt like life had no meaning, I decided to go back to coop servers because of the warm memories I had from the early 2010s. And you know what? Playing coop and having a community to talk to about anything helped me and a few other guys find a ray of hope. It gave me the strength to seek treatment, and now I’ve recovered and can lead a normal life. So don't be so quick to judge coop servers when you have no idea what they mean to people.

Good for you. I'm not your buddy though. There's people out there who deeply care about other types of gamemodes too and they don't have server owners who know how to fix issues with NPCs

@JoriKos
Copy link
Copy Markdown
Contributor

JoriKos commented Mar 26, 2026

I'd like to ask again, @YourSourceBoiii, what's the issue with making it ConVar-based?

@henk717
Copy link
Copy Markdown

henk717 commented Mar 26, 2026

Replying to #1840 (comment)

Keep in mind that I ultimately don't have to care about this whole debate, I do it out of passion for the game not out of self interest. If you manage to get this PR in it literally won't impact me and will just ensure these classic maps run well on my server and that people wanting to enjoy them have to come to places like bouncy to play them.

NPC infighting would be a problem because they are meant to target players and not be distracted off screen, I just said its not that big of a deal compared to all the other issues you are introducing into the game by adding this.

You say what other gamemodes, I'm going to flip that question. What gamemodes or things would actually benefit from your change? Name a single one. Actually, lets just go trough the list.

Would deathmatch benefit from your PR? No, NPC's might be there as decoration on a map. If they now turn hostile unintentionally that would not be good. If they are intended to be hostile like on that one antlion cave map they already will be.

Whats next... Roleplay servers. Would roleplay servers benefit from this PR? No, because the friendly status to the player could make a NPC vendor move from its original location its meant to be at. Or, if they used a hostile NPC for a vendor and made it immortal so it can't be killed they now have the same issue as the co-op maps do.

Would puzzle servers benefit from the PR? No, because they to rely on the NPC's being exactly as they defined and some of them might have vortigaunts which could lead to the immortal enemies issue.

Would zombie survivor servers benefit from this PR? Well, if there is a zombie survival server they probably already have attacking zombies. And if a map has a vortigaunt you're introducing the immortal vortigaunt bug.

Would cheat/script servers benefit from this PR? Nope. Once again they need the flexibility of defining what the NPC's do. You don't need these relationships at all on a cheat server, you could for example easily spawn a timer that makes the NPC's hostile on spawn. You'd make one script defining all these default behaviors and you'd get the exact thing you are trying to PR. So for cheat servers its also a no.

Would co-op servers benefit from this PR? No because you are going to break over 100 coop maps that are made for the vanilla game. The kind of map this does help is the same kind of map that needs a custom server build to begin with to work correctly. What you will instead do is completely kill off the self hosting of coop maps and force groups of friends to play on well maintained coop servers with classic maps.

Would fishing servers benefit form this PR? No, every fishing map I have ever seen has the correct AI relationships set just like the co-op maps. Wanna know what they also have? Vorts. Having a vort snipe you constantly is already annoying on fishing maps when you have no guns. Want to know whats worse? An immortal vortigaunt that this would introduce.

You seem to dislike me and just make unfounded claims. I ran the competitive servers for a while helping the competitive community. I helped the socal community get a proper dedicated server which underlying OS I help maintain for them. I helped that server get more content. I've warned other server owners when their servers were insecure back in the day where this was a bigger issue. My map fixes that end in _bb were never protected and other server owners have taken them.

I made the firewall script not because of some "Fearmongering" but to combat real spam. A picture says more than a thousand words they say right? Explain me being on every server at once if I joined only one of them and this fake bouncy hosting deathmatch maps.
fakespamproof

There actually was a mapping contest : https://steamcommunity.com/groups/bouncyball/announcements/detail/1294065920988893057

But I'm getting to far off topic.

The topic remains that you are trying to make a change that impacts the wider community that doesn't want this change, and only experienced server owners have the ability to resist it. That's not good.

If you want to make this cvar based and have it be OPT IN (because they don't go away when the cvar is turned off at least not on my version and new players wouldn't have a clue about it) then I actually don't object. Options are fine.

But you never shared your motive here, what are you Actually trying to achieve? What is impossible that requires this fix? Because it would be trivial to find a better solution without valve merging this, and lets be honest they don't usually merge these PR's even for actual bug fixes to the game that are tried and tested.

If you come with an open mind and seek a solution for your use case then:

  1. You can just ask the community for help on how to solve the issue.
  2. You can add this behind a cvar and just turn the cvar on.

@YourSourceBoiii
Copy link
Copy Markdown
Author

Would deathmatch benefit from your PR? No, NPC's might be there as decoration on a map.

Literally nobody does that

Whats next... Roleplay servers. Would roleplay servers benefit from this PR?

Yes, because hostile NPCs would attack the players

Would puzzle servers benefit from the PR? No, because they to rely on the NPC's being exactly as they defined and some of them might have vortigaunts which could lead to the immortal enemies issue.

NPC use in puzzles is extremely rare and the few times that I have seen them used they are hostile and unkillable. I cannot think of a single puzzles map which would break if this got accepted

Would cheat/script servers benefit from this PR? Nope. Once again they need the flexibility of defining what the NPC's do. You don't need these relationships at all on a cheat server, you could for example easily spawn a timer that makes the NPC's hostile on spawn. You'd make one script defining all these default behaviors and you'd get the exact thing you are trying to PR. So for cheat servers its also a no.

Yes they would benefit and what you're saying here is complete nonsense. You can't use the ai_relationship entities because those need to be fired with an input to work and ent_fire is disabled for anybody other than listen server hosts by default (and it's not easy or straightforward to get it working for anybody else). Furthermore running any cfg script will get you kicked nowadays since the 2025 update made it so that by default servers will autokick you if you do too many commands at once.
And oh yeah, everybody I have ever met in scripting servers just wanted to spam tons of NPCs that shoot at each other, which would be possible without having to know about a ton of esoteric Source engine shit if this PR got accepted

Would co-op servers benefit from this PR? No because you are going to break over 100 coop maps.

Less than 100 coop maps would break

As for the fishing maps, I was unaware about that and if it's not too difficult I'm willing to add a convar to this PR that would allow vorts and other NPCs to toggle their invincibility

You seem to dislike me and just make unfounded claims. I ran the competitive servers for a while helping the competitive community. I helped the socal community get a proper dedicated server which underlying OS I help maintain for them. I helped that server get more content. I've warned other server owners when their servers were insecure back in the day where this was a bigger issue. My map fixes that end in _bb were never protected and other server owners have taken them.

All of this shit is marginal compared to the tons of exclusive plugins, maps and server files you have. "I helped a random community configure their linux once", if you cared about the game you would release some stuff for everybody to enjoy and use instead of hoarding it for 17 years

I made the firewall script not because of some "Fearmongering" but to combat real spam.

Yes and then you made the claim that they're stealing steam auth tickets which has literally never been proven.

But you never shared your motive here, what are you Actually trying to achieve?

Use your eyes and read the replies I made previously

@YourSourceBoiii
Copy link
Copy Markdown
Author

I'd like to ask again, @YourSourceBoiii, what's the issue with making it ConVar-based?

I personally don't think everybody should be given an option to revert the game back to a broken state just because some dudes on a coop server are too lazy to edit a few really old map files

@JoriKos
Copy link
Copy Markdown
Contributor

JoriKos commented Mar 27, 2026

Replaying to #1840 (comment)

This is a bad mentality though, you want to be accomodating to the whole playerbase. Especially when the effort of adding a ConVar seems to be very minimal, and when the average playercount doesn't even reach 300 most days I don't think you can really afford to have a personal gripe against people that don't want to decompile maps, edit the maps, and recompile maps. This kind of PR should never be accepted with this kind of mindset behind it.

@henk717
Copy link
Copy Markdown

henk717 commented Mar 27, 2026

I personally don't think everybody should be given an option to revert the game back to a broken state just because some dudes on a coop server are too lazy to edit a few really old map files

You are missing the point completely. Servers like mine aren't to lazy to edit "a few" (Meaning 100+) maps. From the perspective of my own server go right ahead with this PR and break it for everyone else I don't have to care about it because the code would never even reach my server.

What you are breaking aren't the "Server owners who are to lazy to edit a few maps" its people who want to play a specific co-op map with a friend on a listen server. They have absolutely zero clue how to fix this. And, they can't "Edit a few maps" to fix this. You are forgetting that there is no such thing as defining an empty state. Once you set it they can't get rid of it anymore short of running their own custom builds of hl2dm.

So again, since you seem to hate co-op servers so much by all means continue with your push with this and create a duopoly of servers capable of running them. (I am being sarcastic here for those who otherwise like taking me out of context, obviously I am only rebutting this PR to protect people who want to play these maps locally with a friend).

(Roleplay) Yes, because hostile NPCs would attack the players

This is not something that roleplay servers want, and if they do they can either define this with their roleplay plugin or have the entity on a map. I know of one particular roleplay server who had this as an event kinda thing on the map, the enemies attacked just fine. But you are going to break the servers where the NPC's are just meant to be a vendor and not do anything. So it once again benefits nobody and just breaks stuff.

NPC use in puzzles is extremely rare

I never played them to much, but I recall a lot of them having end rooms. But notice what you are saying here, if there are invincible NPC's on the map the last thing you want to do is turn those hostile against the mappers wishes.

Yes they would benefit and what you're saying here is complete nonsense. You can't use the ai_relationship entities because those need to be fired with an input to work and ent_fire is disabled for anybody other than listen server hosts by default (and it's not easy or straightforward to get it working for anybody else).

You know nothing about this games ecosystem and it shows. Every respectable cheat server runs a plugin that automatically fires mp_disable_autokick for everyone joining which disables the very protections you speak off. Its not complicated to setup at all, just install this : https://forums.alliedmods.net/showthread.php?p=665602 and then combine it with a plugin that blocks unsafe commands like rcon password takeovers / point_servercommand entities, etc. The proper cheat servers all have this and on any of them you can do this fine. On a listen server you can type it manually for the people playing with you, and if you have your own dedicated cheat server you can install the plugin. Alternatively you could host your self compiled SDK2013 with this change baked in, host a modified gm_flatgrass with the ai_relationships on the maps etc.

Without ent_fire there is no point in having a cheat server so we can assume that ent_fire is available.
Here is a one liner : ent_fire npc* setrelationship "player d_ht 99"
But again if you wanted to host a server where npc's attack by default just have a single ai_relationship baked into the map which sets npc_* to hate the player. Takes one entity, they attack now.

Less than 100 coop maps would break

Maybe take the word of the guy who reviewed your code and knows it from experience over randomly saying its not true.
Remember how combines were always broken in the game? That means the only proper ranged enemy maps can use are vortigaunts. That means almost every co-op map has a vortigaunt on it. 100 was actually a conservative estimate since there are over 200 co-op maps in the game. You are turning all the vortigaunts immortal with the PR as is, so you are breaking 100+ maps.

I'm willing to add a convar to this PR that would allow vorts and other NPCs to toggle their invincibility

Step in the right direction, but its easier to just make your change opt in instead of trying to force it onto everyone.

stealing steam auth tickets

My claims get taken out of context sometimes. I said they were fueling the fake servers with auth tickets from the players joining them. This is demonstrably true because without that you can't rank fake players on the master server, you'd join the proxy server and when you left it wouldn't register the disconnect. Keeping that ticket active as long as possible.

Normal servers use the exact same tickets for player verification, but release them on disconnect.

Anyway I am done larping that this discussion matters. We all know valve isn't going to merge this, but people asked me to weigh in on it and give my opinions so I did it for them. I mostly just find it sad to see that you are so unwilling to listen and integrate the feedback. You could have cvar gated it and turned this from a disaster for the game to cool feature, multiple people asked you to. You didn't listen.

In the off chance that this does get merged as is and server owners now have broken servers as a result I dont mind helping the linux based servers out in getting a build of the game with the change removed if they need me to.

I think I said about everything there is to say on the matter in case people ever want to understand why the game depends on having these undefined by default.

@YourSourceBoiii
Copy link
Copy Markdown
Author

YourSourceBoiii commented Mar 28, 2026

@henk717 so much nonsense in your reply, I'm not even gonna take the time to respond again because you just come up with new bullshit claims every time

Anyway I am done larping that this discussion matters.

And yet you still cared enough to reply to it on a friday at midnight

@JoriKos
Copy link
Copy Markdown
Contributor

JoriKos commented Mar 28, 2026

And yet you still cared enough to reply to it on a friday at midnight

https://en.wikipedia.org/wiki/Time_zone ?

@vadim-ktnkv

This comment was marked as off-topic.

@YourSourceBoiii

This comment was marked as off-topic.

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.

5 participants