summaryrefslogtreecommitdiff
path: root/entities/effects/player_gib/init.lua
blob: 2afcae0a2f6c20ba48a1a59423136e5299fcef88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function EFFECT:Init( data )

	local scale = data:GetScale()

	if scale < 2 then
		self.Entity:SetModel( table.Random( GAMEMODE.SmallGibs ) )
	else
		self.Entity:SetModel( table.Random( GAMEMODE.BigGibs ) ) 
	end

	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMaterial( "models/flesh" )
	
	self.Entity:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
	self.Entity:SetCollisionBounds( Vector( -128 -128, -128 ), Vector( 128, 128, 128 ) )
	self.Entity:SetAngles( Angle( math.Rand(0,360), math.Rand(0,360), math.Rand(0,360) ) )
	
	local phys = self.Entity:GetPhysicsObject()
	
	if IsValid( phys ) then
	
		local vec = VectorRand()
		vec.z = math.Clamp( vec.z, -0.4, 0.8 )
	
		phys:Wake()
		phys:SetMass( 100 )
		phys:AddAngleVelocity( VectorRand() * 500 )
		phys:SetMaterial( "gmod_silent" )
		
		if scale < 2 then
		
			phys:SetVelocity( vec * math.Rand( 100, 200 ) )
		
		else
		
			phys:SetVelocity( vec * math.Rand( 300, 600 ) )
		
		end
	
	end
	
	self.LifeTime = CurTime() + 15
	
end

function EFFECT:Think( )

	return self.LifeTime > CurTime()
	
end

function EFFECT:Render()

	self.Entity:DrawModel()

end