summaryrefslogtreecommitdiff
path: root/entities/effects/fire_explosion/init.lua
blob: f4fe3399a4e5e671eaec98c70333a0400a9b1f3b (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function EFFECT:Init( data )

	self.DieTime = CurTime() + 1.5

	local pos = data:GetOrigin()
	local normal = data:GetNormal()
	local emitter = ParticleEmitter( pos )

	local particle = emitter:Add( "effects/blood_core", pos )
	particle:SetDieTime( math.Rand( 1.0, 1.5 ) )
	particle:SetStartAlpha( 255 )
	particle:SetEndAlpha( 0 )
	particle:SetStartSize( 10 )
	particle:SetEndSize( math.random( 50, 100 ) )
	particle:SetRoll( math.Rand( -360, 360 ) )
	particle:SetColor( 50, 50, 50 )

	for i=1, 10 do

		local particle = emitter:Add( "effects/muzzleflash"..math.random(1,4), pos )
		particle:SetVelocity( VectorRand() * 50 + normal * 50 )
		particle:SetDieTime( math.Rand( 0.3, 0.6 ) )
		particle:SetStartAlpha( 255 )
		particle:SetEndAlpha( 0 )
		particle:SetStartSize( math.Rand( 5, 10 ) )
		particle:SetEndSize( math.Rand( 30, 60 ) )
		particle:SetRoll( math.Rand( -360, 360 ) )
		particle:SetColor( 200, 150, 100 )

	end

	for i=1, math.random(5,10) do

		local vec = normal * math.random( 150, 200 ) + VectorRand() * 50
		local normalized = vec:GetNormal():Angle()

		local particle = emitter:Add( "effects/yellowflare", pos )
		particle:SetVelocity( normal * math.random(150,200) + VectorRand() * 50 )
		particle:SetLifeTime( 0 )
		particle:SetDieTime( math.Rand( 1.5, 3.5 ) )
		particle:SetStartAlpha( 255 )
		particle:SetEndAlpha( 0 )
		particle:SetStartSize( math.random( 4, 8 ) )
		particle:SetEndSize( 0 )
		particle:SetRoll( math.Rand( -360, 360 ) )
		particle:SetColor( 200, 100, 50 )

		particle:SetGravity( Vector( 0, 0, -500 ) )
		particle:SetCollide( true )
		particle:SetBounce( math.Rand( 0, 0.2 ) )

	end

	emitter:Finish()

	local dlight = DynamicLight( self:EntIndex() )

	if dlight then

		dlight.Pos = pos
		dlight.r = 255
		dlight.g = 150
		dlight.b = 50
		dlight.Brightness = 3
		dlight.Decay = 512
		dlight.size = 256 * math.Rand( 0.5, 1.0 )
		dlight.DieTime = CurTime() + 5

	end

end

function EFFECT:Think( )

	return self.DieTime > CurTime()

end

function EFFECT:Render()

end