Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. if self.Owner:KeyDown(IN_USE) then
  2.                 local trd={}
  3.                 trd.start=self.Owner:EyePos()
  4.                 local dist=100
  5.                 trd.endpos=trd.start+self.Owner:GetAimVector()*dist
  6.                 trd.filter=self.Owner
  7.                 local tr=util.TraceLine(trd)
  8.                 if tr.Hit and !self.TrEntity then
  9.                     self.TrEntity=tr.Entity
  10.                     self.TrEntity.WeaponHoldPos=self.TrEntity.WeaponHoldPos or self.TrEntity:WorldToLocal(tr.HitPos)
  11.                     self.TrEntity.WeaponHoldDistance=trd.start:Distance(tr.HitPos)
  12.                 end
  13.                 if self.TrEntity and ValidEntity(self.TrEntity) and self.TrEntity.WeaponHoldPos then
  14.                     local pos=self.TrEntity:LocalToWorld(self.TrEntity.WeaponHoldPos)
  15.                     dist=self.TrEntity.WeaponHoldDistance
  16.                     if pos:Distance(trd.start)>120 then
  17.                         self.TrEntity.WeaponHoldPos=nil
  18.                         self.TrEntity=nil
  19.                     else
  20.                         local ph=self.TrEntity:GetPhysicsObject()
  21.                         if ph and ph:IsValid() then
  22.                             ph:ApplyForceOffset((self.TrEntity:GetVelocity()*-0.1+trd.start+tr.Normal*dist-pos)*200*math.Clamp(300-ph:GetMass(),0,250)/300*math.Clamp(ph:GetMass()-1,0.1,15)/15, pos)
  23.                             ph:AddAngleVelocity(ph:GetAngleVelocity()*-0.1)
  24.                         end
  25.                     end
  26.                 end
  27.             elseif self.TrEntity then
  28.                 self.TrEntity.WeaponHoldPos=nil
  29.                 self.TrEntity=nil
  30.             end
  31.         end
  32.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement