@name Quas Wex Exort by OROCHI
@inputs 
@outputs T SOA:array BMult Mult BSpd Spd Z S:array SSV:array M QQD QWD QED QIKD QEX INV:string INVT TSV IW IWT IWE:entity CS CST CSTE:entity CSE:entity
@outputs GW GWT GWE1:entity GWE2:entity TN TNT TNE:entity EM EMT EMH:array EME:entity AL ALT CM CMT CMTAR:vector CME:entity
@outputs SS SSE:entity SST FS FSE1:entity FSE2:entity FSAE:entity FSAT FST FSAO FSATAR:vector DB DBE:entity DBTAR:vector DBT AAE:entity AATAR:vector AADEL CURWEP:entity
@persist 
@trigger 

interval(10)
if (first())
{
    entity():propNotSolid(1)
    entity():setAlpha(0)
    T = 0
    BSpd = 2
    Spd = BSpd
    BMult = 40
    Mult = BMult
    Z = 40
    M = 0
    QQD = 0
    QWD = 0
    QED = 0
    QIKD = 0
    QEX = 0
    INV = "000"
    INVT = 0
    IW = 0
    CS = 0
    GW = 0
    TN = 0
    EM = 0
    AL = 0
    CM = 0
    SS = 0
    FS = 0
    DB = 0
    CURWEP = owner():weapon()
    CURWEP:setAlpha(0)
   for (N = 0, 2, 1)
{
    holoCreate(N)
    holoDisableShading(N, 1)
    #holoParent(N, owner())
    holoModel(N, "hqsphere")
    holoMaterial(N, "models/shiny")
    SOA[N, number] = T + 360/3*N
    SO = SOA[N, number]
    S[N, number] = 0
    SSV[N, number] = S[N, number]
    Col = hsl2rgb(225-360+85*S[N,number],1,0.5)
    holoColor(N, Col)
    holoEntity(N):setTrails(32,32,1, "trails/laser", Col, 255)
    holoAlpha(N, 180)
    holoPos(N, owner():pos()+vec(sin(SO)*Mult, cos(SO)*Mult,Z+sin(SO/2)*20))
} 
}


#SPHERE CONTROL----------------------------------------------------------------------
for (N = 0, 2, 1)
{

    SOA[N, number] = Spd + SOA[N,number]
    SO = SOA[N, number]
    if (SSV[N, number] != S[N, number])
    {
        Col = hsl2rgb(225-360+85*S[N,number],1,0.5)
        holoEntity(N):setTrails(32,32,1, "trails/laser", Col, 255)
        holoColor(N, Col)
        SSV[N, number] = S[N, number]
    }
    holoPos(N, owner():pos()+vec(sin(SO)*Mult, cos(SO)*Mult,Z+sin(SO/2+T)*20))
} 

if (owner():keyUse()&&!QQD)
{
 S[M, number] = 0   
 M++   
QQD = 1
}
if (owner():keyReload()&&!QWD)
{
 S[M, number] = 1   
 M++  
QWD = 1 
}
if (owner():keyZoom()&&!QED)
{
 S[M, number] = 2   
 M++   
QED = 1
}

if (!owner():keyUse())
{
    QQD=0
}
if (!owner():keyReload())
{
    QWD=0
}
if (!owner():keyZoom())
{
    QED=0
}

if (M>=3)
{
    M=0
}

if (AADEL>0)
{
    AAE:applyForce(AATAR*25000-AAE:vel())
    AADEL-=0.01
}

if (AADEL<=0)
{
    AAE:propBreak()
}

if (owner():keyAttack1()&&AADEL<=0)
{
    AAE = propSpawn("models/props_phx/misc/potato_launcher_explosive.mdl", owner():shootPos()+owner():eye()*40, 0)
    Col = hsl2rgb(225-360+(85*S[0,number]+85*S[1,number]+85*S[2,number])/3,1,0.5)
    AAE:setTrails(64,0,0.1, "trails/laser", Col, 255)
    AAE:setColor(vec(0,0,0), 0)
    AATAR = owner():eye()
    AAE:propGravity(0)
    if (ALT > 0)
    {
        AADEL = 0.4
    }
    else
    {
    AADEL = 0.8
}
}
#INVOCATIONS-------------------------------------------------------------------------

