@name Camera Man
@inputs Thrust_Forward Thrust_Backward Strafe_Left Strafe_Right Rise Fall Active
@inputs Primary Secondary Switch Hover
@outputs Fade Power Grab Force Ignite Fireball Force_Strength
@persist P Y R Selected Held_Down Airdrag Velocity:vector Mode_Num

interval(1)
Power = 1
Fade = 10000
Smooth = 300
Strength = 16
Airdrag = 300000+(Hover*500000)
Owner = owner()
Self = entity()
Self:setMass(50000)

P = angnorm(entity():angles():pitch()-Owner:eye():toAngle():pitch())	
Y = angnorm(entity():angles():yaw()-Owner:eye():toAngle():yaw())	
R = angnorm(entity():angles():roll())-0
Pitch = P*5 + $P*50
Yaw = Y*5 + $Y*50
Roll = R*5 + $R*50
Velocity = Self:velL()

Thrust = (Thrust_Forward - Thrust_Backward) * (150000+Airdrag)
Strafe = (Strafe_Right - Strafe_Left) * (150000+Airdrag)
Vert = (Rise - Fall) * (150000+Airdrag)

if (Active == 1){
Self:applyOffsetForce(entity():up()*Pitch*Self:mass()*2/Smooth,Self:massCenter()+entity():forward()*(Strength))    
Self:applyOffsetForce((-1)*entity():up()*Pitch*Self:mass()*2/Smooth,Self:massCenter()+entity():forward()*(-Strength))    
Self:applyOffsetForce(entity():up()*Roll*Self:mass()*2/Smooth,Self:massCenter()+entity():right()*(Strength))    
Self:applyOffsetForce((-1)*entity():up()*Roll*Self:mass()*2/Smooth,Self:massCenter()+entity():right()*(-Strength))    
Self:applyOffsetForce(entity():right()*Yaw*Self:mass()*2/Smooth,Self:massCenter()+entity():forward()*(Strength))    
Self:applyOffsetForce((-1)*entity():right()*Yaw*Self:mass()*2/Smooth,Self:massCenter()+entity():forward()*(-Strength))
}
applyForce(Thrust*Self:forward())
applyForce(Strafe*Self:right())
applyForce(Vert*Self:up())



    if (Velocity:x() > 0){applyForce(-Airdrag*Self:forward())}
    if (Velocity:x() < 0){applyForce(Airdrag*Self:forward())}
    
    if (Velocity:y() > 0){applyForce(Airdrag*Self:right())}
    if (Velocity:y() < 0){applyForce(-Airdrag*Self:right())}
    
    if (Velocity:z() > 0){applyForce(-Airdrag*Self:up())}
    if (Velocity:z() < 0){applyForce(Airdrag*Self:up())}
    
    
Grab = Primary

if (Switch == 1){

if (Mode_Num == 0 & Held_Down == 0){
Mode_Num = 1
hint("Igniter",3)
Held_Down = 1}

if (Mode_Num == 1 & Held_Down == 0){
Mode_Num = 2
hint("Fireball",3)
Held_Down = 1}

if (Mode_Num == 2 & Held_Down == 0){
Mode_Num = 0
hint("Forcer",3)
Held_Down = 1}
}

if (Switch == 0){Held_Down = 0}
if (Secondary == 1 & Force == 1){
Force_Strength = 1000000000}

if (Secondary == 0){
Force = 0
Ignite = 0
Force_Strength = 0}

if (Secondary == 1){
if(Mode_Num == 0){
Force = 1
Ignite = 0}

if(Mode_Num == 1){
Force = 0
Ignite = 1}


if(Mode_Num == 2){
Force = 1
Ignite = 1}
}

