Eccid

TTT Tripwire Mine

Jan 7th, 2013
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.92 KB | None | 0 0
  1.     if SERVER then
  2.        AddCSLuaFile( "shared.lua" )
  3.        resource.AddFile("materials/SSR/icon_tripwire.png")
  4.     end
  5.      
  6.     SWEP.HoldType                           = "slam"
  7.      
  8.     if CLIENT then
  9.      
  10.        SWEP.PrintName    = "Tripwire Mine"
  11.        SWEP.Slot         = 6
  12.      
  13.        SWEP.ViewModelFlip = true
  14.        SWEP.ViewModelFOV                    = 64
  15.        
  16.        SWEP.EquipMenuData = {
  17.           type = "item_weapon",
  18.           desc = [[A mine, with a red laster, placeable on walls.
  19.           When the red laser is crossed by innocents or
  20.           detectives, the mine explodes. Can be shot and
  21.           destroyed by innocents and detectives.]]
  22.        };
  23.      
  24.        SWEP.Icon = "SSR/icon_tripwire.png"
  25.     end
  26. SWEP.Base = "weapon_tttbase"
  27.      
  28.     SWEP.ViewModel                          = "models/weapons/v_slam.mdl"   -- Weapon view model
  29.     SWEP.WorldModel                         = "models/weapons/w_slam.mdl"   -- Weapon world model
  30.     SWEP.FiresUnderwater = false
  31.      
  32.     SWEP.Primary.Sound                      = Sound("")             -- Script that calls the primary fire sound
  33.     SWEP.Primary.Delay                      = .5                    -- This is in Rounds Per Minute
  34.     SWEP.Primary.ClipSize                   = 3             -- Size of a clip
  35.     SWEP.Primary.DefaultClip                = 3             -- Bullets you start with
  36.     SWEP.Primary.Automatic                  = false         -- Automatic = true; Semi Auto = false
  37.     SWEP.Primary.Ammo                       = "slam"
  38.     SWEP.LimitedStock = true
  39.    
  40.     SWEP.NoSights = true
  41.      
  42.     SWEP.AllowDrop = false
  43.     SWEP.Kind = WEAPON_EQUIP
  44.     SWEP.CanBuy = {ROLE_TRAITOR}
  45.      
  46.     function SWEP:Deploy()
  47.             self:SendWeaponAnim( ACT_SLAM_TRIPMINE_DRAW )
  48.             return true
  49.     end
  50.      
  51.     function SWEP:SecondaryAttack()
  52.             return false
  53.     end    
  54.      
  55.     function SWEP:OnRemove()
  56.        if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
  57.           RunConsoleCommand("lastinv")
  58.        end
  59.     end
  60.      
  61. function SWEP:PrimaryAttack()
  62.     self:TripMineStick()
  63.     self.Weapon:EmitSound( Sound( "Weapon_SLAM.SatchelThrow" ) )
  64.     self.Weapon:SetNextPrimaryFire(CurTime()+(self.Primary.Delay))
  65. end
  66.      
  67. function SWEP:TripMineStick()
  68.  if SERVER then
  69.       local ply = self.Owner
  70.       if not IsValid(ply) then return end
  71.  
  72.  
  73.       local ignore = {ply, self.Weapon}
  74.       local spos = ply:GetShootPos()
  75.       local epos = spos + ply:GetAimVector() * 80
  76.       local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
  77.  
  78.       if tr.HitWorld then
  79.          local mine = ents.Create("npc_tripmine")
  80.          if IsValid(mine) then
  81.  
  82.             local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, mine)
  83.  
  84.             if tr_ent.HitWorld then
  85.  
  86.                local ang = tr_ent.HitNormal:Angle()
  87.                ang.p = ang.p + 90
  88.  
  89.                mine:SetPos(tr_ent.HitPos + (tr_ent.HitNormal * 3))
  90.                mine:SetAngles(ang)
  91.                mine:SetOwner(ply)
  92.                mine:Spawn()
  93.  
  94.                                 mine.fingerprints = self.fingerprints
  95.                                
  96.                                 self:SendWeaponAnim( ACT_SLAM_TRIPMINE_ATTACH )
  97.                                
  98.                                 local holdup = self.Owner:GetViewModel():SequenceDuration()
  99.                                
  100.                                 timer.Simple(holdup,
  101.                                 function()
  102.                                 if SERVER then
  103.                                         self:SendWeaponAnim( ACT_SLAM_TRIPMINE_ATTACH2 )
  104.                                 end    
  105.                                 end)
  106.                                        
  107.                                 timer.Simple(holdup + .1,
  108.                                 function()
  109.                                         if SERVER then
  110.                                                 if self.Owner == nil then return end
  111.                                                 if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
  112.                                                 --self.Owner:StripWeapon(self.Gun)
  113.                                                 --RunConsoleCommand("lastinv")
  114.                                                 self:Remove()
  115.                                                 else
  116.                                                 self:Deploy()
  117.                                                 end
  118.                                         end
  119.                                 end)
  120.                        
  121.  
  122.                                --self:Remove()
  123.                                 self.Planted = true
  124.                                
  125.     self:TakePrimaryAmmo( 1 )
  126.                                
  127.                         end
  128.             end
  129.          end
  130.       end
  131. end
  132.  
  133. function SWEP:Reload()
  134.    return false
  135. end
Advertisement
Add Comment
Please, Sign In to add comment