• Damage drop off & Kill display
    5 replies, posted
Hello amigos! Im making a PUBG Hud. Im almost finished but i need to do some finishing touches. One thing that i need is whenever the player gets damage it's gets a drop off. Like this: [URL="http://www.youtube.com/watch?v=3n_BZK12Vzw&t=1m17s"]http://www.youtube.com/watch?v=3n_BZK12Vzw&t=1m17s[/URL] And whenever a player is under a certain amount of health for example 50% or 25% the bar will get Red. Im using RoundedBoxes for the healthbar. The second thing is the kill display. I was working on it but i couldn't get it to work. It's whenever a player kills a other player it displays this: [url]http://www.youtube.com/watch?v=3n_BZK12Vzw&t=3m28s[/url] I hope you can get me a step further by helping me out and giving me some tips that i could use making this all work. Thank you for your time.
Maybe provide code????? We cannot help you much without your code. Also, what do you mean by damage drop off? Do you mean the blood on the screen? To make the bar red after it reaches a certain percentage, just create an if statement checking if [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/Health]Entity:Health[/url] is lower than a percentage of the player's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetMaxHealth]Entity:GetMaxHealth[/url]. To make a kill display, grab the number of frags the player has using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Frags]Player:Frags[/url] and then draw it on their screen using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/DrawText]draw.DrawText[/url]. If you want, you can use the surface library instead of the draw library.
damage drop off garrysmod/gamemodes/base/gamemode/player.lua [CODE]function GM:ScalePlayerDamage( ply, hitgroup, dmginfo) local attacker = dmginfo:GetAttacker() local usedgun = attacker:GetActiveWeapon():GetClass() local caliber = attacker:GetActiveWeapon():GetPrimaryAmmoType() -- alternative method, use ammo types to create universal weapon damage fall off -- instead of individual weapon damage fall off graphs if IsValid(attacker) and IsValid(ply) then local attackpos = attacker:GetPos() local victimpos = ply:GetPos() local range = attackpos:Distance(victimpos) local metre = (512 / 9.75) -- conversion from hammer units to metres (512 units = 9.75m) if usedgun == ("cw_l115") then -- a weapon damage fall off graph for the l115 gun local effrange = (100 * metre) -- range at which damage falls off, straight line graph from max damage to 3 times max damage local maxrange = (200 * metre) -- range at which gun is ineffective greatly, 3 times less damage local maxdmg = 550 -- make sure its the same as the weapons damage if range > maxrange then local falloff = 0.3 dmginfo:ScaleDamage(falloff) elseif range > effrange then local falloff = (((maxdmg - (maxdmg/3)) / ((effrange - maxrange)) * range) + ((maxdmg - (maxdmg/3)) / (effrange - maxrange) * range)) dmginfo:ScaleDamage(falloff/maxdmg) elseif range > 0 then dmginfo:ScaleDamage(1) elseif usedgun == ("cw_ak47") then -- weapon fall off for the ak47 local effrange = (50 * metre) local maxrange = (70 * metre) local maxdmg = 190 if range > maxrange then local falloff = 0.3 dmginfo:ScaleDamage(falloff) elseif range > effrange then local falloff = (((maxdmg - (maxdmg/3)) / ((effrange - maxrange)) * range) + ((maxdmg - (maxdmg/3)) / (effrange - maxrange) * range)) dmginfo:ScaleDamage(falloff/maxdmg) elseif range > 0 then dmginfo:ScaleDamage(1) end end end end[/CODE] kill display addons goto Steam\steamapps\common\GarrysMod\bin and create a shortcut of the gmad.exe file, put it into a folder on your desktop then find the following addons inside your addons folder drag and drop them onto the gmad.exe file individually to create their source code dont profit of their work [url]https://steamcommunity.com/sharedfiles/filedetails/?id=601936815[/url] -- untested [url]https://steamcommunity.com/sharedfiles/filedetails/?id=191294108[/url] -- working red damage indication hud [CODE]hook.Add("HUDPaint", "DrawMyHud" , function() local client = LocalPlayer() if !client:Alive() then return end if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end --- all your hud elements below --- ------------------------------------------- -- the screen goes red when you take damage! if(client:Health() >= 100) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(0,0,0,0)) elseif(client:Health() >= 95) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(5,0,0,5)) elseif(client:Health() >= 90) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(10,0,0,10)) elseif(client:Health() >= 85) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(15,0,0,15)) elseif(client:Health() >= 80) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(20,0,0,20)) elseif(client:Health() >= 75) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(25,0,0,25)) elseif(client:Health() >= 70) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(30,0,0,30)) elseif(client:Health() >= 65) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(35,0,0,35)) elseif(client:Health() >= 60) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(40,0,0,40)) elseif(client:Health() >= 55) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(45,0,0,45)) elseif(client:Health() >= 50) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(50,0,0,50)) elseif(client:Health() >= 45) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(55,0,0,55)) elseif(client:Health() >= 40) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(60,0,0,60)) elseif(client:Health() >= 35) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(65,0,0,65)) elseif(client:Health() >= 30) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(70,0,0,70)) elseif(client:Health() >= 25) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(75,0,0,75)) elseif(client:Health() >= 20) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(80,0,0,80)) elseif(client:Health() >= 15) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(85,0,0,85)) elseif(client:Health() >= 10) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(90,0,0,90)) elseif(client:Health() >= 5) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(95,0,0,95)) elseif(client:Health() >= 0) then draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(100,0,0,100)) end end)[/CODE] [editline]23rd September 2017[/editline] local falloff = (((maxdmg - (maxdmg/3)) / ((effrange - maxrange)) * range) + ((maxdmg - (maxdmg/3)) / (effrange - maxrange) * range)) is wrong dont use it
can't tell if the post above is a troll or if he's being serious. either way that's hilarious. [lua] hook.Add("HUDPaint", "DrawMyHud" , function() local client = LocalPlayer() if !client:Alive() then return end local EPIC_RED_SCREEN_AMOUNT = (client:Health()/client:GetMaxHealth())*100 draw.RoundedBox(0,0,0,ScrW(),ScrH(), Color(EPIC_RED_SCREEN_AMOUNT,0,0,EPIC_RED_SCREEN_AMOUNT) end) [/lua]
He didn't actually mean the red screen with your health going down, he meant those animated sections when you get damage that go from initial amount of health, to the correct, true one (after damage)
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Lerp]Lerp[/url]? [editline]26th September 2017[/editline] Good tutorial by CodeBlue. [url]https://www.youtube.com/watch?v=OeXt3WknAoA[/url]
Sorry, you need to Log In to post a reply to this thread.