Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.14 KB | None | 0 0
  1. --[[-------------------------------------------------------------------------
  2. Energy Rifle by Demonkush
  3. ---------------------------------------------------------------------------]]
  4. AddCSLuaFile()
  5. SWEP.PrintName = "Лазер пушечка"
  6. SWEP.HoldType = "ar2"
  7. SWEP.ViewModel = "models/weapons/c_irifle.mdl"
  8. SWEP.WorldModel = "models/weapons/w_irifle.mdl"
  9. SWEP.ShowWorldModel = true
  10. SWEP.ShowViewModel = true
  11. SWEP.UseHands = true
  12. SWEP.ViewModelFlip = false
  13. SWEP.Icon = "vgui/ttt/icon_polter"
  14. SWEP.ViewModelFOV = 70
  15. SWEP.Kind = WEAPON_HEAVY
  16. SWEP.Base = "weapon_tttbase"
  17.  
  18. SWEP.Slot = 2
  19.  
  20. function SWEP:OnDrop()
  21. self:Remove()
  22. end
  23.  
  24. SWEP.Primary.ClipSize = -1
  25. SWEP.Primary.DefaultClip = -1
  26. SWEP.Primary.Automatic = true
  27. SWEP.Primary.Ammo = "none"
  28. SWEP.Primary.Sound = "demon_laserrifle.shoot"
  29. SWEP.Primary.Damage = 0
  30.  
  31. SWEP.Secondary.ClipSize = -1
  32. SWEP.Secondary.DefaultClip = -1
  33. SWEP.Secondary.Automatic = false
  34. SWEP.Secondary.Ammo = "none"
  35.  
  36. SWEP.SoundDelay = 0
  37. SWEP.PunchDelay = 0
  38. SWEP.NextAttack = 0.5
  39. SWEP.Energy = 100
  40. SWEP.MaxEnergy = 100
  41. SWEP.RechargeDelay = 1
  42.  
  43. SWEP.WeaponMode = "powershot"
  44.  
  45. local weaponmodes = {}
  46. weaponmodes["powershot"] = "Power Shot" -- Super Beam
  47. weaponmodes["pulsebomb"] = "Pulse Bomb" -- Bomb
  48. weaponmodes["shockblast"] = "Shock Blast" -- Shotgun
  49.  
  50. if SERVER then
  51. util.AddNetworkString("demon_laserrifle_sendmode")
  52. util.AddNetworkString("demon_laserrifle_delay")
  53. end
  54.  
  55. function SWEP:SendMode(mode)
  56. if CLIENT then return end
  57. net.Start("demon_laserrifle_sendmode")
  58. net.WriteString(mode)
  59. net.WriteEntity(self)
  60. net.Send(self:GetOwner())
  61. end
  62.  
  63. function SWEP:SendDelay(delay)
  64. if CLIENT then return end
  65. net.Start("demon_laserrifle_delay")
  66. net.WriteInt(delay,8)
  67. net.WriteEntity(self)
  68. net.Send(self:GetOwner())
  69. end
  70.  
  71. function SWEP:Reload()
  72. self:CycleWeapon()
  73. end
  74.  
  75. function SWEP:CycleWeapon()
  76. if CLIENT then return end
  77. if self.NextAttack > CurTime() then return end
  78. self.NextAttack = CurTime()+0.5
  79. self:SendDelay(0.5)
  80. local mode = self.WeaponMode
  81. if mode == "powershot" then
  82. self.WeaponMode = "pulsebomb"
  83. elseif mode == "pulsebomb" then
  84. self.WeaponMode = "shockblast"
  85. elseif mode == "shockblast" then
  86. self.WeaponMode = "powershot"
  87. end
  88. self:SendMode(self.WeaponMode)
  89. end
  90.  
  91. if CLIENT then
  92. net.Receive("demon_laserrifle_sendmode",function(len,pl)
  93. local mode = net.ReadString()
  94. local wep = net.ReadEntity()
  95. if !IsValid(wep) then return end
  96. wep.WeaponMode = mode
  97. wep:EmitSound("npc/roller/mine/rmine_chirp_quest1.wav",45,90,0.5)
  98. end)
  99. net.Receive("demon_laserrifle_delay",function(len,pl)
  100. local delay = net.ReadInt(8)
  101. local wep = net.ReadEntity()
  102. if !IsValid(wep) then return end
  103. wep.NextAttack = CurTime() + delay
  104. end)
  105. end
  106.  
  107. --[[-------------------------------------------------------------------------
  108. Functions
  109. ---------------------------------------------------------------------------]]
  110. function SWEP:Initialize()
  111. self.NextAttack = 0
  112. self.Energy = 100
  113. self.MaxEnergy = 100
  114. self.RechargeDelay = 0
  115. self:SetHoldType(self.HoldType)
  116. self:SetNWInt("Energy",self.MaxEnergy)
  117. end
  118.  
  119. function SWEP:Think()
  120. if CLIENT then
  121. LocalPlayer():GetViewModel():SetMaterial("")
  122. end
  123. if self.RechargeDelay < CurTime() then
  124. if self.Energy < self.MaxEnergy then
  125. self.Energy = math.Clamp(self.Energy+1,0,self.MaxEnergy)
  126. self:SetNWInt("Energy",self.Energy)
  127. end
  128. self.RechargeDelay = CurTime() + 0.1
  129. end
  130. end
  131.  
  132. function SWEP:CanAttack(energy)
  133. if self.NextAttack < CurTime() then
  134. if self.Energy >= energy then
  135. return true
  136. else return false end
  137. else return false end
  138. end
  139.  
  140.  
  141. function SWEP:PrimaryAttack()
  142. if !self:CanAttack(3) then return end
  143.  
  144. self:EmitSound("demon_laserrifle.shoot")
  145. self:GetOwner():SetAnimation(PLAYER_ATTACK1)
  146. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  147.  
  148. local bullet = {}
  149. bullet.Num = 1
  150. bullet.Src = self:GetOwner():GetShootPos()
  151. bullet.Dir = self:GetOwner():GetAimVector()
  152. bullet.Spread = Vector(0.01, 0.01, 0)
  153. bullet.Tracer = 1
  154. bullet.TracerName = "demon_tracer_laser"
  155. bullet.Force = 3
  156. bullet.Damage = 15
  157. bullet.Callback = function(att,tr,dmg)
  158. if tr.Hit then
  159. sound.Play("ambient/levels/labs/electric_explosion5.wav",tr.HitPos,75,100,0.5)
  160.  
  161. local blast = EffectData()
  162. blast:SetOrigin(tr.HitPos)
  163. blast:SetScale(0.5)
  164. util.Effect("demon_blast_small",blast)
  165.  
  166. local col = HSVToColor(RealTime() * 64 % 360, 0.65, 1)
  167. local impact = EffectData()
  168. impact:SetOrigin(tr.HitPos)
  169. impact:SetNormal(tr.HitNormal)
  170. impact:SetScale(1)
  171. impact:SetAngles(Angle(col.r,col.g,col.b))
  172. util.Effect("demon_decal_pulse",impact)
  173.  
  174. local blast = EffectData()
  175. blast:SetOrigin(tr.HitPos)
  176. blast:SetScale(0.125)
  177. blast:SetAngles(Angle(col.r,col.g,col.b))
  178. util.Effect("fx_model_blast",blast)
  179. end
  180. end
  181.  
  182. local r = math.random(1,2)
  183. if r == 1 then
  184. self.Energy = self.Energy - 3
  185. self:SetNWInt("Energy",self.Energy)
  186. end
  187.  
  188. self:GetOwner():ViewPunch(Angle(math.Rand(-1,1),math.Rand(-0.5,0.5),0))
  189. self:GetOwner():FireBullets(bullet)
  190.  
  191. self.NextAttack = CurTime()+0.1
  192. self:SendDelay(0.1)
  193. end
  194.  
  195. local explodedmgents = {
  196. "npc_strider",
  197. "npc_combinegunship",
  198. "npc_combinedropship",
  199. "npc_rollermine",
  200. "npc_helicopter",
  201. "combine_mine",
  202. "func_tank"
  203. }
  204.  
  205.  
  206. function SWEP:PowerShot()
  207. self:EmitSound("demon_laserrifle.shootbig")
  208. self:GetOwner():SetAnimation(PLAYER_ATTACK1)
  209. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  210.  
  211. local bullet = {}
  212. bullet.Num = 1
  213. bullet.Src = self:GetOwner():GetShootPos()
  214. bullet.Dir = self:GetOwner():GetAimVector()
  215. bullet.Spread = Vector(0.01, 0.01, 0)
  216. bullet.Tracer = 1
  217. bullet.TracerName = "demon_tracer_laser"
  218. bullet.Force = 10
  219. bullet.Damage = 0
  220. bullet.Callback = function(att,tr,dmginfo)
  221. if tr.Hit then
  222. if self.Energy >= 75 then
  223. sound.Play("ambient/levels/labs/electric_explosion2.wav",tr.HitPos,85,125,0.8)
  224. else
  225. sound.Play("ambient/levels/labs/electric_explosion2.wav",tr.HitPos,75,155,0.7)
  226. end
  227. if SERVER then
  228. for _, ent in ipairs(ents.FindInSphere(tr.HitPos,145)) do
  229. if IsValid(ent) then
  230. if ent != self:GetOwner() then
  231. local dmg = DamageInfo()
  232. dmg:SetDamage(dmginfo:GetDamage())
  233. dmg:SetAttacker(self:GetOwner())
  234. dmg:SetInflictor(self)
  235. ent:TakeDamageInfo(dmg)
  236. if ent:GetClass() == "combine_mine" then
  237. ent:Fire("Disarm","",0)
  238. end
  239. if ent:GetClass() == "func_tank" or ent:GetClass() == "func_tankmortar" then
  240. ent:Remove()
  241. end
  242. else
  243. local diff = tr.HitPos:Distance(self:GetOwner():GetPos())
  244. local ang = (tr.HitPos - self:GetOwner():GetPos()):Angle():Forward()
  245. if diff < 100 then
  246. self:GetOwner():SetVelocity(-ang*512)
  247. end
  248. end
  249. end
  250. end
  251. end
  252.  
  253. local blast = EffectData()
  254. blast:SetOrigin(tr.HitPos)
  255. blast:SetScale(5)
  256. util.Effect("demon_blast_small",blast)
  257.  
  258. local col = HSVToColor(RealTime() * 64 % 360, 0.65, 1)
  259. local impact = EffectData()
  260. impact:SetOrigin(tr.HitPos)
  261. impact:SetNormal(tr.HitNormal)
  262. impact:SetScale(2)
  263. impact:SetAngles(Angle(col.r,col.g,col.b))
  264. util.Effect("demon_decal_pulse",impact)
  265.  
  266. local blast = EffectData()
  267. blast:SetOrigin(tr.HitPos)
  268. blast:SetScale(0.25)
  269. blast:SetAngles(Angle(col.r,col.g,col.b))
  270. util.Effect("fx_model_blast",blast)
  271. end
  272. end
  273.  
  274. self:GetOwner():ViewPunch(Angle(math.Rand(-1,1),math.Rand(-0.5,0.5),0))
  275. self:GetOwner():FireBullets(bullet)
  276. end
  277.  
  278. function SWEP:PulseBomb()
  279. self:EmitSound("demon_laserrifle.shootbig")
  280. self:GetOwner():SetAnimation(PLAYER_ATTACK1)
  281. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  282.  
  283. if SERVER then
  284. local bomb = ents.Create("demon_laserrifle_pulsebomb")
  285. bomb:SetPos(self:GetOwner():GetShootPos())
  286. bomb:SetOwner(self:GetOwner())
  287. bomb:Spawn()
  288. bomb.Energy = self.Energy
  289.  
  290. local phys = bomb:GetPhysicsObject()
  291. if IsValid(phys) then
  292. phys:SetVelocity(self:GetOwner():GetAimVector()*2048)
  293. end
  294. end
  295.  
  296. self:GetOwner():ViewPunch(Angle(math.Rand(-1,1),math.Rand(-0.5,0.5),0))
  297. end
  298.  
  299. function SWEP:ShockBlast()
  300. self:EmitSound("demon_laserrifle.shootbig")
  301. self:GetOwner():SetAnimation(PLAYER_ATTACK1)
  302. self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  303.  
  304. local bullet = {}
  305. bullet.Num = 5
  306. bullet.Src = self:GetOwner():GetShootPos()
  307. bullet.Dir = self:GetOwner():GetAimVector()
  308. bullet.Spread = Vector(0.1, 0.1, 0)
  309. bullet.Tracer = 1
  310. bullet.TracerName = "demon_tracer_laser"
  311. bullet.Force = 25
  312. bullet.Damage = 5
  313. bullet.Callback = function(att,tr,dmginfo)
  314. if tr.Hit then
  315. if SERVER then
  316. for _, ent in ipairs(ents.FindInSphere(tr.HitPos,55)) do
  317. if IsValid(ent) then
  318. if ent != self:GetOwner() then
  319. local dmg = DamageInfo()
  320. dmg:SetDamage(dmginfo:GetDamage())
  321. dmg:SetAttacker(self:GetOwner())
  322. dmg:SetInflictor(self)
  323. ent:TakeDamageInfo(dmg)
  324. end
  325. if self.Energy >= 75 then
  326. if ent != self:GetOwner() then
  327. if ent:GetClass() == "combine_mine" then
  328. ent:Fire("Disarm","",0)
  329. end
  330. if ent:GetClass() == "func_tank" then
  331. ent:Remove()
  332. end
  333. else
  334. local diff = tr.HitPos:Distance(self:GetOwner():GetPos())
  335. local ang = (tr.HitPos - self:GetOwner():GetPos()):Angle():Forward()
  336. if diff < 100 then
  337. self:GetOwner():SetVelocity(-ang*512)
  338. end
  339. end
  340. end
  341. end
  342. end
  343. end
  344.  
  345. local scale = 1
  346. if self.Energy >= 75 then
  347. scale = 2.5
  348. if self.SoundDelay < CurTime() then
  349. sound.Play("ambient/levels/labs/electric_explosion2.wav",tr.HitPos,85,75,0.8)
  350. self.SoundDelay = CurTime() + 0.1
  351. end
  352. else
  353. if self.SoundDelay < CurTime() then
  354. sound.Play("ambient/levels/labs/electric_explosion2.wav",tr.HitPos,75,100,0.7)
  355. self.SoundDelay = CurTime() + 0.1
  356. end
  357. end
  358. local blast = EffectData()
  359. blast:SetOrigin(tr.HitPos)
  360. blast:SetScale(scale/2)
  361. util.Effect("demon_blast_small",blast)
  362.  
  363. local col = HSVToColor(RealTime() * 64 % 360, 0.65, 1)
  364. local impact = EffectData()
  365. impact:SetOrigin(tr.HitPos)
  366. impact:SetNormal(tr.HitNormal)
  367. impact:SetScale(scale/5)
  368. impact:SetAngles(Angle(col.r,col.g,col.b))
  369. util.Effect("demon_decal_pulse",impact)
  370.  
  371. local blast = EffectData()
  372. blast:SetOrigin(tr.HitPos)
  373. blast:SetScale(scale/10)
  374. blast:SetAngles(Angle(col.r,col.g,col.b))
  375. util.Effect("fx_model_blast",blast)
  376. end
  377. end
  378.  
  379. if self.PunchDelay < CurTime() then
  380. self:GetOwner():ViewPunch(Angle(math.Rand(-1,1),math.Rand(-0.5,0.5),0))
  381. self.PunchDelay = CurTime() + 0.1
  382. end
  383. self:GetOwner():FireBullets(bullet)
  384. end
  385.  
  386. function SWEP:SecondaryAttack()
  387. if !self:CanAttack(40) then return end
  388.  
  389. if self.WeaponMode == "powershot" then
  390. self:PowerShot()
  391. end
  392.  
  393. if self.WeaponMode == "pulsebomb" then
  394. self:PulseBomb()
  395. end
  396.  
  397. if self.WeaponMode == "shockblast" then
  398. self:ShockBlast()
  399. end
  400.  
  401.  
  402. self.Energy = self.Energy - 40
  403. self:SetNWInt("Energy",self.Energy)
  404.  
  405.  
  406. self.NextAttack = CurTime()+1
  407. self:SendDelay(1)
  408. end
  409.  
  410. function SWEP:DoImpactEffect() return true end
  411.  
  412. function SWEP:Deploy()
  413. return true
  414. end
  415.  
  416. function SWEP:Holster()
  417. return true
  418. end
  419.  
  420. function SWEP:OnRemove()
  421. end
  422.  
  423. --[[-------------------------------------------------------------------------
  424. Client
  425. ---------------------------------------------------------------------------]]
  426. if CLIENT then
  427.  
  428. local sights_opacity = CreateConVar("ttt_ironsights_crosshair_opacity", "0.8", FCVAR_ARCHIVE)
  429. local crosshair_brightness = CreateConVar("ttt_crosshair_brightness", "1.0", FCVAR_ARCHIVE)
  430. local crosshair_size = CreateConVar("ttt_crosshair_size", "1.0", FCVAR_ARCHIVE)
  431. local disable_crosshair = CreateConVar("ttt_disable_crosshair", "0", FCVAR_ARCHIVE)
  432. local enable_color_crosshair = CreateConVar("ttt_crosshair_color_enable", "0", FCVAR_ARCHIVE)
  433. local crosshair_color_r = CreateConVar("ttt_crosshair_color_r", "30", FCVAR_ARCHIVE)
  434. local crosshair_color_g = CreateConVar("ttt_crosshair_color_g", "160", FCVAR_ARCHIVE)
  435. local crosshair_color_b = CreateConVar("ttt_crosshair_color_b", "160", FCVAR_ARCHIVE)
  436.  
  437. local enable_gap_crosshair = CreateConVar("ttt_crosshair_gap_enable", "0", FCVAR_ARCHIVE)
  438. local crosshair_gap = CreateConVar("ttt_crosshair_gap", "0", FCVAR_ARCHIVE)
  439.  
  440. local crosshair_opacity = CreateConVar("ttt_crosshair_opacity", "1", FCVAR_ARCHIVE)
  441. local crosshair_static = CreateConVar("ttt_crosshair_static", "0", FCVAR_ARCHIVE)
  442. local crosshair_weaponscale = CreateConVar("ttt_crosshair_weaponscale", "1", FCVAR_ARCHIVE)
  443. local crosshair_thickness = CreateConVar("ttt_crosshair_thickness", "1", FCVAR_ARCHIVE)
  444. local crosshair_outlinethickness = CreateConVar("ttt_crosshair_outlinethickness", "0", FCVAR_ARCHIVE)
  445. local enable_dot_crosshair = CreateConVar("ttt_crosshair_dot", "0", FCVAR_ARCHIVE)
  446.  
  447. function SWEP:DrawHUD()
  448. if self.HUDHelp then
  449. self:DrawHelp()
  450. end
  451.  
  452. local client = LocalPlayer()
  453.  
  454. if disable_crosshair:GetBool() or not IsValid(client) then return end
  455.  
  456. local sights = not self.NoSights and self:GetIronsights()
  457. local x = math.floor(ScrW() * 0.5)
  458. local y = math.floor(ScrH() * 0.5)
  459. local scale = crosshair_weaponscale:GetBool() and math.max(0.2, 1.5 * self:GetPrimaryCone()) or 1
  460. local timescale = 1
  461.  
  462. if not crosshair_static:GetBool() then
  463. timescale = (2 - math.Clamp((CurTime() - self:LastShootTime()) * 5, 0.0, 1.0))
  464. end
  465.  
  466. local alpha = sights and sights_opacity:GetFloat() or crosshair_opacity:GetFloat()
  467. local bright = crosshair_brightness:GetFloat() or 1
  468. local gap = enable_gap_crosshair:GetBool() and math.floor(timescale * crosshair_gap:GetFloat()) or math.floor(20 * scale * timescale * (sights and 0.8 or 1))
  469. local thickness = crosshair_thickness:GetFloat()
  470. local outline = math.floor(crosshair_outlinethickness:GetFloat())
  471. local length = math.floor(gap + 25 * crosshair_size:GetFloat() * scale * timescale)
  472. local offset = thickness * 0.5
  473.  
  474. if outline > 0 then
  475. surface.SetDrawColor(0, 0, 0, 255 * alpha)
  476. surface.DrawRect(x - length - outline, y - offset - outline, length - gap + outline * 2, thickness + outline * 2)
  477. surface.DrawRect(x + gap - outline, y - offset - outline, length - gap + outline * 2, thickness + outline * 2)
  478. surface.DrawRect(x - offset - outline, y - length - outline, thickness + outline * 2, length - gap + outline * 2)
  479. surface.DrawRect(x - offset - outline, y + gap - outline, thickness + outline * 2, length - gap + outline * 2)
  480. end
  481.  
  482. if enable_color_crosshair:GetBool() then
  483. surface.SetDrawColor(crosshair_color_r:GetInt() * bright, crosshair_color_g:GetInt() * bright, crosshair_color_b:GetInt() * bright, 255 * alpha)
  484. else
  485. -- somehow it seems this can be called before my player metatable
  486. -- additions have loaded
  487. if client.GetSubRoleData then
  488. local col = client:GetRoleColor()
  489.  
  490. surface.SetDrawColor(col.r * bright, col.g * bright, col.b * bright, 255 * alpha)
  491. else
  492. surface.SetDrawColor(0, 255 * bright, 0, 255 * alpha)
  493. end
  494. end
  495.  
  496. -- draw crosshair dot
  497. if enable_dot_crosshair:GetBool() then
  498. surface.DrawRect(x - thickness * 0.5, y - thickness * 0.5, thickness, thickness)
  499. end
  500.  
  501. surface.DrawRect(x - length, y - offset, length - gap, thickness)
  502. surface.DrawRect(x + gap, y - offset, length - gap, thickness)
  503. surface.DrawRect(x - offset, y - length, thickness, length - gap)
  504. surface.DrawRect(x - offset, y + gap, thickness, length - gap)
  505.  
  506. local energy = self:GetNWInt("Energy")
  507. local energytext = ""
  508. if energy > 0 then
  509. if energy < 10 then
  510. energytext = "Мало энергии"
  511. end
  512. energytext = "Энергия: "..energy
  513. else
  514. energytext = "Нет энергии"
  515. end
  516. local x,y = ScrW()-12,ScrH()-64
  517. local energyval = math.Clamp((energy*2),16,200)
  518. surface.SetDrawColor(Color(155,155,255,215))
  519. surface.DrawRect(x-energyval,y,energyval-16,34)
  520. surface.SetDrawColor(Color(0,0,0,215))
  521. surface.DrawOutlinedRect(x-energyval,y,energyval-16,34)
  522. draw.SimpleTextOutlined(
  523. energytext,
  524. "DermaLarge",
  525. ScrW()-32,
  526. ScrH()-32,
  527. Color(215,235,255,225),
  528. TEXT_ALIGN_RIGHT,
  529. TEXT_ALIGN_BOTTOM,
  530. 2,
  531. Color(0,0,0,215)
  532. )
  533.  
  534. local col = Color(255,255,255,255)
  535. local powershot = weaponmodes[self.WeaponMode]
  536. if energy >= 15 then
  537. if energy >= 75 then
  538. col = HSVToColor(RealTime() * 32 % 360, 0.8, 1)
  539. powershot = "Super "..powershot
  540. end
  541. else
  542. col = Color(255,255,255,55)
  543. end
  544. draw.SimpleTextOutlined(
  545. "Пкм: "..powershot,
  546. "Trebuchet18",
  547. ScrW()-32,
  548. ScrH()-68,
  549. col,
  550. TEXT_ALIGN_RIGHT,
  551. TEXT_ALIGN_BOTTOM,
  552. 2,
  553. Color(0,0,0,215)
  554. )
  555. local col = Color(255,255,255,255)
  556. if energy <= 0 then
  557. col = Color(255,255,255,55)
  558. end
  559. draw.SimpleTextOutlined(
  560. "ЛКМ: стреляй",
  561. "Trebuchet18",
  562. ScrW()-32,
  563. ScrH()-84,
  564. col,
  565. TEXT_ALIGN_RIGHT,
  566. TEXT_ALIGN_BOTTOM,
  567. 2,
  568. Color(0,0,0,215)
  569. )
  570. if self.NextAttack > CurTime() then
  571. local amt = CurTime()-self.NextAttack
  572. end
  573. draw.SimpleTextOutlined(
  574. "R: режим меняй",
  575. "Trebuchet18",
  576. ScrW()-32,
  577. ScrH()-100,
  578. Color(255,255,255,115),
  579. TEXT_ALIGN_RIGHT,
  580. TEXT_ALIGN_BOTTOM,
  581. 2,
  582. Color(0,0,0,115)
  583. )
  584.  
  585. end
  586.  
  587. local GetPTranslation = LANG.GetParamTranslation
  588.  
  589. -- Many non-gun weapons benefit from some help
  590. local help_spec = {text = "", font = "TabLarge", xalign = TEXT_ALIGN_CENTER}
  591. function SWEP:DrawHelp()
  592. local data = self.HUDHelp
  593. local translate = data.translatable
  594. local primary = data.primary
  595. local secondary = data.secondary
  596.  
  597. if translate then
  598. primary = primary and GetPTranslation(primary, data.translate_params)
  599. secondary = secondary and GetPTranslation(secondary, data.translate_params)
  600. end
  601.  
  602. help_spec.pos = {ScrW() * 0.5, ScrH() - 40}
  603. help_spec.text = secondary or primary
  604.  
  605. draw.TextShadow(help_spec, 2)
  606.  
  607. -- if no secondary exists, primary is drawn at the bottom and no top line
  608. -- is drawn
  609. if secondary then
  610. help_spec.pos[2] = ScrH() - 60
  611. help_spec.text = primary
  612.  
  613. draw.TextShadow(help_spec, 2)
  614. end
  615. end
  616.  
  617. -- mousebuttons are enough for most weapons
  618. local default_key_params = {
  619. primaryfire = Key("+attack", "LEFT MOUSE"),
  620. secondaryfire = Key("+attack2", "RIGHT MOUSE"),
  621. usekey = Key("+use", "USE")
  622. }
  623.  
  624. function SWEP:AddHUDHelp(primary_text, secondary_text, translate, extra_params)
  625. extra_params = extra_params or {}
  626.  
  627. self.HUDHelp = {
  628. primary = primary_text,
  629. secondary = secondary_text,
  630. translatable = translate,
  631. translate_params = table.Merge(extra_params, default_key_params)
  632. }
  633. end
  634.  
  635.  
  636. end
  637.  
  638. --[[-------------------------------------------------------------------------
  639. Sounds
  640. ---------------------------------------------------------------------------]]
  641. sound.Add({
  642. name = "demon_laserrifle.shoot",
  643. channel = CHAN_STATIC,
  644. volume = 0.3,
  645. level = 55,
  646. pitch = {125,135},
  647. sound = "weapons/airboat/airboat_gun_energy1.wav"
  648. })
  649. sound.Add({
  650. name = "demon_laserrifle.shootbig",
  651. channel = CHAN_STATIC,
  652. volume = 0.4,
  653. level = 65,
  654. pitch = {110,120},
  655. sound = "weapons/physcannon/energy_disintegrate4.wav"
  656. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement