Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(SERVER)then
- AddCSLuaFile("shared.lua")
- end
- SWEP.Kind = WEAPON_EQUIP
- SWEP.CanBuy = false
- SWEP.LimitedStock = true
- SWEP.WeaponID = AMMO_ALPHA
- SWEP.IsSilent = false
- if CLIENT then
- SWEP.ViewModelFlip = false
- SWEP.EquipMenuData = {
- type = "item_weapon",
- desc = "alpha_desc"
- };
- end
- if(CLIENT)then
- SWEP.DrawAmmo=false
- SWEP.PrintName="Weapon System Alpha"
- SWEP.DrawCrosshair=false -- crosshairs are for sopping wet pussies
- SWEP.DrawWeaponInfoBox=false
- SWEP.BounceWeaponIcon=false
- SWEP.Slot=1
- SWEP.WepSelectIcon=surface.GetTextureID("vgui/mat_jack_fgalpha_wsi")
- killicon.Add("wep_jack_fungun_alpha","vgui/mat_jack_fgalpha_wsi",Color(255,255,255,255))
- end
- SWEP.Spawnable=false
- SWEP.AdminSpawnable=false
- SWEP.Base="weapon_tttbase"
- SWEP.ViewModelFOV=70
- SWEP.ViewModelFlip=false
- SWEP.ViewModel="models/weapons/v_halo_jeagle.mdl"
- SWEP.WorldModel="models/weapons/w_pistol.mdl"
- SWEP.SwayScale=1.75
- SWEP.BobScale=1.75
- SWEP.DrawAmmo=false
- SWEP.Primary.ClipSize=-1
- SWEP.Primary.DefaultClize=-1
- SWEP.Primary.Ammo="none"
- SWEP.Primary.Automatic=false
- SWEP.Secondary.ClipSize=-1
- SWEP.Secondary.DefaultClip=-1
- SWEP.Secondary.Ammo="none"
- SWEP.Secondary.Automatic=false
- SWEP.DefaultBobSway=2
- SWEP.SprintPos=Vector(2.539,-14.44,-0.441)
- SWEP.SprintAng=Angle(74,-7,0)
- SWEP.ShowWorldModel=false
- SWEP.ViewModelBoneMods = {
- ["Main Frame"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) }
- }
- SWEP.VElements = {
- ["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)
- local Ammo=self:GetDTFloat(1)
- local Frac=1-Ammo
- surface.SetDrawColor((4*Frac-1)*255,(-2*Frac+2)*255,(-4*Frac+1)*255,75)
- for i=0,16 do
- surface.DrawLine(-5,i,19,i)
- end
- surface.SetDrawColor(255,255,255,200)
- surface.DrawOutlinedRect(-5,0,25,17)
- surface.SetTextColor(255,255,255,200)
- surface.SetTextPos(0,2)
- surface.SetFont("Default")
- surface.DrawText(tostring(math.Clamp(math.floor(Ammo*100),0,100)))
- end},
- ["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 = {} },
- ["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 = {} },
- ["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 = {} },
- ["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 = {} }
- }
- SWEP.WElements = {
- ["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 = {} }
- }
- local BurstCoolSoundPlayed=false
- local ReleaseSoundPlayed=false
- local LaserEndPlayed=false
- local LaserBeam=Material("trails/laser")
- local LaserHitPic=Material("sprites/mat_jack_glowything")
- //local FireTable={"fire","fire1","fire2","flame01","flame03","flame04","flatflame","FloorFlame","floorflame2"}
- function SWEP:Initialize()
- self:SetWeaponHoldType("revolver")
- self.LasingSound=CreateSound(self.Weapon,"snd_jack_laserloop.wav")
- self:SetDTInt(0,2) -- 1=drawing, 2=idle, 3=firing, 4=venting, 5=reloading, 6=holstered
- self:SetDTFloat(0,0) -- firing heat
- self:SetDTFloat(1,1) -- current ammunition
- self:SetDTInt(1,0) -- amount that the weapon's held in a sprinting position
- self.NewCartridge=true
- self:SCKInitialize()
- end
- function SWEP:Deploy()
- self:SetDTInt(0,1)
- timer.Simple(.6,function()
- if(IsValid(self))then
- sound.Play("snd_jack_fgpistoldraw.wav",self.Owner:GetShootPos()+self.Owner:GetAimVector()*20,65,100)
- end
- end)
- if(self.NewCartridge)then
- timer.Simple(.7,function()
- if(IsValid(self))then
- sound.Play("snd_jack_smallcharge.wav",self.Owner:GetShootPos()+self.Owner:GetAimVector()*20,65,100)
- self.NewCartridge=false
- end
- end)
- end
- self.Weapon:SendWeaponAnim(ACT_VM_DEPLOY)
- self.Owner:GetViewModel():SetPlaybackRate(1.3)
- timer.Simple(1,function()
- if(IsValid(self))then
- self:SetDTInt(0,2)
- self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
- end
- end)
- end
- function SWEP:PrimaryAttack()
- if(self:GetDTInt(1)>10)then return end
- if not(self:GetDTInt(0)==2)then return end
- if(self:GetDTFloat(1)<=0)then return end
- self:SetNextPrimaryFire(CurTime()+.2)
- local ShootPos=self.Owner:GetShootPos()+self.Owner:GetAimVector()*20
- sound.Play("snd_jack_laserbegin.wav",ShootPos,70,100)
- self.LasingSound:Play()
- self:SetDTInt(0,3)
- ReleaseSoundPlayed=false
- BurstCoolSoundPlayed=false
- LaserEndPlayed=false
- umsg.Start("JackysDynamicFGBobSwayScaling")
- umsg.Entity(self)
- umsg.Float(.5)
- umsg.End()
- end
- //FOR INSTANCE, THIS MASK ALLOWS THE TRACE TO SEE THROUGH WINDOWS fuck that shit
- function SWEP:LaserTrace(stert,ayund,filtah,stack)
- if(stack>=30)then print("CRASH PREVENTION: You're shooting the laser at something that's confusing the logic.") return end -- prevent errors
- local TressDat={}
- TressDat.start=stert
- TressDat.endpos=ayund
- TressDat.filter=filtah
- TressDat.mask=MASK_SHOT
- local Tress=util.TraceLine(TressDat)
- if(Tress.Hit)then
- if((Tress.Entity:GetColor().a<=150)or(Tress.MatType==MAT_GLASS))then
- if(Tress.Entity:IsWorld())then
- self:LaserTrace(Tress.HitPos+Tress.Normal*5,Tress.HitPos+Tress.Normal*40000,{self.Owner},stack+1)
- else
- self:LaserTrace(Tress.HitPos,Tress.HitPos+Tress.Normal*40000,{self.Owner,Tress.Entity},stack+1)
- end
- else
- self.CurrentTracedPosition=Tress.HitPos -- used by the drawing functions, stored for efficiency
- self.CurrentTracedNormal=Tress.HitNormal -- used by the drawing functions, stored for efficiency
- if(SERVER)then
- local WantSomeIceWithThatBurn=DamageInfo()
- WantSomeIceWithThatBurn:SetDamage(math.Rand(.275,.375))
- WantSomeIceWithThatBurn:SetDamagePosition(Tress.HitPos)
- WantSomeIceWithThatBurn:SetDamageForce(Vector(0,0,0))
- WantSomeIceWithThatBurn:SetAttacker(self.Owner)
- WantSomeIceWithThatBurn:SetInflictor(self.Weapon)
- if(Tress.Entity:IsOnFire())then
- WantSomeIceWithThatBurn:SetDamageType(DMG_GENERIC)
- elseif(math.random(1,9)==5)then
- WantSomeIceWithThatBurn:SetDamageType(DMG_BURN)
- else
- WantSomeIceWithThatBurn:SetDamageType(DMG_DIRECT)
- end
- Tress.Entity:TakeDamageInfo(WantSomeIceWithThatBurn)
- umsg.Start("JackysLaserLightUMSG")
- umsg.Vector(Tress.HitPos)
- umsg.End()
- if not(self.NextBurnSoundEmitTime)then self.NextBurnSoundEmitTime=CurTime() end
- if(self.NextBurnSoundEmitTime<CurTime())then
- sound.Play("snd_jack_laserburn.wav",Tress.HitPos+Tress.HitNormal,70,100)
- self.NextBurnSoundEmitTime=CurTime()+.075
- end
- if(math.random(1,4)==2)then
- util.Decal("FadingScorch",Tress.HitPos+Tress.HitNormal,Tress.HitPos-Tress.HitNormal)
- end
- if(math.random(1,2)==1)then
- local Poof=EffectData()
- Poof:SetOrigin(Tress.HitPos)
- Poof:SetScale(1)
- Poof:SetNormal(Tress.HitNormal)
- 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
- Poof:SetStart(Tress.Entity:GetVelocity())
- util.Effect("eff_jack_tinymelt",Poof)
- else
- util.Effect("eff_jack_tinyburn",Poof)
- end
- end
- end
- end
- end
- end
- function SWEP:Think()
- self.LaserShake=VectorRand()*math.Rand(.01,.05)
- if(SERVER)then
- local Held=self:GetDTInt(1)
- if(self.Owner:KeyDown(IN_SPEED))then
- if(Held<100)then self:SetDTInt(1,Held+6) end
- else
- if(Held>0)then self:SetDTInt(1,Held-6) end
- end
- end
- local Heat=self:GetDTFloat(0)
- local Red=math.Clamp(Heat*463-69,0,255)
- local Green=math.Clamp(Heat*1275-1020,0,255)
- local Blue=math.Clamp(Heat*2550-2295,0,255)
- //self.Owner:PrintMessage(HUD_PRINTCENTER,tostring(math.Round(Red)).." "..tostring(math.Round(Green)).." "..tostring(math.Round(Blue)))
- self.VElements["narg"].color=Color(Red,Green,Blue,255)
- local State=self:GetDTInt(0)
- //self.Owner:PrintMessage(HUD_PRINTCENTER,State)
- if((State==4)or(State==5))then return end
- if((self.Owner:InVehicle())or(self.Owner:KeyDown(IN_ZOOM)))then
- if(State==3)then
- self.LasingSound:Stop()
- self:SetDTInt(0,2)
- end
- return
- end
- local BaseShootPos=self.Owner:GetShootPos()
- local ShootPos=BaseShootPos+self.Owner:GetRight()*4-self.Owner:GetUp()*5
- local AimVec=self.Owner:GetAimVector()
- self.CurrentAimVector=AimVec -- used by the drawing functions, stored for efficiency
- if(State==3)then
- self:SetDTFloat(0,math.Clamp(Heat+.0012,0,1))
- local Ammo=self:GetDTFloat(1)
- local Loss=(.0028+.18*Heat^4)*.01
- //self.Owner:PrintMessage(HUD_PRINTCENTER,Loss)
- self:SetDTFloat(1,Ammo-Loss)
- if not(self.NextLasingSoundTime)then self.NextLasingSoundTime=CurTime()+.1 end
- if(self.NextLasingSoundTime<CurTime())then
- self.LasingSound:Stop()
- self.LasingSound:Play()
- self.NextLasingSoundTime=CurTime()+3.15
- end
- self:LaserTrace(BaseShootPos,BaseShootPos+AimVec*40000,{self.Owner},1)
- self.Owner:ViewPunch(Angle(math.Rand(-.05,.05),math.Rand(-.05,.05),math.Rand(-.05,.05)))
- end
- end
- function SWEP:BurstCool()
- if(self:GetDTInt(0)==4)then return end
- self:SetDTInt(0,4)
- self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
- self.Owner:GetViewModel():SetPlaybackRate(.25)
- self.Owner:SetAnimation(PLAYER_ATTACK1)
- if not(BurstCoolSoundPlayed)then
- BurstCoolSoundPlayed=true
- if(SERVER)then
- self.Weapon:EmitSound("snd_jack_laservent.wav",70,100)
- end
- end
- local Pewf=EffectData()
- Pewf:SetOrigin(self.Owner:GetShootPos()+self.Owner:GetAimVector()*20+self.Owner:GetRight()*4)
- Pewf:SetStart(self.Owner:GetVelocity())
- util.Effect("eff_jack_instantvent",Pewf)
- timer.Simple(.2,function()
- if(IsValid(self))then
- local Pewf=EffectData()
- Pewf:SetOrigin(self.Owner:GetShootPos()+self.Owner:GetAimVector()*20+self.Owner:GetRight()*4)
- Pewf:SetStart(self.Owner:GetVelocity())
- util.Effect("eff_jack_instantvent",Pewf)
- end
- end)
- timer.Simple(.4,function()
- if(IsValid(self))then
- local Pewf=EffectData()
- Pewf:SetOrigin(self.Owner:GetShootPos()+self.Owner:GetAimVector()*20+self.Owner:GetRight()*4)
- Pewf:SetStart(self.Owner:GetVelocity())
- util.Effect("eff_jack_instantvent",Pewf)
- end
- end)
- timer.Simple(1.6,function()
- if(IsValid(self))then
- self:SetDTInt(0,2)
- BurstCoolSoundPlayed=false
- end
- end)
- end
- function SWEP:SecondaryAttack()
- if not(self:GetDTInt(0)==2)then return end
- if not(self:GetDTFloat(0)>.15)then return end
- self:BurstCool()
- end
- if(CLIENT)then
- local function MakeMagHot(data)
- local self=data:ReadEntity()
- self.VElements["herp"].surpresslightning=true
- self.VElements["herp"].material="models/debug/debugwhite"
- end
- usermessage.Hook("JackysAlphaFGMagHot",MakeMagHot)
- local function MakeMagCool(data)
- local self=data:ReadEntity()
- self.VElements["herp"].surpresslightning=false
- self.VElements["herp"].material=nil
- end
- usermessage.Hook("JackysAlphaFGMagCool",MakeMagCool)
- end
- function SWEP:Reload()
- if not(self:GetDTInt(0)==2)then return end
- local InitialRemaining=self:GetDTFloat(1)
- local InitialReserve=self.Owner:GetAmmoCount("GaussEnergy")
- if((InitialRemaining<=.01)and(InitialReserve>0))then
- self:SetDTInt(0,5)
- umsg.Start("JackysAlphaFGMagHot",self.Owner)
- umsg.Entity(self.Weapon)
- umsg.End()
- self.Weapon:SendWeaponAnim(ACT_VM_RELOAD)
- self.Owner:GetViewModel():SetPlaybackRate(.8)
- self.Owner:SetAnimation(PLAYER_RELOAD)
- self.Weapon:EmitSound("snd_jack_laserreload.wav",70,100)
- timer.Simple(.4,function()
- if(IsValid(self))then
- if(SERVER)then
- local Empty=ents.Create("ent_jack_fgcartridge")
- local LolAng=self.Owner:EyeAngles()
- local Pos,Ang=self.Owner:GetBonePosition(self.Owner:LookupBone("ValveBiped.Bip01_R_Hand"))
- Empty:SetPos(Pos+Ang:Up()*10-Ang:Forward()*10)
- LolAng:RotateAroundAxis(LolAng:Forward(),90)
- LolAng:RotateAroundAxis(LolAng:Up(),180)
- Empty:SetAngles(LolAng)
- Empty:SetDTBool(0,true)
- Empty:Spawn()
- Empty:Activate()
- Empty:GetPhysicsObject():SetVelocity(self.Owner:GetVelocity())
- end
- self:SetDTFloat(1,0)
- end
- end)
- timer.Simple(.6,function()
- if(IsValid(self))then
- umsg.Start("JackysAlphaFGMagCool",self.Owner)
- umsg.Entity(self.Weapon)
- umsg.End()
- end
- end)
- timer.Simple(1.5,function()
- if(IsValid(self))then
- local Missing=100-InitialRemaining
- if(InitialReserve>=Missing)then
- self:SetDTFloat(1,1)
- self.Owner:RemoveAmmo(Missing,"GaussEnergy")
- else
- self.Owner:RemoveAmmo(InitialReserve,"GaussEnergy")
- self:SetDTFloat(1,math.Clamp(InitialRemaining+InitialReserve+.01,0,1))
- end
- sound.Play("snd_jack_smallcharge.wav",self.Owner:GetShootPos()+self.Owner:GetAimVector()*20,65,100)
- end
- end)
- timer.Simple(2,function()
- if(IsValid(self))then
- self:SetDTInt(0,2)
- end
- end)
- end
- end
- function SWEP:Holster()
- self.LasingSound:Stop()
- self:SetDTInt(0,6)
- self:SetDTInt(1,0)
- self:SCKHolster()
- return true
- end
- function SWEP:OnDrop()
- self.LasingSound:Stop()
- end
- if(CLIENT)then
- function SWEP:DrawHUD()
- -- *overwrite* :3
- end
- function SWEP:GetViewModelPosition(pos,ang)
- ang:RotateAroundAxis(ang:Right(),4)
- pos=pos-ang:Up()*1
- if(self:GetDTInt(0)==3)then
- pos=pos+self.LaserShake
- end
- local Held=self:GetDTInt(1)/100
- if(Held>0)then
- local Right=ang:Right()
- local Up=ang:Up()
- local Forward=ang:Forward()
- pos=pos+self.SprintPos.x*Right*Held+self.SprintPos.y*Up*Held+self.SprintPos.z*Forward*Held
- ang:RotateAroundAxis(Right,self.SprintAng.p*Held)
- ang:RotateAroundAxis(Up,self.SprintAng.y*Held)
- ang:RotateAroundAxis(Forward,self.SprintAng.r*Held)
- end
- return pos,ang
- end
- function SWEP:ViewModelDrawn()
- /*- 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
- local Flicker=math.Rand(.8,1.2)
- local VM=self.Owner:GetViewModel()
- local Pos,Ang=VM:GetBonePosition(VM:LookupBone("Main Frame"))
- local Nupos=Pos+self.CurrentAimVector*20+self.Owner:GetRight()*2-self.Owner:GetUp()*2
- render.SetMaterial(LaserBeam)
- render.DrawBeam(Nupos,self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,3,0,0,Color(255,255,255,100))
- render.DrawBeam(Nupos,self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,15,0,0,Color(255,0,0,75))
- render.SetMaterial(LaserHitPic)
- render.DrawSprite(self.CurrentTracedPosition+self.CurrentTracedNormal,13*Flicker,13*Flicker,Color(255,100,100,255))
- render.DrawSprite(self.CurrentTracedPosition+self.CurrentTracedNormal,50*Flicker,50*Flicker,Color(255,60,60,100))
- render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,self.CurrentTracedNormal,25*Flicker,25*Flicker,Color(255,100,100,255))
- render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,-self.CurrentTracedNormal,25*Flicker,25*Flicker,Color(255,100,100,255))
- render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,self.CurrentTracedNormal,75*Flicker,75*Flicker,Color(255,60,60,100))
- render.DrawQuadEasy(self.CurrentTracedPosition+self.CurrentTracedNormal*0.5,-self.CurrentTracedNormal,75*Flicker,75*Flicker,Color(255,60,60,100))
- end-*/
- self:SCKViewModelDrawn()
- end
- function SWEP:DrawWorldModel()
- self:SCKDrawWorldModel()
- end
- end
- /*---------------- These things operate OUTSIDE of the weapon --------------------------*/
- local function PlayEndSound(ply,key)
- if not(key==IN_ATTACK)then return end
- local Wep=ply:GetActiveWeapon()
- if(IsValid(Wep))then
- if(Wep:GetClass()=="wep_jack_fungun_alpha")then
- if(Wep:GetDTInt(0)==3)then
- if not(ReleaseSoundPlayed)then
- ReleaseSoundPlayed=true
- sound.Play("snd_jack_laserend.wav",Wep:GetPos(),70,100)
- end
- if(SERVER)then
- umsg.Start("JackysDynamicFGBobSwayScaling")
- umsg.Entity(Wep)
- umsg.Float(Wep.DefaultBobSway)
- umsg.End()
- end
- Wep.LasingSound:Stop()
- Wep:SetDTInt(0,2)
- end
- end
- end
- end
- hook.Add("KeyRelease","JackysAlphaLaserReleaseSound",PlayEndSound)
- local function GunThink()
- for key,wep in pairs(ents.FindByClass("wep_jack_fungun_alpha"))do
- local Heat=wep:GetDTFloat(0)
- if(Heat)then
- local State=wep:GetDTInt(0)
- if(State==3)then
- if((wep:GetDTFloat(1)<=0)or(wep.Owner:KeyDown(IN_SPEED)))then
- if not(LaserEndPlayed)then
- LaserEndPlayed=true
- sound.Play("snd_jack_laserend.wav",wep:GetPos(),70,100)
- end
- if(SERVER)then
- umsg.Start("JackysDynamicFGBobSwayScaling")
- umsg.Entity(wep)
- umsg.Float(wep.DefaultBobSway)
- umsg.End()
- end
- wep.LasingSound:Stop()
- wep:SetDTInt(0,2)
- elseif(Heat==1)then
- if not(LaserEndPlayed)then
- LaserEndPlayed=true
- sound.Play("snd_jack_laserend.wav",wep:GetPos(),70,100)
- end
- if(SERVER)then
- umsg.Start("JackysDynamicFGBobSwayScaling")
- umsg.Entity(wep)
- umsg.Float(wep.DefaultBobSway)
- umsg.End()
- end
- wep.LasingSound:Stop()
- wep:BurstCool() -- emergency cooling interrupt, protect the pistol from dumbass users
- wep:SetDTFloat(0,.9999)
- end
- end
- if(State==4)then
- wep:SetDTFloat(0,math.Clamp(Heat-.0075,0,1))
- else
- wep:SetDTFloat(0,math.Clamp(Heat-.0003,0,1))
- end
- end
- end
- end
- hook.Add("Think","JackysAlphaFunGunThinking",GunThink)
- if(CLIENT)then
- local function Flash(data)
- local vector=data:ReadVector()
- local dlight=DynamicLight()
- if(dlight)then
- dlight.MinLight=0
- dlight.Pos=vector
- dlight.r=15
- dlight.g=5
- dlight.b=5
- dlight.Brightness=1
- dlight.Size=450
- dlight.Decay=10000
- dlight.DieTime=CurTime()+.2
- dlight.Style=0
- end
- end
- usermessage.Hook("JackysLaserLightUMSG",Flash)
- local function DrawLazah()
- for key,Weaponu in pairs(ents.FindByClass("wep_jack_fungun_alpha"))do
- local playah=Weaponu.Owner
- if(IsValid(playah))then
- local LocalPlayah=LocalPlayer()
- //if(((playah==LocalPlayah)and(LocalPlayah:ShouldDrawLocalPlayer()))or not(playah==LocalPlayah))then
- if(Weaponu:GetDTInt(0)==3)then
- local Flicker=math.Rand(.8,1.2)
- //local PosAng=Weaponu:GetAttachment(Weaponu:LookupAttachment("muzzle"))
- //if(PosAng)then
- local Nupos=playah:GetShootPos()+playah:GetAimVector()*33+playah:GetRight()*4-playah:GetUp()*6
- render.SetMaterial(LaserBeam)
- render.DrawBeam(Nupos,Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,3,0,0,Color(255,255,255,40))
- render.DrawBeam(Nupos,Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,15,0,0,Color(255,0,0,20))
- render.SetMaterial(LaserHitPic)
- render.DrawSprite(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal,13*Flicker,13*Flicker,Color(255,100,100,255))
- render.DrawSprite(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal,50*Flicker,50*Flicker,Color(255,60,60,100))
- render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,Weaponu.CurrentTracedNormal,40*Flicker,40*Flicker,Color(255,100,100,255))
- render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,-Weaponu.CurrentTracedNormal,40*Flicker,40*Flicker,Color(255,100,100,255))
- render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,Weaponu.CurrentTracedNormal,100*Flicker,100*Flicker,Color(255,60,60,100))
- render.DrawQuadEasy(Weaponu.CurrentTracedPosition+Weaponu.CurrentTracedNormal*0.5,-Weaponu.CurrentTracedNormal,100*Flicker,100*Flicker,Color(255,60,60,100))
- //end
- end
- //end
- end
- end
- end
- hook.Add("PostDrawTranslucentRenderables","JackyFunGunAlphaLaser",DrawLazah)
- end
- /*------------------------------------------------------------------------------------
- Below this line is Clavus' SWEP Construction Kit base code.
- Clavus is KREDIT TO TEEM
- ALL HAIL CLAVUS
- ------------------------------------------------------------------------------------*/
- function SWEP:SCKInitialize()
- if CLIENT then
- // Create a new table for every weapon instance
- self.VElements = table.FullCopy( self.VElements )
- self.WElements = table.FullCopy( self.WElements )
- self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
- self:CreateModels(self.VElements) // create viewmodels
- self:CreateModels(self.WElements) // create worldmodels
- // init view model bone build function
- if IsValid(self.Owner) then
- local vm = self.Owner:GetViewModel()
- if IsValid(vm) then
- self:ResetBonePositions(vm)
- end
- // Init viewmodel visibility
- if (self.ShowViewModel == nil or self.ShowViewModel) then
- vm:SetColor(Color(255,255,255,255))
- else
- // we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
- vm:SetColor(Color(255,255,255,1))
- // ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
- // 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
- vm:SetMaterial("Debug/hsv")
- end
- end
- end
- end
- function SWEP:SCKHolster()
- if CLIENT and IsValid(self.Owner) then
- local vm = self.Owner:GetViewModel()
- if IsValid(vm) then
- self:ResetBonePositions(vm)
- end
- end
- end
- if CLIENT then
- SWEP.vRenderOrder = nil
- function SWEP:SCKViewModelDrawn()
- local vm = self.Owner:GetViewModel()
- if !IsValid(vm) then return end
- if (!self.VElements) then return end
- self:UpdateBonePositions(vm)
- if (!self.vRenderOrder) then
- // we build a render order because sprites need to be drawn after models
- self.vRenderOrder = {}
- for k, v in pairs( self.VElements ) do
- if (v.type == "Model") then
- table.insert(self.vRenderOrder, 1, k)
- elseif (v.type == "Sprite" or v.type == "Quad") then
- table.insert(self.vRenderOrder, k)
- end
- end
- end
- for k, name in ipairs( self.vRenderOrder ) do
- local v = self.VElements[name]
- if (!v) then self.vRenderOrder = nil break end
- if (v.hide) then continue end
- local model = v.modelEnt
- local sprite = v.spriteMaterial
- if (!v.bone) then continue end
- local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
- if (!pos) then continue end
- if (v.type == "Model" and IsValid(model)) then
- model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- model:SetAngles(ang)
- //model:SetModelScale(v.size)
- local matrix = Matrix()
- matrix:Scale(v.size)
- model:EnableMatrix( "RenderMultiply", matrix )
- if (v.material == "") then
- model:SetMaterial("")
- elseif (model:GetMaterial() != v.material) then
- model:SetMaterial( v.material )
- end
- if (v.skin and v.skin != model:GetSkin()) then
- model:SetSkin(v.skin)
- end
- if (v.bodygroup) then
- for k, v in pairs( v.bodygroup ) do
- if (model:GetBodygroup(k) != v) then
- model:SetBodygroup(k, v)
- end
- end
- end
- if (v.surpresslightning) then
- render.SuppressEngineLighting(true)
- end
- render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
- render.SetBlend(v.color.a/255)
- model:DrawModel()
- render.SetBlend(1)
- render.SetColorModulation(1, 1, 1)
- if (v.surpresslightning) then
- render.SuppressEngineLighting(false)
- end
- elseif (v.type == "Sprite" and sprite) then
- local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- render.SetMaterial(sprite)
- render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
- elseif (v.type == "Quad" and v.draw_func) then
- local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- cam.Start3D2D(drawpos, ang, v.size)
- v.draw_func( self )
- cam.End3D2D()
- end
- end
- end
- SWEP.wRenderOrder = nil
- function SWEP:SCKDrawWorldModel()
- if (self.ShowWorldModel == nil or self.ShowWorldModel) then
- self:DrawModel()
- end
- if (!self.WElements) then return end
- if (!self.wRenderOrder) then
- self.wRenderOrder = {}
- for k, v in pairs( self.WElements ) do
- if (v.type == "Model") then
- table.insert(self.wRenderOrder, 1, k)
- elseif (v.type == "Sprite" or v.type == "Quad") then
- table.insert(self.wRenderOrder, k)
- end
- end
- end
- if (IsValid(self.Owner)) then
- bone_ent = self.Owner
- else
- // when the weapon is dropped
- bone_ent = self
- end
- for k, name in pairs( self.wRenderOrder ) do
- local v = self.WElements[name]
- if (!v) then self.wRenderOrder = nil break end
- if (v.hide) then continue end
- local pos, ang
- if (v.bone) then
- pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
- else
- pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
- end
- if (!pos) then continue end
- local model = v.modelEnt
- local sprite = v.spriteMaterial
- if (v.type == "Model" and IsValid(model)) then
- model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- model:SetAngles(ang)
- //model:SetModelScale(v.size)
- local matrix = Matrix()
- matrix:Scale(v.size)
- model:EnableMatrix( "RenderMultiply", matrix )
- if (v.material == "") then
- model:SetMaterial("")
- elseif (model:GetMaterial() != v.material) then
- model:SetMaterial( v.material )
- end
- if (v.skin and v.skin != model:GetSkin()) then
- model:SetSkin(v.skin)
- end
- if (v.bodygroup) then
- for k, v in pairs( v.bodygroup ) do
- if (model:GetBodygroup(k) != v) then
- model:SetBodygroup(k, v)
- end
- end
- end
- if (v.surpresslightning) then
- render.SuppressEngineLighting(true)
- end
- render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
- render.SetBlend(v.color.a/255)
- model:DrawModel()
- render.SetBlend(1)
- render.SetColorModulation(1, 1, 1)
- if (v.surpresslightning) then
- render.SuppressEngineLighting(false)
- end
- elseif (v.type == "Sprite" and sprite) then
- local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- render.SetMaterial(sprite)
- render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
- elseif (v.type == "Quad" and v.draw_func) then
- local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- cam.Start3D2D(drawpos, ang, v.size)
- v.draw_func( self )
- cam.End3D2D()
- end
- end
- end
- function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
- local bone, pos, ang
- if (tab.rel and tab.rel != "") then
- local v = basetab[tab.rel]
- if (!v) then return end
- // Technically, if there exists an element with the same name as a bone
- // you can get in an infinite loop. Let's just hope nobody's that stupid.
- pos, ang = self:GetBoneOrientation( basetab, v, ent )
- if (!pos) then return end
- pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
- ang:RotateAroundAxis(ang:Up(), v.angle.y)
- ang:RotateAroundAxis(ang:Right(), v.angle.p)
- ang:RotateAroundAxis(ang:Forward(), v.angle.r)
- else
- bone = ent:LookupBone(bone_override or tab.bone)
- if (!bone) then return end
- pos, ang = Vector(0,0,0), Angle(0,0,0)
- local m = ent:GetBoneMatrix(bone)
- if (m) then
- pos, ang = m:GetTranslation(), m:GetAngles()
- end
- if (IsValid(self.Owner) and self.Owner:IsPlayer() and
- ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
- ang.r = -ang.r // Fixes mirrored models
- end
- end
- return pos, ang
- end
- function SWEP:CreateModels( tab )
- if (!tab) then return end
- // Create the clientside models here because Garry says we can't do it in the render hook
- for k, v in pairs( tab ) do
- if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
- string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
- v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
- if (IsValid(v.modelEnt)) then
- v.modelEnt:SetPos(self:GetPos())
- v.modelEnt:SetAngles(self:GetAngles())
- v.modelEnt:SetParent(self)
- v.modelEnt:SetNoDraw(true)
- v.createdModel = v.model
- else
- v.modelEnt = nil
- end
- elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
- and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
- local name = v.sprite.."-"
- local params = { ["$basetexture"] = v.sprite }
- // make sure we create a unique name based on the selected options
- local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
- for i, j in pairs( tocheck ) do
- if (v[j]) then
- params["$"..j] = 1
- name = name.."1"
- else
- name = name.."0"
- end
- end
- v.createdSprite = v.sprite
- v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
- end
- end
- end
- local allbones
- local hasGarryFixedBoneScalingYet = false
- function SWEP:UpdateBonePositions(vm)
- if self.ViewModelBoneMods then
- if (!vm:GetBoneCount()) then return end
- // !! WORKAROUND !! //
- // We need to check all model names :/
- local loopthrough = self.ViewModelBoneMods
- if (!hasGarryFixedBoneScalingYet) then
- allbones = {}
- for i=0, vm:GetBoneCount() do
- local bonename = vm:GetBoneName(i)
- if (self.ViewModelBoneMods[bonename]) then
- allbones[bonename] = self.ViewModelBoneMods[bonename]
- else
- allbones[bonename] = {
- scale = Vector(1,1,1),
- pos = Vector(0,0,0),
- angle = Angle(0,0,0)
- }
- end
- end
- loopthrough = allbones
- end
- // !! ----------- !! //
- for k, v in pairs( loopthrough ) do
- local bone = vm:LookupBone(k)
- if (!bone) then continue end
- // !! WORKAROUND !! //
- local s = Vector(v.scale.x,v.scale.y,v.scale.z)
- local p = Vector(v.pos.x,v.pos.y,v.pos.z)
- local ms = Vector(1,1,1)
- if (!hasGarryFixedBoneScalingYet) then
- local cur = vm:GetBoneParent(bone)
- while(cur >= 0) do
- local pscale = loopthrough[vm:GetBoneName(cur)].scale
- ms = ms * pscale
- cur = vm:GetBoneParent(cur)
- end
- end
- s = s * ms
- // !! ----------- !! //
- if vm:GetManipulateBoneScale(bone) != s then
- vm:ManipulateBoneScale( bone, s )
- end
- if vm:GetManipulateBoneAngles(bone) != v.angle then
- vm:ManipulateBoneAngles( bone, v.angle )
- end
- if vm:GetManipulateBonePosition(bone) != p then
- vm:ManipulateBonePosition( bone, p )
- end
- end
- else
- self:ResetBonePositions(vm)
- end
- end
- function SWEP:ResetBonePositions(vm)
- if (!vm:GetBoneCount()) then return end
- for i=0, vm:GetBoneCount() do
- vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
- vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
- vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
- end
- end
- /**************************
- Global utility code
- **************************/
- // Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
- // Does not copy entities of course, only copies their reference.
- // WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
- function table.FullCopy( tab )
- if (!tab) then return nil end
- local res = {}
- for k, v in pairs( tab ) do
- if (type(v) == "table") then
- res[k] = table.FullCopy(v) // recursion ho!
- elseif (type(v) == "Vector") then
- res[k] = Vector(v.x, v.y, v.z)
- elseif (type(v) == "Angle") then
- res[k] = Angle(v.p, v.y, v.r)
- else
- res[k] = v
- end
- end
- return res
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement