E2 Problem

Hi, I hope this is the right section…

I found this code and i really want to make it works but it’s very glitchy…When i spawn it the prop attacks me using its tail instead of head and i don’t know what to do.I tried to fix it changing E:applyforce in applyforce, Headbone:applyforce or similar but it’s still messed up, if i use Headbone…using only applyforce without E: or Headbone: makes the E2 flying against wall or ground in my direction.I’ll give you the original code,sorry if it’s messed up but when I did some test on it i forgot to remove some nonsense random things.I “optimized” this shit and now it works well but it still uses the tail for attacking target and it has got 600 ops 0.0

You can find the necessary model here: https://steamcommunity.com/sharedfil.../?id=310621704


@name test giant ragdoll
@inputs 
@outputs 
@persist  Targ:entity Player:entity  Sounds:array Delay Soundhit:array Soundpain:array
@trigger 
E=entity():isWeldedTo()
if(E:model()!="models/xenians/tentacle.mdl") 
    {
        selfDestruct()
    }
runOnTick(1)
 if(first()){
        entity():setAlpha(0)
        Sounds[1, string] = "npc/strider/striderx_alert2.wav"
        Sounds[2, string] = "npc/strider/striderx_alert4.wav"
        Sounds[3, string] = "npc/strider/striderx_alert5.wav"
        Sounds[4, string] = "npc/strider/striderx_alert6.wav"
        Soundhit[1,string] = "npc/strider/strider_step1.wav"
        Soundhit[2,string] = "npc/strider/strider_step2.wav"
        Soundhit[3,string] = "npc/strider/strider_step3.wav"
        Soundhit[4,string] = "npc/strider/strider_step4.wav"
        Soundhit[5,string] = "npc/strider/strider_step5.wav"
        Soundhit[6,string] = "npc/strider/strider_step6.wav"
        Soundhit[7,string] = "npc/strider/strider_step7.wav"
        Soundpain[1,string] = "npc/zombie_poison/pz_pain1.wav"
        Soundpain[2,string] = "npc/zombie_poison/pz_pain2.wav"
        Soundpain[3,string] = "npc/strider/striderx_pain8.wav"
        Soundpain[4,string] = "npc/zombie_poison/pz_die2.wav"
        Soundpain[5,string] = "npc/zombie_poison/pz_die1.wav"
        soundPlay(1,100,"npc/zombie_poison/pz_breathe_loop1.wav")
}
O=owner()
if(findCanQuery())
{   
    findByClass("player")
    findSortByDistance(E:pos())

    Targ = findClosest(E:pos())
}
Headbone=E:bone(10)
Tailbone=E:bone(0)
Pos=Targ:shootPos()
if ((E:pos():distance(Pos) < 100) & !Delay) {
    Force = 10^12
    E:applyForce(((Targ:pos()-E:pos())*3-E:vel())*E:mass())
    Delay = 1
} else {
if(O:keyPressed("H")){
    Force = 5
    E:applyForce(((Targ:pos()-E:pos())*550-E:vel())*E:mass())
    Base = vec(0,0,220)
Tailbone:applyForce(Base*7.5)
Headbone:applyForce(-Base)
}
}
if (clk("delay")) {Delay = 0}
Base = vec(0,0,120)
Tailbone:applyForce(Base*7.5)
Headbone:applyForce(-Base)
if(!Delay){
    timer("breath",3715)
    
}
if(Headbone:pos():distance(Pos) <350){
    timer("delay",8500)
if(clk("delay")){

    Targ:soundPlay(0,0,Sounds:string(round(random(5))))
}
}
if(clk("breath")){
    
soundPlay(1,100,"npc/zombie_poison/pz_breathe_loop1.wav")
}

if(O:keyPressed("J")){
    timer("pain",1)
    E:applyForce(((Targ:pos()-E:pos())*-150-E:vel())*E:mass())
    Tailbone:applyForce(Base*-7.5)
    E:propNotSolid(1)
}else{stoptimer("pain")
E:propNotSolid(0)}


if(clk("pain")){
    Targ:soundPlay(0,0,Soundpain:string(round(random(5)))) timer("pain",10000)
}

if(O:keyAttack1() & O:keyAttack2() & O:keyPressed("E")){
    selfDestruct()
}

if(O:keyPressed("L")){
Targ:soundPlay(3,10,Sounds:string(round(random(5))))
}