Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- DEFINE_BASECLASS( "base_anim" )
- ENT.PrintName = "Test Box"
- ENT.Author = "NeatNit"
- ENT.Category = "Fun + Games"
- ENT.Spawnable = true
- ENT.AdminOnly = false
- ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
- -- This is the spawn function. It's called when a client calls the entity to be spawned.
- -- If you want to make your SENT spawnable you need one of these functions to properly create the entity
- --
- -- ply is the name of the player that is spawning it
- -- tr is the trace from the player's eyes
- --
- function ENT:SpawnFunction( ply, tr, ClassName )
- if not tr.Hit then return end
- local SpawnPos = tr.HitPos + tr.HitNormal * 100
- local SpawnAng = ply:EyeAngles()
- SpawnAng.p = 0
- SpawnAng.y = SpawnAng.y + 180
- local ent = ents.Create( ClassName )
- ent:SetCreator( ply )
- ent:SetPos( SpawnPos )
- ent:SetAngles( SpawnAng )
- ent:Spawn()
- ent:Activate()
- ent:DropToFloor()
- return ent
- end
- --[[---------------------------------------------------------
- Name: Initialize
- -----------------------------------------------------------]]
- function ENT:Initialize()
- -- Sets what model to use
- self:SetModel( "models/props_junk/wood_crate001a.mdl" )
- -- Physics stuff
- self:SetMoveType( MOVETYPE_VPHYSICS )
- self:SetSolid( SOLID_VPHYSICS )
- -- Init physics only on server, so it doesn't mess up physgun beam
- if ( SERVER ) then self:PhysicsInit( SOLID_VPHYSICS ) end
- -- Make prop to fall on spawn
- local phys = self:GetPhysicsObject()
- if ( IsValid( phys ) ) then phys:Wake() end
- end
- --[[---------------------------------------------------------
- Name: OnTakeDamage
- -----------------------------------------------------------]]
- -- function ENT:OnTakeDamage( dmginfo )
- -- -- React physically when shot/getting blown
- -- self:TakePhysicsDamage( dmginfo )
- -- end
- --[[---------------------------------------------------------
- Name: Use
- -----------------------------------------------------------]]
- -- function ENT:Use( activator, caller )
- -- -- self:RebuildPhysics()
- -- -- self:Remove()
- -- -- if ( activator:IsPlayer() ) then
- -- -- -- Give the collecting player some free health
- -- -- local health = activator:Health()
- -- -- activator:SetHealth( health + 5 )
- -- -- activator:SendLua( "achievements.EatBall()" )
- -- -- end
- -- end
- if ( SERVER ) then return end -- We do NOT want to execute anything below in this FILE on SERVER
- local sents = {}
- local drawing = false
- function ENT:ShouldDraw()
- return drawing or self == halo.RenderedEntity()
- end
- function ENT:Draw()
- if self:ShouldDraw() then self:DrawModel() return end
- error("Why is this running?")
- end
- function ENT:DrawTranslucent()
- if self:ShouldDraw() then self:DrawModel() return end
- sents[self] = true
- end
- local mat_refract = Material("pp/morph/refract")
- local mat_copy = Material("pp/copy")
- local mat_blur = Material("pp/blurscreen")
- local tex_morph = render.GetScreenEffectTexture()
- local tex_store = render.GetMorphTex1()
- hook.Add("PreDrawViewModel", "Draw morphed sents",function()
- if not next(sents) then return end -- list is empty
- drawing = true
- mat_refract:SetTexture("$fbtexture", tex_store)
- mat_refract:SetTexture("$normalmap", tex_morph)
- local r = TimedSin(0.5, 30, 225, 0)
- local g = TimedSin(0.5, 30, 225, math.pi / 2)
- for ent, _ in pairs(sents) do
- render.CopyRenderTargetToTexture(tex_store)
- render.UpdateScreenEffectTexture()
- render.PushRenderTarget(tex_morph)
- render.Clear(128, 128, 128, 255, false, true) -- keep depth, clear stencil
- render.SetStencilEnable(true)
- render.SetStencilTestMask(2)
- render.SetStencilWriteMask(2)
- render.SetStencilReferenceValue(2)
- render.SetStencilCompareFunction(STENCIL_ALWAYS)
- render.SetStencilZFailOperation(STENCIL_ZERO)
- render.SetStencilPassOperation(STENCIL_REPLACE)
- render.OverrideDepthEnable(true, false)
- ent:DrawModel()
- render.OverrideDepthEnable(false)
- render.SetStencilCompareFunction(STENCIL_EQUAL)
- render.SetStencilPassOperation(STENCIL_KEEP)
- render.SetStencilFailOperation(STENCIL_KEEP)
- render.SetStencilZFailOperation(STENCIL_KEEP)
- render.ClearBuffersObeyStencil(r, g, 128, 255, true)
- render.SetStencilEnable(false)
- cam.Start2D()
- surface.SetDrawColor(128, 128, 128)
- surface.DrawOutlinedRect(0, 0, ScrW(), ScrH())
- cam.End2D()
- render.SetStencilEnable(true)
- render.SetMaterial(mat_blur)
- mat_blur:SetTexture("$basetexture", tex_morph)
- for i = 20, 1, -1 do
- mat_blur:SetFloat("$blur", i)
- mat_blur:Recompute()
- render.DrawScreenQuad()
- end
- render.SetStencilEnable(false)
- render.PopRenderTarget()
- mat_copy:SetTexture("$basetexture", tex_store)
- render.SetMaterial(mat_copy)
- render.DrawScreenQuad()
- render.SetMaterial(mat_refract)
- render.DrawScreenQuad()
- end
- sents = {}
- drawing = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement