@name MUSICAL CLOAK v3
@inputs V:vector
@model models/props_junk/sawblade001a.mdl

Chip = entity()
It = owner()
runOnChat(1)

Chip = entity()
runOnChat(1)
It=owner()

#Name: Slave


    E=entity()
    O=owner()
if(tickClk()){
    ##############################
    if(->V){
        Target=V
    }else{
        if(!O:keyUse()){
        Target=O:shootPos()+vec(0,0,60) # Above the owner's head.
    }elseif(O:keyUse()){
    Target=O:aimPos()+vec(0,0,50) # Above where the owner is looking.
}
}
    E:applyForce(((Target-E:pos())*10-E:vel())*E:mass()) #<-- makes E go to Target
    ##############################
}elseif(first()){
    E=entity()
    O=owner()
    runOnTick(1)
}

                #STABILISE
                TarQ = quat(O:eyeAngles()+ang(90,0,90)) #Calculate quaternion for target orientation
                CurQ = quat(E) #Calculate current orientation quaternion
                
                #TarQ/CurQ is a quaternion representing the rotation that will rotate the object from current orientation to the target one.
                Q = TarQ/CurQ
                
                #applyTorque() works on intrinsic vectors! Get the rotation vector and transform it.
                EP=E:pos()
                TTV = E:toLocal(rotationVector(Q)+EP)
                #Alternatively, can use "V = transpose(matrix(E))*rotationVector(Q)"
                
                #Apply torque. angVelVector() works like a delta term.
                #Factors 150 and 12 can be adjusted to achieve best effect.
                E:applyTorque((150*TTV - 12*E:angVelVector())*E:inertia())



if (It:lastSaid() == "!active") {
    It:setMaterial("models/shadertest/predator")
owner():soundPlay(1000,1000,"abandon/cyber/bass1.wav")
hideChat(1)
}

if (It:lastSaid() == "!deactive") {
    It:setMaterial("")
owner():soundPlay(1000,1000,"abandon/cyber/bass1.wav") 
hideChat(1)  
}


if (It:lastSaid() == "!portal") {
owner():soundPlay(1000,1000,"music/portal_still_alive.mp3")
hideChat(1)    
}

if(It:lastSaid() == "!falcon") {
owner():soundPlay(1000,1000,"captainfalcon_t.mp3")
hideChat(1)
concmd("say FALCON")
}


if(It:lastSaid() == "!bananaphone") {
owner():soundPlay(1000,1000,"bananaphone/banana_cake.mp3")
hideChat(1)
}

if(It:lastSaid() == "!sandwicheat") {
    owner():soundPlay(1000,1000,"heavy/sandwicheat09.wav")
    hideChat(1)
}

if(It:lastSaid() == "!escort") {
    owner():soundPlay(1000,1000,"npc/partyescort.wav")
    hideChat(1)
}

if(It:lastSaid() == "!vheal") {
    owner():soundPlay(1000,1000,"npc/vort/vorthealsingle_loop.wav")
    hideChat(1)
}

if(It:lastSaid() == "!bass") {
    owner():soundPlay(1000,1000,"common/bass.wav")
    hideChat(1)
}

if(It:lastSaid() == "!rave") {
    owner():soundPlay(1000,1000,"ravebreak.mp3")
    hideChat(1)
}

if(It:lastSaid() == "!rise") {
    owner():soundPlay(1000,1000,"vo/gman_misc/gman_riseshine.wav")
    hideChat(1)
}

if(It:lastSaid() == "!gman2") {
    owner():soundPlay(1000,1000,"vo/gman_misc/gman_02.wav")
    hideChat(1)
}

if(It:lastSaid() == "!gman3") {
    owner():soundPlay(1000,1000,"vo/gman_misc/gman_03.wav")
    hideChat(1)
}

if(It:lastSaid() == "!gman4") {
    owner():soundPlay(1000,1000,"vo/gman_misc/gman_04.wav")
    hideChat(1)
}

if(It:lastSaid() == "!blue") {
    owner():soundPlay(1000,1000,"blue.mp3")
    hideChat(1)
}

if(It:lastSaid() == "!promote") {
    owner():soundPlay(1000,1000,"autopromote/promote.wav")
    hideChat(1)
}

if(It:lastSaid() == "!wel1") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome01.wav")
    hideChat(1)
}

if(It:lastSaid() == "!wel2") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome02.wav")
    hideChat(1)
}


if(It:lastSaid() == "!wel3") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome03.wav")
hideChat(1)
}

if(It:lastSaid() == "!wel4") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome04.wav")
hideChat(1)
}

if(It:lastSaid() == "!wel5") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome05.wav")
hideChat(1)
}

if(It:lastSaid() == "!wel6") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome06.wav")
hideChat(1)
}

if(It:lastSaid() == "!wel7") {
    owner():soundPlay(1000,1000,"vo/breencast/br_welcome07.wav")
hideChat(1)
}

if(It:lastSaid() =="!pickc1") {
    owner():soundPlay(1000,1000,"npc/metropolice/vo/pickupthecan1.wav")
hideChat(1)
}
if(It:lastSaid() =="!pickc2") {
    owner():soundPlay(1000,1000,"npc/metropolice/vo/pickupthecan2.wav")
hideChat(1)
}

