Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SWEP maker
- -- Version 1.0
- -- All code written by -NPGC-Dominate(UN?D)
- SWEP.Base = "weapon_base" -- Sets up everything not defined in this script (It's not because I'm leaving stuff out, it just defines what to do with animations etc)
- -- Effect settings
- SWEP.PrintName = "crossbow" -- The name of the weapon
- SWEP.Slot = 2 -- The weapon slot this SWEP belongs in (0-5)
- SWEP.SlotPos = 3 -- The position in the slot this weapon belongs in (0-infinity, DO NOT COVER UP EXISTING WEAPONS)
- SWEP.DrawAmmo = true -- Display how much ammo this weapon has left?
- SWEP.DrawCrosshair = true -- Display the crosshair?
- SWEP.ViewModel = "models/weapons/v_crossbow.mdl" -- First person model
- SWEP.WorldModel = "models/weapons/w_crossbow.mdl" -- Third person model
- SWEP.ReloadSound = "weapons/c79/bolt.rel.wav" -- What sound should this weapon make when reloaded?
- SWEP.HoldType = "crossbow" -- What kind of weapon this is (to define how it's held)
- -- Other settings
- SWEP.Weight = 20 -- How powerful is this weapon?
- SWEP.AutoSwitchTo = false -- Automatically switch to this weapon if it's more powerful than what we're already holding
- SWEP.AutoSwitchFrom = false -- Automatically switch from this weapon if what we pick up is more powerful than this weapon
- SWEP.Spawnable = true -- Can clients spawn this weapon?
- SWEP.AdminSpawnable = true -- Can admins spawn this weapon?
- -- Weapon info
- SWEP.Author = "[DX]K-A-T-R-A-N" -- Who made this
- SWEP.Contact = "contact here" -- How you can contact who made this
- SWEP.Purpose = "insert purpose" -- Why was this made?
- SWEP.Instructions = "instructions here" -- How do you use this?
- -- Primary fire settings
- SWEP.Primary.Sound = "weapons/CROSSBOW/crossbow-1.wav" -- What sound should this weapon make when fired?
- SWEP.Primary.Damage = 100 -- How much damage each bullet inflicts
- SWEP.Primary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
- SWEP.Primary.Recoil = 5 -- How much we should punch the view
- SWEP.Primary.Cone = 1 -- How many degrees the bullets can spread (90 max)
- SWEP.Primary.Delay = 0.1 -- How many seconds between each shot
- SWEP.Primary.ClipSize = 5 -- How big the clip is
- SWEP.Primary.DefaultClip = 100 -- How much ammo the gun comes with
- SWEP.Primary.Tracer = 1 -- Fire a tracer round every so many bullets
- SWEP.Primary.Force = 50 -- How much force the bullets have when they hit physics objects
- SWEP.Primary.TakeAmmoPerBullet = true -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
- SWEP.Primary.Automatic = true -- Is this weapon automatic?
- SWEP.Primary.Ammo = "357" -- Primary ammo type
- -- Secondary fire settings
- SWEP.Secondary.Sound = "weapons/CROSSBOW/Boom1.wav" -- What sound should this weapon make when fired?
- SWEP.Secondary.Damage = 50 -- How much damage each bullet inflicts
- SWEP.Secondary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
- SWEP.Secondary.Recoil = 5 -- How much we should punch the view
- SWEP.Secondary.Cone = 1 -- How many degrees the bullets can spread (90 max)
- SWEP.Secondary.Delay = 0.1 -- How many seconds between each shot
- SWEP.Secondary.ClipSize = 1 -- How big the clip is
- SWEP.Secondary.DefaultClip = 100 -- How much ammo the gun comes with
- SWEP.Secondary.Tracer = 1 -- Fire a tracer round every so many bullets
- SWEP.Secondary.Force = 70 -- How much force the bullets have when they hit physics objects
- SWEP.Secondary.TakeAmmoPerBullet = true -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
- SWEP.Secondary.Automatic = false -- Is this weapon automatic?
- SWEP.Secondary.Ammo = "pistol" -- Secondary ammo type
- -- Functions that we can use to run certain code at certain times
- -- I don't suggest you play around with this stuff unless you know what you're doing
- function SWEP:Initialize() -- Called when this script is run
- end
- function SWEP:PrimaryAttack() -- Called when we press primary fire
- if ( !self:CanPrimaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
- local bullet = {} -- Set up the shot
- bullet.Num = self.Primary.NumShots -- How many bullets we'll fire at once
- bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
- bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
- bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 ) -- Bullet spread
- bullet.Tracer = self.Primary.Tracer -- Set up tracer rounds
- bullet.Force = self.Primary.Force -- Set the bullet's force
- bullet.Damage = self.Primary.Damage -- Define how much damage each bullet does
- bullet.AmmoType = self.Primary.Ammo -- Define what kind of ammo we're using
- self.Owner:FireBullets( bullet ) -- Shoot!vvvvvvvvvvvvvvv
- self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation
- self.Owner:MuzzleFlash() -- Crappy muzzle light
- self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation
- self.Weapon:EmitSound(Sound(self.Primary.Sound)) -- Make shooty noises
- self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
- if (self.Primary.TakeAmmoPerBullet) then -- Set up ammo loss
- self:TakePrimaryAmmo(self.Primary.NumShots)
- else
- self:TakePrimaryAmmo(1)
- end
- self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) -- Don't shoot again until the delay has expired
- end
- function SWEP:SecondaryAttack() -- Called when we press secondary fire
- if ( !self:CanSecondaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
- local bullet = {} -- Set up the shot
- bullet.Num = self.Secondary.NumShots -- How many bullets we'll fire at once
- bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
- bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
- bullet.Spread = Vector( self.Secondary.Cone / 90, self.Secondary.Cone / 90, 0 ) -- Bullet spread
- bullet.Tracer = self.Secondary.Tracer -- Set up tracer rounds
- bullet.Force = self.Secondary.Force -- Set the bullet's force
- bullet.Damage = self.Secondary.Damage -- Define how much damage each bullet does
- bullet.AmmoType = self.Secondary.Ammo -- Define what kind of ammo we're using
- self.Owner:FireBullets( bullet ) -- Shoot!
- self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK ) -- View model animation
- self.Owner:MuzzleFlash() -- Crappy muzzle light
- self.Owner:SetAnimation( PLAYER_ATTACK2 ) -- 3rd Person Animation
- self.Weapon:EmitSound(Sound(self.Secondary.Sound)) -- Make shooty noises
- self.Owner:ViewPunch(Angle( -self.Secondary.Recoil, 0, 0 ))
- if (self.Secondary.TakeAmmoPerBullet) then -- Set up ammo loss
- self:TakeSecondaryAmmo(self.Secondary.NumShots)
- else
- self:TakeSecondaryAmmo(1)
- end
- self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) -- Don't shoot again until the delay has expired
- end
- function SWEP:Think() -- Called every frame while this weapon is active
- end
- function SWEP:Reload() -- Called when we reload
- self:DefaultReload(ACT_VM_RELOAD)
- return true
- end
- function SWEP:Deploy() -- Called when we take this weapon out
- return true
- end
- function SWEP:Holster() -- Called when we put this weapon away
- return true
- end
- function SWEP:OnRemove() -- Called right before this gun goes bye-bye
- end
- function SWEP:OnRestore() -- Called when we load a save where you have this weapon, or if the admin changes the map
- end
- function SWEP:Precache() -- Use this function to precache resources
- end
- function SWEP:OwnerChanged() -- Called when this weapons is dropped or someone else picks it up
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement