Public feed #598895

Unnamed

public text v1 · immutable
Raw Edit
·published 2007-07-01 18:09 UTC
rendered paste body
function SWEP:Think()
	if self.heldEnt != nil && self.heldEnt:IsValid() then
		desiPos = self.Owner:EyePos() + self.Owner:GetAimVector() * 70
		ent = self.heldEnt
		local phy = ent:GetPhysicsObject()
		if phy:IsValid() then
			local mag = desiPos:Distance(ent:GetPos())
			if mag > 100 then
				self:DropHeld()
				return
			end
			mag = mag*mag*ent.ogMass*0.5
			--if mag > 110 then mag = 110 end
			phy:SetDragCoefficient(1000/mag)
			if mag > 500 then mag = 500 end
			phy:ApplyForceCenter((desiPos-ent:GetPos()):GetNormal()*mag)
		end
		self.Weapon:NextThink(CurTime()+0.02)
	else
		self.Weapon:NextThink(CurTime()+0.1)
	end
end