Python1320

Open Source WtfCore

May 12th, 2011
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.94 KB | None | 0 0
  1. local ENT={}
  2. ENT.Type            = "anim"
  3. ENT.Base            = "base_anim"
  4.  
  5. ENT.RenderGroup         = RENDERGROUP_TRANSLUCENT
  6.  
  7.  
  8. if SERVER then
  9.  
  10.  
  11.     function ENT:Initialize()
  12.  
  13.         self:SetMoveType( 0 )
  14.         self:DrawShadow( false )
  15.         self:SetModel( "models/dav0r/hoverball.mdl" )
  16.         self:PhysicsInitSphere(260)
  17.     --      self:PhysicsInit(SOLID_VPHYSICS)
  18.         self:SetMoveType(MOVETYPE_VPHYSICS)
  19.         self:SetSolid(SOLID_VPHYSICS)
  20.         self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
  21.         self:GetPhysicsObject():EnableMotion(false)
  22.        
  23.         --  self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
  24.         self:SetPos(ms.mapdata.coreeffect)
  25.         self:SetTrigger(true)
  26.     end
  27.  
  28.  
  29.     function ENT:OnRemove()
  30.         print("Black hole removed",self)
  31.     end
  32.     local Whitelist={
  33.         ["prop_physics"]=true,
  34.         }
  35.     function ENT:StartTouch( ent )
  36.         if not Whitelist[ent:GetClass()] then return end
  37.         print(self,"disintegrate:",ent)
  38.         ent:SetName("dissolvemenao")
  39.         ent:GetPhysicsObject():EnableGravity(false)
  40.         local e=ents.Create'env_entity_dissolver'
  41.         e:SetKeyValue("dissolvetype","3")
  42.         e:SetKeyValue("target","dissolvemenao")
  43.         e:SetKeyValue("dissolvetype","2")
  44.         e:Spawn()
  45.         e:Activate()
  46.         e:Fire("Dissolve","dissolvemenao",0)
  47.         SafeRemoveEntityDelayed(e,1)
  48.     end
  49.    
  50.  
  51. else ------------------------ CLIENT -------------------------
  52.  
  53.        
  54.  
  55.  
  56. local tbl=util.KeyValuesToTable[["Aftershock"
  57. {
  58.     "<dx90"
  59.     {
  60.         "$fallbackmaterial" "Models\Combine_Dropship\dropshipsheet_normal"
  61.     }
  62.  
  63.    
  64.     "$colortint" "[0 0 0]"
  65.     "$refractamount" "1"
  66.  
  67.     "$SilhouetteThickness" "0.7"
  68.     "$SilhouetteColor" "[0 0 0]"
  69.     "$GroundMin" "-1"
  70.     "$GroundMax" "-1"
  71.     "$BlurAmount" "0"
  72.  
  73.     "$time" "0.0"
  74.     "Proxies"
  75.     {
  76.         "CurrentTime"
  77.         {
  78.             "resultVar" "$time"
  79.         }
  80.     }
  81. }
  82.  
  83. ]]
  84.     INT=INT and INT+1 or 20
  85.     mat=CreateMaterial("testmat"..INT,"Aftershock",tbl)
  86.     local mat2 = Material("models/props_lab/cornerunit_cloud" )
  87.  
  88.  
  89.     function ENT:Initialize()
  90.         local vec=Vector(600,600,600)
  91.         self:SetRenderBounds(vec,-vec)
  92.         self.snd=CreateSound(self,"ambient/machines/combine_shield_loop3.wav")
  93.     end
  94.     -- fix bug >:(
  95.     function ENT:OnRemove()
  96.         local vec=Vector(600,600,600)
  97.         self:SetRenderBounds(vec,-vec)
  98.         self.snd:Stop()-- ffuuu
  99.     end
  100.    
  101.     local fadearea=100
  102.     local endfade=900
  103.     local pi=math.pi
  104.     function ENT:GetMotionBlurValues( x, y, fwd, spin )
  105.         local EntPos = self:GetPos()
  106.         a=((EyePos() - EntPos ):GetNormalized():DotProduct( EyeAngles():Forward()*-1 ))
  107.         local fwd=a and a > 0.85 and a-0.85 or 0
  108.         local distance=EyePos():Distance(EntPos)
  109.         if fwd and fwd > 0 and distance<=endfade then
  110.             local distfactor = distance - endfade+fadearea
  111.             distfactor=1-(distfactor/fadearea)
  112.             distfactor=distfactor>1 and 1 or distfactor<0 and 0 or distfactor
  113.             local final=fwd*distfactor
  114.     --      print("Blur:",final)
  115.             return 0,0,final*(0.9+0.1*(math.sin(CurTime()*2))),final*0.4
  116.         end
  117.     end
  118.  
  119.     ENT.losethink=false
  120.     ENT.lostthink=true -- now we can find it
  121.     function ENT.Think(s)
  122.  
  123.         if s.losethink and not s.lostthink then
  124.             s.lostthink=true
  125.             --print"lost think"
  126.             hook.Remove('GetMotionBlurValues',"CoreMotBlur")
  127.             if s.snd then
  128.                 s.snd:FadeOut(1)
  129.             end
  130.             s.Think=nil
  131.         elseif s.lostthink and not s.losethink then
  132.             hook.Add('GetMotionBlurValues',"CoreMotBlur",function() -- yeah, just one core, poor us!
  133.                 if not IsValid(s) then hook.Remove('GetMotionBlurValues',"CoreMotBlur") end
  134.                 return s:GetMotionBlurValues( x, y, fwd, spin )
  135.             end)
  136.             if s.snd then
  137.                 s.snd:Play()
  138.             end
  139.             --print"gained think"
  140.             s.lostthink=false
  141.         end
  142.         s.losethink=true
  143.        
  144.  
  145.        
  146.     end
  147.    
  148.     ENT._Think=ENT.Think
  149.    
  150.     local size=Vector(4,4,4)
  151.     local lasttime=RealTime()
  152.     local target=10
  153.     local last=10
  154.     local asd=false
  155.     function ENT.Draw(s)
  156.         -- Think hack
  157.         s.losethink=false
  158.         s.Think=s._Think
  159.  
  160.        
  161.         -- Switch scale
  162.         if lasttime + 4 < RealTime() then
  163.             lasttime = RealTime()
  164.             last=target
  165.             asd=!asd
  166.             target=math.Rand(10,17)
  167.         end
  168.        
  169.         -- math
  170.         local frac = ( RealTime()- lasttime )/0.4
  171.         frac = frac > 1 and 1 or frac
  172.  
  173.         local scale = Lerp( frac, last, target )
  174.  
  175.         -- it's aliiive!
  176.         scale=scale+math.sin(RealTime()*2)*0.3
  177.  
  178.         -- Set it up!
  179.         SetMaterialOverride(mat)
  180.             s:SetModelScale(size*scale)
  181.             s:DrawModel()
  182.             s:SetModelScale(size*scale*0.99)
  183.             s:DrawModel()
  184.            
  185.         SetMaterialOverride(mat)
  186.             s:SetModelScale(size*scale*0.98)
  187.             s:DrawModel()
  188.         SetMaterialOverride( 0 )
  189.        
  190.         -- Dynalight!
  191.         local id = s:EntIndex()+(asd and 4096 or 0) -- okay i'm lazy :p
  192.         local dlight = DynamicLight( id )
  193.         if dlight then
  194.             dlight.Pos = s:GetPos()
  195.             dlight.r = 10
  196.             dlight.g = 20
  197.             dlight.b = 200
  198.             dlight.Brightness = 10
  199.             dlight.Size = 900
  200.             dlight.Decay = 256
  201.             dlight.DieTime = CurTime() + 1
  202.             dlight.Style = 0
  203.         end
  204.        
  205.     end
  206.  
  207. end
  208. scripted_ents.Register(ENT, "lua_core_effect", true)
  209.  
  210. -- INIT
  211.  
  212. if SERVER then
  213.     timer.Simple(2,function()
  214.         if IsValid(a) then a:Remove() end
  215.         a=ents.Create'lua_core_effect'
  216.         a:SetPos(ms.mapdata.coreeffect)
  217.         a:Spawn()
  218.         a:Activate()
  219.     end)
  220. else
  221.    
  222. end
Advertisement
Add Comment
Please, Sign In to add comment