-- This SWEP was generated by mblunk's swep factory. SWEP.Base = "weapon_base" -- Visual/sound settings if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "ar2" end SWEP.PrintName = "Star Wars Blaster" SWEP.Category = "NPC SWEPS (Not really intended for player use, but here you go)" SWEP.Slot = 2 SWEP.SlotPos = 4 SWEP.DrawAmmo = true SWEP.DrawCrosshair = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 64 SWEP.ViewModel = "models/weapons/v_smg1.mdl" SWEP.WorldModel = "models/weapons/w_smg1.mdl" SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav" //SWEP.HoldType = "ar2" -- Other settings SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.Spawnable = true SWEP.AdminSpawnable = true -- SWEP info SWEP.Author = "Xystus234" SWEP.Contact = "" SWEP.Purpose = "Because I can!" SWEP.Instructions = "Aim away from face!" -- Primary fire settings SWEP.Primary.Sound = "weapons/blaster.wav" SWEP.Primary.Damage = 1 SWEP.Primary.NumShots = 1 SWEP.Primary.Recoil = 1 SWEP.Primary.Cone = 16 SWEP.Primary.Delay = 0.3 SWEP.Primary.ClipSize = 45 SWEP.Primary.DefaultClip = 256 SWEP.Primary.Tracer = 1 SWEP.Primary.Force = 5 SWEP.Primary.TakeAmmoPerBullet = false SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "SMG1" -- Secondary fire settings SWEP.Secondary.Sound = "" SWEP.Secondary.Damage = 10 SWEP.Secondary.NumShots = 1 SWEP.Secondary.Recoil = 1 SWEP.Secondary.Cone = 3 SWEP.Secondary.Delay = 0.01 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Tracer = 1 SWEP.Secondary.Force = 5 SWEP.Secondary.TakeAmmoPerBullet = false SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "" -- Hooks function SWEP:Initialize() if ( SERVER ) then self:SetWeaponHoldType( self.HoldType ) end end function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end local shoot_angle = Vector(0,0,0) if self.Owner:IsNPC() then if self.Owner:GetEnemy() != NULL && self.Owner:GetEnemy() != nil then shoot_angle = self.Owner:GetEnemy():GetPos() - self.Owner:GetPos() //apply accuracy shoot_angle = shoot_angle + Vector(math.random(-150,150),math.random(-150,150),math.random(-150,150))*(shoot_angle:Distance(Vector(0,0,0))/700) //print("Shoot angle is:") //print(shoot_angle) shoot_angle:Normalize() //print("Normalized, shoot angle is:") //print(shoot_angle) else return end else shoot_angle = self.Owner:GetAimVector() end local shoot_pos = self.Owner:GetPos() + self.Owner:GetRight() * 5 + self.Owner:GetUp() * 50 + shoot_angle * 35 if self.Owner:IsPlayer() then shoot_pos = self.Owner:GetPos() + self.Owner:GetRight() * 5 + self.Owner:GetUp() * 55 + shoot_angle * 35 end local shot = ents.Create("proj_dan_blaster_shot") shot:SetPos(shoot_pos) shot:SetAngles(shoot_angle:Angle()) shot:Activate() shot:Spawn() local phy = shot:GetPhysicsObject() if phy:IsValid() then phy:ApplyForceCenter((shoot_angle * 200000)) end //print("When shot, shoot angle is:") //print((shoot_angle * 1000)) self.Owner:MuzzleFlash() self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) self.Owner:SetAnimation( PLAYER_ATTACK1 ) self.Weapon:EmitSound(Sound(self.Primary.Sound)) //self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 )) if !self.Owner:IsNPC() then if (self.Primary.TakeAmmoPerBullet) then self:TakePrimaryAmmo(self.Primary.NumShots) else self:TakePrimaryAmmo(1) end end self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) end function SWEP:SecondaryAttack() end function SWEP:Think() end function SWEP:Reload() self.Weapon:DefaultReload(ACT_VM_RELOAD) return true end function SWEP:Deploy() return true end function SWEP:Holster() return true end function SWEP:OnRemove() end function SWEP:OnRestore() end function SWEP:Precache() end function SWEP:OwnerChanged() end