Facepunch / garrysmod-requests

Feature requests for Garry's Mod
86 stars 24 forks source link

Add ability set Engine Entities as base of SENT/SNPC #2448

Closed TetraTheta closed 2 months ago

TetraTheta commented 3 months ago

The description of ENT.Base says 'The base entity to derive from. This must be a valid Lua entity'.

This is frustrating because I want to make a separate SENT/SNPC that the differences between origianl entity are just few functions. Some may be implemented by using hook, but some won't be able to implement becuase there is no corresponding hook for it.

For example:

As far as I know, to override few aspects of Engine Entity, I have to either re-write its code into Lua and modify it, or use hook that might not be available.

Entity:AddCallback exists, but it seems this is only available for OnAngleChange, BuildBonePositions, PhysicsCollide, BuildFlexWeights, according to Entity Callbacks that is linked in Entity:AddCallback. If then, this is not what I should use.


If there is a way to implement these things currently, please tell me how to do it.

If this isn't possible at all, it would be very nice to tell me the detailed reason of why it can't be implemented, not just 'impossible'.

robotboy655 commented 2 months ago

It's not impossible, but it is unfeasible.

The way scripted entities work is that there's a special entity class internally that calls all those Lua entity hooks. Getting what you want to work would require to have every single entity in the whole game call those Lua hooks separately. This is not only is a huge amount of work, it is also far less maintainable.

TetraTheta commented 2 months ago

Thank you for the detailed explanation about why it is not implemented yet!
All I've heard so far were just "no you can't" or "you have to re-implement vital functions in Lua way"...

I 100% understand about your explanation and stance. Thank you for the kind answer!