Open BREEDNKMs opened 3 years ago
This sort of thing is usually handled via a return value from the hook, but we already tried that and it ended in disaster. Most people want their SNPCs immortal I guess.
Yes I noticed that, by the mean time I was adapting my snpcs to work along with default damage hook. It was very difficult for those to "return 1", or they could have even set their SNPCs' m_takedamage to 0.
This is why I thought passing the damage to base classes with a method would be a bit more ideal if they don't want to change any bits of their hooks. If it doesn't work that way, the same method you have tried can be revised, this time with m_takedamage 0 by default. Most SNPCs existing in the workshop do not even handle m_takedamage in any way.
While scripting an AI using the default base npc, it requires scripters to write their own damage receiving methods from scratch. I tried to replicate valve's code in OnTakeDamage, but it is a bit detailed and not all features can be replicated, especially creating the ragdoll serverside or clientside, dissolving weapons and ragdoll without env_entity_dissolver, picking appropriate schedule and inspecting damage position, informing squad members and calling game events (no game event can be emitted through Lua), react according to DMG enums (DMG_REMOVENORAGDOLL, DMG_SHOCK, DMG_DISSOLVE etc..), dependent damage receiving based on scripted events and g_vecAttackDir, thus I found it is unpractical to write snpc's damage code which behave just like half-life 2 npcs.
Instead, I found it would be more useful to call the default damage script, in some way like:
`function ENT:OnTakeDamage(dmginfo) self:OnEngineTakeDamage(dmginfo) end ``
Which would call CBaseCombatCharacter's damage function and handle the rest. It will be similar to calling baseclass's OnTakeDamage. Those who would like to implement their damage hook would basically avoid using this.
Don't know which alternating name would be best, though. It can be Entity:OnTakeDamage_Base as well.
Thank you for your attention.