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.lua43
1 files changed, 30 insertions, 13 deletions
diff --git a/gamemode/core/combat/cl_weaponswing.lua b/gamemode/core/combat/cl_weaponswing.lua
index 46603ba..54f7dee 100644
--- a/gamemode/core/combat/cl_weaponswing.lua
+++ b/gamemode/core/combat/cl_weaponswing.lua
@@ -1,5 +1,6 @@
local CLIENT_PAC_DIR = "artery/client/pacs"
local itm = nrequire("item.lua")
+local stt = nrequire("cl_state.lua")
local ball
function finddmgpoint(name)
local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name)
@@ -15,12 +16,23 @@ function finddmgbox(who,name)
local outfit = CompileString(string.format("return {%s}",filetext),name)()
assert(outfit ~= nil, string.format("Failed to compile %q",filetext))
ball = who:FindPACPart(outfit, "wep_box")
- print("box is", ball,type(ball))
assert(ball ~= pac.NULL, string.format("Could not find a prop called %q on pac %q","web_box",name))
end
local swingtbl = {}
local tracking = false
+local animent
+
+local swingtodraw = nil
+hook.Add("PreDrawTranslucentRenderables","draw_wepswing",function()
+ local lpp = LocalPlayer():GetPos()
+ if swingtodraw ~= nil then
+ for i = 2, #swingtodraw do
+ render.DrawLine( lpp + swingtodraw[i], lpp + swingtodraw[i-1], Color(255,0,0,255), false )
+ render.DrawLine( lpp + swingtodraw[i], lpp + swingtodraw[i-1] + Vector(0,0,10), Color(0,255,0,255), false )
+ end
+ end
+end)
net.Receive("artery_doanimation",function()
local animname = net.ReadString()
@@ -29,23 +41,30 @@ net.Receive("artery_doanimation",function()
local pacname = net.ReadString()
local animdir = net.ReadString()
local who = net.ReadEntity()
+ local waittime = net.ReadDouble()
swingtbl = {}
--pac.SetupENT(who)
finddmgbox(who,pacname)
- tracking = true
+ animent = who
print("Doing animation:",animname,animtime,echoname)
+ who:SetupBones()
who:SetLuaAnimation(animname)
+ stt.invopen=true
+ timer.Simple(waittime,function()
+ tracking = true
+ end)
timer.Simple(animtime,function()
tracking = false
+ stt.invopen=false
+ print("Stopping animation",animname)
who:StopLuaAnimation(animname)
net.Start("artery_notifyserverofswing")
net.WriteString(wepname)
- net.WriteString(animdir)
- print("Seding swingtbl:")
- PrintTable(swingtbl)
+ net.WriteString(animname)
net.WriteTable(swingtbl)
net.SendToServer()
+ swingtodraw = swingtbl
end)
end)
@@ -57,16 +76,14 @@ concommand.Add("artery_startanimation",function(ply,cmd,args)
end)
end)
---[[
local lastpos
hook.Add("Tick","trace_weppos",function()
- if not ball or not ball.Entity then return end
+ if not IsValid(ball) or not IsValid(ball.Entity) 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())
+ --print("Distance between ", ball.Entity:GetPos(), "and", lastpos, " is" ,ball.Entity:GetPos():Distance(lastpos))
+ if --[[ball.Entity:GetPos():Distance(lastpos) > 0.5 and]] tracking then
+ swingtbl[#swingtbl + 1] = ball.Entity:GetPos() - animent:GetPos()
+ --print(ball.Entity:GetPos() - animent:GetPos())
+ lastpos = ball.Entity:GetPos()
end
- lastpos = ball.Entity:GetPos()
end)
-]]