aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/itemsystem/weapons_common.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-08-09 17:53:52 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-08-09 17:53:52 -0400
commitd4f197a35c207c9891d3f4dc5e9708af48c935de (patch)
treeee8fd3960c3a3fb4ecaf0f62b50d251f007ebaf3 /gamemode/shared/itemsystem/weapons_common.lua
parent2fe3c4551344870e3784733fce2d95027b5c8382 (diff)
downloadartery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.gz
artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.bz2
artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.zip
Added some weapons
Diffstat (limited to 'gamemode/shared/itemsystem/weapons_common.lua')
-rw-r--r--gamemode/shared/itemsystem/weapons_common.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/gamemode/shared/itemsystem/weapons_common.lua b/gamemode/shared/itemsystem/weapons_common.lua
new file mode 100644
index 0000000..5da9b9a
--- /dev/null
+++ b/gamemode/shared/itemsystem/weapons_common.lua
@@ -0,0 +1,59 @@
+
+ART = ART or {}
+
+
+function ART.playermovedir(player)
+ local vel = player:GetVelocity():GetNormalized()
+ vel.z = 0
+ local swings = {
+ {player:GetForward(),"forward"},
+ {-player:GetForward(),"backward"},
+ {player:GetRight(),"right"},
+ {-player:GetRight(),"left"}
+ }
+ table.sort(swings,function(a,b)
+ return vel:Dot(a[1]) > vel:Dot(b[1])
+ end)
+ return swings[1][2]
+end
+
+local positionset = {}
+
+function ART.swingarc(player,times,positions,onhit)
+ local positionpoints = {}
+ table.insert(positionset,positionpoints)
+ local hitents = {}
+ for k,v in ipairs(times) do
+ timer.Simple(v,function()
+ local weaponpos = positions[k] + player:GetPos()
+ table.insert(positionpoints,weaponpos)
+ if #positionpoints > 1 then
+ local tr = util.TraceLine({
+ start = positionpoints[#positionpoints-1],
+ endpos = positionpoints[#positionpoints],
+ })
+ if tr.Hit then
+ onhit(tr)
+ end
+ end
+ end)
+ end
+ timer.Simple(times[#times],function()
+ print("Inserted swing, drawn positions are now:")
+ PrintTable(positionset)
+ end)
+end
+
+hook.Add( "HUDPaint", "weaponswings", function()
+ cam.Start3D() -- Start the 3D function so we can draw onto the screen.
+ for k,v in pairs(positionset) do
+ for i = 1,#v-1 do
+ render.DrawLine( v[i], v[i+1], Color(255,0,0,255), false )
+ end
+ end
+ --render.SetMaterial( material ) -- Tell render what material we want, in this case the flash from the gravgun
+ --render.DrawSprite( pos, 16, 16, white ) -- Draw the sprite in the middle of the map, at 16x16 in it's original colour with full alpha.
+ cam.End3D()
+end )
+
+return wcommon