I have been trying to create my own function for creating explosions but most of my functions have failed, could someone be bothered to recreate it in Lua for me or point me to the C++ version?
[lua]
info = DamageInfo( )
info:SetDamageType( DMG_BLAST )
info:SetDamagePosition( pos )
info:SetMaxDamage( 150 )
info:SetDamage( 75 )
info:SetAttacker( self:GetOwner( ) )
info:SetInflictor( self )
for k, v in ipairs( ents.GetAll( ) ) do
if ValidEntity( v ) and v:Health( ) > 0 then
p = v:GetPos( )
if p:Distance( pos ) <= 128 then
info:SetDamage( 75 * ( 1 - p:Distance( pos ) / 128 ) )
info:SetDamageForce( ( p - pos ):Normalize( ) * 512 )
v:TakeDamageInfo( info )
end
end
end
[/lua]
Where self is a SENT that the player shoots in this case, and pos is where the entity impacted with something.
Instead of a linear Fall down a Quadratic fall down would be better? Aka 2x times further 4x less damage?
[QUOTE=commander204;19608322]Instead of a linear Fall down a Quadratic fall down would be better? Aka 2x times further 4x less damage?[/QUOTE]
It's really up to the coder. I just used linear when I wrote that because it's simple.
[QUOTE=commander204;19608322]Instead of a linear Fall down a Quadratic fall down would be better? Aka 2x times further 4x less damage?[/QUOTE]
What do you mean by this?
I mean instead the damage going down like this:
linear = you double the distance the damage falls of by the double
quadratic = you double the distance the damage falls of by the quadruple(Is a word atleast what google chrome says.).
[QUOTE=Kogitsune;19608182]Where self is a SENT that the player shoots in this case, and pos is where the entity impacted with something.[/QUOTE]
Have fun exploding people through walls.
The code that inflicts the damage is pretty well hidden, took me a while to find it.
It's in game/shared/gamerules.cpp
[cpp]void CGameRules::RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore, CBaseEntity *pEntityIgnore )[/cpp]
Good luck implementing that, it's surpringly complex, and I never managed to port it properly to Lua.
Just do a trace from the blast origin to all the players, and if you can directly hit it, then execute Kogitsune's code.
This isn't dumb, this is the best way of making players not get hit by blast damage through walls.
Sorry, you need to Log In to post a reply to this thread.