if(It:lastSaid() =="!pickc3") {
    owner():soundPlay(1000,1000,"npc/metropolice/vo/pickupthecan3.wav")
hideChat(1)
}

if (It:lastSaid() == "!flesh") {
    It:setMaterial("models/flesh")
hideChat(1)
}

if (It:lastSaid() == "!predator") {
    It:setMaterial("models/shadertest/predator")
hideChat(1)
}

if (It:lastSaid() == "!normal") {
    It:setMaterial("")
    It:setColor(255,255,255)
    owner():weapon():setColor(255,255,255)
    owner():weapon():setAlpha(255)
hideChat(1)
}
 if (It:lastSaid() == "!wood") {
    It:setMaterial("phoenix_storms/wood")
hideChat(1)
}
 if (It:lastSaid() == "!space") {
    It:setMaterial("models/props_lab/warp_sheet")
hideChat(1)
}
if (It:lastSaid() == "!lag") {
    It:setMaterial("phoenix_storms/lag_sign")
hideChat(1)
}
if (It:lastSaid() == "!stripe") {
    It:setMaterial("phoenix_storms/stripes")
hideChat(1)
}
if (It:lastSaid() == "!glass") {
    It:setMaterial("models/props_combine/health_charger_glass")
hideChat(1)
}

if (It:lastSaid() == "!wireframe") {
    It:setMaterial("models/wireframe")
hideChat(1)
}

if (It:lastSaid() == "!money") {
    It:setMaterial("models/props/cs_assault/dollar")
hideChat(1)
}

if (It:lastSaid() == "!fender") {
    It:setMaterial("phoenix_storms/fender")
hideChat(1)
}

if (It:lastSaid() == "!fwood") {
    It:setMaterial("phoenix_storms/fender_wood")
hideChat(1)
}

if (It:lastSaid() == "!eletric") {
    It:setMaterial("models/alyx/emptool_glow")
hideChat(1)
}

if (It:lastSaid() == "!linesGB") {
    It:setMaterial("models/XQM/LightLinesGB")
hideChat(1)
}

if (It:lastSaid() == "!linesred") {
    It:setMaterial("models/XQM/LightLinesred")
hideChat(1)
}

if (It:lastSaid() == "!window") {
    It:setMaterial("hunter/mywindow")
hideChat(1)
}

if (It:lastSaid() == "!red") {
    It:setColor(255,0,0)
    owner():weapon():setColor(255,0,0)
hideChat(1)
}
if (It:lastSaid() == "!green") {
    It:setColor(0,255,0)
    owner():weapon():setColor(0,255,0)
hideChat(1)
}

if (It:lastSaid() == "!blue") {
    It:setColor(0,0,255)
    owner():weapon():setColor(0,0,255)
hideChat(1)
}

if (It:lastSaid() == "!white") {
    It:setColor(255,255,255)
    owner():weapon():setColor(255,255,255)
hideChat(1)
}

if (It:lastSaid() == "!yellow") {
    It:setColor(200,200,0)
    owner():weapon():setColor(255,255,255)
hideChat(1)
}

if (It:lastSaid() == "!black") {
    It:setColor(0,0,0)
    owner():weapon():setColor(0,0,0)
hideChat(1)
}

if (It:lastSaid() == "!weapon") {
    concmd("say WEAPON ON")
owner():weapon():setAlpha(255)
hideChat(1)
}

if (It:lastSaid() == "!weapon off") {
    concmd("say WEAPON OFF")
owner():weapon():setAlpha(0)
hideChat(1)
}

if (It:lastSaid() == "!weapon skin") {
owner():weapon():setMaterial("phoenix_storms/mat/mat_phx_metallic2")
hideChat(1)
}

if (It:lastSaid() == "!weapon skin off") {
owner():weapon():setMaterial("")
hideChat(1)
}

if (It:lastSaid() == "kill me") {
    concmd("say ulx rocket avatar")
hideChat(1)
}

if (It:lastSaid() == "god") {
    concmd("say !god avatar")
hideChat(1)
}

if (It:lastSaid() == "!grass") {
    It:setMaterial("nature/grassfloor002a")
hideChat(1)
}

if (It:lastSaid() == "!portal") {
    It:setMaterial("models/props/metal_box_skin001")
    hideChat(1)
}

if (It:lastSaid() == "!e2") {
    It:setMaterial("beer/wiremod/gate_e2")
    hideChat(1)
}

if (It:lastSaid() == "!CHICKEN BUT") {
    concmd("say test")
    hideChat(1)
}

if(It:lastSaid() == "!2s") {
    owner():soundPlay(1000,1000,"exosounds/2sexy.mp3")
    hideChat(1)
}

if(It:lastSaid() == "!br") {
    owner():soundPlay(1000,1000,"exosounds/barrel roll.mp3")
    hideChat(1)
}

if(It:lastSaid() == "!boom") {
    owner():soundPlay(1000,1000,"exosounds/boom!.mp3")
    hideChat(1)
}

if(It:lastSaid() == "!speak english") {
    owner():soundPlay(1000,1000,"exosounds/do you speak english.mp3")
    hideChat(1)
}
