Linos_Melendi

Untitled

Jul 22nd, 2014
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. SWEP.Offset = {
  2.     Pos = {
  3.         Up = 10,
  4.         Right = 1,
  5.         Forward = -4,
  6.     },
  7.     Ang = {
  8.         Up = 0,
  9.         Right = 0,
  10.         Forward = 90,
  11.     }
  12. }
  13.  
  14. function SWEP:DrawWorldModel( )
  15.         local hand, offset, rotate
  16.  
  17.         local pl = self:GetOwner()
  18.  
  19.         if IsValid( pl ) then
  20.                         local boneIndex = pl:LookupBone( "LrigScull" )
  21.                         local boneIndexH = pl:LookupBone( "ValveBiped.Bip01_R_Hand" )
  22.                         if boneIndex then
  23.                                 local pos, ang = pl:GetBonePosition( boneIndex )
  24.                                 pos = pos + ang:Forward() * self.Offset.Pos.Forward + ang:Right() * self.Offset.Pos.Right + ang:Up() * self.Offset.Pos.Up
  25.  
  26.                                 ang:RotateAroundAxis( ang:Up(), self.Offset.Ang.Up)
  27.                                 ang:RotateAroundAxis( ang:Right(), self.Offset.Ang.Right )
  28.                                 ang:RotateAroundAxis( ang:Forward(),  self.Offset.Ang.Forward )
  29.  
  30.                                 self:SetRenderOrigin( pos )
  31.                                 self:SetRenderAngles( ang )
  32.                                 self:DrawModel()
  33.                         else       
  34.                         if boneIndexH then
  35.                                 local pos, ang = pl:GetBonePosition( boneIndexH )
  36.                                 pos = pos + ang:Forward() * self.Offset.Pos.Forward + ang:Right() * self.Offset.Pos.Right + ang:Up() * self.Offset.Pos.Up
  37.  
  38.                                 ang:RotateAroundAxis( ang:Up(), self.Offset.Ang.Up)
  39.                                 ang:RotateAroundAxis( ang:Right(), self.Offset.Ang.Right )
  40.                                 ang:RotateAroundAxis( ang:Forward(),  self.Offset.Ang.Forward )
  41.  
  42.                                 self:SetRenderOrigin( pos )
  43.                                 self:SetRenderAngles( ang )
  44.                                 self:DrawModel()
  45.                         end    
  46.                         end
  47.                 else
  48.                 self:SetRenderOrigin( nil )
  49.                 self:SetRenderAngles( nil )
  50.                 self:DrawModel()
  51.         end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment