From 233e478e40d72a091f70f18dc6846066a4f52016 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Thu, 24 Aug 2017 20:32:34 -0400 Subject: Fix all linter warnings --- gamemode/core/combat/cl_damage.lua | 39 ++++++++++++++------------------- gamemode/core/combat/cl_weaponswing.lua | 5 ++--- gamemode/core/combat/sv_weaponswing.lua | 30 ++++++++++++------------- 3 files changed, 32 insertions(+), 42 deletions(-) (limited to 'gamemode/core/combat') diff --git a/gamemode/core/combat/cl_damage.lua b/gamemode/core/combat/cl_damage.lua index fee8175..5059588 100644 --- a/gamemode/core/combat/cl_damage.lua +++ b/gamemode/core/combat/cl_damage.lua @@ -1,18 +1,12 @@ --Displays numbers for damage -local drawables = { - [1] = { - starttime = CurTime(), - ammt = 5, - startpos = LocalPlayer():GetEyeTrace().HitPos - } -} +local drawables = {} net.Receive("art_damage_ent",function() print("Notified of damage") local who = net.ReadEntity() local dmg = net.ReadDouble() - + --A random vector in the entity local aa,bb = who:WorldSpaceAABB() local mr = math.random @@ -22,48 +16,47 @@ net.Receive("art_damage_ent",function() ammt = dmg, startpos = Vector(rx,ry,rz) } - + --Max 255 drawables at once - drawables[#drawables+1 % 255] = drawinfo + drawables[(#drawables + 1) % 255] = drawinfo end) hook.Add( "PostDrawOpaqueRenderables", "art_damage_draw", function() local trace = LocalPlayer():GetEyeTrace() local angle = trace.HitNormal:Angle() - + local lpp,sp = LocalPlayer():GetPos(),trace.HitPos local to = lpp - sp local matang = to:Angle() - + matang.r = 90 - matang.y = matang.y+90 + matang.y = matang.y + 90 matang.p = 0 render.DrawLine( trace.HitPos, trace.HitPos + 8 * angle:Forward(), Color( 255, 0, 0 ), true ) render.DrawLine( trace.HitPos, trace.HitPos + 8 * -angle:Right(), Color( 0, 255, 0 ), true ) render.DrawLine( trace.HitPos, trace.HitPos + 8 * angle:Up(), Color( 0, 0, 255 ), true ) - + surface.SetFont( "Trebuchet24" ) - local lpp = LocalPlayer():GetPos() for k,v in pairs(drawables) do local ct = CurTime() local delta = ct - v.starttime - local alpha = 255 * (math.log(v.ammt) - (delta/2)) + local alpha = 255 * (math.log(v.ammt) - (delta / 2)) if alpha < 1 then drawables[k] = nil continue end local lam = math.log(v.ammt) - local lad = (20/lam) + local lad = 20 / lam local opx = math.sin(delta) * lad local opy = math.cos(delta) * lad - local dpos = v.startpos + Vector(opx,opy,delta*100*(1/v.ammt)+20) - local matang = (lpp - dpos):Angle() - matang.r = 90 - matang.y = matang.y + 90 - matang.p = 0 + local dpos = v.startpos + Vector(opx,opy,delta * 100 * (1 / v.ammt) + 20) + local nmatang = (lpp - dpos):Angle() + nmatang.r = 90 + nmatang.y = nmatang.y + 90 + nmatang.p = 0 surface.SetTextColor( 255, 255, 255, alpha ) - cam.Start3D2D( dpos, matang, lam ) + cam.Start3D2D( dpos, nmatang, lam ) surface.SetTextPos(0,0) surface.DrawText(tostring(v.ammt)) cam.End3D2D() diff --git a/gamemode/core/combat/cl_weaponswing.lua b/gamemode/core/combat/cl_weaponswing.lua index 11557e5..ec5b954 100644 --- a/gamemode/core/combat/cl_weaponswing.lua +++ b/gamemode/core/combat/cl_weaponswing.lua @@ -1,5 +1,4 @@ local CLIENT_PAC_DIR = "artery/client/pacs" -local itm = nrequire("item.lua") local stt = nrequire("cl_state.lua") local ball function finddmgpoint(name) @@ -65,13 +64,13 @@ net.Receive("artery_doanimation",function() print("Doing animation:",animname,animtime,echoname) who:SetupBones() who:SetLuaAnimation(animname) - stt.invopen=true + stt.invopen = true timer.Simple(waittime,function() tracking = true end) timer.Simple(animtime,function() tracking = false - stt.invopen=false + stt.invopen = false print("Stopping animation",animname) who:StopLuaAnimation(animname) net.Start("artery_notifyserverofswing") diff --git a/gamemode/core/combat/sv_weaponswing.lua b/gamemode/core/combat/sv_weaponswing.lua index f754000..ea43f0b 100644 --- a/gamemode/core/combat/sv_weaponswing.lua +++ b/gamemode/core/combat/sv_weaponswing.lua @@ -1,14 +1,14 @@ --[[ This file tells you what weapons need their swings recalculated ]] -local itm = nrequire("core/inventory/item.lua") -local inv = nrequire("core/inventory/inventory.lua") +-- local itm = nrequire("core/inventory/item.lua") +-- local inv = nrequire("core/inventory/inventory.lua") local wep = nrequire("core/inventory/common/weapons.lua") local ws = {} --Cache swing hits, if we used one once, we'll probably use it again soon -local swingcache_size = 30 -local swingcache = {} --Swing arc cache +-- local swingcache_size = 30 +-- local swingcache = {} --Swing arc cache --A table of all the items that are swingable local swingable = {} @@ -25,18 +25,18 @@ net.Receive("artery_notifyserverofswing",function() local weapon = net.ReadString() local anim = net.ReadString() local data = net.ReadTable() - + print("Got swing data for ",weapon,anim) PrintTable(data) - + --Get the data that already exists for this weapon local olddata = file.Read("artery/dynamic/swingdata/" .. weapon .. ".txt","DATA") if olddata == nil then olddata = {} else olddata = util.JSONToTable(util.Decompress(olddata)) end - + --Add our new data olddata[anim] = data - + --And save back file.Write("artery/dynamic/swingdata/" .. weapon .. ".txt",util.Compress(util.TableToJSON(olddata))) end) @@ -86,10 +86,8 @@ function ws.doSwing(weapon,ply,callback) for k,v in pairs(hitthings) do callback(v) end - if #hitthings == 0 then - if weapon.onMiss then - weapon:onMiss(ply) - end + if #hitthings == 0 and weapon.onMiss then + weapon:onMiss(ply) end end) end @@ -100,7 +98,7 @@ concommand.Add("artery_recordanimations",function(ply,cmd,args) local e = ply e:SetAngles(Angle(0,0,0)) e:SetEyeAngles(Angle(0,0,0)) - + --Add everything in swingables to a queue to be recorded for k,v in pairs(swingable) do for i,j in pairs(v.attacks) do @@ -115,7 +113,7 @@ concommand.Add("artery_recordanimations",function(ply,cmd,args) recordqueue[#recordqueue + 1] = tn end end - + --Create timers for everything local timefromnow = 0 for k,v in ipairs(recordqueue) do @@ -123,7 +121,7 @@ concommand.Add("artery_recordanimations",function(ply,cmd,args) print("timefromnow 1 is",timefromnow) --Put the item into the inventory local tfunc = function(nowtime) - local whentoremove = nowtime + 1 + v[3] + 1 + --local whentoremove = nowtime + 1 + v[3] + 1 timer.Simple(nowtime,function() print("timefromnow 2 is",nowtime) local einv = e.data.inventories[1] @@ -178,7 +176,7 @@ concommand.Add("artery_checkSwingable",function(ply,cmd,args) end nitms = nitms + 1 end - + print("Scanned ",nitms,"swingable items, could not find data for:\n\t",table.concat(noswingdata,"\n\t")) end) -- cgit v1.2.3-70-g09d2