changed phys projectile ricochet behaviour

This commit is contained in:
Blu 2019-11-05 18:10:21 +01:00
parent 465cca239c
commit a48fc663e3
3 changed files with 7 additions and 9 deletions

View File

@ -213,17 +213,13 @@ function simfphys.FirePhysBullet( data )
projectile.Attacker = data.attacker
projectile.DeflectAng = data.DeflectAng
projectile.AttackingEnt = data.attackingent
local filter = data.filter
table.insert( filter, projectile )
projectile.Force = data.Force and data.Force or 100
projectile.Damage = data.Damage and data.Damage or 100
projectile.BlastRadius = data.BlastRadius and data.BlastRadius or 200
projectile.BlastDamage = data.BlastDamage and data.BlastDamage or 50
projectile:SetBlastEffect( isstring( data.BlastEffect ) and data.BlastEffect or "simfphys_tankweapon_explosion" )
projectile:SetSize( data.Size and data.Size or 1 )
projectile.Filter = filter
projectile.Filter = table.Copy( data.filter )
projectile:Spawn()
projectile:Activate()
end
@ -262,7 +258,7 @@ function simfphys.FireBullet( data )
bullet.Callback = function(att, tr, dmginfo)
if tr.Entity ~= Entity(0) then
if simfphys.IsCar( tr.Entity ) then
sound.Play( Sound( ImpactSounds[ math.random(1,table.Count( ImpactSounds )) ] ), tr.HitPos, 140)
sound.Play( Sound( ImpactSounds[ math.random(1,table.Count( ImpactSounds )) ] ), tr.HitPos, SNDLVL_90dB)
end
end
end

View File

@ -65,7 +65,7 @@ function ENT:Think()
maxs = Size,
mins = -Size,
filter = function( ent )
if ent:GetClass() ~= "gmod_sent_vehicle_fphysics_wheel" and not table.HasValue( self.Filter, ent ) then return true end
if ent ~= self and ent:GetClass() ~= "gmod_sent_vehicle_fphysics_wheel" and not table.HasValue( self.Filter, ent ) then return true end
end
} )
@ -85,10 +85,12 @@ function ENT:Think()
local Ax = math.deg( math.acos( math.Clamp( trace.HitNormal:Dot(shootDirection) ,-1,1) ) )
local Fx = math.cos( math.rad( Ax ) ) * thVel
self.Vel = (shootDirection * (thVel - math.abs(Fx)) - trace.HitNormal * Fx * 2) * 0.2
self.Vel = (shootDirection * thVel - trace.HitNormal * Fx * 2) * math.max((1 - hitangle / 45) * 0.5,0.2)
trace.Entity:GetPhysicsObject():ApplyForceOffset( shootDirection * thVel * self.Force * 0.5, trace.HitPos )
table.insert( self.Filter, trace.Entity )
self:SetPos( self:GetPos() + self.Vel * FixTick )
self.Vel = self.Vel - Vector(0,0,0.15) * FixTick

View File

@ -76,7 +76,7 @@ local function cannon_fire(ply,vehicle,shootOrigin,shootDirection)
projectile.Damage = 3500
projectile.Force = 8000
projectile.Size = 15
projectile.DeflectAng = 30
projectile.DeflectAng = 20
projectile.BlastRadius = 300
projectile.BlastDamage = 1000
projectile.BlastEffect = "simfphys_tankweapon_explosion"