All pastes #500169 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-21 14:01 UTC
rendered paste body
// The cool GetAng function by Hamp
function GetAng( a, b)
local c = Vector( a.x - b.x, a.y - b.y, a.z - b.z )
local d = math.sqrt( ( c.x ^ 2 ) + ( c.y ^ 2 ) + (c.z ^ 2 ) )
local e = Vector( -( c.x / d ), -( c.y / d ), -( c.z / d ) )
angle = Angle(e:Angle().p,e:Angle().y,e:Angle().r)
return angle
end


// using it
// Pull in props
	//local allprops = ents.FindByClass( "prop_physics" )
	local entsaround = ents.FindInSphere( self.Entity:GetPos(), 300 )  
 		for nr, prop in ipairs( entsaround ) do
 		if prop:IsValid() then
 		if prop:GetClass()=="prop_physics" or prop:GetClass()=="prop_vehicle_jeep" or prop:GetClass()=="prop_vehicle_airboat" or prop:GetClass()=="prop_vehicle_prisoner_pod" then
 			local calcpos = prop:LocalToWorld(prop:OBBCenter())
			local ang = GetAng(self.Entity:GetPos(), calcpos)
 			local selectedprop = prop:GetPhysicsObject()
			local propmass = selectedprop:GetMass()
			selectedprop:ApplyForceCenter( -1*ang:Forward() * math.Rand( 500*propmass, 800*propmass ) )
			
			// Make nice lines between nade and props
		local effectdata = EffectData()
		effectdata:SetOrigin( selectedprop:GetPos() )
		effectdata:SetStart( self.Entity:GetPos() )
		effectdata:SetAttachment( 1 )
		effectdata:SetEntity( self.Enity )
		util.Effect( "BananaNadePull_line", effectdata )
			
			end
			end
 		end