@name FailCake Aerial Fate Plates V1
@persist Once2 On
@persist Vect:vector V4:entity [E O]:entity POWER
@trigger all
@model models/hunter/plates/plate1x1.mdl

if(first() | duped()){
#reworked
hint("* Made By FailCake * -> www.youtube.com/users/edunad ",7) 
  
runOnTick(1)

## SETTINGS
POWER = 1000
## SETTINGS

E = entity()
O = owner()
  
E:setMaterial("phoenix_storms/dome")
holoCreate(1)
holoModel(1,"cube")
holoPos(1,E:pos())
holoMaterial(1,"phoenix_storms/future_vents")
holoScale(1,vec(5,5,0.1))

holoCreate(2)
holoModel(2,"cube")
holoPos(2,E:pos()+vec(0,0,1))
holoMaterial(2,"phoenix_storms/gear")
holoScale(2,vec(2,2,0.1))
holoParent(2,E)
}

Bn = rangerOffsetHull(20,E:pos(),E:up(),vec(20,20,1))
    
if(changed(Bn:hit()) && Bn:hit()){
Vect = (holoEntity(1):pos()-E:pos()+vec(0,0,60))
On = 1

if(Once2 == 0){
Once2 = 1
E:propFreeze(0)
timer("wait",1500)
E:soundPlay(100,100,"doors/door_metal_thin_open1.wav")
}

E:applyForce(Vect*500 + $Vect*500)

}else{

if(On == 1){
Vect = (holoEntity(1):pos()-E:pos()+vec(0,0,60))
E:applyForce(Vect*POWER + $Vect*POWER)    
}

if(clk("wait")){

On = 0
if(Once2 == 1){
Once2 = 0
E:soundPlay(100,100,"doors/door_metal_thin_close2.wav")
}

E:setPos(holoEntity(1):pos() + vec(0,0,0))
E:setAng(holoEntity(1):angles())
E:propFreeze(1)
}

}

TarQ = quat(holoEntity(1):angles())
CurQ = quat(E)
Q = TarQ/CurQ
V = E:toLocal(rotationVector(Q)+E:pos())
E:applyTorque((900*V - 12*E:angVelVector())*E:inertia()) 

## Made By Failcake
## Requires PropCore!


