Garry's Mod

Garry's Mod

Team Fortress 2 Bots [2022]
sockpuppetclock 2021 年 4 月 15 日 上午 7:09
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
最后由 sockpuppetclock 编辑于; 2021 年 10 月 22 日 下午 3:16
< >
正在显示第 1 - 15 条,共 18 条留言
IvanVladimir0435 2021 年 4 月 15 日 上午 7:12 
Interesting, I'll try it out and see how it goes
IvanVladimir0435 2021 年 4 月 15 日 上午 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 2021 年 4 月 15 日 上午 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 2021 年 4 月 15 日 上午 7:26 
引用自 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 2021 年 4 月 15 日 上午 7:37 
alright, done
Garry 2021 年 4 月 18 日 上午 2:22 
thanks im gonna try it
Garry 2021 年 4 月 18 日 上午 2:42 
uh i don't see the "sv_tf2ainpc_relationships.lua"
Gintarjo 2021 年 4 月 18 日 上午 11:33 
引用自 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 2021 年 4 月 18 日 下午 12:18 
引用自 Gintarjo
引用自 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 2021 年 4 月 19 日 下午 4: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
最后由 sockpuppetclock 编辑于; 2021 年 4 月 19 日 下午 4:39
sockpuppetclock 2021 年 4 月 19 日 下午 5: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  [开发者] 2021 年 4 月 24 日 下午 3:08 
Wow, nicely done!
sockpuppetclock 2021 年 4 月 25 日 下午 12:26 
Would you be willing to update the addon with this? Most people probably won't find this thread
MAKEMEDEEP45 2021 年 5 月 21 日 上午 8:44 
引用自 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 2021 年 5 月 22 日 下午 3:49 
BUG LAG: If, you put a bot 2 fps at will Thats all.
< >
正在显示第 1 - 15 条,共 18 条留言
每页显示数: 1530 50