Modifying Gmod base npcs

Does anyone know where the lua (if it is coded in lua) files for the npcs such as turrets and zombies are stored? If its not coded in lua, (its part of the half-life stuff right?) How I can go about modifying the logic for the npcs?

Would I have to create the entity and edit it from there?

Such as; Make the turrets only target other npcs, and ignore players, or change the range of turrets?

To my knowledge all the HL2 NPC’s Gun’s etc… are done in c++. The source code is available but you would have to basically rewrite the whole thing in LUA.

I believe it may be easier to find a NextBot script of a turret, and then modify or build off that as a base to get you started.

This is basically what I did, but with SWEPS so I could code a gun in LUA because you get full scripting control over the whole object.

You may be able to get away with using the HL2 NPC’s and just extending them with LUA if you only want to add some simple logic, and don’t need the burden of full control of the whole object.

Those pages have some nice example code, and remember that players are also entities, so if you have teams or classes, you can loop through players, check their team class, or name, and then decide if they are friendly or not to the turret.

To check out all the NPC functions check out the category on the wiki

That’s the thing, there are no NextBot turrets. There’s barely any NextBot examples out there save for TF2 Ghost and Sanic; all other NextBots haven’t been made public.