Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
function SWEP:MakeOtherModel() if (CLIENT) then local vm = self.Owner:GetViewModel() self.Owner.Decor1 = ClientsideModel("models/weapons/v_pistol.mdl", RENDER_GROUP_VIEW_MODEL_OPAQUE) self.Owner.Decor1:SetPos(vm:GetPos() + vm:GetRight()*0) self.Owner.Decor1:SetAngles(vm:GetAngles()) self.Owner.Decor1:SetParent(vm) self.Owner.Decor1:SetModelScale(Vector(1, 1, 1)) self.Owner.Decor1:SetNoDraw(true) end end function SWEP:ViewModelDrawn() if (CLIENT) then if not self.Owner.Decor1 then self:MakeOtherModel() end if self.Owner.Decor1 then self.Owner.Decor1:DrawModel() end if LocalPlayer():GetActiveWeapon():GetNWBool("OtherModRePos") then self.Owner.Decor1:Remove() self:MakeOtherModel() end self.Owner.Decor1:FrameAdvance( RealFrameTime( ) ) if self.Weapon:GetNWBool("SecDraw") then self.Owner.Decor1:SetSequence(self.Owner.Decor1:LookupSequence("draw")) self.Owner.Decor1:SetCycle(0) end if self.Weapon:GetNWBool("SecIdle") then self.Owner.Decor1:SetSequence(self.Owner.Decor1:LookupSequence("idle01")) self.Owner.Decor1:SetCycle(0) end if self.Weapon:GetNWBool("SecIdleEmpty") then self.Owner.Decor1:SetSequence(self.Owner.Decor1:LookupSequence("idle01empty")) self.Owner.Decor1:SetCycle(0) end if self.Weapon:GetNWBool("SecFire") then self.Owner.Decor1:SetCycle(0) self.Owner.Decor1:SetSequence(self.Owner.Decor1:LookupSequence("fire"..math.random(1,3).."")) self.Owner.Decor1:SetCycle(0) end if self.Weapon:GetNWBool("SecReload") then self.Owner.Decor1:SetSequence(self.Owner.Decor1:LookupSequence("reload")) self.Owner.Decor1:SetCycle(0) end end end if (SERVER) then AddCSLuaFile("shared.lua") SWEP.HoldType = "pistol" end if (CLIENT) then SWEP.Category = "Dual Wields"; SWEP.PrintName = "Dual Hl2 Pistols" SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.IconLetter = "N" SWEP.ViewModelFOV = 58 killicon.AddFont("weapon_real_cs_ak47", "CSKillIcons", SWEP.IconLetter, Color( 0, 200, 0, 255 ) ) end SWEP.Instructions = "" SWEP.Author = "Zoey" SWEP.Contact = "" SWEP.Base = "insurgency_base" SWEP.ViewModelFlip = true SWEP.Spawnable = false SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_pistol.mdl" SWEP.WorldModel = "models/weapons/w_pistol.mdl" SWEP.Primary.Sound = Sound( "Weapon_Pistol.Single" ) SWEP.Primary.EmptySound = Sound( "Weapon_Pistol.Empty" ) SWEP.Primary.Recoil = 0.2 SWEP.Primary.Damage = 8 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.015 SWEP.Primary.ClipSize = 18 SWEP.Primary.Delay = 0.13 SWEP.Primary.DefaultClip = 100 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "pistol" SWEP.Secondary.Sound = Sound( "Weapon_Pistol.Single" ) SWEP.Secondary.EmptySound = Sound( "Weapon_Pistol.Empty" ) SWEP.Secondary.Recoil = 0.2 SWEP.Secondary.Damage = 8 SWEP.Secondary.NumShots = 1 SWEP.Secondary.Cone = 0.015 SWEP.Secondary.ClipSize = 18 SWEP.Secondary.Delay = 0.13 SWEP.Secondary.DefaultClip = 100 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "pistol" SWEP.IronSightsPos = Vector (0,0,0) SWEP.IronSightsAng = Vector (0,0,0) SWEP.Penetration = true SWEP.MaxPenetration = 11.5 SWEP.MaxWoodPenetration = 16.5 SWEP.Ricochet = true SWEP.MaxRicochet = 0 function SWEP:Deploy() if not self.Weapon:GetNWBool("First") then self.Weapon:SetNWBool("First",true) self.Weapon:SetNWInt("Ammo2",18) end if self.Weapon:Clip1() > 0 then self.Weapon:SendWeaponAnim(ACT_VM_DRAW) else self.Weapon:SendWeaponAnim(ACT_VM_DRAW_EMPTY) end self.Weapon:SetNWBool("OtherModRePos",true) timer.Simple(0.05, function() self.Weapon:SetNWBool("OtherModRePos",false) end) timer.Simple(0.04, function() self.Weapon:SetNWBool("SecDraw",true) end) timer.Simple(0.065, function() self.Weapon:SetNWBool("SecDraw",false) end) self.SecIdle = (CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.Idle = (CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.Reloadaftershoot = CurTime() + self.Owner:GetViewModel():SequenceDuration() self.Weapon:SetNextPrimaryFire(CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.Weapon:SetNextSecondaryFire(CurTime() + self.Owner:GetViewModel():SequenceDuration()) return true end function SWEP:Holster() return true end /*--------------------------------------------------------- Reload ---------------------------------------------------------*/ function SWEP:Reload() if self.Owner:KeyDown(IN_USE) then self:ReloadAlt() return false end if self.Reloadaftershoot and CurTime()< self.Reloadaftershoot then return end if ( self.Weapon:Clip1() < self.Primary.ClipSize ) and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then self.Weapon:SendWeaponAnim(ACT_VM_RELOAD) self.Weapon:EmitSound("Weapon_Pistol.Reload") self.Reloadaftershoot = CurTime() + self.Owner:GetViewModel():SequenceDuration() self.Weapon:SetNextPrimaryFire(CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.Weapon:SetNextSecondaryFire(CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.DoReload = (CurTime() + self.Owner:GetViewModel():SequenceDuration() - 0.2) self.Idle = (CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.Owner:SetAnimation(PLAYER_RELOAD) end end /*--------------------------------------------------------- Reload ---------------------------------------------------------*/ function SWEP:ReloadAlt() if self.Reloadaftershoot and CurTime()< self.Reloadaftershoot then return end if ( self.Weapon:GetNWInt("Ammo2") < self.Primary.ClipSize ) and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then self.Weapon:EmitSound("Weapon_Pistol.Reload") self.Weapon:SetNWBool("SecReload",true) timer.Simple(0.05, function() self.Weapon:SetNWBool("SecReload",false) end) self.Reloadaftershoot = CurTime() + 2 self.Weapon:SetNextPrimaryFire(CurTime() + 2) self.Weapon:SetNextSecondaryFire(CurTime() + 2) self.DoSecReload = (CurTime() + 2) self.SecIdle = (CurTime() + 2) self.Owner:SetAnimation(PLAYER_RELOAD) end end /*--------------------------------------------------------- Think ---------------------------------------------------------*/ function SWEP:Think() if self.Idle and CurTime()>=self.Idle then self.Idle = nil if self.Weapon:Clip1() > 0 then self.Weapon:SendWeaponAnim(ACT_VM_IDLE) else self.Weapon:SendWeaponAnim(ACT_VM_IDLE_EMPTY) end end if self.SecIdle and CurTime()>=self.SecIdle then self.SecIdle = nil self.Weapon:SetNWBool("SecIdle",true) timer.Simple(0.04, function() self.Weapon:SetNWBool("SecIdle",false) end) end if self.DoSmoke and CurTime()>=self.DoSmoke then self:SmokeEffect() end if self.DoReload and CurTime()>=self.DoReload then self:Reloadgun() end if self.DoSecReload and CurTime()>=self.DoSecReload then self.DoSecReload = nil local start = self.Weapon:GetNWInt("Ammo2") local taken = math.min( self.Primary.ClipSize, self.Primary.ClipSize - start, self.Owner:GetAmmoCount( self.Primary.Ammo ) ) self.Weapon:SetNWInt("Ammo2",18) self.Owner:RemoveAmmo( taken , self.Weapon:GetPrimaryAmmoType() ) end end /*--------------------------------------------------------- PrimaryAttack ---------------------------------------------------------*/ function SWEP:PrimaryAttack() if self.Weapon:Clip1() <= 0 or self.Owner:WaterLevel() >= 3 then self.Weapon:EmitSound(self.Primary.EmptySound) return end self.Weapon:EmitSound(self.Primary.Sound) if self.Weapon:Clip1() > 1 then self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) else self.Weapon:SendWeaponAnim(ACT_VM_DRYFIRE) end self:FireBullet(self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone) self.Owner:ViewPunch(Angle(math.Rand(-0.5,-2.5) * self.Primary.Recoil, math.Rand(-1,1) *self.Primary.Recoil, 0)) self.Idle = (CurTime() + self.Owner:GetViewModel():SequenceDuration()) self:TakePrimaryAmmo(1) self.Reloadaftershoot = CurTime() + 0.3 self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) self.DoSmoke = CurTime() + 1.2 end /*--------------------------------------------------------- SecondaryAttack ---------------------------------------------------------*/ function SWEP:SecondaryAttack() if self.Weapon:GetNWInt("Ammo2") <= 0 or self.Owner:WaterLevel() >= 3 then self.Weapon:EmitSound(self.Primary.EmptySound) return end self.Weapon:EmitSound(self.Primary.Sound) self.Weapon:SetNWBool("SecFire",true) timer.Simple(0.02, function() self.Weapon:SetNWBool("SecFire",false) end) self.SecIdle = CurTime() + 0.8 self:FireBullet(self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone) self.Owner:ViewPunch(Angle(math.Rand(-0.5,-2.5) * self.Primary.Recoil, math.Rand(-1,1) *self.Primary.Recoil, 0)) self.SecIdle = (CurTime() + self.Owner:GetViewModel():SequenceDuration()) self.Weapon:SetNWInt("Ammo2", self.Weapon:GetNWInt("Ammo2") - 1) self.Reloadaftershoot = CurTime() + 0.3 self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) self.DoSmoke = CurTime() + 1.2 end function SWEP:DrawHUD() if (CLIENT) then draw.SimpleText("Secondary Ammo Left: "..LocalPlayer():GetActiveWeapon():GetNWInt("Ammo2").."","ScoreboardText",ScrW() / 1.2, ScrH() / 1.14,Color(220,20,20,255)) end end
This paste will be private.
From the Design Piracy series on my blog: