Garry's Mod

Garry's Mod

Auto Remove Stuck NPCs
105 Comments
Gorigo 14 Nov @ 6:28am 
theres should be option to check if entity cant move
我是小卡齐娜1903年 9 Aug @ 3:31am 
How this will works on a custom npc ???
Would be nice alternative option to teleport any friendly ally warp next to you, and add Resistance to the option pool
ZachNohKap 30 Mar @ 10:15pm 
@Winn thank you king!
Winn 30 Mar @ 10:26am 
Conflicts with Zippy's Active Ragdoll mod, they are detected as stuck when they ragdoll and are instantly deleted.
MrGermandeutsch 21 Mar @ 3:56pm 
Oh if only. But alas, it seems to just be a distant dream.
Coffee Man  [author] 21 Mar @ 3:54pm 
If only you'd have been specifically warned about that specific side effect in the description or something, am I right?
tactical dude 21 Mar @ 12:24pm 
Sadly it takes away some or even most of the npcs on the hl2 maps.
MrGermandeutsch 7 Mar @ 12:39am 
This is a blessing.
ZachNohKap 6 Mar @ 4:02pm 
Dude. You literally have a catgirl as your pfp.
Ben_19M 6 Mar @ 10:06am 
youre rather drab, mr mud
My Name is Mud 6 Mar @ 10:05am 
and i dress in blue yes navy blue
Ben_19M 6 Mar @ 9:38am 
is this the most boring sonsabitch ive ever seen?
Tixerx 6 Mar @ 6:36am 
Hello mud
My Name is Mud 6 Mar @ 6:26am 
my name is mud
Léa ♥ 6 Mar @ 12:01am 
Sorry for the formatting, the [code] tag is not supported in comments, I didn't know that, we lost the indentation. I sent you an invitation if you would like to discuss more, it will be with pleasure, I have a lot to learn ^^ Thank you
Léa ♥ 5 Mar @ 11:56pm 
@Coffee Man Thank you for this info !!
This code checks if the position of an npc has changed during 10s otherwise deletes it
[code]
local monitoredNPCs = {
"npc_zombie",
"npc_fastzombie",
"npc_poisonzombie",
"npc_zombine"
}

hook.Add("OnEntityCreated", "CheckStuckNPCs", function(_ent)
if GetConVar("a_cleanstucknpc"):GetBool() then
if IsValid(_ent) and _ent:IsNPC() then
if table.HasValue(monitoredNPCs, _ent:GetClass()) then
timer.Simple(1, function()
local _startpos = _ent:GetPos()
timer.Create(
tostring(_ent), 10, 0, function()
if IsValid(_ent) then
local _currentpos = _ent:GetPos()
if (_currentpos == _startpos) then
_ent:Remove()
timer.Remove(tostring(_ent))
else
_startpos = _currentpos
end
end
end
)
end
)
end
end
end
end)[/code]
Coffee Man  [author] 5 Mar @ 9:44pm 
@dvpweb

The structure of a trace in Gmod's Wiki uses start: https://wiki.facepunch.com/gmod/Structures/Trace

You can see a code example here as well: https://wiki.facepunch.com/gmod/util.TraceLine
Coffee Man  [author] 5 Mar @ 9:41pm 
@Doxhot
You're spawning wholeass dropships randomly in sandbox maps that can land and deploy soldiers xd? For that particular case, you'd need a solid 10 seconds before the NPC checks out ok. But the timer I put for the removal check is there to both make sure the NPC is initialized properly and to allow a quick cleanup if you're constantly spawning NPCs in close proximity to you as well.

@dvpweb
You can modify it, fork it, publish your version, whatever, I let anyone do that. But you still didn't explain why should start be changed with startpos. NPCs disappearing is probably due to how that specific spawner works. I may update this release and change the timer to something like 2 or 3 seconds to hopefully add a little bit more compatibility in general.
Léa ♥ 5 Mar @ 9:27pm 
@Coffee Man Yes sorry, I realized afterwards that my dev was becoming a little off topic my request is more linked to another addon and what's more I put my messages in FR without translating them. In fact, start does not work, you use endpos and logically I told myself that it was startpos to use in the query and indeed, it works better.
Säm 5 Mar @ 9:23pm 
I never play campaign maps, but that's fair. I like to avoid generic auto-summoning methods if I can
Léa ♥ 5 Mar @ 9:21pm 
This is exactly what I modified for the Simple Horde Mode addon, I put at least 10 seconds between each npc position test otherwise, they disappear shortly after being created. I will see about publishing the script
Coffee Man  [author] 5 Mar @ 9:17pm 
@Doxhot
Even if you increase the timer to prevent that specific case from happening, the addon is still going to significantly break a lot of other cases if used in a campaign map. You can have a timer up to 15 seconds and a lot of NPCs in campaign maps will still be removed when they shouldn't because of how they're initially placed. Thats why I'm stating in the description to avoid using the addon when playing in campaign maps entirely. You should mainly use it when you fill sandbox maps with randomly spawning NPCs.

