Blood splat on screen when hit and when close to splatter?
2 replies, posted
I would like to know how to have blood splats on your HUD when you get shot and when close to a blood splatter. and then fade away after 5 seconds.
all help is appreciated.
thanks :)
[lua]function GM:HUDPaint()
self.BaseClass:HUDPaint()
GAMEMODE:OnHUDPaint()
end
function GM:OnHUDPaint()
GAMEMODE:PaintBlood()
end
function GM:PaintBlood()
if #Stains < 1 then return end
for k,v in pairs( Stains ) do
v.Alpha = math.Approach( v.Alpha, 0, FrameTime() * v.DieRate * -1 )
surface.SetTexture( v.Mat )
surface.SetDrawColor( 255, 10, 10, v.Alpha )
surface.DrawTexturedRectRotated( v.X, v.Y, v.W, v.H, v.Rotation )
end
for k,v in pairs( Stains ) do
if v.Alpha < 2 then
table.remove( Stains, k )
elseif not LocalPlayer():Alive() then
v.DieRate = 30
end
end
end
function AddStain()
local x, y, w, h = ScrW() * math.Rand(-0.2,1), ScrH() * math.Rand(-0.2,1), ScrW() * math.Rand(0.3,0.6), ScrH() * math.Rand(0.3,0.6)
table.insert( Stains, {X = x, Y = y, W = w, H = h, Mat = table.Random( StainMats ), DieRate = math.Rand(5,15), Rot = math.random(0,360), Alpha = math.random(50,150)} )
end[/lua]
Just how Zombie Onslaught does it. Check the [URL="http://fretta-svn.googlecode.com/svn/trunk/zombieonslaught/gamemode/cl_hud.lua"]rest of code here[/URL].
Thanks for the help man this is really useful I'm going to test it now :)
Sorry, you need to Log In to post a reply to this thread.