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]
[code]attempt to call method 'GetDamageType' (a nil value)[/code]
[QUOTE=TheGreatVax;17365959][code]attempt to call method 'GetDamageType' (a nil value)[/code][/QUOTE]
[URL=http://wiki.garrysmod.com/?title=CTakeDamageInfo.GetDamageType]GetDamageType[/URL]
[lua]if dmginfo:GetDamageType() == DMG_BURN then[/lua]
Fail.
[code]function arguments expected near '=='[/code]
[lua]if inflictor:GetClass() == "entityflame" then[/lua]
works just fine
[QUOTE=TheGreatVax;17366073]Fail.
[code]function arguments expected near '=='[/code]
[lua]if inflictor:GetClass() == "entityflame" then[/lua]
works just fine[/QUOTE]
Forgot the (). Just fixed it.
That's the exact same thing I used before (I opened the thread) and it still [code]attempt to call method 'GetDamageType' (a nil value)[/code]s
[QUOTE=TheGreatVax;17366123]That's the exact same thing I used before (I opened the thread) and it still [code]attempt to call method 'GetDamageType' (a nil value)[/code]s[/QUOTE]
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
Sorry, you need to Log In to post a reply to this thread.