Advertisement
TerryPeppers

Untitled

Jul 29th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1.  
  2. if ( SERVER ) then
  3.  
  4. AddCSLuaFile( "shared.lua" )
  5.  
  6. end
  7.  
  8. if ( CLIENT ) then
  9.  
  10. SWEP.PrintName = "E-60R"
  11. SWEP.Author = "Syntax_Error752"
  12. SWEP.ViewModelFOV = 60
  13. SWEP.Slot = 4
  14. SWEP.SlotPos = 1
  15. SWEP.WepSelectIcon = surface.GetTextureID("HUD/killicons/E60R")
  16.  
  17. killicon.Add( "weapon_752_e60r", "HUD/killicons/E60R", Color( 255, 80, 0, 255 ) )
  18.  
  19. end
  20.  
  21. SWEP.HoldType = "rpg"
  22. SWEP.Base = "weapon_swsft_base"
  23. SWEP.Category = "Star Wars"
  24.  
  25. SWEP.Spawnable = true
  26. SWEP.AdminSpawnable = true
  27.  
  28. SWEP.ViewModel = "models/weapons/v_E60R.mdl"
  29. SWEP.WorldModel = "models/weapons/w_E60R.mdl"
  30.  
  31. SWEP.Weight = 5
  32. SWEP.AutoSwitchTo = false
  33. SWEP.AutoSwitchFrom = false
  34.  
  35. local FireSound = Sound ("weapons/E60R_fire.wav");
  36. local ReloadSound = Sound ("weapons/E60R_reload.wav");
  37.  
  38. SWEP.Primary.Recoil = 10
  39. SWEP.Primary.Damage = 200
  40. SWEP.Primary.NumShots = 1
  41. SWEP.Primary.Cone = 0.15
  42. SWEP.Primary.ClipSize = 1
  43. SWEP.Primary.Delay = 1
  44. SWEP.Primary.DefaultClip = 3
  45. SWEP.Primary.Automatic = true
  46. SWEP.Primary.Ammo = "rpg_round"
  47.  
  48. SWEP.Secondary.Automatic = false
  49. SWEP.Secondary.Ammo = "none"
  50.  
  51. /*---------------------------------------------------------
  52. ---------------------------------------------------------*/
  53. function SWEP:Initialize()
  54. if ( SERVER ) then
  55. self:SetNPCMinBurst( 30 )
  56. self:SetNPCMaxBurst( 30 )
  57. self:SetNPCFireRate( 0.01 )
  58. end
  59. self:SetWeaponHoldType( self.HoldType )
  60. self.Weapon:SetNetworkedBool( "Ironsights", false )
  61. end
  62.  
  63. function SWEP:PrimaryAttack()
  64. self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  65. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  66. if ( !self:CanPrimaryAttack() ) then return end
  67. self.Weapon:EmitSound( FireSound )
  68. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  69. self:FireRocket() --self:FireRocket( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
  70. self:TakePrimaryAmmo( 1 )
  71. if ( self.Owner:IsNPC() ) then return end
  72. self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
  73. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  74. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  75. end
  76. end
  77.  
  78. function SWEP:FireRocket()
  79. local aim = self.Owner:GetAimVector()
  80. local side = aim:Cross(Vector(0,0,1))
  81. local up = side:Cross(aim)
  82. local pos = self.Owner:GetShootPos() + aim * 24 + side * 8 + up * -1 --offsets the rocket so it spawns from the muzzle (hopefully)
  83. local rocket = ents.Create("e60r_rocket")
  84. if !rocket:IsValid() then return false end
  85. rocket:SetAngles(aim:Angle())
  86. rocket:SetPos(pos)
  87. rocket:SetOwner(self.Owner)
  88. rocket:Spawn()
  89. rocket:Activate()
  90. rocket:SetVelocity(rocket:GetForward()*2500)
  91. end
  92.  
  93. function SWEP:Think()
  94. if self.Weapon:Clip1() > 0 then
  95. self.Weapon:SendWeaponAnim(ACT_VM_IDLE_DEPLOYED)
  96. end
  97. end
  98.  
  99. function SWEP:Reload()
  100. if (self.Weapon:Clip1() < self.Primary.ClipSize) then
  101. if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  102. self.Weapon:EmitSound( ReloadSound )
  103. end
  104. self.Weapon:DefaultReload( ACT_VM_RELOAD );
  105. self:SetIronsights( false )
  106. end
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement