Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile( "shared.lua" )
- end
- SWEP.HoldType = "revolver"
- if CLIENT then
- SWEP.PrintName = "Healing Rifle"
- SWEP.Slot = 6
- SWEP.Icon = "VGUI/ttt/icon_scout"
- end
- SWEP.Base = "weapon_tttbase"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.Kind = WEAPON_EQUIP
- SWEP.WeaponID = AMMO_HEALRIFLE
- SWEP.CanBuy = {ROLE_DETECTIVE} -- only detectives can buy
- SWEP.LimitedStock = true -- only buyable once
- SWEP.Primary.Delay = 3
- SWEP.Primary.Recoil = 7
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "357"
- SWEP.HealAmount = ( math.Rand( 30,100 ) )
- SWEP.Primary.Cone = 0.003
- SWEP.Primary.ClipSize = 3
- SWEP.Primary.ClipMax = 3
- SWEP.Primary.DefaultClip = 3
- SWEP.HeadshotMultiplier = 0
- SWEP.AutoSpawnable = false
- SWEP.AmmoEnt = "item_ammo_feringun"
- SWEP.UseHands = true
- SWEP.ViewModelFlip = false
- SWEP.ViewModelFOV = 54
- SWEP.ViewModel = Model("models/weapons/cstrike/c_snip_scout.mdl")
- SWEP.WorldModel = Model("models/weapons/w_snip_scout.mdl")
- SWEP.Primary.Sound = Sound(")weapons/scout/scout_fire-1.wav")
- SWEP.Secondary.Sound = Sound("Default.Zoom")
- SWEP.IronSightsPos = Vector( 5, -15, -2 )
- SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
- function SWEP:SetZoom(state)
- if CLIENT then
- return
- elseif 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
- -- Add some zoom to ironsights for this gun
- function SWEP:SecondaryAttack()
- if not self.IronSightsPos then return end
- if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
- bIronsights = not self:GetIronsights()
- self:SetIronsights( bIronsights )
- if SERVER then
- self:SetZoom(bIronsights)
- else
- self:EmitSound(self.Secondary.Sound)
- end
- self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
- end
- function SWEP:PreDrop()
- self:SetZoom(false)
- self:SetIronsights(false)
- return self.BaseClass.PreDrop(self)
- end
- function SWEP:Reload()
- self.Weapon:DefaultReload( ACT_VM_RELOAD );
- self:SetIronsights( false )
- self:SetZoom(false)
- end
- function SWEP:Holster()
- self:SetIronsights(false)
- self:SetZoom(false)
- return true
- end
- 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
- function SWEP:PrimaryAttack()
- if ( !self:CanPrimaryAttack() ) then return end
- if ( !SERVER ) then return end
- local tr = util.TraceLine( {
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 99999999,
- filter = self.Owner
- } )
- local ent = tr.Entity
- if ( IsValid( ent ) && ( ent:IsPlayer() or ent:IsNPC() ) ) then
- if self.Owner:KeyDown(IN_USE) then
- if ent:Health() <= 1 then
- return false
- else
- self.Owner:EmitSound( self.Primary.Sound )
- self.Owner:EmitSound( self.Secondary.Sound )
- ent:SetHealth( ent:Health() - self.HurtAmount )
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
- self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- if ent:Health() <= 1 then ent:SetHealth( self.MinAmount ) end
- end
- else
- self.Owner:EmitSound( self.Primary.Sound )
- self.Owner:EmitSound( self.Secondary.Sound )
- ent:SetHealth( math.min( ent:GetMaxHealth(), ent:Health() + self.HealAmount ) )
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
- self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- end
- timer.Simple( self:SequenceDuration(), function() if ( !IsValid( self ) ) then return end self:SendWeaponAnim( ACT_VM_IDLE ) end )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement