Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.38 KB | None | 0 0
  1. SWEP.Author = "Zombie Extinguisher"
  2. SWEP.Contact = ""
  3. SWEP.Purpose = "Shoot Flares to get rescued"
  4. SWEP.Instructions = "Reload on full clip to change the Flaremode"
  5. SWEP.Base = "weapon_base"
  6. SWEP.Gun = ("flaregun_hud")
  7.  
  8. SWEP.Weight = 5
  9. SWEP.AutoSwitchTo = true
  10. SWEP.AutoSwitchFrom = false
  11. SWEP.HoldType = "pistol"
  12. SWEP.Category = "Zombie's Weps"
  13. SWEP.PrintName = "The Flare Gun"
  14.  
  15. SWEP.Secondary.IronFOV = 60
  16.  
  17. SWEP.Slot = 1
  18. SWEP.SlotPos = 3
  19. SWEP.DrawAmmo = false
  20. SWEP.DrawCrosshair = true
  21. SWEP.ViewModelFOV = 65
  22. SWEP.ViewModelFlip = false
  23. SWEP.Spawnable = true
  24. SWEP.AdminSpawnable = false
  25. SWEP.BounceWeaponIcon = false
  26.  
  27. SWEP.ViewModel = "models/weapons/v_flaregun.mdl"
  28. SWEP.WorldModel = "models/weapons/w_pistol.mdl"
  29.  
  30. function SWEP:Initialize()
  31. if CLIENT then
  32. self:SetColor(255, 0, 0, 255)
  33. end
  34. end
  35.  
  36. SWEP.Primary.Sound = Sound( "weapons/flaregun/fire.wav" )
  37. SWEP.Primary.NumShots = 1
  38. SWEP.Primary.ClipSize = 1
  39. SWEP.Primary.DefaultClip = 0
  40. SWEP.Primary.Automatic = false
  41. SWEP.Primary.Delay = 1
  42. SWEP.AmmoType = "smg1"
  43.  
  44.  
  45. SWEP.Secondary.Sound = Sound( "weapons/flaregun/fire.wav" )
  46. SWEP.Secondary.NumShots = 1
  47. SWEP.Secondary.ClipSize = 1
  48. SWEP.Secondary.DefaultClip = 0
  49. SWEP.Secondary.Automatic = false
  50. SWEP.Secondary.Delay = 1
  51. SWEP.AmmoType = "smg1"
  52.  
  53. SWEP.SightsPos = Vector(-5.64, -6.535, 2.68)
  54. SWEP.SightsAng = Vector(0, 0, 0)
  55. SWEP.RunSightsPos = Vector (2, -5, -5)
  56. SWEP.RunSightsAng = Vector (15, 0, 0)
  57.  
  58. local EnableMode3= CreateConVar( "flaregun_mode3", 1 )
  59. local EnableMode2= CreateConVar( "flaregun_mode2", 1 )
  60.  
  61.  
  62. function SWEP:PrimaryAttack()
  63. if self.mode == 1 then
  64. if self:Clip1() <= 0 then return end
  65. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  66. self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  67. self:ShootFlare()
  68. self.Weapon:EmitSound( self.Primary.Sound )
  69. self:SetClip1( self:Clip1() -1 )
  70. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  71. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  72. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  73. if self:Clip1() == 0 then
  74. self:DefaultReload( ACT_VM_RELOAD )
  75. end
  76.  
  77. elseif self.mode == 2 then
  78.  
  79. if EnableMode2:GetBool() == true then
  80.  
  81. if self:Clip1() <= 0 then return end
  82. if self:Clip1() <= 1 then return end
  83. self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  84. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  85. self:ShootFlare2()
  86. self.Weapon:EmitSound( self.Primary.Sound )
  87. self:SetClip1( self:Clip1() -2 )
  88. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  89. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  90. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  91. if self:Clip1() == 0 then
  92. self:DefaultReload( ACT_VM_RELOAD )
  93. end
  94. elseif EnableMode2:GetBool() == false then
  95. self.Owner:PrintMessage(HUD_PRINTTALK, "[FLAREGUN]\nSry this mode is disabled")
  96. end
  97.  
  98. elseif self.mode == 3 then
  99.  
  100. if EnableMode3:GetBool() == true then
  101. if self:Clip1() <= 0 then return end
  102. if self:Clip1() <= 1 then return end
  103. self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  104. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  105. self:ShootFlare3()
  106. self:FireDamage()
  107. self.Owner:SetHealth( self.Owner:Health() + 10 )
  108. self.Weapon:EmitSound( self.Primary.Sound )
  109. self:SetClip1( self:Clip1() -6 )
  110. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  111. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  112. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  113. if self:Clip1() == 0 then
  114. self:DefaultReload( ACT_VM_RELOAD )
  115. end
  116. elseif EnableMode3:GetBool() == false then
  117. self.Owner:PrintMessage(HUD_PRINTTALK, "[FLAREGUN]\nSry this mode is disabled")
  118. end
  119.  
  120. end
  121. end
  122.  
  123. function SWEP:ShootFlare()
  124. if SERVER then
  125. local tracer = self.Owner:GetEyeTrace()
  126. local Flare1 = ents.Create( "env_flare" )
  127. if !Flare1:IsValid() then return false end
  128. Flare1:SetPos(self.Owner:GetShootPos())
  129. Flare1:SetAngles( self.Owner:GetAimVector( ):Angle() )
  130. Flare1:SetKeyValue("spawnflags", 4)
  131. Flare1:SetKeyValue( "scale", "9" )
  132. Flare1:EmitSound("Weapon_Flaregun.Burn")
  133. Flare1:Spawn()
  134. SafeRemoveEntityDelayed(Flare1, 100)
  135. Flare1:Activate()
  136. Flare1:Fire( "Launch", "1500", 0.1 )
  137. end
  138.  
  139. end
  140.  
  141. function SWEP:FireDamage()
  142. if SERVER then
  143. flame = ents.Create("point_hurt")
  144.  
  145. flame:SetPos(Flare3:GetPos())
  146. if !flame:IsValid() then return false end
  147. flame:SetOwner(self.Owner)
  148. flame:SetKeyValue("DamageRadius", 10000)
  149. flame:SetKeyValue("Damage", 10)
  150. flame:SetKeyValue("DamageDelay", 0.4)
  151. flame:SetKeyValue("DamageType", 8)
  152. flame:Spawn()
  153. flame:Fire("TurnOn", "", 0)
  154. flame:Fire("kill", "", 0.5)
  155. end
  156. end
  157.  
  158. function SWEP:ShootFlare2()
  159. if SERVER then
  160. local tracer = self.Owner:GetEyeTrace()
  161.  
  162. Flare2 = ents.Create( "env_flare" )
  163. if !Flare2:IsValid() then return false end
  164. Flare2:SetPos(self.Owner:GetShootPos())
  165. Flare2:SetAngles( self.Owner:GetAimVector( ):Angle() )
  166. Flare2:SetKeyValue("spawnflags", 4)
  167. Flare2:SetKeyValue( "scale", "20" )
  168. Flare2:EmitSound("Weapon_Flaregun.Burn")
  169. Flare2:Spawn()
  170. SafeRemoveEntityDelayed(Flare2, 130)
  171. Flare2:Activate()
  172. Flare2:Fire( "Launch", "5000", 0.1 )
  173. end
  174. end
  175.  
  176. function SWEP:ShootFlare3()
  177. if SERVER then
  178. local tracer = self.Owner:GetEyeTrace()
  179. Flare3 = ents.Create( "env_flare" )
  180. if !Flare3:IsValid() then return false end
  181. Flare3:SetPos(self.Owner:GetShootPos())
  182. Flare3:SetAngles( self.Owner:GetAimVector( ):Angle() )
  183. Flare3:SetKeyValue("spawnflags", 4)
  184. Flare3:SetKeyValue( "scale", "60" )
  185. Flare3:EmitSound("Weapon_Flaregun.Burn")
  186. Flare3:Spawn()
  187. SafeRemoveEntityDelayed(Flare3, 130)
  188. Flare3:Activate()
  189. Flare3:Fire( "Launch", "1500", 0.1 )
  190. end
  191. end
  192.  
  193. function SWEP:Reload()
  194.  
  195. if self:Clip1() == 6 then
  196. if self.mode == 1 and CurTime() > self.changemode then
  197. self.changemode = CurTime() + 1
  198. self:SetClip1( self:Clip1() -1 )
  199. self:DefaultReload( ACT_VM_RELOAD )
  200. self.Weapon:EmitSound(Sound("AmmoCrate.Open"))
  201. self:SetClip1( self:Clip1() +1 )
  202. if SERVER then
  203. self.Owner:PrintMessage(HUD_PRINTTALK, "Big Flares Selected")
  204. end
  205. self.mode = 2
  206.  
  207. elseif self.mode == 2 and CurTime() > self.changemode then
  208. self.changemode = CurTime() + 1
  209. self:SetClip1( self:Clip1() -1 )
  210. self:DefaultReload( ACT_VM_RELOAD )
  211. self.Weapon:EmitSound(Sound("AmmoCrate.Open"))
  212. self:SetClip1( self:Clip1() +1 )
  213. if SERVER then
  214. self.Owner:PrintMessage(HUD_PRINTTALK, "Flare Fire Emitters Selected")
  215. end
  216. self.mode = 3
  217.  
  218. elseif self.mode == 3 and CurTime() > self.changemode then
  219. self.changemode = CurTime() + 1
  220. self:SetClip1( self:Clip1() -1 )
  221. self:DefaultReload( ACT_VM_RELOAD )
  222. self.Weapon:EmitSound(Sound("AmmoCrate.Open"))
  223. self:SetClip1( self:Clip1() +1 )
  224. if SERVER then
  225. self.Owner:PrintMessage(HUD_PRINTTALK, "Small Flares Selected")
  226. end
  227. self.mode = 1
  228. end
  229.  
  230. elseif self:Clip1() < 6 then
  231. self:DefaultReload( ACT_VM_RELOAD )
  232. end
  233.  
  234. end
  235.  
  236. function SWEP:SecondaryAttack()
  237. end
  238.  
  239. function SWEP:Initialize()
  240. self.mode = 1
  241. self.changemode = 0
  242.  
  243. if CLIENT then
  244. local oldpath = "vgui/hud/name" -- the path goes here
  245. local newpath = string.gsub(oldpath, "name", self.Gun)
  246. self.WepSelectIcon = surface.GetTextureID(newpath)
  247. end
  248. end
  249.  
  250. function SWEP:IronSight()
  251.  
  252. if !self.Owner:IsNPC() then
  253. if self.ResetSights and CurTime() >= self.ResetSights then
  254. self.ResetSights = nil
  255.  
  256. if self.Silenced then
  257. self:SendWeaponAnim(ACT_VM_IDLE_SILENCED)
  258. else
  259. self:SendWeaponAnim(ACT_VM_IDLE)
  260. end
  261. end end
  262.  
  263. if self.CanBeSilenced and self.NextSilence < CurTime() then
  264. if self.Owner:KeyDown(IN_USE) and self.Owner:KeyPressed(IN_ATTACK2) then
  265. self:Silencer()
  266. end
  267. end
  268.  
  269. if self.SelectiveFire and self.NextFireSelect < CurTime() and not (self.Weapon:GetNWBool("Reloading")) then
  270. if self.Owner:KeyDown(IN_USE) and self.Owner:KeyPressed(IN_RELOAD) then
  271. self:SelectFireMode()
  272. end
  273. end
  274.  
  275. --copy this...
  276. if self.Owner:KeyDown(IN_SPEED) and not (self.Weapon:GetNWBool("Reloading")) then -- If you are running
  277. self.Weapon:SetNextPrimaryFire(CurTime()+0.3) -- Make it so you can't shoot for another quarter second
  278. self.IronSightsPos = self.RunSightsPos -- Hold it down
  279. self.IronSightsAng = self.RunSightsAng -- Hold it down
  280. self:SetIronsights(true, self.Owner) -- Set the ironsight true
  281. self.Owner:SetFOV( 0, 0.3 )
  282. end
  283.  
  284. if self.Owner:KeyReleased (IN_SPEED) then -- If you release run then
  285. self:SetIronsights(false, self.Owner) -- Set the ironsight true
  286. self.Owner:SetFOV( 0, 0.3 )
  287. end -- Shoulder the gun
  288.  
  289. --down to this
  290. if !self.Owner:KeyDown(IN_USE) and !self.Owner:KeyDown(IN_SPEED) then
  291. -- If the key E (Use Key) is not pressed, then
  292.  
  293. if self.Owner:KeyPressed(IN_ATTACK2) and not (self.Weapon:GetNWBool("Reloading")) then
  294. self.Owner:SetFOV( self.Secondary.IronFOV, 0.3 )
  295. self.IronSightsPos = self.SightsPos -- Bring it up
  296. self.IronSightsAng = self.SightsAng -- Bring it up
  297. self:SetIronsights(true, self.Owner)
  298. self.DrawCrosshair = false
  299. -- Set the ironsight true
  300.  
  301. if CLIENT then return end
  302. end
  303. end
  304.  
  305. if self.Owner:KeyReleased(IN_ATTACK2) and !self.Owner:KeyDown(IN_USE) and !self.Owner:KeyDown(IN_SPEED) then
  306. -- If the right click is released, then
  307. self.Owner:SetFOV( 0, 0.3 )
  308. self.DrawCrosshair = true
  309. self:SetIronsights(false, self.Owner)
  310. -- Set the ironsight false
  311.  
  312. if CLIENT then return end
  313. end
  314.  
  315. if self.Owner:KeyDown(IN_ATTACK2) and !self.Owner:KeyDown(IN_USE) and !self.Owner:KeyDown(IN_SPEED) then
  316. self.SwayScale = 0.05
  317. self.BobScale = 0.05
  318. else
  319. self.SwayScale = 1.0
  320. self.BobScale = 1.0
  321. end
  322. end
  323.  
  324. /*---------------------------------------------------------
  325. Think
  326. ---------------------------------------------------------*/
  327.  
  328.  
  329. function SWEP:Think()
  330. self:IronSight()
  331. end
  332.  
  333. /*---------------------------------------------------------
  334. GetViewModelPosition
  335. ---------------------------------------------------------*/
  336. local IRONSIGHT_TIME = 0.3
  337. -- Time to enter in the ironsight mod
  338.  
  339. function SWEP:GetViewModelPosition(pos, ang)
  340.  
  341. if (not self.IronSightsPos) then return pos, ang end
  342.  
  343. local bIron = self.Weapon:GetNWBool("Ironsights")
  344.  
  345. if (bIron != self.bLastIron) then
  346. self.bLastIron = bIron
  347. self.fIronTime = CurTime()
  348.  
  349. end
  350.  
  351. local fIronTime = self.fIronTime or 0
  352.  
  353. if (not bIron and fIronTime < CurTime() - IRONSIGHT_TIME) then
  354. return pos, ang
  355. end
  356.  
  357. local Mul = 1.0
  358.  
  359. if (fIronTime > CurTime() - IRONSIGHT_TIME) then
  360. Mul = math.Clamp((CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1)
  361.  
  362. if not bIron then Mul = 1 - Mul end
  363. end
  364.  
  365. local Offset = self.IronSightsPos
  366.  
  367. if (self.IronSightsAng) then
  368. ang = ang * 1
  369. ang:RotateAroundAxis(ang:Right(), self.IronSightsAng.x * Mul)
  370. ang:RotateAroundAxis(ang:Up(), self.IronSightsAng.y * Mul)
  371. ang:RotateAroundAxis(ang:Forward(), self.IronSightsAng.z * Mul)
  372. end
  373.  
  374. local Right = ang:Right()
  375. local Up = ang:Up()
  376. local Forward = ang:Forward()
  377.  
  378. pos = pos + Offset.x * Right * Mul
  379. pos = pos + Offset.y * Forward * Mul
  380. pos = pos + Offset.z * Up * Mul
  381.  
  382. return pos, ang
  383. end
  384.  
  385. /*---------------------------------------------------------
  386. SetIronsights
  387. ---------------------------------------------------------*/
  388. function SWEP:SetIronsights(b)
  389. self.Weapon:SetNetworkedBool("Ironsights", b)
  390. end
  391.  
  392. function SWEP:GetIronsights()
  393. return self.Weapon:GetNWBool("Ironsights")
  394. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement