Guest User

Expression 2 Stencil Core Examples

a guest
Nov 4th, 2019
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.11 KB | None | 0 0
  1. @name AST Stencils
  2. @persist Chip:entity
  3.  
  4. if (first())
  5. {
  6.     #change this to what enum you want to test
  7.     #current enums are:
  8.     #
  9.     #_STENCIL_WHITELIST
  10.     #_STENCIL_BLACKLIST
  11.     #_STENCIL_WHITELIST_WORLD
  12.     #
  13.     #and new ones are:
  14.     #
  15.     #_STENCIL_RENDER_TARGET
  16.     #_STENCIL_WHITELIST_MATERIAL
  17.    
  18.     Num = _STENCIL_WHITELIST
  19.    
  20.     #the switch case below will show you how I set up each stencil
  21.     #transparency is important with most stencils
  22.    
  23.     Chip = entity()
  24.    
  25.     Chip:setAlpha(255)
  26.    
  27.     if (0 & owner():weapon():type() == "gmod_tool")
  28.     {
  29.         hint("or you will get a bug with transparency.", 5)
  30.         hint("Don't forget to holster your toolgun,", 5)
  31.     }
  32.    
  33.     switch (Num)
  34.     {
  35.         case _STENCIL_WHITELIST,
  36.             #create and parent entities
  37.             holoCreate(1, Chip:toWorld(vec(0, 40, 0)), vec(5), Chip:angles(), vec(255), "plane")
  38.             holoParent(1, Chip)
  39.            
  40.             holoCreate(2, Chip:toWorld(vec(0, 40, -10)), vec(0.2), Chip:angles(), vec(255, 0, 0), "models/props_c17/FurnitureWashingmachine001a.mdl")
  41.             holoParent(2, Chip)
  42.            
  43.             holoCreate(3, Chip:toWorld(vec(17, 40, 13.2)), vec(0.6), Chip:angles(), vec(255), "models/props_c17/FurnitureWashingmachine001a.mdl")
  44.             holoAlpha(3, 0)
  45.             holoParent(3, Chip)
  46.            
  47.             stencilCreate(1) #no need to add the type as _STENCIL_WHITELIST is the default type
  48.             stencilAddEntity(1, holoEntity(2)) #add an entity to get affected by the stencil
  49.             stencilAddEntity(1, holoEntity(3)) #transparency isn't handled in stencils, so you can hide entities outside the stencil
  50.            stencilAddReferenceEntity(1, holoEntity(1)) #add an entity to render with the stencil
  51.            stencilSetEntityOverrideColor(1, vec(0, 255, 0))
  52.            
  53.            #keep in mind that if an entity gets culled off by the source engine it will not
  54.        break
  55.        case _STENCIL_BLACKLIST,
  56.            holoCreate(1, Chip:toWorld(vec(0, 40, 22)), vec(1), Chip:angles())
  57.            holoAlpha(1, 0)
  58.            holoParent(1, Chip)
  59.            
  60.            holoCreate(2, Chip:toWorld(vec(0, 40, 22)), vec(1), Chip:angles(), vec(255), "models/props_c17/FurnitureWashingmachine001a.mdl")
  61.            holoAlpha(2, 0)
  62.            holoParent(2, Chip)
  63.            
  64.            stencilCreate(1, _STENCIL_BLACKLIST)
  65.            stencilAddEntity(1, holoEntity(2))
  66.            stencilAddReferenceEntity(1, holoEntity(1))
  67.        break
  68.        case _STENCIL_WHITELIST_WORLD, #I like indenting these. I think they should be automaticaly
  69.            Chip:setAlpha(0)
  70.            Chip:setAng(toWorldAng(vec(), toWorldAng(vec(), ang(0, 0, 180), vec(), ang(0, 0, 90)), vec(), ang(0, owner():eyeAngles()[2] + 90, 0)))
  71.            Chip:setPos(owner():shootPos() + owner():eye():setZ(0):normalized() * 80 + vec(0, 0, 8))
  72.            
  73.            holoCreate(1, Chip:toWorld(vec(0, 0, 1.75)), vec(6), Chip:angles(), vec(255), "plane")
  74.            holoAlpha(1, 0)
  75.            holoParent(1, Chip)
  76.            
  77.            holoCreate(2, Chip:toWorld(vec(100, 10, -500)), vec(1), Chip:toWorld(toWorldAng(vec(), ang(0, 30, 0), vec(), ang(90, 0, 90))), vec(255), "models/props_wasteland/cargo_container01.mdl")
  78.            holoAlpha(2, 0)
  79.            holoParent(2, Chip)
  80.            
  81.            holoCreate(3, Chip:pos(), vec(2), Chip:angles(), vec(255), "models/props_phx/construct/windows/window1x1.mdl")
  82.            holoParent(3, Chip)
  83.            
  84.            holoCreate(4, Chip:toWorld(vec(0, 72, -60)), vec(1), Chip:toWorld(toWorldAng(vec(), ang(0, 180, 0), vec(), ang(90, 0, 90))), vec(255), owner():model())
  85.            holoAlpha(4, 0)
  86.            holoParent(4, Chip)
  87.            
  88.            #ifdef holoAnim(number, string)
  89.            holoAnim(4, "taunt_laugh", 0, 1)
  90.            #endif
  91.            
  92.            stencilCreate(1, _STENCIL_WHITELIST_WORLD)
  93.            stencilAddEntity(1, holoEntity(2))
  94.            stencilAddEntity(1, holoEntity(4))
  95.            stencilAddReferenceEntity(1, holoEntity(1))
  96.        break
  97.    }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment