Open Shigbeard opened 6 years ago
Also I understand this gamemode has been released as is however I figured by submitting this bug onto the repo in the public domain, perhaps some individual may come along and go "yeah, I'll take this project under my wings" and fix it.
NPCs don't interact with the navmesh. Nextbot NPCs do.
The zombies aren't NextBot, they're just normal NPCs with some scripting thrown on top.. not SNPC's though.
The way they're spawned is by getting a trace down in an area around a player. If the trace hits the ground, it's considered valid. If it hits a prop, it is not.
A way to fix this, might be to trace from the player to the trace origin spot too to see if there is a collision with the world. You could ignore everything except world for this secondary trace as the problem only involves zombies spawning behind world geometry where there is 'ground' that it traced down and hit.
I doubt this is something I'll fix.. but if someone wants to submit a pull request, I'll review it and merge it if it works.
I fully understand these are default NPCs, but their spawning behavior has nothing to do with the fact they are or aren't nextbot. You can still utilize functions that interact with the navmesh in order to determine a "better" spawn point around the player.
Your proposition sounds promising, but certain edge cases may still occur where a position may be valid, but due to a piece of world geometry being in the way (say, a waist high fence), it would be considered an invalid spawn. My proposition, which to clarify is to check the spawn position found by the existing code to see if it is within a nav-mesh square, and if not, do not spawn, would prevent all cases of zombies spawning in places where they simply do not belong (Examples: behind walls where pieces of floor exist due to lazy mapping practices, sharp cliff faces, on top of cliff tops where the player would not logically stand).
The nav mesh would not need to aid in the navigation of the bots, but would aid in determining what the engine (or even the mapper) deems walkable space, and we can then simply say "if the space is walkable, the space is spawnable."
Again, I understand that SGS is released as is, you want to do other things with your life and thats cool. I'm simply throwing this idea out there incase someone else may wish to take it on (even I might, depending on how I feel, in which case I can reference this issue from the pull request, making things nice and clean because <3 github)
What is the problem?
In certain edge cases where the map's geometry is... shall we say... bethesda quality (that is, with pieces of geometry hidden behind cliff faces or out of bounds), Zombies tend to spawn in very irregular spots, and can sometimes compromise bases that would otherwise appear to be zombie-proof.
This creates an issue for people looking to build themed bases, or bases that are pleasant to look at. Due to the erroneous nature of zombie spawning, in combination with the way zombies tend to harm players that appear to be protected by props, the only guaranteed safe building method is to build a box in the sky, with a ramp access.
What do I think is the cause of the problem?
I think the problem originates from the way the gamemode detects "walkable space". You see this issue as well in Meteor spawns, basically the game considers any flat surface or near flat surface with a minimum amount of height clearance as walkable, and this simply isn't an accurate means of detecting walkable space.
How do I think this can be fixed?
The Source engine has a feature for identifying walkable spaces as well as notable points on the map for AI to use. This feature is called a Nav Mesh, and Garry's Mod has a Lua library for interacting with this feature, with functions such as navmesh.Find. As it is quite simple to generate a nav mesh for most maps, it would be reasonable to require maps to have a generated Nav Mesh in order to play the gamemode.
This only becomes an issue when we contemplate the following details...
In a few select circumstances, it may not be feasable let alone possible to generate a Nav Mesh for a map, which means that the gamemode would then simply not spawn zombies (or, on the other hand, fall back to erroneous code that can produce situations like this). This is why I propose another alternative, which would be harder to implement, more involved, and would ultimately rely on the player to play the game without abusing glitches such as surfing or bhopping.
This alternative would have the game actively map spaces that a player walks, naturally discarding data where the player has already been, where the player has been deep in water, where the player has been walking on a prop, etc. At first, this map of walkable space would be very incomplete and inaccurate, but over time it would hold more and more data for places where a player has stood, with their feet planted firmly on the ground, that the game could easily consider walkable.
The issue with this alternative is that the player may not move around the entire map, and so the data would almost always be incomplete, though it would be plentiful in regards to high traffic areas (such as around ore deposits, popular base locations, etc.