-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Add support for custom dmg events #53
Comments
Hey. I'll have to look into this. I had to do something similar for a poison dart weapon and I can't remember exactly how I did it. |
I can't remember the exact logic for how it works out the name of the damaging entity. I'll have to check it next week as I'm away this week. |
For a poison dart gun I've worked on, I have a separate entity to do poison damage to the player - Here's how it does the damage local dmginfo = DamageInfo()
dmginfo:SetDamage(damageAmount)
dmginfo:SetAttacker(self:GetOwner())
dmginfo:SetInflictor(self)
dmginfo:SetDamageType(DMG_POISON)
self.Target:TakeDamageInfo(dmginfo) This seems to result in the classname being used in the damage logs. Here's the logic in the damage logs which determines what name to use for the damage entity. function Damagelog:WeaponFromDmg(dmg)
local inf = dmg:GetInflictor()
local wep = nil
local isWorldDamage = inf != nil and inf.IsWorld and inf:IsWorld()
if IsValid(inf) or isWorldDamage then
if inf:IsWeapon() or inf.Projectile then
wep = inf
elseif dmg:IsDamageType(DMG_BLAST) then
wep = "DMG_BLAST"
elseif dmg:IsDamageType(DMG_DIRECT) or dmg:IsDamageType(DMG_BURN) then
wep = "DMG_BURN"
elseif dmg:IsDamageType(DMG_CRUSH) or dmg:IsDamageType(DMG_FALL) then
wep = "DMG_CRUSH"
elseif dmg:IsDamageType(DMG_SLASH) then
wep = "DMG_SLASH"
elseif dmg:IsDamageType(DMG_CLUB) then
wep = "DMG_CLUB"
elseif dmg:IsDamageType(DMG_SHOCK) then
wep = "DMG_SHOCK"
elseif dmg:IsDamageType(DMG_ENERGYBEAM) then
wep = "DMG_ENERGYBEAM"
elseif dmg:IsDamageType(DMG_SONIC) then
wep = "DMG_SONIC"
elseif dmg:IsDamageType(DMG_PHYSGUN) then
wep = "DMG_PHYSGUN"
elseif inf:IsPlayer() then
wep = inf:GetActiveWeapon()
if not IsValid(wep) then
wep = IsValid(inf.dying_wep) and inf.dying_wep
end
end
end
if type(wep) ~= "string" then
return IsValid(wep) and wep:GetClass()
else
return wep
end
end |
This is how I've been attributing damage with my turret. The damage logs display the attacker (player) but not the inflictor (turret). I have also set the PrintName attribute in the entity. I have a feeling that maybe this line of code in the damagelogs is why it's not working I will mess around with it and report back. |
Would you be able to add support for PlayerTakeRealDamage similar to how you did with TTTEquipmentUse. I have traitor weapons that deal damage that either doesn't get logged or deals damage as an entity so it says "unknown weapon." I've been trying to use a similar method to how you did for equipment but it's a bit more complicated.
The text was updated successfully, but these errors were encountered: