Advertisement
Guest User

Untitled

a guest
Dec 21st, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 33.70 KB | None | 0 0
  1. if(SERVER)then
  2.     AddCSLuaFile("shared.lua")
  3. end
  4.  
  5.  
  6.  
  7.  
  8. SWEP.Kind = WEAPON_EQUIP
  9. SWEP.CanBuy = false
  10. SWEP.LimitedStock = true
  11. SWEP.WeaponID = AMMO_ALPHA
  12. SWEP.IsSilent = false
  13.  
  14. if CLIENT then
  15.  
  16.    
  17.  
  18.  
  19.    SWEP.ViewModelFlip = false
  20.  
  21.    SWEP.EquipMenuData = {
  22.       type = "item_weapon",
  23.       desc = "alpha_desc"
  24.    };
  25.  
  26.  
  27. end
  28.  
  29.  
  30.  
  31.  
  32.  
  33. if(CLIENT)then
  34.     SWEP.DrawAmmo=false
  35.     SWEP.PrintName="Weapon System Alpha"
  36.     SWEP.DrawCrosshair=false -- crosshairs are for sopping wet pussies
  37.     SWEP.DrawWeaponInfoBox=false
  38.     SWEP.BounceWeaponIcon=false
  39.     SWEP.Slot=1
  40.     SWEP.WepSelectIcon=surface.GetTextureID("vgui/mat_jack_fgalpha_wsi")
  41.     killicon.Add("wep_jack_fungun_alpha","vgui/mat_jack_fgalpha_wsi",Color(255,255,255,255))
  42. end
  43.  
  44. SWEP.Spawnable=false
  45. SWEP.AdminSpawnable=false
  46. SWEP.Base="weapon_tttbase"
  47. SWEP.ViewModelFOV=70
  48. SWEP.ViewModelFlip=false
  49. SWEP.ViewModel="models/weapons/v_halo_jeagle.mdl"
  50. SWEP.WorldModel="models/weapons/w_pistol.mdl"
  51. SWEP.SwayScale=1.75
  52. SWEP.BobScale=1.75
  53. SWEP.DrawAmmo=false
  54.  
  55. SWEP.Primary.ClipSize=-1
  56. SWEP.Primary.DefaultClize=-1
  57. SWEP.Primary.Ammo="none"
  58. SWEP.Primary.Automatic=false
  59. SWEP.Secondary.ClipSize=-1
  60. SWEP.Secondary.DefaultClip=-1
  61. SWEP.Secondary.Ammo="none"
  62. SWEP.Secondary.Automatic=false
  63.  
  64. SWEP.DefaultBobSway=2
  65. SWEP.SprintPos=Vector(2.539,-14.44,-0.441)
  66. SWEP.SprintAng=Angle(74,-7,0)
  67. SWEP.ShowWorldModel=false
  68. SWEP.ViewModelBoneMods = {
  69.     ["Main Frame"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) }
  70. }
  71. SWEP.VElements = {
  72.     ["hurr"] = { type = "Quad", bone = "Main Frame", rel = "", pos = Vector(1, -1.65, 1.1), angle = Angle(0, -90, 60.34), size = 0.025, draw_func = function(self)
  73.         local Ammo=self:GetDTFloat(1)
  74.         local Frac=1-Ammo
  75.         surface.SetDrawColor((4*Frac-1)*255,(-2*Frac+2)*255,(-4*Frac+1)*255,75)
  76.         for i=0,16 do
  77.             surface.DrawLine(-5,i,19,i)
  78.         end
  79.         surface.SetDrawColor(255,255,255,200)
  80.         surface.DrawOutlinedRect(-5,0,25,17)
  81.         surface.SetTextColor(255,255,255,200)
  82.         surface.SetTextPos(0,2)
  83.         surface.SetFont("Default")
  84.         surface.DrawText(tostring(math.Clamp(math.floor(Ammo*100),0,100)))
  85.     end},
  86.     ["narg"] = { type = "Model", model = "models/mass_effect_3/weapons/misc/jeatsink.mdl", bone = "Main Frame", rel = "", pos = Vector(-1, 0, 1.5), angle = Angle(0, -90, 0), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = true, material = "models/debug/debugwhite", skin = 0, bodygroup = {} },
  87.     ["lol"] = { type = "Model", model = "models/mass_effect_3/weapons/pistols/m-3 jredator.mdl", bone = "Main Frame", rel = "", pos = Vector(0.455, 0, 1.363), angle = Angle(0, 90, 0), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
  88.     ["derp"] = { type = "Model", model = "models/mass_effect_3/weapons/misc/jhermal clip.mdl", bone = "Slide", rel = "", pos = Vector(1, 0, -1.101), angle = Angle(0, 0, 0), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
  89.     ["herp"] = { type = "Model", model = "models/mass_effect_3/weapons/misc/jeatsink.mdl", bone = "Mag", rel = "", pos = Vector(0.1, 0, 2), angle = Angle(180, 90, 81), size = Vector(1.299, 0.699, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  90. }
  91. SWEP.WElements = {
  92.     ["lol"] = { type = "Model", model = "models/mass_effect_3/weapons/pistols/m-3 jredator.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(3.181, 1.2, -3.5), angle = Angle(180, 90, 0), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  93. }
  94.  
  95. local BurstCoolSoundPlayed=false
  96. local ReleaseSoundPlayed=false
  97. local LaserEndPlayed=false
  98. local LaserBeam=Material("trails/laser")
  99. local LaserHitPic=Material("sprites/mat_jack_glowything")
  100. //local FireTable={"fire","fire1","fire2","flame01","flame03","flame04","flatflame","FloorFlame","floorflame2"}
  101.  
  102. function SWEP:Initialize()
  103.     self:SetWeaponHoldType("revolver")
  104.     self.LasingSound=CreateSound(self.Weapon,"snd_jack_laserloop.wav")
  105.     self:SetDTInt(0,2) -- 1=drawing, 2=idle, 3=firing, 4=venting, 5=reloading, 6=holstered
  106.     self:SetDTFloat(0,0) -- firing heat
  107.     self:SetDTFloat(1,1) -- current ammunition
  108.     self:SetDTInt(1,0) -- amount that the weapon's held in a sprinting position
  109.     self.NewCartridge=true
  110.    
  111.     self:SCKInitialize()
  112. end
  113.  
  114. function SWEP:Deploy()
  115.     self:SetDTInt(0,1)
  116.     timer.Simple(.6,function()
  117.         if(IsValid(self))then
  118.             sound.Play("snd_jack_fgpistoldraw.wav",self.Owner:GetShootPos()+self.Owner:GetAimVector()*20,65,100)
  119.         end
  120.     end)
  121.     if(self.NewCartridge)then
  122.         timer.Simple(.7,function()
  123.             if(IsValid(self))then
  124.                 sound.Play("snd_jack_smallcharge.wav",self.Owner:GetShootPos()+self.Owner:GetAimVector()*20,65,100)
  125.                 self.NewCartridge=false
  126.             end
  127.         end)
  128.     end
  129.     self.Weapon:SendWeaponAnim(ACT_VM_DEPLOY)
  130.     self.Owner:GetViewModel():SetPlaybackRate(1.3)
  131.     timer.Simple(1,function()
  132.         if(IsValid(self))then
  133.             self:SetDTInt(0,2)
  134.             self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  135.         end
  136.     end)
  137. end
  138.  
  139. function SWEP:PrimaryAttack()
  140.     if(self:GetDTInt(1)>10)then return end
  141.     if not(self:GetDTInt(0)==2)then return end
  142.     if(self:GetDTFloat(1)<=0)then return end
  143.     self:SetNextPrimaryFire(CurTime()+.2)
  144.     local ShootPos=self.Owner:GetShootPos()+self.Owner:GetAimVector()*20
  145.     sound.Play("snd_jack_laserbegin.wav",ShootPos,70,100)
  146.     self.LasingSound:Play()
  147.     self:SetDTInt(0,3)
  148.     ReleaseSoundPlayed=false
  149.     BurstCoolSoundPlayed=false
  150.     LaserEndPlayed=false
  151.     umsg.Start("JackysDynamicFGBobSwayScaling")
  152.     umsg.Entity(self)
  153.     umsg.Float(.5)
  154.     umsg.End()
  155. end
  156.  
  157. //FOR INSTANCE, THIS MASK ALLOWS THE TRACE TO SEE THROUGH WINDOWS fuck that shit
  158.  
  159. function SWEP:LaserTrace(stert,ayund,filtah,stack)
  160.     if(stack>=30)then print("CRASH PREVENTION: You're shooting the laser at something that's confusing the logic.") return end -- prevent errors
  161.     local TressDat={}
  162.     TressDat.start=stert
  163.     TressDat.endpos=ayund
  164.     TressDat.filter=filtah
  165.     TressDat.mask=MASK_SHOT
  166.     local Tress=util.TraceLine(TressDat)
  167.     if(Tress.Hit)then
  168.         if((Tress.Entity:GetColor().a<=150)or(Tress.MatType==MAT_GLASS))then
  169.             if(Tress.Entity:IsWorld())then
  170.                 self:LaserTrace(Tress.HitPos+Tress.Normal*5,Tress.HitPos+Tress.Normal*40000,{self.Owner},stack+1)
  171.             else
  172.                 self:LaserTrace(Tress.HitPos,Tress.HitPos+Tress.Normal*40000,{self.Owner,Tress.Entity},stack+1)
  173.             end
  174.         else
  175.             self.CurrentTracedPosition=Tress.HitPos -- used by the drawing functions, stored for efficiency
  176.             self.CurrentTracedNormal=Tress.HitNormal -- used by the drawing functions, stored for efficiency
  177.             if(SERVER)then
  178.                 local WantSomeIceWithThatBurn=DamageInfo()
  179.                 WantSomeIceWithThatBurn:SetDamage(math.Rand(.275,.375))
  180.                 WantSomeIceWithThatBurn:SetDamagePosition(Tress.HitPos)
  181.                 WantSomeIceWithThatBurn:SetDamageForce(Vector(0,0,0))
  182.                 WantSomeIceWithThatBurn:SetAttacker(self.Owner)
  183.                 WantSomeIceWithThatBurn:SetInflictor(self.Weapon)
  184.                 if(Tress.Entity:IsOnFire())then
  185.                     WantSomeIceWithThatBurn:SetDamageType(DMG_GENERIC)
  186.                 elseif(math.random(1,9)==5)then
  187.                     WantSomeIceWithThatBurn:SetDamageType(DMG_BURN)
  188.                 else
  189.                     WantSomeIceWithThatBurn:SetDamageType(DMG_DIRECT)
  190.                 end
  191.                 Tress.Entity:TakeDamageInfo(WantSomeIceWithThatBurn)
  192.                
  193.                 umsg.Start("JackysLaserLightUMSG")
  194.                 umsg.Vector(Tress.HitPos)
  195.                 umsg.End()
  196.                
  197.                 if not(self.NextBurnSoundEmitTime)then self.NextBurnSoundEmitTime=CurTime() end
  198.                 if(self.NextBurnSoundEmitTime<CurTime())then
  199.                     sound.Play("snd_jack_laserburn.wav",Tress.HitPos+Tress.HitNormal,70,100)
  200.                     self.NextBurnSoundEmitTime=CurTime()+.075
  201.                 end
  202.                 if(math.random(1,4)==2)then
  203.                     util.Decal("FadingScorch",Tress.HitPos+Tress.HitNormal,Tress.HitPos-Tress.HitNormal)
  204.                 end
  205.                 if(math.random(1,2)==1)then
  206.                     local Poof=EffectData()
  207.                     Poof:SetOrigin(Tress.HitPos)
  208.                     Poof:SetScale(1)
  209.                     Poof:SetNormal(Tress.HitNormal)
  210.                     if((Tress.MatType==MAT_CONCRETE)or(Tress.MatType==MAT_METAL)or(Tress.MatType==MAT_COMPUTER)or(Tress.MatType==MAT_GRATE)or(Tress.MatType==MAT_TILE)or(Tress.MatType==MAT_GLASS)or(Tress.MatType==MAT_SAND))then
  211.                         Poof:SetStart(Tress.Entity:GetVelocity())
  212.                         util.Effect("eff_jack_tinymelt",Poof)
  213.                     else
  214.                         util.Effect("eff_jack_tinyburn",Poof)
  215.                     end
  216.                 end
  217.             end
  218.         end
  219.     end
  220. end
  221.  
  222. function SWEP:Think()
  223.     self.LaserShake=VectorRand()*math.Rand(.01,.05)
  224.    
  225.     if(SERVER)then
  226.         local Held=self:GetDTInt(1)
  227.         if(self.Owner:KeyDown(IN_SPEED))then
  228.             if(Held<100)then self:SetDTInt(1,Held+6) end
  229.         else
  230.             if(Held>0)then self:SetDTInt(1,Held-6) end
  231.         end
  232.     end
  233.    
  234.     local Heat=self:GetDTFloat(0)
  235.     local Red=math.Clamp(Heat*463-69,0,255)
  236.     local Green=math.Clamp(Heat*1275-1020,0,255)
  237.     local Blue=math.Clamp(Heat*2550-2295,0,255)
  238.     //self.Owner:PrintMessage(HUD_PRINTCENTER,tostring(math.Round(Red)).." "..tostring(math.Round(Green)).." "..tostring(math.Round(Blue)))
  239.     self.VElements["narg"].color=Color(Red,Green,Blue,255)
  240.  
  241.     local State=self:GetDTInt(0)
  242.     //self.Owner:PrintMessage(HUD_PRINTCENTER,State)
  243.     if((State==4)or(State==5))then return end
  244.     if((self.Owner:InVehicle())or(self.Owner:KeyDown(IN_ZOOM)))then
  245.         if(State==3)then
  246.             self.LasingSound:Stop()
  247.             self:SetDTInt(0,2)
  248.         end
  249.         return
  250.     end
  251.  
  252.     local BaseShootPos=self.Owner:GetShootPos()
  253.     local ShootPos=BaseShootPos+self.Owner:GetRight()*4-self.Owner:GetUp()*5
  254.     local AimVec=self.Owner:GetAimVector()
  255.     self.CurrentAimVector=AimVec -- used by the drawing functions, stored for efficiency
  256.    
  257.     if(State==3)then
  258.         self:SetDTFloat(0,math.Clamp(Heat+.0012,0,1))
  259.         local Ammo=self:GetDTFloat(1)
  260.         local Loss=(.0028+.18*Heat^4)*.01
  261.         //self.Owner:PrintMessage(HUD_PRINTCENTER,Loss)
  262.         self:SetDTFloat(1,Ammo-Loss)
  263.         if not(self.NextLasingSoundTime)then self.NextLasingSoundTime=CurTime()+.1 end
  264.         if(self.NextLasingSoundTime<CurTime())then
  265.             self.LasingSound:Stop()
  266.             self.LasingSound:Play()
  267.             self.NextLasingSoundTime=CurTime()+3.15
  268.         end
  269.         self:LaserTrace(BaseShootPos,BaseShootPos+AimVec*40000,{self.Owner},1)
  270.         self.Owner:ViewPunch(Angle(math.Rand(-.05,.05),math.Rand(-.05,.05),math.Rand(-.05,.05)))
  271.     end
  272. end
  273.  
  274. function SWEP:BurstCool()
  275.     if(self:GetDTInt(0)==4)then return end
  276.     self:SetDTInt(0,4)
  277.  
  278.     self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  279.     self.Owner:GetViewModel():SetPlaybackRate(.25)
  280.     self.Owner:SetAnimation(PLAYER_ATTACK1)
  281.     if not(BurstCoolSoundPlayed)then
  282.         BurstCoolSoundPlayed=true
  283.         if(SERVER)then
  284.             self.Weapon:EmitSound("snd_jack_laservent.wav",70,100)
  285.         end
  286.     end
  287.     local Pewf=EffectData()
  288.     Pewf:SetOrigin(self.Owner:GetShootPos()+self.Owner:GetAimVector()*20+self.Owner:GetRight()*4)
  289.     Pewf:SetStart(self.Owner:GetVelocity())
  290.     util.Effect("eff_jack_instantvent",Pewf)
  291.     timer.Simple(.2,function()
  292.         if(IsValid(self))then
  293.             local Pewf=EffectData()
  294.             Pewf:SetOrigin(self.Owner:GetShootPos()+self.Owner:GetAimVector()*20+self.Owner:GetRight()*4)
  295.             Pewf:SetStart(self.Owner:GetVelocity())
  296.             util.Effect("eff_jack_instantvent",Pewf)
  297.         end
  298.     end)
  299.     timer.Simple(.4,function()
  300.         if(IsValid(self))then
  301.             local Pewf=EffectData()
  302.             Pewf:SetOrigin(self.Owner:GetShootPos()+self.Owner:GetAimVector()*20+self.Owner:GetRight()*4)
  303.             Pewf:SetStart(self.Owner:GetVelocity())
  304.             util.Effect("eff_jack_instantvent",Pewf)
  305.         end
  306.     end)
  307.     timer.Simple(1.6,function()
  308.         if(IsValid(self))then
  309.             self:SetDTInt(0,2)
  310.             BurstCoolSoundPlayed=false
  311.         end
  312.     end)
  313. end
  314.  
  315. function SWEP:SecondaryAttack()
  316.     if not(self:GetDTInt(0)==2)then return end
  317.     if not(self:GetDTFloat(0)>.15)then return end
  318.     self:BurstCool()
  319. end
  320.  
  321. if(CLIENT)then
  322.     local function MakeMagHot(data)
  323.         local self=data:ReadEntity()
  324.         self.VElements["herp"].surpresslightning=true
  325.         self.VElements["herp"].material="models/debug/debugwhite"
  326.     end
  327.     usermessage.Hook("JackysAlphaFGMagHot",MakeMagHot)
  328.  
  329.     local function MakeMagCool(data)
  330.         local self=data:ReadEntity()
  331.         self.VElements["herp"].surpresslightning=false
  332.         self.VElements["herp"].material=nil
  333.     end
  334.     usermessage.Hook("JackysAlphaFGMagCool",MakeMagCool)
  335. end
  336.  
  337. function SWEP:Reload()
  338.     if not(self:GetDTInt(0)==2)then return end
  339.     local InitialRemaining=self:GetDTFloat(1)
  340.     local InitialReserve=self.Owner:GetAmmoCount("GaussEnergy")
  341.     if((InitialRemaining<=.01)and(InitialReserve>0))then
  342.         self:SetDTInt(0,5)
  343.         umsg.Start("JackysAlphaFGMagHot",self.Owner)
  344.         umsg.Entity(self.Weapon)
  345.         umsg.End()
  346.         self.Weapon:SendWeaponAnim(ACT_VM_RELOAD)
  347.         self.Owner:GetViewModel():SetPlaybackRate(.8)
  348.         self.Owner:SetAnimation(PLAYER_RELOAD)
  349.         self.Weapon:EmitSound("snd_jack_laserreload.wav",70,100)
  350.         timer.Simple(.4,function()
  351.             if(IsValid(self))then
  352.                 if(SERVER)then
  353.                     local Empty=ents.Create("ent_jack_fgcartridge")
  354.                     local LolAng=self.Owner:EyeAngles()
  355.                     local Pos,Ang=self.Owner:GetBonePosition(self.Owner:LookupBone("ValveBiped.Bip01_R_Hand"))
  356.                     Empty:SetPos(Pos+Ang:Up()*10-Ang:Forward()*10)
  357.                     LolAng:RotateAroundAxis(LolAng:Forward(),90)
  358.                     LolAng:RotateAroundAxis(LolAng:Up(),180)
  359.                     Empty:SetAngles(LolAng)
  360.                     Empty:SetDTBool(0,true)
  361.                     Empty:Spawn()
  362.                     Empty:Activate()
  363.                     Empty:GetPhysicsObject():SetVelocity(self.Owner:GetVelocity())
  364.                 end
  365.                 self:SetDTFloat(1,0)
  366.             end
  367.         end)
  368.         timer.Simple(.6,function()
  369.             if(IsValid(self))then
  370.                 umsg.Start("JackysAlphaFGMagCool",self.Owner)
  371.                 umsg.Entity(self.Weapon)
  372.                 umsg.End()
  373.             end
  374.         end)
  375.         timer.Simple(1.5,function()
  376.             if(IsValid(self))then
  377.                 local Missing=100-InitialRemaining
  378.                 if(InitialReserve>=Missing)then
  379.                     self:SetDTFloat(1,1)
  380.                     self.Owner:RemoveAmmo(Missing,"GaussEnergy")
  381.                 else
  382.                     self.Owner:RemoveAmmo(InitialReserve,"GaussEnergy")
  383.                     self:SetDTFloat(1,math.Clamp(InitialRemaining+InitialReserve+.01,0,1))
  384.                 end
  385.                 sound.Play("snd_jack_smallcharge.wav",self.Owner:GetShootPos()+self.Owner:GetAimVector()*20,65,100)
  386.             end
  387.         end)
  388.         timer.Simple(2,function()
  389.             if(IsValid(self))then
  390.                 self:SetDTInt(0,2)
  391.             end
  392.         end)
  393.     end
  394. end
  395.  
  396. function SWEP:Holster()
  397.     self.LasingSound:Stop()
  398.     self:SetDTInt(0,6)
  399.     self:SetDTInt(1,0)
  400.     self:SCKHolster()
  401.     return true
  402. end
  403.  
  404. function SWEP:OnDrop()
  405.     self.LasingSound:Stop()
  406. end
  407.  
  408. if(CLIENT)then
  409.     function SWEP:DrawHUD()
  410.         -- *overwrite*  :3
  411.     end
  412.     function SWEP:GetViewModelPosition(pos,ang)
  413.         ang:RotateAroundAxis(ang:Right(),4)
  414.         pos=pos-ang:Up()*1
  415.         if(self:GetDTInt(0)==3)then
  416.             pos=pos+self.LaserShake
  417.         end
  418.         local Held=self:GetDTInt(1)/100
  419.         if(Held>0)then
  420.             local Right=ang:Right()
  421.             local Up=ang:Up()
  422.             local Forward=ang:Forward()
  423.             pos=pos+self.SprintPos.x*Right*Held+self.SprintPos.y*Up*Held+self.SprintPos.z*Forward*Held
  424.             ang:RotateAroundAxis(Right,self.SprintAng.p*Held)
  425.             ang:RotateAroundAxis(Up,self.SprintAng.y*Held)
  426.             ang:RotateAroundAxis(Forward,self.SprintAng.r*Held)
  427.         end
  428.         return pos,ang
  429.     end
  430.     function SWEP:ViewModelDrawn()
  431.     /*- if(self:GetDTInt(0)==3)then --there used to be two laser drawing functions (which looked BEAUTIFUL), but I commented them out in favor of one to reduce lag
  432.             local Flicker=math.Rand(.8,1.2)
  433.             local VM=self.Owner:GetViewModel()
  434.             local Pos,Ang=VM:GetBonePosition(VM:LookupBone("Main Frame"))
  435.             local Nupos=Pos+self.CurrentAimVector*20+self.Owner:GetRight()*2-self.Owner:GetUp()*2
  436.             render.SetMaterial(LaserBeam)
  437.             render.DrawBeam(Nupos,self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,3,0,0,Color(255,255,255,100))
  438.             render.DrawBeam(Nupos,self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,15,0,0,Color(255,0,0,75))
  439.             render.SetMaterial(LaserHitPic)
  440.             render.DrawSprite(self.CurrentTracedPosition+self.CurrentTracedNormal,13*Flicker,13*Flicker,Color(255,100,100,255))
  441.             render.DrawSprite(self.CurrentTracedPosition+self.CurrentTracedNormal,50*Flicker,50*Flicker,Color(255,60,60,100))
  442.             render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,self.CurrentTracedNormal,25*Flicker,25*Flicker,Color(255,100,100,255))
  443.             render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,-self.CurrentTracedNormal,25*Flicker,25*Flicker,Color(255,100,100,255))
  444.             render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,self.CurrentTracedNormal,75*Flicker,75*Flicker,Color(255,60,60,100))
  445.             render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,-self.CurrentTracedNormal,75*Flicker,75*Flicker,Color(255,60,60,100))
  446.         end-*/
  447.    
  448.         self:SCKViewModelDrawn()
  449.     end
  450.     function SWEP:DrawWorldModel()
  451.         self:SCKDrawWorldModel()
  452.     end
  453. end
  454.  
  455. /*---------------- These things operate OUTSIDE of the weapon --------------------------*/
  456.  
  457. local function PlayEndSound(ply,key)
  458.     if not(key==IN_ATTACK)then return end
  459.     local Wep=ply:GetActiveWeapon()
  460.     if(IsValid(Wep))then
  461.         if(Wep:GetClass()=="wep_jack_fungun_alpha")then
  462.             if(Wep:GetDTInt(0)==3)then
  463.                 if not(ReleaseSoundPlayed)then
  464.                     ReleaseSoundPlayed=true
  465.                     sound.Play("snd_jack_laserend.wav",Wep:GetPos(),70,100)
  466.                 end
  467.                 if(SERVER)then
  468.                     umsg.Start("JackysDynamicFGBobSwayScaling")
  469.                     umsg.Entity(Wep)
  470.                     umsg.Float(Wep.DefaultBobSway)
  471.                     umsg.End()
  472.                 end
  473.                 Wep.LasingSound:Stop()
  474.                 Wep:SetDTInt(0,2)
  475.             end
  476.         end
  477.     end
  478. end
  479. hook.Add("KeyRelease","JackysAlphaLaserReleaseSound",PlayEndSound)
  480.  
  481. local function GunThink()  
  482.     for key,wep in pairs(ents.FindByClass("wep_jack_fungun_alpha"))do
  483.         local Heat=wep:GetDTFloat(0)
  484.         if(Heat)then
  485.             local State=wep:GetDTInt(0)
  486.             if(State==3)then
  487.                 if((wep:GetDTFloat(1)<=0)or(wep.Owner:KeyDown(IN_SPEED)))then
  488.                     if not(LaserEndPlayed)then
  489.                         LaserEndPlayed=true
  490.                         sound.Play("snd_jack_laserend.wav",wep:GetPos(),70,100)
  491.                     end
  492.                     if(SERVER)then
  493.                         umsg.Start("JackysDynamicFGBobSwayScaling")
  494.                         umsg.Entity(wep)
  495.                         umsg.Float(wep.DefaultBobSway)
  496.                         umsg.End()
  497.                     end
  498.                     wep.LasingSound:Stop()
  499.                     wep:SetDTInt(0,2)
  500.                 elseif(Heat==1)then
  501.                     if not(LaserEndPlayed)then
  502.                         LaserEndPlayed=true
  503.                         sound.Play("snd_jack_laserend.wav",wep:GetPos(),70,100)
  504.                     end
  505.                     if(SERVER)then
  506.                         umsg.Start("JackysDynamicFGBobSwayScaling")
  507.                         umsg.Entity(wep)
  508.                         umsg.Float(wep.DefaultBobSway)
  509.                         umsg.End()
  510.                     end
  511.                     wep.LasingSound:Stop()
  512.                     wep:BurstCool() -- emergency cooling interrupt, protect the pistol from dumbass users
  513.                     wep:SetDTFloat(0,.9999)
  514.                 end
  515.             end
  516.             if(State==4)then
  517.                 wep:SetDTFloat(0,math.Clamp(Heat-.0075,0,1))
  518.             else
  519.                 wep:SetDTFloat(0,math.Clamp(Heat-.0003,0,1))
  520.             end
  521.         end
  522.     end
  523. end
  524. hook.Add("Think","JackysAlphaFunGunThinking",GunThink)
  525.  
  526. if(CLIENT)then
  527.     local function Flash(data)
  528.         local vector=data:ReadVector()
  529.         local dlight=DynamicLight()
  530.         if(dlight)then
  531.             dlight.MinLight=0
  532.             dlight.Pos=vector
  533.             dlight.r=15
  534.             dlight.g=5
  535.             dlight.b=5
  536.             dlight.Brightness=1
  537.             dlight.Size=450
  538.             dlight.Decay=10000
  539.             dlight.DieTime=CurTime()+.2
  540.             dlight.Style=0
  541.         end
  542.     end
  543.     usermessage.Hook("JackysLaserLightUMSG",Flash)
  544.  
  545.     local function DrawLazah()
  546.         for key,Weaponu in pairs(ents.FindByClass("wep_jack_fungun_alpha"))do
  547.             local playah=Weaponu.Owner
  548.             if(IsValid(playah))then
  549.                 local LocalPlayah=LocalPlayer()
  550.                 //if(((playah==LocalPlayah)and(LocalPlayah:ShouldDrawLocalPlayer()))or not(playah==LocalPlayah))then
  551.                     if(Weaponu:GetDTInt(0)==3)then
  552.                         local Flicker=math.Rand(.8,1.2)
  553.                         //local PosAng=Weaponu:GetAttachment(Weaponu:LookupAttachment("muzzle"))
  554.                         //if(PosAng)then
  555.                             local Nupos=playah:GetShootPos()+playah:GetAimVector()*33+playah:GetRight()*4-playah:GetUp()*6
  556.                             render.SetMaterial(LaserBeam)
  557.                             render.DrawBeam(Nupos,Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,3,0,0,Color(255,255,255,40))
  558.                             render.DrawBeam(Nupos,Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,15,0,0,Color(255,0,0,20))
  559.                             render.SetMaterial(LaserHitPic)
  560.                             render.DrawSprite(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal,13*Flicker,13*Flicker,Color(255,100,100,255))
  561.                             render.DrawSprite(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal,50*Flicker,50*Flicker,Color(255,60,60,100))
  562.                             render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,Weaponu.CurrentTracedNormal,40*Flicker,40*Flicker,Color(255,100,100,255))
  563.                             render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,-Weaponu.CurrentTracedNormal,40*Flicker,40*Flicker,Color(255,100,100,255))
  564.                             render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,Weaponu.CurrentTracedNormal,100*Flicker,100*Flicker,Color(255,60,60,100))
  565.                             render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,-Weaponu.CurrentTracedNormal,100*Flicker,100*Flicker,Color(255,60,60,100))
  566.                         //end
  567.                     end
  568.                 //end
  569.             end
  570.         end
  571.     end
  572.     hook.Add("PostDrawTranslucentRenderables","JackyFunGunAlphaLaser",DrawLazah)
  573. end
  574.  
  575. /*------------------------------------------------------------------------------------
  576.  
  577.     Below this line is Clavus' SWEP Construction Kit base code.
  578.     Clavus is KREDIT TO TEEM
  579.     ALL HAIL CLAVUS
  580.  
  581. ------------------------------------------------------------------------------------*/
  582.  
  583. function SWEP:SCKInitialize()
  584.  
  585.     if CLIENT then
  586.    
  587.         // Create a new table for every weapon instance
  588.         self.VElements = table.FullCopy( self.VElements )
  589.         self.WElements = table.FullCopy( self.WElements )
  590.         self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
  591.  
  592.         self:CreateModels(self.VElements) // create viewmodels
  593.         self:CreateModels(self.WElements) // create worldmodels
  594.        
  595.         // init view model bone build function
  596.         if IsValid(self.Owner) then
  597.             local vm = self.Owner:GetViewModel()
  598.             if IsValid(vm) then
  599.                 self:ResetBonePositions(vm)
  600.             end
  601.            
  602.             // Init viewmodel visibility
  603.             if (self.ShowViewModel == nil or self.ShowViewModel) then
  604.                 vm:SetColor(Color(255,255,255,255))
  605.             else
  606.                 // we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
  607.                 vm:SetColor(Color(255,255,255,1))
  608.                 // ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
  609.                 // however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing
  610.                 vm:SetMaterial("Debug/hsv")        
  611.             end
  612.         end
  613.        
  614.     end
  615.  
  616. end
  617.  
  618. function SWEP:SCKHolster()
  619.    
  620.     if CLIENT and IsValid(self.Owner) then
  621.         local vm = self.Owner:GetViewModel()
  622.         if IsValid(vm) then
  623.             self:ResetBonePositions(vm)
  624.         end
  625.     end
  626.  
  627. end
  628.  
  629. if CLIENT then
  630.  
  631.     SWEP.vRenderOrder = nil
  632.     function SWEP:SCKViewModelDrawn()
  633.        
  634.         local vm = self.Owner:GetViewModel()
  635.         if !IsValid(vm) then return end
  636.        
  637.         if (!self.VElements) then return end
  638.        
  639.         self:UpdateBonePositions(vm)
  640.  
  641.         if (!self.vRenderOrder) then
  642.            
  643.             // we build a render order because sprites need to be drawn after models
  644.             self.vRenderOrder = {}
  645.  
  646.             for k, v in pairs( self.VElements ) do
  647.                 if (v.type == "Model") then
  648.                     table.insert(self.vRenderOrder, 1, k)
  649.                 elseif (v.type == "Sprite" or v.type == "Quad") then
  650.                     table.insert(self.vRenderOrder, k)
  651.                 end
  652.             end
  653.            
  654.         end
  655.  
  656.         for k, name in ipairs( self.vRenderOrder ) do
  657.        
  658.             local v = self.VElements[name]
  659.             if (!v) then self.vRenderOrder = nil break end
  660.             if (v.hide) then continue end
  661.            
  662.             local model = v.modelEnt
  663.             local sprite = v.spriteMaterial
  664.            
  665.             if (!v.bone) then continue end
  666.            
  667.             local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
  668.            
  669.             if (!pos) then continue end
  670.            
  671.             if (v.type == "Model" and IsValid(model)) then
  672.  
  673.                 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
  674.                 ang:RotateAroundAxis(ang:Up(), v.angle.y)
  675.                 ang:RotateAroundAxis(ang:Right(), v.angle.p)
  676.                 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  677.  
  678.                 model:SetAngles(ang)
  679.                 //model:SetModelScale(v.size)
  680.                 local matrix = Matrix()
  681.                 matrix:Scale(v.size)
  682.                 model:EnableMatrix( "RenderMultiply", matrix )
  683.                
  684.                 if (v.material == "") then
  685.                     model:SetMaterial("")
  686.                 elseif (model:GetMaterial() != v.material) then
  687.                     model:SetMaterial( v.material )
  688.                 end
  689.                
  690.                 if (v.skin and v.skin != model:GetSkin()) then
  691.                     model:SetSkin(v.skin)
  692.                 end
  693.                
  694.                 if (v.bodygroup) then
  695.                     for k, v in pairs( v.bodygroup ) do
  696.                         if (model:GetBodygroup(k) != v) then
  697.                             model:SetBodygroup(k, v)
  698.                         end
  699.                     end
  700.                 end
  701.                
  702.                 if (v.surpresslightning) then
  703.                     render.SuppressEngineLighting(true)
  704.                 end
  705.                
  706.                 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
  707.                 render.SetBlend(v.color.a/255)
  708.                 model:DrawModel()
  709.                 render.SetBlend(1)
  710.                 render.SetColorModulation(1, 1, 1)
  711.                
  712.                 if (v.surpresslightning) then
  713.                     render.SuppressEngineLighting(false)
  714.                 end
  715.                
  716.             elseif (v.type == "Sprite" and sprite) then
  717.                
  718.                 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  719.                 render.SetMaterial(sprite)
  720.                 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
  721.                
  722.             elseif (v.type == "Quad" and v.draw_func) then
  723.                
  724.                 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  725.                 ang:RotateAroundAxis(ang:Up(), v.angle.y)
  726.                 ang:RotateAroundAxis(ang:Right(), v.angle.p)
  727.                 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  728.                
  729.                 cam.Start3D2D(drawpos, ang, v.size)
  730.                     v.draw_func( self )
  731.                 cam.End3D2D()
  732.  
  733.             end
  734.            
  735.         end
  736.        
  737.     end
  738.  
  739.     SWEP.wRenderOrder = nil
  740.     function SWEP:SCKDrawWorldModel()
  741.        
  742.         if (self.ShowWorldModel == nil or self.ShowWorldModel) then
  743.             self:DrawModel()
  744.         end
  745.        
  746.         if (!self.WElements) then return end
  747.        
  748.         if (!self.wRenderOrder) then
  749.  
  750.             self.wRenderOrder = {}
  751.  
  752.             for k, v in pairs( self.WElements ) do
  753.                 if (v.type == "Model") then
  754.                     table.insert(self.wRenderOrder, 1, k)
  755.                 elseif (v.type == "Sprite" or v.type == "Quad") then
  756.                     table.insert(self.wRenderOrder, k)
  757.                 end
  758.             end
  759.  
  760.         end
  761.        
  762.         if (IsValid(self.Owner)) then
  763.             bone_ent = self.Owner
  764.         else
  765.             // when the weapon is dropped
  766.             bone_ent = self
  767.         end
  768.        
  769.         for k, name in pairs( self.wRenderOrder ) do
  770.        
  771.             local v = self.WElements[name]
  772.             if (!v) then self.wRenderOrder = nil break end
  773.             if (v.hide) then continue end
  774.            
  775.             local pos, ang
  776.            
  777.             if (v.bone) then
  778.                 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
  779.             else
  780.                 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
  781.             end
  782.            
  783.             if (!pos) then continue end
  784.            
  785.             local model = v.modelEnt
  786.             local sprite = v.spriteMaterial
  787.            
  788.             if (v.type == "Model" and IsValid(model)) then
  789.  
  790.                 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
  791.                 ang:RotateAroundAxis(ang:Up(), v.angle.y)
  792.                 ang:RotateAroundAxis(ang:Right(), v.angle.p)
  793.                 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  794.  
  795.                 model:SetAngles(ang)
  796.                 //model:SetModelScale(v.size)
  797.                 local matrix = Matrix()
  798.                 matrix:Scale(v.size)
  799.                 model:EnableMatrix( "RenderMultiply", matrix )
  800.                
  801.                 if (v.material == "") then
  802.                     model:SetMaterial("")
  803.                 elseif (model:GetMaterial() != v.material) then
  804.                     model:SetMaterial( v.material )
  805.                 end
  806.                
  807.                 if (v.skin and v.skin != model:GetSkin()) then
  808.                     model:SetSkin(v.skin)
  809.                 end
  810.                
  811.                 if (v.bodygroup) then
  812.                     for k, v in pairs( v.bodygroup ) do
  813.                         if (model:GetBodygroup(k) != v) then
  814.                             model:SetBodygroup(k, v)
  815.                         end
  816.                     end
  817.                 end
  818.                
  819.                 if (v.surpresslightning) then
  820.                     render.SuppressEngineLighting(true)
  821.                 end
  822.                
  823.                 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
  824.                 render.SetBlend(v.color.a/255)
  825.                 model:DrawModel()
  826.                 render.SetBlend(1)
  827.                 render.SetColorModulation(1, 1, 1)
  828.                
  829.                 if (v.surpresslightning) then
  830.                     render.SuppressEngineLighting(false)
  831.                 end
  832.                
  833.             elseif (v.type == "Sprite" and sprite) then
  834.                
  835.                 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  836.                 render.SetMaterial(sprite)
  837.                 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
  838.                
  839.             elseif (v.type == "Quad" and v.draw_func) then
  840.                
  841.                 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  842.                 ang:RotateAroundAxis(ang:Up(), v.angle.y)
  843.                 ang:RotateAroundAxis(ang:Right(), v.angle.p)
  844.                 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  845.                
  846.                 cam.Start3D2D(drawpos, ang, v.size)
  847.                     v.draw_func( self )
  848.                 cam.End3D2D()
  849.  
  850.             end
  851.            
  852.         end
  853.        
  854.     end
  855.  
  856.     function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
  857.        
  858.         local bone, pos, ang
  859.         if (tab.rel and tab.rel != "") then
  860.            
  861.             local v = basetab[tab.rel]
  862.            
  863.             if (!v) then return end
  864.            
  865.             // Technically, if there exists an element with the same name as a bone
  866.             // you can get in an infinite loop. Let's just hope nobody's that stupid.
  867.             pos, ang = self:GetBoneOrientation( basetab, v, ent )
  868.            
  869.             if (!pos) then return end
  870.            
  871.             pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  872.             ang:RotateAroundAxis(ang:Up(), v.angle.y)
  873.             ang:RotateAroundAxis(ang:Right(), v.angle.p)
  874.             ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  875.                
  876.         else
  877.        
  878.             bone = ent:LookupBone(bone_override or tab.bone)
  879.  
  880.             if (!bone) then return end
  881.            
  882.             pos, ang = Vector(0,0,0), Angle(0,0,0)
  883.             local m = ent:GetBoneMatrix(bone)
  884.             if (m) then
  885.                 pos, ang = m:GetTranslation(), m:GetAngles()
  886.             end
  887.            
  888.             if (IsValid(self.Owner) and self.Owner:IsPlayer() and
  889.                 ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
  890.                 ang.r = -ang.r // Fixes mirrored models
  891.             end
  892.        
  893.         end
  894.        
  895.         return pos, ang
  896.     end
  897.  
  898.     function SWEP:CreateModels( tab )
  899.  
  900.         if (!tab) then return end
  901.  
  902.         // Create the clientside models here because Garry says we can't do it in the render hook
  903.         for k, v in pairs( tab ) do
  904.             if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
  905.                     string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
  906.                
  907.                 v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
  908.                 if (IsValid(v.modelEnt)) then
  909.                     v.modelEnt:SetPos(self:GetPos())
  910.                     v.modelEnt:SetAngles(self:GetAngles())
  911.                     v.modelEnt:SetParent(self)
  912.                     v.modelEnt:SetNoDraw(true)
  913.                     v.createdModel = v.model
  914.                 else
  915.                     v.modelEnt = nil
  916.                 end
  917.                
  918.             elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
  919.                 and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
  920.                
  921.                 local name = v.sprite.."-"
  922.                 local params = { ["$basetexture"] = v.sprite }
  923.                 // make sure we create a unique name based on the selected options
  924.                 local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
  925.                 for i, j in pairs( tocheck ) do
  926.                     if (v[j]) then
  927.                         params["$"..j] = 1
  928.                         name = name.."1"
  929.                     else
  930.                         name = name.."0"
  931.                     end
  932.                 end
  933.  
  934.                 v.createdSprite = v.sprite
  935.                 v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
  936.                
  937.             end
  938.         end
  939.        
  940.     end
  941.    
  942.     local allbones
  943.     local hasGarryFixedBoneScalingYet = false
  944.  
  945.     function SWEP:UpdateBonePositions(vm)
  946.        
  947.         if self.ViewModelBoneMods then
  948.            
  949.             if (!vm:GetBoneCount()) then return end
  950.            
  951.             // !! WORKAROUND !! //
  952.             // We need to check all model names :/
  953.             local loopthrough = self.ViewModelBoneMods
  954.             if (!hasGarryFixedBoneScalingYet) then
  955.                 allbones = {}
  956.                 for i=0, vm:GetBoneCount() do
  957.                     local bonename = vm:GetBoneName(i)
  958.                     if (self.ViewModelBoneMods[bonename]) then
  959.                         allbones[bonename] = self.ViewModelBoneMods[bonename]
  960.                     else
  961.                         allbones[bonename] = {
  962.                             scale = Vector(1,1,1),
  963.                             pos = Vector(0,0,0),
  964.                             angle = Angle(0,0,0)
  965.                         }
  966.                     end
  967.                 end
  968.                
  969.                 loopthrough = allbones
  970.             end
  971.             // !! ----------- !! //
  972.            
  973.             for k, v in pairs( loopthrough ) do
  974.                 local bone = vm:LookupBone(k)
  975.                 if (!bone) then continue end
  976.                
  977.                 // !! WORKAROUND !! //
  978.                 local s = Vector(v.scale.x,v.scale.y,v.scale.z)
  979.                 local p = Vector(v.pos.x,v.pos.y,v.pos.z)
  980.                 local ms = Vector(1,1,1)
  981.                 if (!hasGarryFixedBoneScalingYet) then
  982.                     local cur = vm:GetBoneParent(bone)
  983.                     while(cur >= 0) do
  984.                         local pscale = loopthrough[vm:GetBoneName(cur)].scale
  985.                         ms = ms * pscale
  986.                         cur = vm:GetBoneParent(cur)
  987.                     end
  988.                 end
  989.                
  990.                 s = s * ms
  991.                 // !! ----------- !! //
  992.                
  993.                 if vm:GetManipulateBoneScale(bone) != s then
  994.                     vm:ManipulateBoneScale( bone, s )
  995.                 end
  996.                 if vm:GetManipulateBoneAngles(bone) != v.angle then
  997.                     vm:ManipulateBoneAngles( bone, v.angle )
  998.                 end
  999.                 if vm:GetManipulateBonePosition(bone) != p then
  1000.                     vm:ManipulateBonePosition( bone, p )
  1001.                 end
  1002.             end
  1003.         else
  1004.             self:ResetBonePositions(vm)
  1005.         end
  1006.            
  1007.     end
  1008.      
  1009.     function SWEP:ResetBonePositions(vm)
  1010.        
  1011.         if (!vm:GetBoneCount()) then return end
  1012.         for i=0, vm:GetBoneCount() do
  1013.             vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
  1014.             vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
  1015.             vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
  1016.         end
  1017.        
  1018.     end
  1019.  
  1020.     /**************************
  1021.         Global utility code
  1022.     **************************/
  1023.  
  1024.     // Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
  1025.     // Does not copy entities of course, only copies their reference.
  1026.     // WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
  1027.     function table.FullCopy( tab )
  1028.  
  1029.         if (!tab) then return nil end
  1030.        
  1031.         local res = {}
  1032.         for k, v in pairs( tab ) do
  1033.             if (type(v) == "table") then
  1034.                 res[k] = table.FullCopy(v) // recursion ho!
  1035.             elseif (type(v) == "Vector") then
  1036.                 res[k] = Vector(v.x, v.y, v.z)
  1037.             elseif (type(v) == "Angle") then
  1038.                 res[k] = Angle(v.p, v.y, v.r)
  1039.             else
  1040.                 res[k] = v
  1041.             end
  1042.         end
  1043.        
  1044.         return res
  1045.        
  1046.     end
  1047.    
  1048. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement