diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-02-18 21:55:55 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-02-18 21:55:55 -0500 |
| commit | a22cbeddc5f8fb61e87a30aa14ba354de5cf4431 (patch) | |
| tree | 297c1dbfb23185c5246e1dd7bdec52253a24ba60 /entities/weapons/hands.lua | |
| parent | f4ee62bb0725a3ae94477b2818071f506e4dfd9f (diff) | |
| download | artery-a22cbeddc5f8fb61e87a30aa14ba354de5cf4431.tar.gz artery-a22cbeddc5f8fb61e87a30aa14ba354de5cf4431.tar.bz2 artery-a22cbeddc5f8fb61e87a30aa14ba354de5cf4431.zip | |
Updates
Diffstat (limited to 'entities/weapons/hands.lua')
| -rw-r--r-- | entities/weapons/hands.lua | 101 |
1 files changed, 29 insertions, 72 deletions
diff --git a/entities/weapons/hands.lua b/entities/weapons/hands.lua index d55c416..1354941 100644 --- a/entities/weapons/hands.lua +++ b/entities/weapons/hands.lua @@ -36,81 +36,38 @@ function SWEP:ShouldDropOnDie() return false end -local Box = Vector(8,8,8) - function SWEP:PrimaryAttack() - if not self.Owner.Inventory then return end - local rightitem = self.Owner.Inventory.Equiped["Left"] - if rightitem ~= false and rightitem.onClick ~= nil then - rightitem:onClick(self.Owner) - end - --[[ - if (CLIENT and !IsFirstTimePredicted()) then return end - if (!self.Owner.Weapons or !self.Owner.Weapons[self.Owner.Select]) then return end - if (self.Owner.CD and self.Owner.CD > CurTime()) then return end - - local item = self.Owner.Weapons[self.Owner.Select].Item - - if (!item or !item.OnPrimary) then return end - - self.Owner:SetAnimation( PLAYER_ATTACK1 ) - - local Trace = { - start = self.Owner:GetShootPos(), - endpos = self.Owner:GetShootPos()+self.Owner:GetAimVector()*item.Range, - filter = self.Owner, - mins = Box*-1, - maxs = Box, - } - - local Tr = util.TraceHull(Trace) - - item:OnPrimary(self.Owner,Tr) - - self.Owner.CD = CurTime()+item.CD - ]] + if CLIENT then return end + + --Make sure we have an equipment inventory + if not self.Owner then return end + if not self.Owner.data then return end + if not self.Owner.data.inventories then return end + if not self.Owner.data.inventories[1] then return end + local eqpd = self.Owner.data.inventories[1] + + --Get the weapon we want to fire, and fire it! + local weapon = eqpd:Get({"Left Hand"}) or eqpd:Get({"Dual"}) + if not weapon then return end --Make sure we have a weapon + if weapon.onClick ~= nil then + weapon:onClick(self.Owner) + end end function SWEP:SecondaryAttack() - local rightitem = self.Owner.Inventory.Equiped["Right"] - if rightitem ~= false and rightitem.onClick ~= nil then - rightitem:onClick(self.Owner) - end -end - -if (CLIENT) then - local Zero = Vector(1,1,1) - --[[ - function SWEP:DrawWorldModel() - if (!self.Owner.Weapons or !self.Owner.Weapons[self.Owner.Select]) then return end - - local item = self.Owner.Weapons[self.Owner.Select].Item - - for k,v in pairs(item.Structure) do - local ID = self.Owner:LookupBone(v.Bone) - local Pos,Ang = self.Owner:GetBonePosition(ID) - - local Offset = v.Pos*1 - Offset:Rotate(Ang) - Pos = Pos + Offset - - local Dang = Ang*1 - - Ang:RotateAroundAxis(Dang:Right(),v.Ang.p) - Ang:RotateAroundAxis(Dang:Up(),v.Ang.y) - Ang:RotateAroundAxis(Dang:Forward(),v.Ang.r) - - self.MOB:SetModel(v.Model) - self.MOB:SetRenderOrigin(Pos) - self.MOB:SetRenderAngles(Ang) - - local mat = Matrix() - mat:Scale( v.Size or Zero ) - - self.MOB:EnableMatrix( "RenderMultiply", mat ) - self.MOB:SetupBones() - self.MOB:DrawModel() - end + if CLIENT then return end + + --Make sure we have an equipment inventory + if not self.Owner then return end + if not self.Owner.data then return end + if not self.Owner.data.inventories then return end + if not self.Owner.data.inventories[1] then return end + local eqpd = self.Owner.data.inventories[1] + + --Get the weapon we want to fire, and fire it! + local weapon = eqpd:Get({"Right Hand"}) or eqpd:Get({"Dual"}) + if not weapon then return end --Make sure we have a weapon + if weapon.onClick ~= nil then + weapon:onClick(self.Owner) end - ]] end |
