I have a quite simple and universal SpawnFunction in my base entity:
function ENT:SpawnFunction( ply, tr ) if !tr then if ValidEntity(ply) then tr = ply:GetEyeTraceNoCursor() else return end end if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 20 local ent = ents.Create( self.ClassName ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() ent:OnSpawn() return ent end
When I create entities based on the entity with that function, they get the same SpawnFunction method (I can say that because when doing print(scripted_ents.Get(string classname)) for both entities (base and derived) in console I get the same exact function indexes - function: 03745628). Even though this must be correct, one thing does not happen. The derived entity does not spawn from the spawn menu. I wrote a small fix for that:
function ENT:SpawnFunction(ply) return scripted_ents.Get(self.Base).SpawnFunction(self,ply) end
This works like charm, but doesn’t meet my requirements. Is it possible to make the SpawnFunction of the derived entity auto-derive from its base?