#Ice Wall

    if (IWT<=0&&IWE:isValid())
    {
        IWE:propDelete()
    }
    if (IWT>0)
    {
     IWT-=0.01   
    }
    if (IW&&!IWE:isValid())
    {
        IW = 0
        IWT = 3
        IWE = propSpawn("models/hunter/blocks/cube8x8x025.mdl", owner():shootPos()+owner():eye()*80, owner():eyeAngles()+ ang(vec(90,0,0)), 1)
        IWE:setMaterial("models/props_c17/frostedglass_01a")
        IWE:setColor(vec(0,200,255), 25)
    }
    
    #Cold Snap
    
    if (CST<=0&&CSE:isValid())
    {
        CSE:propDelete()
    }
    if (CST>0)
    {
        CSE:propFreeze(1)
        CSE:setPos(CSTE:shootPos())
     CST-=0.01   
    }
    if (CS&&!CSE:isValid())
    {
        CS = 0
        CST = 2
        CSTE = owner():aimEntity()
        CSE = propSpawn("models/hunter/misc/sphere375x375.mdl", CSTE:shootPos()+vec(0,0,0), ang(vec(0,90,0)), 0)
        CSE:setMaterial("models/props_c17/frostedglass_01a")
    }
    
    #Ghost Walk
    
    if (GWT<=0&&GWE1:isValid())
    {
        GWE1:propDelete()
        GWE2:propDelete()
        owner():setMaterial(owner():model())
    }
    if (GWT>0)
    {
        GWE1:setPos(owner():pos()+vec(0,0,35))
        GWE2:setPos(owner():pos()+vec(0,0,35))
       ColM = 255*(1-abs((1-GWT)))
    GWE1:setColor(vec(ColM, ColM, ColM), 255)
    GWE2:setColor(vec(ColM, ColM, ColM), 255)
    owner():setMaterial("models/props_combine/portalball001_sheet")
     GWT-=0.01   
    }
    if (GW&&!GWE1:isValid())
    {
        GW = 0
        GWT = 2
        GWE1 = propSpawn("models/props_phx/construct/metal_dome360.mdl", owner():pos()+vec(0,0,35), ang(vec(0,90,0)), 1)
        GWE1:setMass(50000)
        GWE1:setMaterial("models/props_combine/portalball001_sheet")
        GWE1:setPos(owner():pos())
        GWE1:setColor(vec(255,255,255), 255    )
        GWE2 = propSpawn("models/props_phx/construct/metal_dome360.mdl", owner():pos()+vec(0,0,35), ang(vec(0,90,180)), 1)
        GWE2:setMass(50000)
        GWE2:setMaterial("models/props_combine/portalball001_sheet")
        GWE2:setPos(owner():pos())
        GWE2:setColor(vec(255,255,255), 255    )
    }
    
    #Tornado
    
   if (TNT<=0&&TNE:isValid())
    {
        TNE:propBreak()
        for (N = 600, 605, 1)
{
    holoDelete(N)
}
    }
    if (TNT>0)
    {
        TNE:applyForce(TNE:up()*(100000))
        for (N = 600, 605, 1)
{
    TNM = ((1-TNT)*100+1)
    TNC = 360/6*(N-600)+T*10
        holoPos(N, TNE:pos()+vec(sin(TNC)*TNM,cos(TNC)*TNM,40))
    }
     TNT-=0.01   
            
    }
    if (TN&&!TNE:isValid())
    {
        TN = 0
        TNT = 1
        TNE = propSpawn("models/hunter/tubes/circle4x4.mdl", owner():aimPos()+vec(0,0,-4), 
        ang(vec(0,0,0)), 0)
        TNE:propGravity(0)
        TNE:setMass(20000)
        TNE:setColor(vec(0,0,0), 0)
        for (N = 600, 605, 1)
{
    holoCreate(N)
    holoScale(N, vec(0,0,0))
    Col = hsl2rgb(0,0,0.5)
    holoColor(N, Col)
    holoEntity(N):setTrails(0,64,0.6, "trails/smoke", Col, 40)
    holoAlpha(N, 180)
    holoPos(N, TNE:pos())
} 
    }
    
    #EMP
    
    if (EMT<=0&&EME:isValid())
    {
        EME:propBreak()
    }
    if (EMT>0)
    {
        RND = 200*(2.9-EMT)
        for (N = 96, 103, 1)
{
    Theta = random(0, 360)
    Phi = random(0,360)
    if ((T+N*8)%16 == 0)
    {
 holoPos(N, EME:pos()+vec(0,0,25)+vec(sin(Phi)*sin(Theta),cos(Phi)*sin(Theta),cos(Theta))*random(-RND, RND))  
}
else
{
 holoPos(N, EME:pos()+vec(0,0,25))     
} 
}

     EMT-=0.01   
    }
    if (EM&&!EME:isValid())
    {
        EM = 0
        EMT = 2.9
        EME = propSpawn("models/props_phx/cannonball_solid.mdl", owner():aimPos()+vec(0,0,8), ang(vec(0,90,0)), 1)
        EME:setColor(vec(255,0,255), 0)

        for (N = 96, 103, 1)
{
 holoCreate(N):setTrails(0,16,2, "trails/laser", vec(255, 0, 255), 255)   
holoScale(N, vec(0,0,0))
holoPos(N, EME:pos()+vec(0,0,25))
}
    }
    
    #Alacrity
    
    if (ALT<=0&&holoEntity(300):isValid())
    {
        holoDelete(300)
        holoDelete(301)
    }
    if (ALT>0)
    {
        RND = 200
        Md = 100
        holoPos(300, owner():attachmentPos("anim_attachment_LH")+vec(random(-RND,RND), random(-RND,RND), random(-RND,RND))/Md)
        holoPos(301, owner():attachmentPos("anim_attachment_RH")+vec(random(-RND,RND), random(-RND,RND), random(-RND,RND))/Md)
     ALT-=0.01   
    }
    if (AL&&!holoEntity(300):isValid())
    {
        AL = 0
        ALT = 4
        Col = hsl2rgb(225-360+(85*S[0,number]+85*S[1,number]+85*S[2,number])/3,1,0.5)
        holoCreate(300):setTrails(0,64,0.2, "trails/laser", Col, 255)
        holoParentAttachment(300, owner(), "anim_attachment_LH")
        holoScale(300, vec(0,0,0))
        holoCreate(301):setTrails(0,64,0.2, "trails/laser", Col, 255)
        holoParentAttachment(301, owner(), "anim_attachment_RH")
        holoScale(301, vec(0,0,0))
    }
    
    #Chaos Meteor
    
    if (CMT<=0&&CME:isValid())
    {
        CME:propDelete()
    }
    if (CMT>0)
    {
        CME:applyForce(CMTAR*500000-CME:vel())
        if (CMT<0.4)
        {
CME:setAlpha(255/0.4*CMT)
}
     CMT-=0.01   
    }
    if (CM&&!CME:isValid())
    {
        CM = 0
        CMT = 3
        CME = propSpawn("models/hunter/misc/sphere375x375.mdl", owner():pos()+vec(0,0,400), ang(vec(0,90,0)), 0)
        CME:setMaterial("phoenix_storms/metalset_1-2")
        CME:setMass(50000)
        CMTAR = owner():eye()
        CME:setColor(vec(255,180,125), 255)
    }
    
    #Sun Strike
    
    if (SST<=0&&SSE:isValid())
    {
        SSE:propBreak()
    }
    if (SST>0)
    {
        holoPos(200, holoEntity(200):pos()-vec(0,0,100))
     SST-=0.01   
    }
    if (SS&&!SSE:isValid())
    {
        SS = 0
        SST = 2
        SSE = propSpawn("models/props_phx/amraam.mdl", owner():aimPos()+vec(0,0,1250), ang(vec(90,0,0)), 0)
        SSE:setMass(50000)
        SSE:setColor(vec(0,0,0), 0)
        holoCreate(200):setTrails(0,1280,2, "trails/laser", vec(255, 180, 125), 255) 
        holoScale(200, vec(0,0,0))
        holoPos(200, owner():aimPos()+vec(0,0,10000))
    }
    
    #Forge Spirit
    
    if (FST<=0&&FSE1:isValid())
    {
        FSE1:propDelete()
        holoDelete(402)
        FSE2:propDelete()
        holoDelete(403)
    }
    if (FST>0)
    {
        
        FSM = 4
        FSS = 16
        FSE1:setPos(owner():pos()+vec(0,0,60)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw()+180,0))))
        FSE1:setAng(owner():eyeAngles()+ ang(vec(0,0,0)))
        holoPos(400, FSE1:pos()+vec(sin(T*FSS)*FSM,cos(T*FSS)*FSM,sin(T*4)*20-20):rotate(ang(vec(0,owner():eyeAngles():yaw()+90,0))))
        holoPos(402, owner():pos()+vec(0,0,60-4*6)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw(),0))))
        FSE2:setPos(owner():pos()+vec(0,0,60)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw(),0))))
        FSE2:setAng(owner():eyeAngles()+ ang(vec(0,0,0)))
        holoPos(401, FSE2:pos()+vec(sin(T*FSS)*FSM,cos(T*FSS)*FSM,sin(T*4)*20-20):rotate(ang(vec(0,owner():eyeAngles():yaw()+90,0))))
        holoPos(403, owner():pos()+vec(0,0,60-4*6)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw()+180,0))))    
            
            if (FSAT>0)
{
    FSAE:applyForce(FSATAR*25000-FSAE:vel())
    FSAT-=0.01
}

