hook.Add( "HUDShouldDraw", "HideHUD", function( name ) if name == "CHudHealth" then return false end end ) --A function that rotates a point around another point local function rotatepoint(x,y,cx,cy,rot) rot = math.rad(rot) local cs,sn = math.cos(rot),math.sin(rot) local px = x * cs - y * sn; local py = x * sn + y * cs; return px,py end --Add a function to the draw library to draw elipses for blood local segments = 20 local fade = 0.5 function draw.DrawElipse(x,y,radius,elong,rotation) rotation = math.rad(rotation) local cir = {} table.insert( cir, { x = x, y = y, u = fade, v = fade } ) for i = 0, segments do local a = math.rad( ( i / segments ) * -360 ) local xu,yu = math.sin(a),math.cos(a) local xpos = xu * radius * elong local ypos = yu * radius local cs,sn = math.cos(rotation),math.sin(rotation) xpos,ypos = xpos * cs - ypos * sn, xpos * sn + ypos * cs table.insert( cir, { x = x + xpos, y = y + ypos, u = 1, v = 1 } ) end surface.DrawPoly( cir ) end local width,height = ScrW(),ScrH() local padding = height / 32 local barheight = height / 16 local bubbles = {} local blobs = {} local lastpos = 0 local bubbleradius = height/64 local delpoint = height hook.Add( "Tick", "Hudpaintbloodtick",function() for k,v in pairs(blobs) do if v.y > delpoint then blobs[k] = nil else blobs[k] = { ["x"] = v.x + v.xv, ["y"] = v.y + v.yv, ["xv"] = v.xv, ["yv"] = v.yv + 1, } end end for k,v in pairs(bubbles) do if v.y < height - padding - barheight -bubbleradius then bubbles[k] = nil else local subheight = v.y - (1.5 + math.sin((v.y/4) + (v.x*10)))/5 bubbles[k].y = subheight end end end) local lasthealth local obarlength = width / 4 local barlength = obarlength local xs,ys = padding,height - padding - barheight local bubblespawnrate,bubblespawnchance = 1,0.7 timer.Create("Healthbar_bubble_timer",bubblespawnrate,0,function() if math.random() < bubblespawnchance then local newbubble = { ["x"] = math.random(xs + bubbleradius,barlength-bubbleradius), ["y"] = height - padding + bubbleradius } table.insert(bubbles,newbubble) end end) hook.Add( "HUDPaint", "HUD_DrawHealth", function() --Spawn a bunch of blobs if our health has changed local health = LocalPlayer():Health() if lasthealth == nil then lasthealth = health end if health ~= lasthealth then local difference = lasthealth - health barlength = obarlength * (health/100) for i=0,difference*3 do local rtime = math.random() timer.Simple(rtime,function() local yvel = -20 + math.random(10) local xvel = (math.random()*5) local xpos = padding + xs + barlength - difference - 5 local ypos = ys + (math.random() * barheight) table.insert(blobs,{ x = xpos, y = ypos, xv = xvel, yv = yvel, }) end) end lasthealth = health end --Draw the current health thing --Background surface.SetDrawColor(100,100,100,100) surface.DrawRect( xs, ys, obarlength, barheight) --Foreground surface.SetDrawColor( 150, 0, 0, 255 ) surface.DrawRect( xs, ys, barlength, barheight ) --Heighlighting/shadows local heighlightheight = barheight/3 for k = 1, heighlightheight do local perc = Lerp(k/heighlightheight,100,0) surface.SetDrawColor( 150+perc, perc, perc, 255) surface.DrawRect( xs, ys+k, barlength, 1) end for k = 1, heighlightheight do local perc = Lerp(k/heighlightheight,0,100) surface.SetDrawColor( 150 - perc, 0, 0, 255) surface.DrawRect(xs, ys+k+(2*heighlightheight), barlength, 1) end --Draw bubbles render.SetScissorRect( xs, ys, xs + barlength, ys + barheight, true ) -- Enable the rect surface.SetDrawColor(250,150,150,10) for k,v in pairs(bubbles) do surface.DrawCircle(v.x,v.y,bubbleradius,250,150,150,30) draw.DrawElipse(v.x,v.y,bubbleradius,1,0) end render.SetScissorRect( 0, 0, 0, 0, false ) -- Disable after you are done --Draw the animation for blobs surface.SetDrawColor(150,0,0,255) for k,v in pairs(blobs) do --Elongation is based on velocity local elong = (v.yv^2 + v.xv^2)^0.5 elong = elong/5 elong = math.Clamp(elong,1,3) --Rotation is also based on velcotiy local rot = math.deg(math.atan(v.yv/v.xv)) draw.DrawElipse(v.x,v.y,10/elong,elong, rot) end end )