mirror of
https://github.com/SpaxscE/simfphys_armed.git
synced 2025-03-04 03:13:26 -05:00
tracer,sound + deflect on prop_physics
This commit is contained in:
parent
fc84fabe4c
commit
3d7bc75878
@ -31,7 +31,8 @@ function EFFECT:Init( data )
|
|||||||
self:SetRenderBoundsWS( self.StartPos, self.EndPos )
|
self:SetRenderBoundsWS( self.StartPos, self.EndPos )
|
||||||
|
|
||||||
self.TracerTime = math.min( 1, self.StartPos:Distance( self.EndPos ) / 15000 )
|
self.TracerTime = math.min( 1, self.StartPos:Distance( self.EndPos ) / 15000 )
|
||||||
self.Length = math.Rand( 0.1, 0.15 )
|
|
||||||
|
self.Length = math.Rand( 0.05, 0.1 )
|
||||||
|
|
||||||
-- Die when it reaches its target
|
-- Die when it reaches its target
|
||||||
self.DieTime = CurTime() + self.TracerTime
|
self.DieTime = CurTime() + self.TracerTime
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
include("shared.lua")
|
include("shared.lua")
|
||||||
|
|
||||||
|
ENT.mat = Material( "sprites/animglow02" )
|
||||||
|
ENT.mat2 = Material( "effects/simfphys_armed/spark" )
|
||||||
|
|
||||||
function ENT:Initialize()
|
function ENT:Initialize()
|
||||||
self.PixVis = util.GetPixelVisibleHandle()
|
|
||||||
|
|
||||||
self.Materials = {
|
self.Materials = {
|
||||||
"particle/smokesprites_0001",
|
"particle/smokesprites_0001",
|
||||||
"particle/smokesprites_0002",
|
"particle/smokesprites_0002",
|
||||||
@ -23,16 +24,21 @@ function ENT:Initialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.OldPos = self:GetPos()
|
self.OldPos = self:GetPos()
|
||||||
|
|
||||||
self.emitter = ParticleEmitter(self.OldPos, false )
|
self.emitter = ParticleEmitter(self.OldPos, false )
|
||||||
end
|
end
|
||||||
|
|
||||||
local mat = Material( "sprites/animglow02" )
|
|
||||||
function ENT:Draw()
|
function ENT:Draw()
|
||||||
|
if not self.Dir or not self.Size then return end
|
||||||
|
|
||||||
|
if self.Size > 5 then return end
|
||||||
|
|
||||||
|
local pos = self:GetPos()
|
||||||
|
|
||||||
|
render.SetMaterial( self.mat2 )
|
||||||
|
render.DrawBeam( pos, self.OldPos - self.Dir * 250, self.Size * 5, 1, 0, Color( 255, 255, 255, 255 ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function ENT:Think()
|
function ENT:Think()
|
||||||
local curtime = CurTime()
|
|
||||||
local pos = self:GetPos()
|
local pos = self:GetPos()
|
||||||
|
|
||||||
if pos ~= self.OldPos then
|
if pos ~= self.OldPos then
|
||||||
@ -50,36 +56,41 @@ function ENT:doFX( newpos, oldpos )
|
|||||||
local Dir = Sub:GetNormalized()
|
local Dir = Sub:GetNormalized()
|
||||||
local Len = Sub:Length()
|
local Len = Sub:Length()
|
||||||
|
|
||||||
|
self.Dir = Dir
|
||||||
|
self.Size = self:GetSize()
|
||||||
|
|
||||||
for i = 1, Len, 15 do
|
for i = 1, Len, 15 do
|
||||||
local pos = oldpos + Dir * i
|
local pos = oldpos + Dir * i
|
||||||
|
|
||||||
local particle = self.emitter:Add( self.Materials[math.random(1, table.Count(self.Materials) )], pos )
|
local particle = self.emitter:Add( self.Materials[math.random(1, table.Count(self.Materials) )], pos )
|
||||||
|
|
||||||
if particle then
|
if particle then
|
||||||
particle:SetGravity( Vector(0,0,100) + VectorRand() * 50 )
|
particle:SetGravity( Vector(0,0,100) + VectorRand() * 50 )
|
||||||
particle:SetVelocity( -self:GetForward() * 500 )
|
particle:SetVelocity( -Dir * 500 )
|
||||||
particle:SetAirResistance( 600 )
|
particle:SetAirResistance( 600 )
|
||||||
particle:SetDieTime( math.Rand(0.1,0.5) )
|
particle:SetDieTime( math.Rand(0.1,0.5) )
|
||||||
particle:SetStartAlpha( 80 )
|
particle:SetStartAlpha( 80 )
|
||||||
particle:SetStartSize( (math.Rand(6,12) / 20) * self:GetSize() )
|
particle:SetStartSize( (math.Rand(6,12) / 20) * self.Size )
|
||||||
particle:SetEndSize( (math.Rand(20,30) / 20) * self:GetSize() )
|
particle:SetEndSize( (math.Rand(20,30) / 20) * self.Size )
|
||||||
particle:SetRoll( math.Rand( -1, 1 ) )
|
particle:SetRoll( math.Rand( -1, 1 ) )
|
||||||
particle:SetColor( 120,120,120 )
|
particle:SetColor( 120,120,120 )
|
||||||
particle:SetCollide( false )
|
particle:SetCollide( false )
|
||||||
end
|
end
|
||||||
|
|
||||||
local particle = self.emitter:Add( mat, pos )
|
if self.Size > 5 then
|
||||||
if particle then
|
local particle = self.emitter:Add( self.mat, pos )
|
||||||
particle:SetVelocity( -self:GetForward() * 300 + self:GetVelocity())
|
if particle then
|
||||||
particle:SetDieTime( 0.1 )
|
particle:SetVelocity( -Dir * 300 + self:GetVelocity())
|
||||||
particle:SetAirResistance( 0 )
|
particle:SetDieTime( 0.1 )
|
||||||
particle:SetStartAlpha( 255 )
|
particle:SetAirResistance( 0 )
|
||||||
particle:SetStartSize( self:GetSize() )
|
particle:SetStartAlpha( 255 )
|
||||||
particle:SetEndSize( 0 )
|
particle:SetStartSize( self.Size )
|
||||||
particle:SetRoll( math.Rand(-1,1) )
|
particle:SetEndSize( 0 )
|
||||||
particle:SetColor( 255,255,255 )
|
particle:SetRoll( math.Rand(-1,1) )
|
||||||
particle:SetGravity( Vector( 0, 0, 0 ) )
|
particle:SetColor( 255,255,255 )
|
||||||
particle:SetCollide( false )
|
particle:SetGravity( Vector( 0, 0, 0 ) )
|
||||||
|
particle:SetCollide( false )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -46,6 +46,12 @@ function ENT:Initialize()
|
|||||||
self.Vel = self:GetForward() * 200
|
self.Vel = self:GetForward() * 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local CanDeflectOn = {
|
||||||
|
["gmod_sent_vehicle_fphysics_base"] = true,
|
||||||
|
["gmod_sent_vehicle_fphysics_wheel"] = true,
|
||||||
|
["prop_physics"] = true,
|
||||||
|
}
|
||||||
|
|
||||||
function ENT:Think()
|
function ENT:Think()
|
||||||
local curtime = CurTime()
|
local curtime = CurTime()
|
||||||
self:NextThink( curtime )
|
self:NextThink( curtime )
|
||||||
@ -72,7 +78,7 @@ function ENT:Think()
|
|||||||
|
|
||||||
self.DeflectAng = self.DeflectAng or 25
|
self.DeflectAng = self.DeflectAng or 25
|
||||||
|
|
||||||
if hitangle < self.DeflectAng and not self.Bounced and (simfphys.IsCar( trace.Entity ) or trace.Entity:GetClass() == "gmod_sent_vehicle_fphysics_wheel") then
|
if hitangle < self.DeflectAng and not self.Bounced and CanDeflectOn[ trace.Entity:GetClass() ] then
|
||||||
|
|
||||||
local thVel = self.Vel:Length()
|
local thVel = self.Vel:Length()
|
||||||
|
|
||||||
@ -119,7 +125,9 @@ function ENT:Think()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local attackingEnt = IsValid( self.AttackingEnt ) and self.AttackingEnt or self
|
local attackingEnt = IsValid( self.AttackingEnt ) and self.AttackingEnt or self
|
||||||
util.BlastDamage( attackingEnt, self.Attacker, tr.HitPos,self.BlastRadius,self.BlastDamage)
|
local attacker = IsValid( self.Attacker ) and self.Attacker or self
|
||||||
|
|
||||||
|
util.BlastDamage( attackingEnt, attacker, tr.HitPos,self.BlastRadius,self.BlastDamage)
|
||||||
|
|
||||||
util.Decal("scorch", tr.HitPos - tr.HitNormal, tr.HitPos + tr.HitNormal)
|
util.Decal("scorch", tr.HitPos - tr.HitNormal, tr.HitPos + tr.HitNormal)
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user