summaryrefslogtreecommitdiff
path: root/entities/effects/puke_explosion/init.lua
blob: afc00f6600c2c3b7f3c22aa6eb45606d7aedb499 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
EFFECT.Color = Color(100,50,0)

function EFFECT:Init( data )

	self.DieTime = CurTime() + 1.5
	self.SoundTime = 0

	local pos = data:GetOrigin() + Vector(0,0,50)
	local emitter = ParticleEmitter( pos )

	self.Pos = pos

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

	for i=1, math.random(4,8) do

		local particle = emitter:Add( "effects/blood", pos )
		particle:SetVelocity( VectorRand() * 100 + Vector(0,math.random(-25,25),50) )
		particle:SetDieTime( 1.0 )
		particle:SetStartAlpha( 255 )
		particle:SetEndAlpha( 0 )
		particle:SetStartSize( math.random( 20, 40 ) )
		particle:SetEndSize( math.random( 50, 150 ) )
		particle:SetRoll( math.Rand( -360, 360 ) )
		particle:SetColor( self.Color.r, self.Color.g, 0 )
		particle:SetGravity( Vector( 0, 0, -300 ) )

	end

	for i=1, 10 do

		local vec = VectorRand()
		vec.z = math.Rand( -0.2, 1.0 )

		local particle = emitter:Add( "nuke/gore" .. math.random(1,2), pos )
		particle:SetVelocity( vec * 300 )
		particle:SetDieTime( math.Rand( 0.8, 1.0 ) )
		particle:SetStartAlpha( 200 )
		particle:SetEndAlpha( 0 )
		particle:SetStartSize( math.random( 10, 20 ) )
		particle:SetEndSize( math.random( 100, 150 ) )
		particle:SetRoll( math.Rand( -360, 360 ) )
		particle:SetColor( self.Color.r, self.Color.g + math.random(0,20), 0 )
		particle:SetGravity( Vector( 0, 0, -400 ) )

	end

	for i=1, math.random(3,6) do

		local vec = VectorRand()
		vec.z = math.Rand( -0.2, 1.0 )

		local particle = emitter:Add( "nuke/gore" .. math.random( 1, 2 ), pos + Vector( 0, 0, math.random( -10, 10 ) ) )
		particle:SetVelocity( vec * 300 )
		particle:SetLifeTime( 0 )
		particle:SetDieTime( math.Rand( 2.0, 4.0 ) )
		particle:SetStartAlpha( 255 )
		particle:SetEndAlpha( 255 )
		particle:SetStartSize( math.random( 8, 12 ) )
		particle:SetEndSize( 1 )
		particle:SetRoll( math.Rand( -360, 360 ) )
		particle:SetColor( self.Color.r, self.Color.g, 0 )

		particle:SetGravity( Vector( 0, 0, -500 ) )
		particle:SetCollide( true )
		particle:SetBounce( 0.5 )

		particle:SetCollideCallback( function( part, pos, normal )

			util.Decal( "yellowblood", pos + normal, pos - normal )

		end )

	end

	emitter:Finish()

	for i=1, 10 do

		local ed = EffectData()
		ed:SetOrigin( pos + Vector( 0, 0, math.random( 0, 30 ) ) )

		if i < 5 then
			ed:SetScale( 1 )
		else
			ed:SetScale( 2 )
		end

		util.Effect( "player_gib", ed, true, true )

	end

end

function EFFECT:Think()

	if self.SoundTime < CurTime() then

		sound.Play( table.Random( GAMEMODE.GoreSplat ), self.Pos, 100, math.random(90,110) )

		self.SoundTime = CurTime() + 0.5

	end

	return self.DieTime > CurTime()

end

function EFFECT:Render()

end