if (FSAT<=0)
{
    FSAE:propBreak()
}
            
            if (FSAT<=0)
{
    if (FSAO == 1)
    {
    FSAE = propSpawn("models/props_phx/misc/potato_launcher_explosive.mdl", FSE1:pos()+owner():eye()*40, 0)
}
else
{
    FSAE = propSpawn("models/props_phx/misc/potato_launcher_explosive.mdl", FSE2:pos()+owner():eye()*40, 0)
}
    Col = vec(255, 180, 125)
    FSAE:setTrails(64,0,0.1, "trails/laser", Col, 255)
    FSAE:setColor(vec(0,0,0), 0)
    FSATAR = owner():eye()
    FSAE:propGravity(0)
    FSAT = 0.6
    FSAO*=-1
}

    if (FST<0.4)
        {
FSE1:setAlpha(255/0.4*FST)
FSE2:setAlpha(255/0.4*FST)
holoAlpha(402, (255/0.4*FST))
holoAlpha(403, (255/0.4*FST))
}    
    FST-=0.01   
    }
    if (FS&&!FSE1:isValid())
    {
        FS = 0
        FST = 4
        FSAO = 1
        FSE1 = propSpawn("models/Gibs/HGIBS.mdl", owner():pos()+vec(0,0,60)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw()+180,0))), owner():eyeAngles()+ ang(vec(0,0,0)), 1)
        FSE1:setMaterial("models/Gibs/HGIBS.mdl")
        holoCreate(400):setTrails(0,128,1, "trails/laser", vec(255, 180, 125), 255) 
        holoScale(400, vec(0,0,0))
        holoPos(400, FSE1:pos())
        holoParent(400, FSE1)
        holoCreate(402)
        holoModel(402, "cone")
        holoColor(402, vec(255, 180, 125), 255) 
        holoScale(402, vec(0.2, 0.2, 4))
        holoAng(402, ang(vec(0,0,180)))
        holoPos(402, owner():pos()+vec(0,0,60-4*6)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw(),0))))
        FSE2 = propSpawn("models/Gibs/HGIBS.mdl", owner():pos()+vec(0,0,60)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw(),0))), owner():eyeAngles()+ ang(vec(0,0,0)), 1)
        FSE2:setMaterial("models/Gibs/HGIBS.mdl")
        holoCreate(401):setTrails(0,128,1, "trails/laser", vec(255, 180, 125), 255) 
        holoScale(401, vec(0,0,0))
        holoPos(401, FSE2:pos())
        holoParent(401, FSE2)
        holoCreate(403)
        holoModel(403, "cone")
        holoColor(403, vec(255, 180, 125), 255) 
        holoScale(403, vec(0.2, 0.2, 4))
        holoAng(403, ang(vec(0,0,180)))
        holoPos(403, owner():pos()+vec(0,0,60-4*6)+vec(0,40,0):rotate(ang(vec(0,owner():eyeAngles():yaw()+180,0))))
    }
    
    #Deafening Blast
    
    if (DBT<=0&&DBE:isValid())
    {
        DBE:propDelete()
    }
    if (DBT>0)
    {
        DBE:applyForce(DBTAR*5000000-DBE:vel())
        DBE:setAlpha(255/0.3*DBT)
     DBT-=0.01   
    }
    if (DB&&!DBE:isValid())
    {
        DB = 0
        DBT = 0.3
        DBE = propSpawn("models/hunter/tubes/tube4x4x2c.mdl", owner():shootPos()+owner():eye()*1, owner():eyeAngles()+ ang(vec(180,0,0)), 0)
        DBE:setMass(50000)
        DBE:propGravity(0)
        DBE:setMaterial("models/shiny")
        DBE:setTrails(256,0,0.4, "trails/tube", vec(255, 255, 255), 255)
        DBE:setColor(vec(255,255,255), 255)
        DBTAR = owner():eye()
    }