@dvpweb
You've deleted and reposted your comment like 50 times. Why should start be changed with startpos exactly?
Säm 5 Mar @ 5:44pm 
Is there any way to change the time until they're removed? This doesn't play well with the functional dropships addon and deletes people before they deploy properly
Léa ♥ 5 Mar @ 2:54pm 
I think we should replace "start" with "startpos"
For your information, I readapted the code for this addon
https://steamproxy.com/sharedfiles/filedetails/comments/2939410311
Léa ♥ 5 Mar @ 7:50am 
Apparently, the list is in \steamapps\workshop\content\4000\3170702564\3170702564_via_crowbar.gma
Autumnis 5 Mar @ 5:15am 
alrighty. i don't use em, was just curious.
Coffee Man  [author] 5 Mar @ 5:05am 
I use the Hassassin's AI in my game, I don't use hgrunts (yet). If they're not commonly used NPCs by the players or I don't use them myself, they won't be included to keep the addon as optimized as possible.

If you happen to use 'em, refer to the Limitations Tab in the description.
Autumnis 5 Mar @ 5:02am 
if you're gonna count the assassins then why not the hgrunts?
Coffee Man  [author] 5 Mar @ 1:40am 
Yes, the black ops assassins from HLS. It's there to add compatibility with one of my other addons.

Hunters and other huge NPCs are pretty buggy if included in the allowed list, they end up getting removed often even in cases when they shouldn't.
couple questions:
- what's monster_human_assassin? the HL1 black ops?
- what about hunters? they're pretty damn huge and have a much greater tendency to get stuck in hallways than the average combine soldier
TZS 4 Mar @ 11:41am 
I'm really surprised it took this many years to finally be a mod like this here. This is gonna be one of those nice qol mods.
Awakened NPC. 4 Mar @ 11:15am 
@Ernie the giant chicken bro really thought @Pyroshark got offended by a your mom joke even though he is obviously joking.
Stewex 4 Mar @ 7:42am 
bro really got offended by a mom joke
Coffee Man  [author] 4 Mar @ 3:48am 
Ok.

Your dad.
Jäger 4 Mar @ 3:32am 
"your mom, etc." Take that back :(
bUh9 4 Mar @ 12:43am 
BUG
Combine unloading from dropships get deleted immediatly
loklal_foxymoksi 4 Mar @ 12:37am 
nice thanks a lot dude!:p03::GDNormal::eli::p2chell::resmile::steamhappy:
ninja joe 3 Mar @ 6:37pm 
Aw crap John! My leg is-

(randomly dissapears all of a sudden)
biocrab 3 Mar @ 3:58pm 
finally those idiots won't get stuck in eachother
thex710 3 Mar @ 3:52pm 
OK, I messed around with the script and managed to make it so ANY npc(SNPCs and Nextbots) can get removed, no need to add them to a list. Still a bit buggy though.
Cêcedilha 3 Mar @ 11:30am 
why are we only getting this now???
AgentBuddPennCentral 3 Mar @ 9:50am 
does it support SNPCS?
John Parkins Gaming 2 Mar @ 7:22pm 
please add support for rebels
aeiou [DFS] 2 Mar @ 6:13pm 
Cool.
Dragai 2 Mar @ 5:07pm 
please make it work for all npcs like nextbots
izyooil moai 2 Mar @ 3:44pm 
fuck you patrick imma search up starfish recipe
N00bGsav™ 2 Mar @ 3:22pm 
Patrick Why?
Anonzie 2 Mar @ 1:45pm 
WWWWWWWWWWOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
cid[bhs] 2 Mar @ 1:29pm 
ok