Advertisement
Guest User

dark

a guest
Mar 2nd, 2010
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | None | 0 0
  1.  
  2. if ( SERVER ) then
  3.  
  4.     resource.AddFile( "materials/VGUI/entities/weapon_football.vmt" )
  5.     resource.AddFile( "materials/VGUI/entities/weapon_football.vtf" )
  6.  
  7.     AddCSLuaFile( "shared.lua" )
  8.  
  9.     SWEP.HoldType           = "crowbar"
  10.  
  11. end
  12.  
  13. if ( CLIENT ) then
  14.  
  15.  
  16.     SWEP.PrintName          = "Football swep"
  17.     SWEP.ClassName          = "weapon_football"
  18.     SWEP.Author             = "dARksOUL.dll"
  19.     SWEP.IconLetter         = "9"
  20.     SWEP.ViewModelFOV       = 70
  21.     SWEP.WepSelectIcon = surface.GetTextureID("weapons/weapon_football")
  22.  
  23.     killicon.AddFont( "prop_physics_multiplayer", "HL2MPTypeDeath", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
  24.  
  25.     function SWEP:DrawWorldModel()
  26.  
  27.         local pPlayer = self.Owner;
  28.  
  29.         if ( !ValidEntity( pPlayer ) ) then
  30.             self.Weapon:DrawModel();
  31.             return;
  32.         end
  33.  
  34.         if ( !self.m_hHands ) then
  35.             self.m_hHands = pPlayer:LookupAttachment( "anim_attachment_rh" );
  36.         end
  37.  
  38.         local hand = pPlayer:GetAttachment( self.m_hHands );
  39.  
  40.         local offset = hand.Ang:Right() * self.HoldPos.x + hand.Ang:Forward() * self.HoldPos.y + hand.Ang:Up() * self.HoldPos.z;
  41.  
  42.         hand.Ang:RotateAroundAxis( hand.Ang:Right(),    self.HoldAng.x );
  43.         hand.Ang:RotateAroundAxis( hand.Ang:Forward(),  self.HoldAng.y );
  44.         hand.Ang:RotateAroundAxis( hand.Ang:Up(),       self.HoldAng.z );
  45.  
  46.         self.Weapon:SetRenderOrigin( hand.Pos + offset )
  47.         self.Weapon:SetRenderAngles( hand.Ang )
  48.  
  49.         self.Weapon:DrawModel()
  50.  
  51.     end
  52.  
  53. end
  54.  
  55.  
  56. SWEP.Base               = "swep_frag"
  57. SWEP.Category           = SWEP.Author
  58.  
  59. SWEP.Spawnable          = true
  60. SWEP.AdminSpawnable     = true
  61.  
  62. SWEP.ViewModel          = "models/weapons/V_hands.mdl"
  63. SWEP.WorldModel         = "models/cloudstrifexiii/football/football.mdl"
  64.  
  65. SWEP.Primary.AmmoType       = "prop_physics_multiplayer"
  66. SWEP.Primary.AmmoModel      = SWEP.WorldModel
  67.  
  68. SWEP.HoldPos            = Vector( -7, 0, 1 )
  69. SWEP.HoldAng            = Vector( 0, 73, 0 )
  70.  
  71. function SWEP:ThrowGrenade( pPlayer )
  72.  
  73.     if ( self.m_bRedraw ) then
  74.         return;
  75.     end
  76.  
  77. if ( !CLIENT ) then
  78.     if ( GAMEMODE.IsSandboxDerived ) then
  79.  
  80.         if ( !pPlayer:CheckLimit( "props" ) ) then return false end
  81.  
  82.     end
  83.  
  84.     local   vecEye = pPlayer:EyePos();
  85.     local   vForward, vRight;
  86.  
  87.     vForward = pPlayer:GetForward();
  88.     vRight = pPlayer:GetRight();
  89.     local vecSrc = vecEye + vForward * 18.0 + vRight * 8.0;
  90.     self:CheckThrowPosition( pPlayer, vecEye, vecSrc );
  91.  
  92.     local vecThrow;
  93.     vecThrow = pPlayer:GetVelocity();
  94.     vecThrow = vecThrow + vForward * 1200;
  95.     local pGrenade = ents.Create( self.Primary.AmmoType );
  96.     pGrenade:SetPos( vecSrc );
  97.     pGrenade:SetModel( self.Primary.AmmoModel );
  98.     pGrenade:SetAngles( vec3_angle );
  99.     pGrenade:SetPhysicsAttacker( pPlayer );
  100.     pGrenade:SetOwner( pPlayer );
  101.     pGrenade:Fire( "SetTimer", GRENADE_TIMER );
  102.     pGrenade:Spawn()
  103.     pGrenade:GetPhysicsObject():SetVelocity( vecThrow );
  104.     pGrenade:GetPhysicsObject():SetMass( self.Primary.Damage );
  105.     pGrenade:GetPhysicsObject():AddAngleVelocity( Angle(600,math.random(-1200,1200),0) );
  106.  
  107.     if ( pGrenade ) then
  108.         if ( pPlayer && !pPlayer:Alive() ) then
  109.             vecThrow = pPlayer:GetVelocity();
  110.  
  111.             local pPhysicsObject = pGrenade:GetPhysicsObject();
  112.             if ( pPhysicsObject ) then
  113.                 vecThrow = pPhysicsObject:SetVelocity();
  114.             end
  115.         end
  116.  
  117.         pGrenade.m_flDamage = self.Primary.Damage;
  118.         pGrenade.m_DmgRadius = GRENADE_DAMAGE_RADIUS;
  119.     end
  120.  
  121.     if ( GAMEMODE.IsSandboxDerived ) then
  122.  
  123.         undo.Create("Prop")
  124.             undo.AddEntity( pGrenade )
  125.             undo.SetPlayer( pPlayer )
  126.         undo.Finish()
  127.  
  128.         pPlayer:AddCleanup( "props", pGrenade )
  129.         pPlayer:AddCount( "props", pGrenade )
  130.  
  131.     end
  132. end
  133.  
  134.     self.m_bRedraw = true;
  135.  
  136.     self.Weapon:EmitSound( self.Primary.Sound );
  137.  
  138.     pPlayer:SetAnimation( PLAYER_ATTACK1 );
  139.  
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement