MPan1

Saints Row 4 Dubstep Gun effect code

Mar 1st, 2016
27
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- THIS WAS ALL COPIED FROM lua\effects\dubstep_wub_effect\init.lua
  2.  
  3. /*============================================================================================
  4.  
  5.     DubstepGun Addon-recoded: Created By Alex5511
  6.    
  7.     Under the copyright (C) protection of DMCA.
  8.    
  9.     My Terms are simply are:
  10.    
  11.     You can edit and learn the code freely however you shall not claim or be proud for any
  12.     additional modificaitons to the current script, doing so i will have to take serious action of
  13.     punching your face in or simply hunting you and your scripted modified version of this mod like a raccoon in the woods.
  14.    
  15.     Anyways you will not learn anything from just looking and copying bits of code, I suggest you
  16.     attemp to make a addon/mod that is 100% made by you and that you can be proud of it without the
  17.     shame of using someone else code, in other words learn by building up your skill.
  18.    
  19.     You shall not:
  20.        
  21.         - Re-upload to another site or workshop even spamming the description of who oringally made it and a link to the orignal addon.
  22.         - Claim that you made any bit of this script.
  23.    
  24.     Final and last statement JUST DONT STEAL ANYTHING, and thank you for your great time for reading all
  25.     of this.
  26.  
  27. ============================================================================================*/
  28.  
  29. local matBulge      = Material("Effects/strider_bulge_dudv")
  30. local matBulge2     = Material("Effects/freeze_unfreeze")
  31. local matBulge3 = Material( "particle/warp_ripple" )
  32.  
  33. function EFFECT:Init(data)
  34.    
  35.     self.Position = data:GetOrigin()
  36.     self.Normal = data:GetNormal()
  37.     self.Ent = data:GetEntity()
  38.     self.KillTime = CurTime() + 0.65
  39.     self:SetRenderBoundsWS(self.Position + Vector()*280,self.Position - Vector()*280)
  40.    
  41.     timer.Simple( 0.1, function()
  42.    
  43.     local ang = self.Normal:Angle():Right():Angle() -- D :
  44.     local emitter = ParticleEmitter(self.Position)
  45.  
  46.     for i=1,50 do
  47.         local vec = (self.Normal + 1.2*VectorRand()):GetNormalized()
  48.         local particle = emitter:Add("sprites/glow04_noz", self.Position + math.Rand(3,30)*vec)
  49.         particle:SetVelocity(math.Rand(700,800)*vec)
  50.         particle:SetDieTime(math.Rand(0.8,1))
  51.         particle:SetStartAlpha(150)
  52.         particle:SetStartSize(math.Rand(40,40))
  53.         particle:SetEndSize(0)
  54.         particle:SetStartLength(math.Rand(30,40))
  55.         particle:SetEndLength(0)
  56.         particle:SetColor( 100, 100, 255 )//SetColor(255,255,255)
  57.         particle:SetGravity(Vector(0,0,-400))
  58.         particle:SetAirResistance(5)
  59.         particle:SetCollide(true)
  60.         particle:SetBounce(0.9)
  61.     end
  62.    
  63.     for i=1,15 do
  64.         ang:RotateAroundAxis(self.Normal,math.Rand(0,360))
  65.         local vec = ang:Forward()
  66.         local particle = emitter:Add("particle/particle_smokegrenade", self.Position + math.Rand(5,20)*vec)
  67.         particle:SetVelocity(math.Rand(600,1200)*vec)
  68.         particle:SetDieTime(math.Rand(2.5,3))
  69.         particle:SetStartAlpha(math.Rand(16,25))
  70.         particle:SetStartSize(math.Rand(40,50))
  71.         particle:SetEndSize(math.Rand(70,80))
  72.         particle:SetColor( 255, 0, 255 )//SetColor( 255, 241, 232 )
  73.         particle:SetAirResistance(600)
  74.     end
  75.    
  76.     for i=1,10 do
  77.         local vec = (self.Normal + 0.6*VectorRand()):GetNormalized()
  78.         local particle = emitter:Add("particle/particle_smokegrenade", self.Position + math.Rand(5,20)*vec)
  79.         particle:SetVelocity(math.Rand(1000,1500)*vec)
  80.         particle:SetDieTime(math.Rand(2.5,3))
  81.         particle:SetStartAlpha(math.Rand(16,25))
  82.         particle:SetStartSize(math.Rand(40,60))
  83.         particle:SetEndSize(math.Rand(80,90))
  84.         particle:SetColor( 100, 160, 255 )//SetColor(255,241,232)
  85.         particle:SetGravity(Vector(0,0,100))
  86.         particle:SetAirResistance(500)
  87.     end
  88.    
  89.     emitter:Finish()
  90.    
  91.    
  92.     local dlight = DynamicLight(math.random(2048,4096)) --This works for some reason.  Don't ask.
  93.     dlight.Pos = self.Position
  94.     dlight.Size = 500
  95.     dlight.DieTime = CurTime() + 0.2
  96.     dlight.r = 255//200
  97.     dlight.g = 100//200
  98.     dlight.b = 255//255
  99.     dlight.Brightness = 5//1
  100.     dlight.Decay = 1000
  101.  
  102.     end )
  103.    
  104. end
  105.  
  106.  
  107. function EFFECT:Think()
  108.    
  109.    
  110.     if CurTime() > self.KillTime then return false end
  111.     return true
  112.        
  113. end
  114.  
  115.  
  116. function EFFECT:Render()
  117.    
  118.     local invintrplt = (self.KillTime - CurTime())/0.65
  119.     local intrplt = 1 - invintrplt
  120.  
  121.     local size = 280 + 200*intrplt
  122.    
  123.     self:SetRenderBoundsWS(self.Position + Vector()*size,self.Position - Vector()*size)
  124.    
  125.     matBulge:SetFloat("$refractamount", math.sin(0.5*invintrplt*math.pi)*0.16)
  126.     render.SetMaterial(matBulge)
  127.     render.UpdateRefractTexture()
  128.     render.DrawSprite(self.Position,size,size,Color(255,255,255,150*invintrplt))
  129.    
  130.     local invintrplt = (self.KillTime - CurTime())/0.65
  131.     local intrplt = 1 - invintrplt
  132.  
  133.     local size = 90 + 50*intrplt*10
  134.    
  135.     self:SetRenderBoundsWS(self.Position + Vector()*size,self.Position - Vector()*size)
  136.    
  137.     matBulge2:SetFloat("$refractamount", math.sin(0.5*invintrplt*math.pi)*0.16)
  138.     render.SetMaterial(matBulge2)
  139.     render.UpdateRefractTexture()
  140.     render.DrawSprite(self.Position,size,size,Color(255, 100, 255,150*invintrplt))
  141.  
  142.     matBulge3:SetFloat("$refractamount", math.sin(0.5*invintrplt*math.pi)*0.16)
  143.     render.SetMaterial(matBulge3)
  144.     render.UpdateRefractTexture()
  145.     render.DrawSprite(self.Position,size,size,Color( 255, 255, 255,150*invintrplt))
  146.    
  147. end
RAW Paste Data