CapsAdmin

Untitled

Sep 1st, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1.  
  2. local FrameTime = FrameTime
  3.  
  4. local function calc_velocity(self, part)
  5.     local diff = part.cached_pos - (part.last_pos or Vector(0,0,0))
  6.     part.last_pos = part.cached_pos
  7.  
  8.     part.last_vel_smooth = part.last_vel_smooth or 0
  9.     part.last_vel_smooth = (part.last_vel_smooth + (diff:Length() - part.last_vel_smooth) * FrameTime() * 4)
  10.    
  11.     return part.last_vel_smooth
  12. end
  13.  
  14. PART.Inputs =
  15. {
  16.     time = RealTime,
  17.     synced_time = CurTime,
  18.     random = function(s, p)
  19.         return math.random()
  20.     end,
  21.    
  22.     camera_distance = function(self, parent)
  23.         return p.cached_pos:Distance(pac.EyePos)
  24.     end,
  25.     angle_distance = function(self, parent)
  26.         return math.Clamp(math.abs(pac.EyeAng:Forward():DotProduct((parent.cached_pos - pac.EyePos):GetNormalized())) - 0.5, 0, 1)
  27.     end,
  28.    
  29.     -- outfit owner
  30.     owner_velocity_length = function(self, parent)
  31.         local owner = self:GetOwner(self.RootOwner)
  32.        
  33.         if owner:IsValid() then
  34.             return parent:GetOwner(self.RootOwner):GetVelocity():Length()
  35.         end
  36.        
  37.         return 0
  38.     end,
  39.     owner_velocity_forward = function(self, parent)
  40.         local owner = self:GetOwner(self.RootOwner)
  41.        
  42.         if owner:IsValid() then
  43.             return owner:EyeAngles():Forward():Dot(calc_velocity(parent))
  44.         end
  45.        
  46.         return 0
  47.     end,
  48.     owner_velocity_right = function(self, parent)
  49.         local owner = self:GetOwner(self.RootOwner)
  50.        
  51.         if owner:IsValid() then
  52.             return owner:EyeAngles():Right():Dot(calc_velocity(parent))
  53.         end
  54.        
  55.         return 0
  56.     end,
  57.     owner_velocity_up = function(self, parent)
  58.         local owner = self:GetOwner(self.RootOwner)
  59.        
  60.         if owner:IsValid() then
  61.             return owner:EyeAngles():Up():Dot(calc_velocity(parent))
  62.         end
  63.        
  64.         return 0
  65.     end,
  66.    
  67.     -- parent part
  68.     parent_velocity_length = function(self, parent)
  69.         parent = parent.Parent
  70.        
  71.         if parent:IsValid() then
  72.             return calc_velocity(parent)
  73.         end
  74.        
  75.         return 0
  76.     end,
  77.     parent_velocity_forward = function(self, parent)
  78.         parent = parent.Parent
  79.        
  80.         if parent:IsValid() then
  81.             return parent.cached_ang:Forward():Dot(calc_velocity(parent))
  82.         end
  83.        
  84.         return 0
  85.     end,
  86.     parent_velocity_right = function(self, parent)
  87.         parent = parent.Parent
  88.        
  89.         if parent:IsValid() then
  90.             return parent.cached_ang:Right():Dot(calc_velocity(parent))
  91.         end
  92.        
  93.         return 0
  94.     end,
  95.     parent_velocity_up = function(self, parent)
  96.         parent = parent.Parent
  97.        
  98.         if parent:IsValid() then
  99.             return parent.cached_ang:Up():Dot(calc_velocity(parent))
  100.         end
  101.        
  102.         return 0
  103.     end
  104. }
Advertisement
Add Comment
Please, Sign In to add comment