@name Chaqua TP E2
@persist [E P T]:entity Ph
if(first())
{
    runOnTick(1)
    runOnChat(1)
    
    E = entity()
    P = E:isConstrainedTo()
    
    E:setColor(0,0,0,0)
    P:setColor(0,0,0,0)
    
    E:propFreeze(1)
    P:propFreeze(1)
    E:propNotSolid(1)
    P:propNotSolid(1)
    
    P:setTrails(20,0,10,"trails/laser",vec(150,0,150),50)
}

if(chatClk(owner()))
{
    LS = owner():lastSaid():lower():explode(" ")
    if(LS[1,string]=="t")
    {
        hideChat(1)
        local TE = findPlayerByName(LS[2,string])
        if(TE:isValid())
        {
            T = TE
            Ph = 1
        }else
        {
            hint("Did not find player",3)
        }
    }
}

switch(Ph)
{
    case 1,
        if(changed(Ph))
        {
            E:propNotSolid(0)
            P:propNotSolid(0)
        }
        
        P:setPos(owner():shootPos()+(owner():eye()*(70 * (1 + (owner():keyAttack2() * 15))))-vec(0,0,10))
        
        if(P:driver():isValid())
        {
            if(P:driver()==owner())
            {
                Ph = 2
            }else
            {
                P:killPod()
            }
        }
    break
    
    case 2,
        if(changed(Ph))
        {
            E:propNotSolid(1)
            P:propNotSolid(1)
        }
    
        P:setPos(T:boxCenterW()-T:eye():setZ(0):normalized()*100)
        #P:setPos(T:shootPos()+vec(0,0,50))
        
        local M1 = owner():keyAttack1()
        local M2 = owner():keyAttack2()
        if(M2&changed(M1)&M1)
        {
            propSpawn("models/props_phx/ww2bomb.mdl",T:shootPos(),1):propBreak()
        }
        
        if(!P:driver():isValid())
        {
            reset()
        }
    break
}
