aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/combat/cl_weaponswing.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/core/combat/cl_weaponswing.lua')
-rw-r--r--gamemode/core/combat/cl_weaponswing.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/gamemode/core/combat/cl_weaponswing.lua b/gamemode/core/combat/cl_weaponswing.lua
new file mode 100644
index 0000000..8ed9637
--- /dev/null
+++ b/gamemode/core/combat/cl_weaponswing.lua
@@ -0,0 +1,57 @@
+local CLIENT_PAC_DIR = "artery/client/pacs"
+
+local ball
+function finddmgpoint(name)
+ local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name)
+ local filetext = file.Read(filepath,"DATA")
+ local outfit = CompileString(string.format("return {%s}",filetext),name)()
+ ball = LocalPlayer():FindPACPart(outfit, "wep_point")
+ print("point is",ball,type(ball))
+end
+
+local swingtbl = {}
+local tracking = false
+
+net.Receive("artery_doanimation",function()
+ local animname = net.ReadString()
+ local animtime = net.ReadDouble()
+ local wepname = net.ReadString()
+ local animdir = net.ReadString()
+
+ swingtbl = {}
+ tracking = true
+ finddmgpoint(wepname)
+ print("Doing animation:",animname,animtime,echoname)
+ LocalPlayer():SetLuaAnimation(animname)
+ timer.Simple(animtime,function()
+ tracking = false
+ LocalPlayer():StopLuaAnimation(animname)
+ net.Start("artery_notifyserverofswing")
+ net.WriteString(wepname)
+ net.WriteString(animdir)
+ print("Seding swingtbl:")
+ PrintTable(swingtbl)
+ net.WriteTable(swingtbl)
+ net.SendToServer()
+ end)
+end)
+
+concommand.Add("artery_startanimation",function(ply,cmd,args)
+ swingtbl = {}
+ ply:SetLuaAnimation(args[1])
+ timer.Simple(args[2],function()
+ ply:StopLuaAnimation(args[1])
+ end)
+end)
+
+local lastpos
+hook.Add("Tick","trace_weppos",function()
+ if not ball then return end
+ if lastpos == nil then lastpos = ball.Entity:GetPos() end
+ --`print("Distance between ", ball.Entity:GetPos(), "and", lastpos, " is" ,ball.Entity:GetPos():Distance(lastpos))
+ if ball.Entity:GetPos():Distance(lastpos) > 2 and tracking then
+ swingtbl[#swingtbl + 1] = ball.Entity:GetPos() - LocalPlayer():GetPos()
+ print(ball.Entity:GetPos() - LocalPlayer():GetPos())
+ end
+ lastpos = ball.Entity:GetPos()
+end)