Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if self.Owner:KeyDown(IN_USE) then
- local trd={}
- trd.start=self.Owner:EyePos()
- local dist=100
- trd.endpos=trd.start+self.Owner:GetAimVector()*dist
- trd.filter=self.Owner
- local tr=util.TraceLine(trd)
- if tr.Hit and !self.TrEntity then
- self.TrEntity=tr.Entity
- self.TrEntity.WeaponHoldPos=self.TrEntity.WeaponHoldPos or self.TrEntity:WorldToLocal(tr.HitPos)
- self.TrEntity.WeaponHoldDistance=trd.start:Distance(tr.HitPos)
- end
- if self.TrEntity and ValidEntity(self.TrEntity) and self.TrEntity.WeaponHoldPos then
- local pos=self.TrEntity:LocalToWorld(self.TrEntity.WeaponHoldPos)
- dist=self.TrEntity.WeaponHoldDistance
- if pos:Distance(trd.start)>120 then
- self.TrEntity.WeaponHoldPos=nil
- self.TrEntity=nil
- else
- local ph=self.TrEntity:GetPhysicsObject()
- if ph and ph:IsValid() then
- 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)
- ph:AddAngleVelocity(ph:GetAngleVelocity()*-0.1)
- end
- end
- end
- elseif self.TrEntity then
- self.TrEntity.WeaponHoldPos=nil
- self.TrEntity=nil
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement