Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
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]
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
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.
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?
For your information, I readapted the code for this addon
https://steamproxy.com/sharedfiles/filedetails/comments/2939410311
If you happen to use 'em, refer to the Limitations Tab in the description.
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.
- 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
Your dad.
Combine unloading from dropships get deleted immediatly
(randomly dissapears all of a sudden)