Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Black Ops Baby Gun
- AddCSLuaFile( "shared.lua" )
- SWEP.Author = "Hoff"
- SWEP.Instructions = ""
- SWEP.Base = "weapon_hoff_base_babygun"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.ViewModel = "models/hoff/weapons/babygun/v_shrinkray_pow.mdl"
- SWEP.WorldModel = "models/hoff/weapons/babygun/w_shrinkray_pow.mdl"
- SWEP.DrawCrosshair = false
- SWEP.ZoomAmount = 5
- SWEP.ViewModelMovementScale = 0.2
- SWEP.PlayBackRate = 30
- SWEP.PlayBackRateSV = 12
- SWEP.SpeedDec = 10
- SWEP.BulletDiameter = 11.5
- SWEP.CaseLength = 22.8
- SWEP.NormalHoldType = "ar2"
- SWEP.RunHoldType = "ar2"
- SWEP.FireModes = {"semi"}
- SWEP.FireDelay = 0.25
- SWEP.FireSound = Sound("weapons/bo_1911/fire.wav")
- SWEP.Recoil = 1.6
- SWEP.DryFire = true
- SWEP.HipSpread = 0.09
- SWEP.AimSpread = 0.009
- SWEP.VelocitySensitivity = 1.7
- SWEP.MaxSpreadInc = 0.06
- SWEP.SpreadPerShot = 0.015
- SWEP.SpreadCooldown = 0.28
- SWEP.Shots = 1
- SWEP.Damage = 40
- SWEP.DeployTime = 1
- SWEP.AimPos = Vector(-10,0,0)
- SWEP.AimAng = Vector(0, 0, 0)
- SWEP.Primary.ClipSize = 5
- SWEP.Primary.DefaultClip = 50
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = "AirboatGun"
- SWEP.Primary.Delay = 1
- SWEP.Secondary.ClipSize = 100
- SWEP.Secondary.DefaultClip = 100
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = "none"
- SWEP.Weight = 5
- SWEP.AutoSwitchTo = false
- SWEP.AutoSwitchFrom = false
- SWEP.PrintName = "31-79 JGb215"
- SWEP.Slot = 3
- SWEP.SlotPos = 1
- SWEP.DrawAmmo = true
- SWEP.Category = "CoD Zombies"
- SWEP.ViewModelFOV = 70
- local ShootSound = Sound("")
- SWEP.HoldType = "ar2"
- SWEP.Distance = 500 * 12
- function SWEP:Initialize()
- self:SetWeaponHoldType( self.HoldType )
- end
- function SWEP:Equip()
- self.Weapon:EmitSound( "hoff/weapons/babygun/shrinkray/plr/wpn_shrink_plr_equip.wav" )
- end
- function SWEP:Deploy()
- timer.Simple(0.4,function()
- self:SendWeaponAnim(ACT_VM_IDLE)
- -- self:EmitSound("hoff/weapons/babygun/shrinkray/reload/wpn_shrink_fins.wav")
- end)
- end
- function SWEP:ShootLightning( )
- local res, start, ende
- start = self.Owner:GetPos() + Vector(0,0,55) + (self.Owner:GetForward() * 50)
- ende = start + self.Distance * self.Owner:GetAimVector( )
- res = util.TraceLine{ start = start, endpos = ende, filter = self.Owner, mask = MASK_SHOT }
- if res.Entity and res.Entity:IsValid( ) and SERVER then
- local ent1 = "npc_zombie"
- local ent2 = "npc_monk"
- for a,b in pairs( ents.FindInSphere( self:GetPos(), 500 )) do
- if b:IsNPC() then
- -- self:DispEffect( "tesla_shot", { Origin = start, Normal = b:GetPos(), Start = res.Entity:GetPos(), Scale = 240, Radius = 12 } )
- local effectName = "tesla_shot"
- local vPoint = b:GetPos()
- local effectdata = EffectData()
- effectdata:SetStart( vPoint ) // not sure if ( we need a start and origin ( endpoint ) for this effect, but whatever
- effectdata:SetOrigin( vPoint )
- effectdata:SetEntity( res.Entity:GetPos() + Vector(0,0,35) )
- effectdata:SetScale( 1 )
- util.Effect( effectName, effectdata )
- end
- end
- local effectName = "tesla_glow"
- local vPoint = res.Entity:GetPos() + Vector(0,0,35)
- local effectdata = EffectData()
- effectdata:SetStart( vPoint ) // not sure if ( we need a start and origin ( endpoint ) for this effect, but whatever
- effectdata:SetOrigin( vPoint )
- effectdata:SetEntity( self )
- effectdata:SetScale( 1 )
- util.Effect( effectName, effectdata )
- for k, v in pairs (ents.FindInSphere(res.Entity:GetPos(),50)) do
- if v:IsNPC() then
- v:SetKeyValue("targetname", "disTarg")
- end
- end
- local dis = ents.Create("env_entity_dissolver")
- dis:SetPos(res.Entity:GetPos())
- dis:SetKeyValue("magnitude", "500")
- dis:SetKeyValue("dissolvetype", "0")
- dis:SetKeyValue("target", "disTarg")
- dis:Spawn()
- dis:Fire("Dissolve", "disTarg", 0)
- dis:Fire("kill", "", 0)
- if res.Entity:IsNPC() then
- local npc = res.Entity
- -- npc:TakeDamage( 99999, self.Owner, self )
- end
- end
- self:DispEffect( "tesla_shot", { Origin = start, Normal = self.Owner:GetAimVector( ), Start = res.HitPos, Scale = 240, Radius = 12 } )
- end
- function SWEP:DispEffect( name, data )
- local data2, k, v
- data2 = EffectData( )
- for k, v in pairs( data ) do
- data2[ "Set" .. k ]( data2, v )
- end
- util.Effect( name, data2 )
- end
- function SWEP:BabyGunProjectile()
- if SERVER then
- local aim = self.Owner:GetAimVector( )
- local force = aim*(3*500)+Vector(0,0,200)
- local tr = self.Owner:GetEyeTrace()
- local projectile = ents.Create ("ent_babygun_proj")
- projectile:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector()))
- projectile:SetAngles (self.Owner:EyeAngles())
- projectile:Spawn()
- timer.Simple(1,function() projectile:Remove() end)
- local phys1 = projectile:GetPhysicsObject();
- local shot_length = tr.HitPos:Length();
- if projectile:IsValid() and phys1:IsValid() then
- phys1:ApplyForceCenter ((self.Owner:GetAimVector() * shot_length) * 100);
- end
- end
- end
- function SWEP:PrimaryAttack()
- if ( !self:CanPrimaryAttack() ) then return end
- self.Owner:ViewPunch( Angle( -0.5, 0, 0 ) )
- local aim = self.Owner:GetAimVector( )
- local force = aim*(3*500)+Vector(0,0,200)
- local tr = self.Owner:GetEyeTrace()
- self:BabyGunProjectile()
- if tr.HitPos:Distance(self.Owner:GetPos()) < 750 then
- timer.Simple(0.2,function()
- ParticleEffect("bbgun_proj_hit",tr.HitPos,Angle(0,0,0),nil)
- for k,v in pairs (ents.FindInSphere(tr.HitPos,125)) do
- if v ~= self.Owner and v:IsValid() then
- if (v:IsNPC() or v:IsPlayer()) then
- if v:GetNWString("IsBaby") ~= "true" and v:GetNWString("IsBaby") ~= "false" then v:SetNWString("IsBaby","false") end
- if v:GetNWString("IsBaby") == "false" then
- v:SetModelScale(0.4)
- timer.Simple(0.25,function() v:EmitSound( "hoff/weapons/babygun/shrinkray/effects/evt_shrink.wav" ) end)
- if v:LookupBone("ValveBiped.Bip01_Head1") ~= nil then
- v:ManipulateBoneScale(v:LookupBone("ValveBiped.Bip01_Head1"),Vector(3.5,3.5,3.5))
- end
- v:SetNWString("IsBaby","true")
- v:SetNWString("ShouldKickBaby","true")
- v:SetNWString("CanAddVelocity","true")
- if v:IsPlayer() then
- v:SetViewOffset(Vector(0,0,25))
- end
- v:SetNWString("BabyOnGround","false")
- timer.Simple(math.random(3,3.15),function()
- if v:IsValid() and v:OnGround() and v:GetNWString("IsBaby") == "true" then
- v:SetModelScale(1)
- if v:LookupBone("ValveBiped.Bip01_Head1") ~= nil then
- v:ManipulateBoneScale(v:LookupBone("ValveBiped.Bip01_Head1"),Vector(1,1,1))
- end
- if v:IsPlayer() then
- v:SetViewOffset(Vector(0,0,64))
- end
- ParticleEffect("bbgun_proj_hit",v:GetPos(),Angle(0,0,0),nil)
- v:SetNWString("ShouldKickBaby","false")
- v:SetNWString("IsBaby","false")
- v:EmitSound( "hoff/weapons/babygun/shrinkray/effects/evt_unshrink.wav" )
- end
- end)
- end
- end
- end
- end
- end)
- end
- self:TakePrimaryAmmo( 1 )
- self.Weapon:EmitSound( "hoff/weapons/babygun/shrinkray/plr/wpn_shrink_plr_quad1.wav" )
- self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
- timer.Simple(0.3,function() if self:IsValid() then self:SendWeaponAnim(ACT_VM_IDLE) end end)
- self:SetNextPrimaryFire(CurTime() + 0.8)
- end
- SWEP.Offset = {
- Pos = {
- Up = 8,
- Right = 0.5,
- Forward = 13,
- },
- Ang = {
- Up = -90,
- Right = 15,
- Forward = 0,
- }
- }
- function SWEP:DrawWorldModel( )
- local hand, offset, rotate
- if not IsValid( self.Owner ) then
- self:DrawModel( )
- return
- end
- if not self.Hand then
- self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
- end
- hand = self.Owner:GetAttachment( self.Hand )
- if not hand then
- self:DrawModel( )
- return
- end
- offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
- hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
- hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
- hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
- self:SetRenderOrigin( hand.Pos + offset )
- self:SetRenderAngles( hand.Ang )
- self:DrawModel( )
- end
- function SWEP:ShouldDropOnDie()
- return false
- end
- SWEP.Primary.Cone = 0.02
- SWEP.NextSecondaryAttack = 0
- function SWEP:OnRestore()
- self.NextSecondaryAttack = 0
- self:SetIronsights( false )
- end
- function SWEP:Reload()
- if !( ( self.Weapon:Clip1() ) < ( self.Primary.ClipSize ) ) then
- return
- else if self.Owner:GetAmmoCount(self.Owner:GetActiveWeapon():GetPrimaryAmmoType()) == 0 then return end
- timer.Simple(self.Owner:GetViewModel():LookupSequence("reload"),function() if self:IsValid() then self:SendWeaponAnim(ACT_VM_IDLE) end end)
- timer.Simple(0.375,function() self.Weapon:EmitSound("hoff/weapons/babygun/shrinkray/reload/wpn_shrink_mag_out.wav") end)
- timer.Simple(2.4,function() if self.Weapon:IsValid() then self.Weapon:EmitSound("hoff/weapons/babygun/shrinkray/reload/wpn_shrink_mag_in.wav") end end)
- self.Weapon:DefaultReload( ACT_VM_RELOAD )
- end
- end
- function Ragdoll(npc,time)
- local hp = npc:Health()
- local mdl = npc:GetModel()
- local skin = npc:GetSkin()
- local class = npc:GetClass()
- local wep = npc:GetActiveWeapon()
- if wep:IsValid() then wep = wep:GetClass() else wep = nil end
- local bones = {}
- for i=1,npc:GetBoneCount() do
- bones[i] = npc:GetBoneMatrix(i)
- end
- local rag = ents.Create("prop_ragdoll")
- rag:SetModel(mdl)
- rag:SetPos(npc:GetPos())
- rag:SetAngles(npc:GetAngles())
- npc:Remove()
- local tbl = {hp=hp,mdl=mdl,skin=skin,class=class,rag=rag,wep=wep}
- rag:Spawn()
- rag:SetSkin(skin)
- for k,v in pairs (bones) do
- rag:SetBoneMatrix(k,v)
- end
- return rag
- end
- hook.Add("Think","KickBabyGunCheck",function()
- for k,v in pairs(player.GetAll()) do
- for a,b in pairs(ents.FindInSphere( v:GetPos(), 35 )) do
- if (b:IsPlayer() or b:IsNPC()) and v ~= b then
- if b:GetNWString("ShouldKickBaby") == "true" then
- local aim = v:GetAimVector()
- local force = aim*(3*500)
- if SERVER then
- if (b:IsNPC() or b:IsPlayer()) then
- local OldBoneScale = b:GetModelScale()
- -- rag:GetPhysicsObject():ApplyForceCenter(Vector(0,0,900))
- if b:GetNWString("CanAddVelocity") == "true" then
- local tr = v:GetEyeTrace();
- local shot_length = tr.HitPos:Length()
- local multiplyscale = math.random(1500,3000)
- local kickSoundTable = {"hoff/weapons/babygun/mini/kicked/zmb_mini_kicked01.wav","hoff/weapons/babygun/mini/kicked/zmb_mini_kicked02.wav","hoff/weapons/babygun/mini/kicked/zmb_mini_kicked03.wav","hoff/weapons/babygun/mini/kicked/zmb_mini_kicked08.wav"}
- b:EmitSound(kickSoundTable[math.random(1,table.Count(kickSoundTable))])
- b:SetVelocity( Vector(aim.x*multiplyscale,aim.y*multiplyscale,math.random(200,350)) )
- b:SetLocalAngularVelocity(Angle(math.random(250,500),math.random(0,5),0))
- b:SetNWString("CanAddVelocity","false")
- timer.Simple(0.1,function()
- b:SetNWString("BabyOnGround","true")
- end)
- end
- end
- end
- end
- end
- end
- end
- for c,d in pairs(ents.GetAll()) do
- if d:IsValid() and d:IsOnGround() and d:GetNWString("BabyOnGround") == "true" and d:GetNWString("IsBaby") == "true" then
- local dpos = d:GetPos()
- if d:IsNPC() then
- d:Remove()
- elseif d:IsPlayer() then
- d:SetNWString("IsBaby","false")
- timer.Simple(0.1,function()
- -- d:Spawn()
- d:SetViewOffset(Vector(0,0,64))
- d:SetModelScale(1)
- if d:LookupBone("ValveBiped.Bip01_Head1") ~= nil then
- d:ManipulateBoneScale(d:LookupBone("ValveBiped.Bip01_Head1"),Vector(1,1,1))
- end
- end)
- if SERVER then
- d:Kill()
- d:Spawn()
- end
- end
- local babyDieTable = {"hoff/weapons/babygun/mini/squashed/zmb_mini_squashed01.wav","hoff/weapons/babygun/mini/squashed/zmb_mini_squashed02.wav","hoff/weapons/babygun/mini/squashed/zmb_mini_squashed03.wav","hoff/weapons/babygun/mini/squashed/zmb_mini_squashed04.wav"}
- d:EmitSound(babyDieTable[math.random(1,table.Count(babyDieTable))])
- local startp = dpos
- local traceinfo = {start = startp, endpos = startp - Vector(0,0,50), filter = ent, mask = MASK_NPCWORLDSTATIC}
- local trace = util.TraceLine(traceinfo)
- local todecal1 = trace.HitPos + trace.HitNormal
- local todecal2 = trace.HitPos - trace.HitNormal
- util.Decal("Blood", todecal1, todecal2)
- if SERVER then
- local gib = ents.Create("ent_gib")
- gib:SetPos(dpos + Vector(0,0,1))
- gib:Spawn()
- local phys = gib:GetPhysicsObject()
- if (phys:IsValid()) then
- phys:SetVelocity(Vector(math.random(-50,50),math.random(-50,50),150) * math.random(2,3))
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement