-- This SWEP was generated by mblunk's swep factory. SWEP.Base = "weapon_base" if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "ar2" end -- Visual/sound settings SWEP.PrintName = "Rocket Launcher" SWEP.Category = "NPC SWEPS (Not really intended for player use, but here you go)" SWEP.Slot = 2 SWEP.SlotPos = 5 SWEP.DrawAmmo = true SWEP.DrawCrosshair = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 64 SWEP.ViewModel = "models/weapons/v_rpg.mdl" SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl" SWEP.ReloadSound = "" //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/stinger_fire1.wav" SWEP.Primary.Damage = 5 SWEP.Primary.NumShots = 1 SWEP.Primary.Recoil = 1 SWEP.Primary.Cone = 10 SWEP.Primary.Delay = 3 SWEP.Primary.ClipSize = 30 SWEP.Primary.DefaultClip = 256 SWEP.Primary.Tracer = 1 SWEP.Primary.Force = 100 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.1 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 = "" SWEP.IronSightsPos = Vector (12.8956, -28.4254, -12.6774) SWEP.IronSightsAng = Vector (4.5724, -180.3716, 0) SWEP.FireDelay = 0 -- Hooks function SWEP:Initialize() if ( SERVER ) then self:SetWeaponHoldType( self.HoldType ) //self:SetIronsights(true) end end function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end if self.FireDelay > CurTime() 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(-85,85),math.random(-85,85),math.random(-85,85))*(shoot_angle:Distance(Vector(0,0,0))/1500) //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 * 100 if self.Owner:IsPlayer() then shoot_pos = self.Owner:GetPos() + self.Owner:GetRight() * 5 + self.Owner:GetUp() * 55 + shoot_angle * 100 end local shot = ents.Create("proj_dan_rocket_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 * 10000)) 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),500,100) //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 ) self.FireDelay = CurTime() + self.Primary.Delay if self.Owner:IsNPC() then self.Owner:SetSchedule(SCHED_HIDE_AND_RELOAD) end 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 function SWEP:GetViewModelPosition( pos, ang ) /* local Offset = self.IronSightsPos local AngMod = self.IronSightsAng local mul = 1 if AngMod then ang = ang * 1 ang:RotateAroundAxis (ang:Right(), AngMod.x * mul) ang:RotateAroundAxis (ang:Up(), AngMod.y * mul) ang:RotateAroundAxis (ang:Forward(), AngMod.z * mul) end local Right = ang:Right() local Up = ang:Up() local Forward = ang:Forward() pos = pos + Offset.x * Right * mul pos = pos + Offset.y * Forward * mul pos = pos + Offset.z * Up * mul return pos, ang */ end