Garry's Mod

Garry's Mod

Team Fortress 2 Bots [2022]
Fix for insane lag this mod can cause even without bots spawned
After testing every addon I have installed, I figured out that this addon was what was causing my fps to crater from 60 to 2 whenever I had a bunch of npcs on the map.

Basically, the addon creates a new infinitely repeating timer for every npc that spawns that is constantly doing table actions and searching the entities list in every individual instance even when there are no tf2 bots on the map. The complexity is multiplied for every npc on the map until your fps is destroyed.

I have rewritten that part of the code into a think hook with a coroutine that doesn't need to run in every npc. i also noticed the code wasn't setting mvm bot relationships for citizens, but the way i coded this should fix all that

How to (Two ways to replace addon files):
a) Extract the whole addon (with anything that can, such as a steam workshop downloader) and place the addon folder into garrysmod/addons/ and then replace the relevant files in there.
Note: Linux and Mac users must rename addon folders placed in addons/ to all lowercase characters or they will not work.

b) Make a new file with the name of the file to replace, with the code in it, and place it in the garrysmod directory directly. In this case you would place it in garrysmod/lua/autorun/server/
You will have to make the directories in the lua folder if they don't exist.


lua/autorun/server/sv_tf2ainpc_relationships.lua
https://pastebin.com/raw/nWSM3Zk4

edit: added onentitycreated hook
e2: minor edit
e3: added instructions and also took out some debug stuff i accidentally left in, woops
e4 oct22: replaced code block with link to correct code. brackets in code might have messed up the code block
Sidst redigeret af sockpuppetclock; 22. okt. 2021 kl. 15:16
< >
Viser 1-15 af 18 kommentarer
IvanVladimir0435 15. apr. 2021 kl. 7:12 
Interesting, I'll try it out and see how it goes
IvanVladimir0435 15. apr. 2021 kl. 7:13 
You could also try setting the relationships when the NPC/NextBot is created, might lag a bit more when spawning them initially, but would reduce greatly the lag mid battle
sockpuppetclock 15. apr. 2021 kl. 7:19 
yeah i could probably edit it so that it only bothers checking the ents list if a new npc was made since the last check
IvanVladimir0435 15. apr. 2021 kl. 7:26 
Oprindeligt skrevet af sockpuppetclock:
yeah i could probably edit it so that it only bothers checking the ents list if a new npc was made since the last check
There's a hook called OnEntityCreated
Should help you with it
sockpuppetclock 15. apr. 2021 kl. 7:37 
alright, done
Garry :3 18. apr. 2021 kl. 2:22 
thanks im gonna try it
Garry :3 18. apr. 2021 kl. 2:42 
uh i don't see the "sv_tf2ainpc_relationships.lua"
Gintarjo 18. apr. 2021 kl. 11:33 
Oprindeligt skrevet af GARRYTALE:
uh i don't see the "sv_tf2ainpc_relationships.lua"
I'm going to guess that I had to make the file and put it in the directory...
IvanVladimir0435 18. apr. 2021 kl. 12:18 
Oprindeligt skrevet af Gintarjo:
Oprindeligt skrevet af GARRYTALE:
uh i don't see the "sv_tf2ainpc_relationships.lua"
I'm going to guess that I had to make the file and put it in the directory...
It's in the autorun folder
sockpuppetclock 19. apr. 2021 kl. 16:39 
even though i'm not 100% sure how files work, you can either

a) extract the whole addon (with anything that can, such as a steam workshop downloader) and place the addon folder into garrysmod/addons/ and then replace the relevant files

b) place it in the garrysmod directory directly. garrysmod/lua/autorun/server/

i'll add instructions to the op
Sidst redigeret af sockpuppetclock; 19. apr. 2021 kl. 16:39
sockpuppetclock 19. apr. 2021 kl. 17:02 
also updated the code, i took out some debug print()'s that i accidentally left in the code and also commented out the cvar that doesn't exist yet (_other_fof) that i uncommented out for some reason
MrNiceGuy518  [udvikler] 24. apr. 2021 kl. 15:08 
Wow, nicely done!
sockpuppetclock 25. apr. 2021 kl. 12:26 
Would you be willing to update the addon with this? Most people probably won't find this thread
MAKEMEDEEP45 21. maj 2021 kl. 8:44 
Oprindeligt skrevet af sockpuppetclock:
Would you be willing to update the addon with this? Most people probably won't find this thread
Imma guess thats a no
wowzers193 22. maj 2021 kl. 15:49 
BUG LAG: If, you put a bot 2 fps at will Thats all.
< >
Viser 1-15 af 18 kommentarer
Per side: 1530 50