Advertisement
WeltEnSTurm

Untitled

Aug 18th, 2010
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1.  
  2. SWEP.Spawnable          = true
  3. SWEP.AdminSpawnable     = true
  4.  
  5. SWEP.PrintName          = "M1014"
  6.  
  7. SWEP.PrintName = "Headcrab Canister Launcher"
  8. SWEP.Slot = 3
  9. SWEP.SlotPos = 1
  10. SWEP.DrawAmmo = false
  11. SWEP.DrawCrosshair = true
  12. SWEP.Weight = 5
  13. SWEP.AutoSwitchTo = true
  14. SWEP.AutoSwitchFrom = true
  15. SWEP.Author = "Jimbomcb"
  16. SWEP.Contact = ""
  17. SWEP.Purpose = ""
  18. SWEP.Instructions = "Launches a Headcrab Canister where you aim."
  19. SWEP.ViewModel = "models/weapons/v_357.mdl"
  20. SWEP.WorldModel = "models/weapons/w_357.mdl"
  21. SWEP.Primary.ClipSize = -1
  22. SWEP.Primary.DefaultClip = -1
  23. SWEP.Primary.Automatic = true
  24. SWEP.Primary.Ammo = "none"
  25. SWEP.Secondary.ClipSize = -1
  26. SWEP.Secondary.DefaultClip = -1
  27. SWEP.Secondary.Automatic = false
  28. SWEP.Secondary.Ammo = "none"
  29.  
  30. local ShootSoundFire = Sound( "Airboat.FireGunHeavy" )
  31. local ShootSoundFail = Sound( "WallHealth.Deny" )
  32. local YawIncrement = 20
  33. local PitchIncrement = 10
  34.  
  35. function SWEP:PrimaryAttack()
  36.     local tr = self.Owner:GetEyeTrace()
  37.     self:ShootEffects(self)
  38.  
  39.     if (SERVER) then
  40.         local aBaseAngle = tr.HitNormal:Angle()
  41.         local aBasePos = tr.HitPos
  42.         local bScanning = true
  43.         local iPitch = 10
  44.         local iYaw = -180
  45.         local iLoopLimit = 0
  46.         local iProcessedTotal = 0
  47.         local tValidHits = {}
  48.  
  49.         while (bScanning == true && iLoopLimit < 500) do
  50.             iYaw = iYaw + YawIncrement
  51.             iProcessedTotal = iProcessedTotal + 1
  52.             if (iYaw >= 180) then
  53.                 iYaw = -180
  54.                 iPitch = iPitch - PitchIncrement
  55.             end
  56.  
  57.             local tLoop = util.QuickTrace( aBasePos, (aBaseAngle+Angle(iPitch,iYaw,0)):Forward()*40000 )
  58.             if (tLoop.HitSky) then
  59.                 table.insert(tValidHits,tLoop)
  60.             end
  61.  
  62.             if (iPitch 0) then
  63.                 local iRand = math.random(1,iHits)
  64.                 local tRand = tValidHits[iRand]
  65.  
  66.                 local ent = ents.Create( "env_headcrabcanister" )
  67.                 ent:SetPos( aBasePos )
  68.                 ent:SetAngles( (tRand.HitPos-tRand.StartPos):Angle() )
  69.                 ent:SetKeyValue( "HeadcrabType", math.random(0,2) )
  70.                 ent:SetKeyValue( "HeadcrabCount", math.random(1,3) )
  71.                 ent:SetKeyValue( "FlightSpeed", math.random(2500,6000) )
  72.                 ent:SetKeyValue( "FlightTime", math.random(2,5) )
  73.                 ent:SetKeyValue( "Damage", math.random(50,90) )
  74.                 ent:SetKeyValue( "DamageRadius", math.random(300,512) )
  75.                 ent:SetKeyValue( "SmokeLifetime", math.random(5,10) )
  76.                 ent:SetKeyValue( "StartingHeight", 1000 )
  77.                 ent:Spawn()
  78.                 ent:Input("FireCanister", self.Owner, self.Owner)
  79.  
  80.                 undo.Create("NPC")
  81.                 undo.AddEntity( ent )
  82.                 undo.SetPlayer( self.Owner )
  83.                 undo.Finish()
  84.                 self:EmitSound( ShootSoundFire )
  85.             else
  86.                 self:EmitSound( ShootSoundFail )
  87.             end
  88.             tLoop = nil
  89.             tValidHits = nil
  90.         end
  91.     end
  92. end
  93.  
  94. function SWEP:SecondaryAttack() self:PrimaryAttack() end
  95.  
  96. function SWEP:ShouldDropOnDie() return false end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement