if SERVER then AddCSLuaFile() resource.AddWorkshop("253737741") end if CLIENT then SWEP.PrintName = "G36 Balrog" SWEP.Slot = 2 SWEP.Icon = "vgui/ttt/icon_sg552" end -- always derive from weapon_tttbase SWEP.Base = "weapon_tttbase" --[[Default GMod values]]-- SWEP.Primary.Ammo = "SMG1" SWEP.Primary.Delay = 0.09 SWEP.Secondary.Delay = 0.09 SWEP.Primary.Recoil = 1.9 SWEP.Primary.Cone = 0.019 SWEP.Primary.Damage = 20 SWEP.Primary.Automatic = true SWEP.Primary.ClipSize = 30 SWEP.Primary.ClipMax = 60 SWEP.Primary.DefaultClip = 30 SWEP.Primary.Sound = Sound("weapons/G36B/B5_fire.wav") -- Script that calls the primary fire sound SWEP.HeadshotMultiplier = 1.7 --[[Model settings]]-- SWEP.ViewModelFOV = 70 SWEP.ViewModelFlip = true SWEP.HoldType = "smg" SWEP.ViewModel = "models/weapons/v_rifl_g36b.mdl" -- Weapon view model SWEP.WorldModel = "models/weapons/w_rifl_g36b.mdl" -- Weapon world model SWEP.IronSightsPos = Vector(5, -15, -2) SWEP.IronSightsAng = Vector(2.6, 1.37, 3.5) --[[TTT config values]]-- -- Kind specifies the category this weapon is in. Players can only carry one of -- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE. -- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8 SWEP.Kind = WEAPON_HEAVY -- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, -- then this gun can be spawned as a random weapon. SWEP.AutoSpawnable = false -- The AmmoEnt is the ammo entity that can be picked up when carrying this gun. SWEP.AmmoEnt = "item_ammo_smg1_ttt" -- If AllowDrop is false, players can't manually drop the gun with Q SWEP.AllowDrop = true -- If IsSilent is true, victims will not scream upon death. SWEP.IsSilent = false -- If NoSights is true, the weapon won't have ironsights SWEP.NoSights = false -- Remove ROLE_DETECTIVE or ROLE_TRAITOR to make it show only for traitor or detectives. -- add some zoom to the scope for this gun function SWEP:SecondaryAttack() if (self.IronSightsPos and self:GetNextSecondaryFire() <= CurTime()) then -- set the delay for left and right click self:SetNextPrimaryFire(CurTime() + self.Secondary.Delay) self:SetNextSecondaryFire(CurTime() + self.Secondary.Delay) local bIronsights = not self:GetIronsights() self:SetIronsights(bIronsights) if SERVER then self:SetZoom(bIronsights) end end end function SWEP:SetZoom(state) if (SERVER and IsValid(self.Owner) and self.Owner:IsPlayer()) then if (state) then self.Owner:SetFOV(20, 0.3) else self.Owner:SetFOV(0, 0.2) end end end function SWEP:ResetIronSights() self:SetIronsights(false) self:SetZoom(false) end function SWEP:PreDrop() self:ResetIronSights() return self.BaseClass.PreDrop(self) end function SWEP:Reload() if (self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then self:DefaultReload(ACT_VM_RELOAD) self:ResetIronSights() end end function SWEP:Holster() self:ResetIronSights() return true end -- draw the scope on the HUD if CLIENT then local scope = surface.GetTextureID("sprites/scope") function SWEP:DrawHUD() if self:GetIronsights() then surface.SetDrawColor(0, 0, 0, 255) local x = ScrW() / 2.0 local y = ScrH() / 2.0 local scope_size = ScrH() -- crosshair local gap = 80 local length = scope_size surface.DrawLine(x - length, y, x - gap, y) surface.DrawLine(x + length, y, x + gap, y) surface.DrawLine(x, y - length, x, y - gap) surface.DrawLine(x, y + length, x, y + gap) gap = 0 length = 50 surface.DrawLine(x - length, y, x - gap, y) surface.DrawLine(x + length, y, x + gap, y) surface.DrawLine(x, y - length, x, y - gap) surface.DrawLine(x, y + length, x, y + gap) -- cover edges local sh = scope_size / 2 local w = (x - sh) + 2 surface.DrawRect(0, 0, w, scope_size) surface.DrawRect(x + sh - 2, 0, w, scope_size) surface.SetDrawColor(255, 0, 0, 255) surface.DrawLine(x, y, x + 1, y + 1) -- scope surface.SetTexture(scope) surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0) else return self.BaseClass.DrawHUD(self) end end function SWEP:AdjustMouseSensitivity() return (self:GetIronsights() and 0.2) or nil end end