include('shared.lua') local beam = Material( "models/alyx/emptool_glow" ) local matLight = Material( "sprites/light_ignorez" ) local matBeam = Material( "effects/lamp_beam" ) function ENT:Initialize() self.PixVis = util.GetPixelVisibleHandle() end function ENT:Draw() self.Entity:SetRenderBoundsWS( self.Entity:GetPos(), self.Entity:GetPos()+(self.Entity:GetUp()*-1)*1000 ) self.Entity:DrawModel() if self.Entity:GetNetworkedBool("on",false) then local trace={} trace.start = self.Entity:GetPos() trace.endpos = self.Entity:GetPos()+(self.Entity:GetUp()*-1)*1000 trace.filter = self.Entity local e=util.TraceLine( trace ) local pos=e.HitPos render.SetMaterial(beam) render.DrawBeam(self.Entity:GetPos(), pos, 10, 1, 1, Color(255,255,255)) for i=1,5 do render.DrawBeam(self.Entity:GetPos(), pos+Vector(math.random(-50,50),math.random(-50,50),math.random(-50,50)), 5, 1, 1, Color(255,255,200)) end local ViewNormal = self:GetPos() - EyePos() local Distance = ViewNormal:Length() ViewNormal:Normalize() local r, g, b, a = self:GetColor() local LightPos = pos render.SetMaterial( matLight ) local Visibile = util.PixelVisible( LightPos, 16, self.PixVis ) if (!Visibile) then return end local Size = math.Clamp( Distance * Visibile * 2, 64, 512 ) Distance = math.Clamp( Distance, 32, 800 ) local Alpha = math.Clamp( (1000 - Distance) * Visibile, 0, 100 ) local Col = Color( r, g, b, Alpha ) render.DrawSprite( LightPos, Size * 0.5, Size * 0.5, Col, Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) local LightPos = self.Entity:GetPos() render.SetMaterial( matLight ) local Visibile = util.PixelVisible( LightPos, 16, self.PixVis ) if (!Visibile) then return end local Size = math.Clamp( Distance * Visibile * 2, 64, 512 ) Distance = math.Clamp( Distance, 32, 800 ) local Alpha = math.Clamp( (1000 - Distance) * Visibile, 0, 100 ) local Col = Color( r, g, b, Alpha ) render.DrawSprite( LightPos, Size * 0.5, Size * 0.5, Col, Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) render.DrawSprite( LightPos, 16, 16, Color(255, 255, 255, Alpha), Visibile ) end if ( LocalPlayer():GetEyeTrace().Entity == self.Entity && EyePos():Distance( self.Entity:GetPos() ) < 512 ) then AddWorldTip(self.Entity:EntIndex(),"Health: "..tostring(self.Entity:GetNetworkedInt("health",0)),0.5,self.Entity:GetPos(),self.Entity) end end function sCalc( ply, origin, angles, fov ) if not LocalPlayer().sDistz then LocalPlayer().sDistz=100 end if LocalPlayer().sDistz<1 then LocalPlayer().sDistz=1 end if LocalPlayer().sDistz>1000 then LocalPlayer().sDistz=1000 end local shut=LocalPlayer():GetNetworkedEntity("Shuttle",LocalPlayer()) if LocalPlayer():GetNetworkedBool("isDriveShuttle",false) and shut~=LocalPlayer() and shut:IsValid() then local view = {} view.origin = shut:GetPos()+ply:GetAimVector():GetNormal()*-LocalPlayer().sDistz view.angles = angles return view end end hook.Add("CalcView", "MyCalcView", sCalc) function ENT:Think() if self.Entity:GetNetworkedBool("on",false) then local dlight = DynamicLight( self:EntIndex() ) if ( dlight ) then local trace={} trace.start = self.Entity:GetPos() trace.endpos = self.Entity:GetPos()+(self.Entity:GetUp()*-1)*1000 trace.filter = self.Entity local e=util.TraceLine( trace ) local pos=e.HitPos dlight.Pos = pos dlight.r = 255 dlight.g = 255 dlight.b = 255 dlight.Brightness = 5 dlight.Decay = 500 dlight.Size = 500 dlight.DieTime = CurTime() + 1 end end if LocalPlayer():GetNetworkedBool("isDriveShuttle",false) then if LocalPlayer():KeyDown(IN_JUMP) then LocalPlayer().sDistz=LocalPlayer().sDistz+5 end if LocalPlayer():KeyDown(IN_DUCK) then LocalPlayer().sDistz=LocalPlayer().sDistz-5 end end end