Entity:OnTakeDamage called under certain (limiting) conditions?

I’m currently trying to get an anim based entity (I have no idea how the different types operate when used in garry’s mod), which overrides the hook OnTakeDamage in its init file. It would seem that OnTakeDamage is only called under certain circumstances, from my testing and from gmod 12 it would seem. I’m trying to get my entity to take damage when it is dropped from a height, although the OnTakeDamage hook is not called.

It appears that this hook should be called for many types of damage, as it appears that the provided CTakeDamageInfo parameter supports fall damage (among many other types).

Is my entity just setup incorrectly, is this a bug, or intentional for whatever reason?

If it’s not dropped from enough of a height to cause physics damage to the model then it won’t get called. You would have to use ENT:PhysicsCollide which is called on any collision (which is not thread safe so store the data in a variable and parse it in the entity’s next ENT:Think()).

So OnTakeDamage is really out of the question here? I dropped the entity from what seemed like 150 feet, I’d imagine that would cause some damage.

Welp, I ended up pretty much just calling TakeDamage on the entity from within the PhysicsCollide hook:

[lua]
local speedFloor = 225 --The minimum speed to consider damaging the printer. This seems to be about a 4 foot drop.
local collSounds = {
“physics/metal/metal_box_break1.wav”,
“physics/metal/metal_box_break2.wav”,
“physics/metal/metal_barrel_impact_hard1.wav”,
“physics/metal/metal_sheet_impact_hard6.wav”
}

function ENT:PhysicsCollide( colData )

--DeltaTime always seems to cap at 1 if the entity hasn't been damaged recently (recently being within a few moments, otherwise this hook is called several times rapidly if the entity is dropped onto the ground)
if colData.DeltaTime == 1 and colData.Speed >= speedFloor then
	local soundChoice = math.random( 1, #collSounds )
	self:EmitSound( collSounds[ soundChoice ], 75, 100 )
	self:TakeDamage( colData.Speed / speedFloor, colData.HitEntity, nil )
end

end
[/lua]

The OnTakeDamage hook ends up getting called. By Calling :GetDamage on the CTakeDamageInfo parameter passed in, I can get the first parameter that I passed into the TakeDamage call. I still think that OnTakeDamage should be called without me having to implement this, but I guess it is what it is. Thanks JetBoom!