Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.18 KB | None | 0 0
  1. if ( CLIENT ) then
  2. SWEP.PrintName = "Gluon Gun"
  3. SWEP.Author = "uwu burglar"
  4. SWEP.Category = "Gluon Gun"
  5. SWEP.Slot = 1
  6. SWEP.SlotPos = 4
  7. SWEP.ViewModelFOV = 90
  8. SWEP.IconLetter = "x"
  9. --killicon.Add( "add the name here", "add directory to it here", color_white )
  10. end
  11.  
  12. SWEP.Spawnable = false
  13. SWEP.AdminSpawnable = false
  14. SWEP.ViewModel = "models/v_egon.mdl"
  15. SWEP.WorldModel = "models/weapons/w_physics.mdl"
  16. SWEP.HoldType = "physgun"
  17. SWEP.IsGluonGun = true
  18.  
  19. SWEP.Primary.ClipSize = 100
  20. SWEP.Primary.Ammo = "Default"
  21. SWEP.Primary.DefaultClip = 300
  22. SWEP.Primary.Automatic = true
  23.  
  24. SWEP.Secondary.ClipSize = -1
  25. SWEP.Secondary.DefaultClip = -1
  26. SWEP.Secondary.Automatic = false
  27. SWEP.Secondary.Ammo = "none"
  28.  
  29. function SWEP:Initialize()
  30. self:SetHoldType(self.HoldType)
  31.  
  32. if (CLIENT) then
  33. Beamz = CreateMaterial( "xeno/beamz2", "UnlitGeneric", {
  34. [ "$basetexture" ] = "sprites/physbeam3",
  35. [ "$additive" ] = "1",
  36. [ "$vertexcolor" ] = "1",
  37. [ "$vertexalpha" ] = "1",
  38. } )
  39. Beamtwo = CreateMaterial( "xeno/beam22", "UnlitGeneric", {
  40. [ "$basetexture" ] = "sprites/laserbeam2",
  41. [ "$additive" ] = "1",
  42. [ "$vertexcolor" ] = "1",
  43. [ "$vertexalpha" ] = "1",
  44. } )
  45. end
  46.  
  47. self.NextShoot = CurTime()
  48. end
  49.  
  50. function SWEP:PrimaryAttack()
  51. if (!self:CanPrimaryAttack()) then return end
  52. if not self.NextShoot then self.NextShoot = CurTime() end
  53. if CurTime()>=self.NextShoot and self.Owner:KeyDown(IN_ATTACK) then
  54. if self.IsReloading then self.IsReloading = false end
  55. if !self.ALT_ON then
  56. self.Weapon:EmitSound("pack/up2.wav")
  57. ChargeSnd = Sound("pack/run2.wav")
  58. self.SndLoop = CreateSound(self.Weapon, ChargeSnd )
  59. self.SndLoop:Play()
  60. self.ALT_ON = true
  61. self:SetNWBool("fier", self.ALT_ON)
  62. end
  63. end
  64. end
  65.  
  66. function SWEP:SecondaryAttack()
  67.  
  68. end
  69.  
  70.  
  71. function SWEP:Think()
  72.  
  73. if (self:Clip1() <= 0) or self.IsReloading then
  74. if self.ALT_ON then
  75. self:SetNextPrimaryFire(CurTime() + 4)
  76. self.ALT_ON = false
  77. if self.SndLoop then
  78. self.SndLoop:Stop()
  79. end
  80. self:SetNWBool("fier", self.ALT_ON)
  81. self.Weapon:EmitSound("pack/off2.wav")
  82. end
  83. return
  84. end
  85.  
  86. if self.Owner:KeyReleased(IN_ATTACK) then
  87. self.ALT_ON = false
  88. if self.SndLoop then
  89. self.SndLoop:Stop()
  90. end
  91. self:SetNWBool("fier", self.ALT_ON)
  92. self.Weapon:EmitSound("pack/off2.wav")
  93. end
  94.  
  95. if self.Owner:KeyDown(IN_ATTACK) and self.ALT_ON then
  96.  
  97. if not self.SndLoop then
  98. self.Weapon:EmitSound("pack/up2.wav")
  99. ChargeSnd = Sound("pack/run2.wav")
  100. self.SndLoop = CreateSound(self.Weapon, ChargeSnd )
  101. self.SndLoop:Play()
  102. end
  103.  
  104. if SERVER then
  105.  
  106. self.Owner:LagCompensation( true )
  107.  
  108. local eyetrace = self.Owner:GetEyeTrace()
  109. local pos = self.Owner:GetShootPos()
  110. local ang = self.Owner:GetAimVector()
  111. local gluon = {}
  112. gluon.start = pos
  113. gluon.endpos = eyetrace.HitPos
  114. gluon.filter = self.Owner
  115. gluon.mins = Vector(-7, -7, 0)
  116. gluon.maxs = Vector(7, 7, 7)
  117. local tr = util.TraceHull(gluon)
  118. if tr.HitPos:Distance(self.Owner:GetPos()) <= 600 or (IsValid(self.Owner) and self.Owner:IsInEvent()) then
  119. if IsValid(tr.Entity) and tr.Entity:IsPlayer() then
  120. local dmg = DamageInfo()
  121. dmg:SetAttacker(self.Owner)
  122. dmg:SetInflictor(self.Weapon)
  123. dmg:SetDamageType(DMG_DISSOLVE)
  124. dmg:SetDamage(150)
  125. tr.Entity:TakeDamageInfo(dmg)
  126.  
  127. self.Owner:LagCompensation( false )
  128.  
  129. end
  130.  
  131. if !self.Owner:IsInEvent() then self:TakePrimaryAmmo( 1 ) end
  132. end
  133.  
  134. self:NextThink( CurTime() + 0.2 )
  135. return true
  136. end
  137.  
  138. function SWEP:Deploy()
  139. self:SetHoldType(self.HoldType)
  140. self.ALT_ON = false
  141. self:SetNWBool("fier", false)
  142. return true
  143. end
  144.  
  145. function SWEP:Equip()
  146. self:SetHoldType(self.HoldType)
  147. end
  148.  
  149. function SWEP:OnRemove()
  150. self:SetNWBool("fier", false)
  151. if self.SndLoop then
  152. self.SndLoop:Stop()
  153. end
  154. end
  155.  
  156. function SWEP:ShootEffects()
  157. self:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
  158. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  159. end
  160.  
  161. function SWEP:ShouldDropOnDie()
  162. return false
  163. end
  164.  
  165.  
  166. if(CLIENT)then
  167. function SWEP:DrawHUD()
  168. end
  169.  
  170. function SWEP:ViewModelDrawn()
  171. self:Drawspiral()
  172. end
  173.  
  174. function SWEP:DrawWorldModel()
  175. self:Drawspiral()
  176. self.Weapon:DrawModel()
  177. end
  178.  
  179.  
  180. function SWEP:Drawspiral()
  181. Beamz = CreateMaterial( "xeno/beamz2", "UnlitGeneric", {
  182. [ "$basetexture" ] = "sprites/physbeam3",
  183. [ "$additive" ] = "1",
  184. [ "$vertexcolor" ] = "1",
  185. [ "$vertexalpha" ] = "1",
  186. } )
  187. Beamtwo = CreateMaterial( "xeno/beam22", "UnlitGeneric", {
  188. [ "$basetexture" ] = "sprites/laserbeam2",
  189. [ "$additive" ] = "1",
  190. [ "$vertexcolor" ] = "1",
  191. [ "$vertexalpha" ] = "1",
  192. } )
  193.  
  194.  
  195. if self:GetNWBool("fier",false) then
  196. local tr = self.Weapon.Owner:GetEyeTraceNoCursor()
  197.  
  198. if tr.Hit then
  199.  
  200.  
  201. self.StartPos = self:GetMuzzlePos( self, 1 )
  202. self.EndPos = tr.HitPos
  203.  
  204.  
  205. if not self.StartPos then return end
  206. if not self.EndPos then return end
  207.  
  208. render.SetMaterial(Material("effects/exit1"))
  209. render.DrawSprite( self.EndPos, 32, 32, Color(255,0,0,255))
  210.  
  211. self.Weapon:SetRenderBoundsWS( self.StartPos, self.EndPos )
  212.  
  213. local sinq = 3
  214. render.SetMaterial( Beamz )
  215. Rotator = Rotator or 0
  216. Rotator = Rotator - 10
  217. local Times = 50 --12
  218. render.StartBeam( 2 + Times );
  219. // add start
  220. self.Dir = (self.EndPos - self.StartPos):GetNormal()
  221. self.Inc = (self.EndPos - self.StartPos):Length() / Times
  222. local RAng = self.Dir:Angle()
  223. RAng:RotateAroundAxis(RAng:Right(),90)
  224. RAng:RotateAroundAxis(RAng:Up(),Rotator)
  225. render.AddBeam(
  226. self.StartPos, // Start position
  227. 20, // Width
  228. CurTime(), // Texture coordinate
  229. Color( 255, 255, 255, 200 ) // Color --Color( 64, 255, 64, 200 )
  230. )
  231.  
  232. for i = 0, Times do
  233. // get point
  234. RAng:RotateAroundAxis(RAng:Up(),360/(Times/sinq))
  235. local point = ( self.StartPos + self.Dir * ( i * self.Inc ) ) + RAng:Forward() * (math.sin((i/Times)*math.pi))*25
  236. render.AddBeam(
  237. point,
  238. 20,
  239. CurTime() + ( 1 / Times ) * i,
  240. Color( 255, 255, 255, 200 )
  241. )
  242. end
  243. render.AddBeam(
  244. self.EndPos,
  245. 20,
  246. CurTime() + 1,
  247. Color( 255, 255, 255, 200 )
  248. )
  249. render.EndBeam()
  250.  
  251. --second beam >_<
  252.  
  253.  
  254. render.StartBeam( 2 + Times );
  255. // add start
  256. self.Dir = (self.EndPos - self.StartPos):GetNormal()
  257. self.Inc = (self.EndPos - self.StartPos):Length() / Times
  258. local RAng = self.Dir:Angle()
  259. RAng:RotateAroundAxis(RAng:Right(),90)
  260. RAng:RotateAroundAxis(RAng:Up(),Rotator*-1)
  261. render.AddBeam(
  262. self.StartPos,
  263. 20,
  264. CurTime(),
  265. Color( 255, 255, 255, 200 )
  266. )
  267.  
  268. for i = 0, Times do
  269. // get point
  270. RAng:RotateAroundAxis(RAng:Up(),360/(Times/sinq))
  271. local point = ( self.StartPos + self.Dir * ( i * self.Inc ) ) + RAng:Forward() * (math.sin((i/Times)*math.pi))*12
  272. render.AddBeam(
  273. point,
  274. 20,
  275. CurTime() + ( 1 / Times ) * i,
  276. Color( 255, 255, 255, 200 )
  277. )
  278. end
  279. render.AddBeam(
  280. self.EndPos,
  281. 20,
  282. CurTime() + 1,
  283. Color( 255, 255, 255, 200 )
  284. )
  285. render.EndBeam()
  286.  
  287. -- third one X_x
  288.  
  289.  
  290. render.StartBeam( 2 + Times );
  291. // add start
  292. self.Dir = (self.EndPos - self.StartPos):GetNormal()
  293. self.Inc = (self.EndPos - self.StartPos):Length() / Times
  294. local RAng = self.Dir:Angle()
  295. RAng:RotateAroundAxis(RAng:Right(),90)
  296. render.AddBeam(
  297. self.StartPos,
  298. 20,
  299. CurTime(),
  300. Color( 255, 255, 255, 200 )
  301. )
  302.  
  303. for i = 0, Times do
  304. // get point
  305. local point = ( self.StartPos + self.Dir * ( i * self.Inc ) ) --+ VectorRand()*math.random(1,10)
  306. render.AddBeam(
  307. point,
  308. 20,
  309. CurTime() + ( 1 / Times ) * i,
  310. Color( 255, 255, 255, 200 )
  311. )
  312. end
  313. render.AddBeam(
  314. self.EndPos,
  315. 20,
  316. CurTime() + 1,
  317. Color( 255, 255, 255, 200 )
  318. )
  319. render.EndBeam()
  320. end
  321. end
  322.  
  323.  
  324. end
  325. function SWEP:GetMuzzlePos( weapon, attachment )
  326.  
  327. if(!IsValid(weapon)) then return end
  328.  
  329. local origin = weapon:GetPos()
  330. local angle = weapon:GetAngles()
  331. if weapon:IsWeapon() and weapon:IsCarriedByLocalPlayer() then
  332. if( IsValid( weapon:GetOwner() ) && GetViewEntity() == weapon:GetOwner() ) then
  333. local viewmodel = weapon:GetOwner():GetViewModel()
  334. if( IsValid( viewmodel ) ) then
  335. weapon = viewmodel
  336. end
  337. end
  338. end
  339. local attachment = weapon:GetAttachment( attachment or 1 )
  340. if( !attachment ) then
  341. return origin, angle
  342. end
  343. return attachment.Pos, attachment.Ang
  344.  
  345. end
  346. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement