How do I check if an entity takes fire damage?
I tried using the “EntityTakeDamage” hook, but unfortunately I don’t know what damagetype fire is. (It apparently isn’t “DMG_BURN”)
And because GetDamageType won’t work for me, I can’t find out.
How do I check if an entity takes fire damage?
I tried using the “EntityTakeDamage” hook, but unfortunately I don’t know what damagetype fire is. (It apparently isn’t “DMG_BURN”)
And because GetDamageType won’t work for me, I can’t find out.
Depending on what you’re doing you could simply setup a whitelist. For instance only damaged by players and Npcs?
Nvm I figured it out
[lua]function IsOnFire( ent, inflictor, attacker, amount, dmginfo )
if inflictor:GetClass() == “entityflame” then
–the entity is on fire
end
end
hook.Add( “EntityTakeDamage”, “Is the ent on fire”, IsOnFire )
[/lua]
It will be DMG_BURN, if what you tried, which I’m assuming is the following doesn’t work.
[lua]if( dmginfo:IsDamageType( DMG_BURN ) ) then[/lua]
Then this surely will.
[lua]if( ( dmginfo:GetDamageType() & DMG_BURN ) == DMG_BURN ) then[/lua]
attempt to call method 'GetDamageType' (a nil value)
Fail.
function arguments expected near '=='
[lua]if inflictor:GetClass() == “entityflame” then[/lua]
works just fine
Forgot the (). Just fixed it.
That’s the exact same thing I used before (I opened the thread) and it still
attempt to call method 'GetDamageType' (a nil value)
s
You’re doing something wrong then:
[lua]hook.Add( “EntityTakeDamage”, “TestFire”, function(ent, inf, att, amt, dmginfo) print(dmginfo:GetDamageType( )) end)[/lua]
Returns 268435456 while on fire.
EDIT: I’m currently getting all the indexes for the ENUMs.
EDIT 2: Come to find out, it’s DMG_DIRECT, not DMG_FIRE.
Damn, must be on my end then. Gotta check my gmod for broken/outdated stuff
Thanks for the help