Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Plates_Hex by DarkE
- @inputs
- @outputs
- @persist Size:vector2 [SpawnedProps GameProps]:array State DestroyAmount NextDestroy:entity PropData:table DestroyQueue:array
- @trigger
- if(first()){
- Size = vec2(25,25)
- DestroyAmount = 5
- runOnTick(1)
- State=1
- }
- if(State == 1){
- while(Size:x()*Size:y()>SpawnedProps:count() && propCanCreate()){
- Prop = propSpawn("models/sprops/geometry/fhex_144.mdl",1)
- #Prop:propGravity(0)
- Prop:setMass(50000)
- Prop:setMaterial("models/debug/debugwhite")
- SpawnedProps:pushEntity(Prop)
- C = SpawnedProps:count()-1
- Box = Prop:boxSize()
- Box = vec(Box:x(),Box:z(),Box:y())
- Box = Box+vec(-1,-1,0)
- #print(Box)
- X = C%Size:x()
- Y = floor(C/Size:x())
- Scale = 40
- #Pos = entity():pos()+vec(X*Box:x(),Y*Box:y(),300+(sin(X*Scale)+cos(Y*Scale))*50)
- #Ang = ang(-cos(X*Scale)*10,0,-sin(Y*Scale)*10)
- if(Y%2==1){
- Pos = entity():pos()+vec(X*Box:x(),Y*Box:y(),300)
- }else{
- Pos = entity():pos()+vec(X*Box:x()+Box:x()/2,Y*Box:y(),300)
- }
- Ang = ang(0,30,90)
- Col = vec(155,155,155)+vec(100,100,100)*((X+Y)%2)
- Alpha = 170
- Prop:setPos(Pos)
- Prop:setAng(Ang)
- Prop:setColor(Col)
- Prop:setAlpha(Alpha)
- PropData[Prop:id(),table] = table( "ang" = Ang, "pos" = Pos, "col" = Col, "alpha" = Alpha )
- }
- if(Size:x()*Size:y()==SpawnedProps:count()){
- GameProps = SpawnedProps:clone()
- State = 3
- timer("update", 3000)
- }
- }elseif(State == 2){
- while(GameProps:count()<SpawnedProps:count() && perf()){
- DestroyQueue = array()
- Prop = SpawnedProps[GameProps:count()+1,entity]
- Prop:propNotSolid(0)
- Prop:setMaterial("models/debug/debugwhite")
- Prop:setPos(PropData[Prop:id(),table]["pos",vector])
- Prop:setAng(PropData[Prop:id(),table]["ang",angle])
- Prop:setColor(PropData[Prop:id(),table]["col",vector])
- Prop:setAlpha(PropData[Prop:id(),table]["alpha",number])
- Prop:propFreeze(1)
- GameProps:pushEntity( Prop )
- }
- if(GameProps:count()==SpawnedProps:count()){
- State = 3
- timer("update", 3000)
- }
- }
- if(clk("reset")){
- GameProps = array()
- State = 2
- }
- if(clk("update") && State == 3){
- while(DestroyQueue:count()>0){
- Prop = DestroyQueue:shiftEntity()
- Prop:setColor(vec(255,0,0))
- soundStop(Prop:id())
- Prop:setMaterial("models/wireframe")
- Prop:setAlpha(0)
- Prop:propNotSolid(1)
- #Prop:propFreeze(0)
- Prop:applyForce(vec(0,0,10000000))
- Prop:soundPlay(Prop:id(),3,"Glass.Break")
- }
- if(GameProps:count()>1){
- while(DestroyQueue:count() < DestroyAmount && GameProps:count() > 1 ){
- Prop = GameProps:removeEntity(random(1,GameProps:count()))
- Prop:soundPlay(Prop:id(),1,"k_lab.teleport_alarm")
- Prop:setAlpha(200)
- Prop:setColor(vec(255,0,0))
- DestroyQueue:pushEntity(Prop)
- }
- timer("update", 1000)
- }else{
- Prop = GameProps:removeEntity(1)
- Prop:soundPlay(Prop:id(),1,"ui/scored.wav")
- Prop:setAlpha(255)
- Prop:setColor(vec(0,255,0))
- timer("reset", 5000)
- State = 0
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement