How are NPCs in games with combat normally handled?

Alrighty, so I’ve been looking into making NPCs for my game for a while now, but I’ve been putting it off as it’s pretty well known that this is arguably one of the most complex topics you could probably deal with on this platform. Given that no NPC systems are interchangeable between games since every game has different systems, (Unless there’s some open sourced NPC framework that I’m not aware of) you’ll ultimately have to make your own.

But, since I’ve never done that before, I’m curious as to how games normally handle NPC’s. I’m pretty sure it’s almost a certainty that each of these systems is a tailor made OOP monster of a task to undertake. Since to my understanding, making optimized NPC’s that can interact with a game’s systems without tanking the games performance, is pretty difficult.

I’m mainly asking as to how these systems work usually. Pathfinding is something I can understand as there are plenty of resources on using pathfinding such as SimplePath, but how exactly is pathfinding dealt with when per say, an NPC is targetting an entity within the workspace. Is the path constantly updated every frame? And while they’re pathfinding, are they constantly checking for other factors through conditional logic? That’s what I would assume but given a complex enough game I would imagine this being an absolute bomb on performance.

Actual actions aren’t much of a concern for me though. The framework I’m using, WCS, makes it pretty easy to initiate actions on both clients and NPCs, so the divide between server and player inputs isn’t a concern.

But overall, I cannot comprehend how bigger games are able to make high quality NPC’s with unfathomably complex logic without it being a hinderance to performance. There are plenty of games without crazy NPC logic, like Blox Fruits for example, but I’m leaning towards the quality of my NPC’s, as well as how you even handle decision making.

The best example I can think of is Deepwoken’s massively complex NPC’s which are pretty impressive, and the server can handle tons of them. (In general I find deepwoken to be a technical herculean feat for several reasons, but the NPC’s are one of the most impressive things I’ve found within it.)