CapsAdmin

Untitled

Oct 18th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 KB | None | 0 0
  1. local ENT = {}
  2. ENT.Type        = "anim"
  3. ENT.Base        = "base_anim"
  4. ENT.ClassName   = "hayashigs_christmas_tree"
  5. ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
  6.  
  7. local Maps = {
  8.  
  9.     aramaki_4d = Vector(-5833.9223632813, 6027.15625, -10238.447265625),
  10.     freespace_revolution = Vector(-10491.779296875, -10135.422851563, -6190.0556640625),
  11.     gm_construct_flatgrass_v6 = Vector(-12550.212890625, -12532.907226563, 0.19838905334473)
  12.    
  13. }
  14.  
  15. if SERVER then
  16.    
  17.     local Decoration = {
  18.    
  19.         Present_1 = {
  20.             Model = "models/effects/bday_gib01.mdl",
  21.             Pos = Vector( 30, -30, 20 ),
  22.             Ang = Angle( 25, -35, 0 )
  23.         },
  24.        
  25.         Present_2 = {
  26.             Model = "models/effects/bday_gib04.mdl",
  27.             Pos = Vector( 60, -47, 2 ),
  28.             Ang = Angle( 0, 0, 0 )
  29.         },
  30.        
  31.         Present_3 = {
  32.             Model = "models/props_lab/citizenradio.mdl",
  33.             Pos = Vector( 20, -70, -1 ),
  34.             Ang = Angle( 0, -66, 0 )
  35.         }
  36.     }
  37.    
  38.     function ENT:Initialize()
  39.  
  40.         self:SetModel( "models/props_foliage/tree_pine_large.mdl" )
  41.         self:PhysicsInit( SOLID_VPHYSICS )
  42.         self:SetSolid( SOLID_VPHYSICS )
  43.         --self:DrawShadow( true )
  44.         --self:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
  45.         self:PhysWake()
  46.         self:GetPhysicsObject():EnableMotion( false )
  47.        
  48.         for _, v in pairs( Decoration ) do
  49.             local Dec = ents.Create( "prop_physics" )
  50.             Dec:SetModel( v.Model )
  51.             local WPos = LocalToWorld( v.Pos, v.Ang, self:GetPos(), self:GetAngles() )
  52.             Dec:SetPos( WPos )
  53.             Dec:SetAngles( v.Ang )
  54.             Dec:Spawn()
  55.             Dec:GetPhysicsObject():EnableMotion( false )
  56.             Dec:SetParent( self )
  57.             Dec:SetSolid( SOLID_VPHYSICS )
  58.         end
  59.        
  60.         self:EmitSound( "hayashigs/christmas/01.mp3", 80, 100 )
  61.        
  62.     end
  63.    
  64.     local function Spawn()
  65.        
  66.         for _, v in pairs( ents.FindByClass( ENT.ClassName ) ) do
  67.             v:Remove()
  68.         end
  69.        
  70.         if Maps[game.GetMap()] then
  71.             local ENT = ents.Create( ENT.ClassName )
  72.                 ENT:SetPos( Maps[game.GetMap()] )
  73.                 ENT:SetAngles( Angle( 0, 0, 0 ) )
  74.                 ENT:Spawn()
  75.         end
  76.        
  77.     end
  78.    
  79.     timer.Create( "hihihi", 3, 1, Spawn )
  80.    
  81. end
  82.  
  83. if CLIENT then
  84.    
  85.     local mat = Material( "particle/fire" )
  86.     local pos = Vector(180,25,115)
  87.    
  88.     local wpos, t -- anti gc?
  89.     local render = render
  90.    
  91.     function ENT:Initialize()
  92.    
  93.         util.PrecacheSound( "hayashigs/christmas/01.mp3" )
  94.    
  95.     end
  96.    
  97.     local ang_origin = Angle(0,0,0)
  98.    
  99.     function ENT:Draw()
  100.         self:DrawModel()
  101.         render.SetMaterial( mat )
  102.    
  103.         if not self.data then
  104.        
  105.             self.data = {}
  106.            
  107.             for i = 1, 100 do
  108.                 local pi = (i/100)*math.pi
  109.                 local revi = (-i + 100) * 1.5
  110.                 local offset = Vector(0,0,100)
  111.                
  112.                 offset = offset + self:GetRight() * math.sin(pi*9) * revi
  113.                 offset = offset + self:GetForward() * math.cos(pi*9) * revi
  114.                 offset = offset + self:GetUp() * i * 6.5
  115.                
  116.                 local randsize = math.random() * 50
  117.                 local randpos = VectorRand() * 15
  118.                
  119.                 table.insert(self.data,
  120.                     {
  121.                         lpos = offset + randpos,
  122.                         sizex = revi/2 + randsize,
  123.                         sizey = revi/2 + randsize,
  124.                         color1 = HSVToColor((i/25)*300, 1, 1),
  125.                         color2 = HSVToColor((i/100)*100+130, 1, 1),
  126.                     }
  127.                 )
  128.             end
  129.            
  130.         else
  131.             t = RealTime()
  132.             for _, params in pairs(self.data) do
  133.                 wpos = LocalToWorld(params.lpos, ang_origin, self:GetPos(), self:GetAngles())
  134.                
  135.                 render.DrawSprite(wpos, params.sizex, params.sizey, t%2 > 1 and params.color1 or params.color2)
  136.             end
  137.         end
  138.     end
  139. end
  140.  
  141. scripted_ents.Register( ENT, ENT.ClassName, true )
Advertisement
Add Comment
Please, Sign In to add comment