summaryrefslogtreecommitdiff
path: root/gamemode/cl_hudstains.lua
blob: 587b1dc4426b9eb4ce9a19ebea331c2c3111b529 (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
local BloodTable = {}

local function DrawBlood()

	if #BloodTable < 1 then return end

	for i=1, #BloodTable do

		if BloodTable[i] then

			local scale = math.Clamp( ( BloodTable[i].DieTime - CurTime() ) / BloodTable[i].Die, 0, 1 )

			if scale == 0 then

				BloodTable[i].Remove = true

			else

				local alpha = math.floor( BloodTable[i].Alpha * scale )

				surface.SetTexture( BloodTable[i].Mat )
				//surface.SetDrawColor( 250, 10, 10, alpha )
				surface.SetDrawColor( 175, 10, 10, alpha )
				surface.DrawTexturedRect( BloodTable[i].X, BloodTable[i].Y, BloodTable[i].Size, BloodTable[i].Size )//, BloodTable[i].Rot )

			end

		end

	end

	for k,v in pairs( BloodTable ) do

		if v.Remove then

			table.remove( BloodTable, k )

			break

		end

	end

end
hook.Add( "HUDPaint", "BloodPaint", DrawBlood )

StainMats = { "nuke/blood/Blood1",
"nuke/blood/Blood2",
"nuke/blood/Blood3",
"nuke/blood/Blood4",
"nuke/blood/Blood5",
"nuke/blood/Blood6",
"nuke/blood/Blood7" }

function AddStain( msg )

	local num = 1

	if msg then

		num = msg:ReadShort()

	end

	for i=1, num do

		local count = #BloodTable + 1

		local size = math.random( 256, 1024 )
		local x = math.random( size * -0.5, ScrW() - ( size * 0.5 ) )
		local y = math.random( size * -0.5, ScrH() - ( size * 0.5 ) )
		local rand = math.Rand( 3.5, 6.5 )

		BloodTable[count] = { Size = size, X = x, Y = y, Mat = surface.GetTextureID( table.Random( StainMats ) ), Die = rand, DieTime = CurTime() + rand, Alpha = math.random( 150, 250 ) }

	end

end

usermessage.Hook( "BloodStain", AddStain )