From 2c4329e2b6e19182a441f79a5c3010011f8ae767 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 27 Nov 2016 22:02:47 -0500 Subject: Vairous updates --- gamemode/shared/itemsystem/weapons/scraphammer.lua | 134 ++++++++++++++++----- 1 file changed, 101 insertions(+), 33 deletions(-) (limited to 'gamemode/shared/itemsystem/weapons/scraphammer.lua') diff --git a/gamemode/shared/itemsystem/weapons/scraphammer.lua b/gamemode/shared/itemsystem/weapons/scraphammer.lua index 9ec7ac9..299d4e2 100644 --- a/gamemode/shared/itemsystem/weapons/scraphammer.lua +++ b/gamemode/shared/itemsystem/weapons/scraphammer.lua @@ -26,6 +26,7 @@ function item.GetOptions(self) local options = {} options["test"] = function() print("You pressed test!") end options["toste"] = function() print("You pressed toste!") end + options["Drop"] = ART.DropItem(self) return options end @@ -60,7 +61,64 @@ item.Shape = { --Optional, If this item can be equiped in any player slots, put them here. item.Equipable = "Right" - +local swingdata = { + ["fwd"] = { + {0.007,Vector(-27,1,9)}, + {0.014,Vector(-20,3,16)}, + {0.020,Vector(-11,6,22)}, + {0.027,Vector(0,7,26)}, + {0.032,Vector(15,7,25)}, + {0.039,Vector(28,6,21)}, + {0.045,Vector(38,4,14)}, + {0.052,Vector(46,0,3)}, + {0.059,Vector(50,-3,-6)}, + {0.065,Vector(52,-6,-15)}, + {0.072,Vector(52,-8,-22)}, + {0.078,Vector(51,-10,-28)}, + {0.084,Vector(50,-11,-31)}, + {0.091,Vector(50,-11,-32)}, + {0.097,Vector(50,-11,-32)} + }, + ["lft"] = { + {0.007,Vector(-6,24,2)}, + {0.014,Vector(-1,26,2)}, + {0.020,Vector(5,28,1)}, + {0.027,Vector(12,28,-1)}, + {0.035,Vector(19,27,-4)}, + {0.042,Vector(27,24,-7)}, + {0.048,Vector(37,17,-13)}, + {0.055,Vector(42,12,-17)}, + {0.061,Vector(45,5,-20)}, + {0.068,Vector(48,-2,-23)}, + {0.075,Vector(49,-8,-25)}, + {0.084,Vector(49,-14,-26)}, + {0.091,Vector(49,-19,-27)}, + {0.097,Vector(48,-22,-27)}, + {0.104,Vector(48,-25,-27)}, + {0.110,Vector(48,-26,-27)}, + {0.117,Vector(48,-27,-27)}, + {0.123,Vector(48,-26,-27)}, + {0.131,Vector(48,-26,-27)} + }, + ["rig"] = { + {0.009,Vector(-3,25,2)}, + {0.017,Vector(3,27,1)}, + {0.025,Vector(11,28,-1)}, + {0.032,Vector(20,27,-4)}, + {0.040,Vector(28,24,-7)}, + {0.051,Vector(36,19,-12)}, + {0.059,Vector(42,11,-17)}, + {0.067,Vector(47,2,-22)}, + {0.075,Vector(49,-5,-25)}, + {0.083,Vector(49,-13,-27)}, + {0.090,Vector(49,-19,-28)}, + {0.098,Vector(48,-24,-28)}, + {0.106,Vector(48,-27,-28)}, + {0.114,Vector(48,-28,-28)}, + {0.121,Vector(48,-27,-28)}, + {0.129,Vector(48,-27,-27)} + }, +} --Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right item.lastSwing = {} @@ -70,26 +128,30 @@ item.onClick = function(self,owner) print("returning because item.lastSwing is " .. item.lastSwing[owner], "but Curtime is",CurTime()) return end item.lastSwing[owner] = CurTime()+1.33 - local fow,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp() + local fwd,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp() local movementtbl = { ["forward"] = function() owner:SetLuaAnimation("hammer_swing_up") timer.Simple(2.33,function() owner:StopLuaAnimation("hammer_swing_up") end) - local hits = ART.swingarc(owner,{ - 1,1.1,1.2,1.3 - },{ - fow*40 + up*26, - fow*60 + up*6, - fow*55 + up*-13, - fow*40 + up*-34, - },function(tr) - if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then + + local times,pos = {},{} + for k,v in ipairs(swingdata["fwd"]) do + times[k] = 1 + v[1] + pos[k] = Vector(v[2]) + pos[k]:Rotate(owner:GetAimVector():Angle()) + end + if pos[1] == nil then return end + local hits = ART.swingarc(owner,times,pos,function(tr) + if not tr.Hit then return end + if tr.Entity.Blocking ~= nil and tr.Entity.Blocking == "forward" then + ART.ApplyEffect(owner,"weapon_blocked") + elseif tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon()) end - print("Hit",tr.Entity) end) + end, ["backward"] = function() @@ -99,18 +161,21 @@ item.onClick = function(self,owner) timer.Simple(2.33,function() owner:StopLuaAnimation("hammer_swing_left") end) - local hits = ART.swingarc(owner,{ - 1,1.1,1.2,1.3 - },{ - rig*30 + up*-5, - rig*20 + fow*40 + up*-9, - rig*-20 + fow*40 + up*-10, - rig*-30 + up*-15, - },function(tr) - if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then - tr.Entity:TakeDamage(10, owner, owner:GetActiveWeapon()) + + local times,pos = {},{} + for k,v in ipairs(swingdata["lft"]) do + times[k] = 1 + v[1] + pos[k] = Vector(v[2]) + pos[k]:Rotate(owner:GetAimVector():Angle()) + end + if pos[1] == nil then return end + local hits = ART.swingarc(owner,times,pos,function(tr) + if not tr.Hit then return end + if tr.Entity.Blocking ~= nil and tr.Entity.Blocking == "left" then + ART.ApplyEffect(owner,"weapon_blocked") + elseif tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then + tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon()) end - print("Hit",tr.Entity) end) end, ["right"] = function() @@ -118,18 +183,21 @@ item.onClick = function(self,owner) timer.Simple(2.33,function() owner:StopLuaAnimation("hammer_swing_right") end) - local hits = ART.swingarc(owner,{ - 1,1.1,1.2,1.3 - },{ - rig*-30 + up*-5, - rig*-10 + fow*40 + up*-9, - rig*10 + fow*40 + up*-10, - rig*30 + up*-15, - },function(tr) - if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then + + local times,pos = {},{} + for k,v in ipairs(swingdata["rig"]) do + times[k] = 1 + v[1] + pos[k] = Vector(v[2]) + pos[k]:Rotate(owner:GetAimVector():Angle()) + end + if pos[1] == nil then return end + local hits = ART.swingarc(owner,times,pos,function(tr) + if not tr.Hit then return end + if tr.Entity.Blocking ~= nil and tr.Entity.Blocking == "right" then + ART.ApplyEffect(owner,"weapon_blocked") + elseif tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon()) end - print("Hit",tr.Entity) end) end, } -- cgit v1.2.3-70-g09d2