#INVOCATION CONTROL----------------------------------------------------------------

if (owner():keyAttack2()&&!QIKD&&INVT<=0)
{
    QEX = 1
    QIKD = 1 
    INV = ""
    INVT = 2
    TSV = T
    for (N=0, 2, 1)
    {
        for (O=0, 2, 1)
        {
            if (N==S[O, number])
            {
                INV = INV + S[O, number]
            }
        }
    }
    #Ice Wall
    if (INV=="002"&&IWT<=0)
    {
        hint("Ice Wall!", 2)
        IW = 1
    }
    #Cold Snap
    if (owner():aimEntity():pos()!=vec(0,0,0))
    {
    if (INV=="000"&&CST<=0)
    {
        hint("Cold Snap!", 2)
        CS = 1
    }
}
else
{
    INVT = 0
}
    #Ghost Walk
    if (INV=="001"&&GWT<=0)
    {
        hint("Ghost Walk!", 2)
        GW = 1
    }
    #Tornado
    if (INV=="011"&&TNT<=0)
    {
        hint("Tornado!", 2)
        TN = 1
    }
    #EMP
    if (INV=="111"&&EMT<=0)
    {
        hint("EMP!", 2)
        EM = 1
    }
    #Alacrity
    if (INV=="112"&&ALT<=0)
    {
        hint("Alacrity!", 2)
        AL = 1
    }
    #Chaos Meteor
    if (INV=="122"&&CMT<=0)
    {
        hint("Chaos Meteor!", 2)
        CM = 1
    }
    #Sun Strike
    if (INV=="222"&&SST<=0)
    {
        hint("Sun Strike!", 2)
        SS = 1
    }
    #Forge Spirit
    if (INV=="022"&&FST<=0)
    {
        hint("Forge Spirit!", 2)
        FS = 1
    }
    #Deafening Blast
    if (INV=="012"&&DBT<=0)
    {
        hint("Deafening Blast!", 2)
        DB = 1
    }
   
}

    
    
#MIX---------------------------------------------------------------------------------
if (!owner():keyAttack2())
{
    QIKD=0
}
if (QEX)
{
    
    Spd+=0.4
}
elseif (Spd>BSpd)
{
    Spd-=0.05
}
if (Spd>=BSpd*4)
{
    QEX = 0
}
if (INVT>0&&(T-TSV)%100==0)
{
    
    INVT--
    hint(toString(INVT), 1)
}
#TIME CONTROL------------------------------------------------------------------------
T++

#--
entity():setPos(owner():shootPos())
if (CURWEP!=owner():weapon())
{
    CURWEP = owner():weapon()
    CURWEP:setAlpha(0)
}