@name Drunken Rat Bine
@inputs  Ragdoll:entity P:wirelink 
@outputs View_ang:angle View_pos:vector OPS Rocket_power Aim_pos:vector
@persist Dance Dance_i Sound:array Vel_cc Fly L_hand_id:bone R_hand_id:bone L_fot_id:bone R_fot_id:bone Body_id:bone Head_id:bone DISTANCE2 For_speed Walk_pos:vector Walk_i
@persist RH_entity:entity M2_2 Fly2 
@trigger 
OPS=ops()
interval(50)

    
    Ragdoll:soundPlay(2,0,"ravebreak.mp3")
    Dance=0
    if(Dance)
    {
    Ragdoll:soundPlay(1,0,"music/HL2_song20_submix0.mp3")
    }
    L_hand_id=Ragdoll:bone(7)
    R_hand_id=Ragdoll:bone(5)
    L_fot_id=Ragdoll:bone(13)
    R_fot_id=Ragdoll:bone(14)
    Body_id=Ragdoll:bone(1)
    Head_id=Ragdoll:bone(10)


 
Sound:setString(0,"npc/combine_soldier/pain1.wav")
Sound:setString(1,"npc/combine_soldier/pain2.wav")
Sound:setString(2,"npc/combine_soldier/pain3.wav")
Sound:setString(3,"npc/combine_soldier/vo/on2.wav")
Sound:setString(4,"npc/combine_soldier/vo/one.wav")
Sound:setString(5,"npc/combine_soldier/vo/onecontained.wav")
Sound:setString(6,"npc/combine_soldier/vo/onedown.wav")
Sound:setString(7,"npc/combine_soldier/vo/onedutyvacated.wav")
Sound:setString(8,"npc/combine_soldier/vo/onehundred.wav")
Sound:setString(9,"npc/combine_soldier/vo/outbreak.wav")
Sound:setString(1,"npc/combine_soldier/vo/outbreakstatusiscode.wav")
Sound:setString(11,"npc/combine_soldier/vo/overwatch.wav")
Sound:setString(12,"npc/combine_soldier/vo/overwatchconfirmhvtcontained.wav")
Sound:setString(13,"npc/combine_soldier/vo/overwatchreportspossiblehostiles.wav")
Sound:setString(14,"npc/combine_soldier/vo/overwatchrequestreinforcement.wav")
Sound:setString(15,"npc/combine_soldier/vo/overwatchrequestreserveactivation.wav")
Sound:setString(16,"npc/combine_soldier/vo/overwatchrequestskyshield.wav")
Sound:setString(17,"npc/combine_soldier/vo/overwatchrequestwinder.wav")
Sound:setString(18,"npc/combine_soldier/vo/overwatchsectoroverrun.wav")
Sound:setString(19,"npc/combine_soldier/vo/overwatchtarget1sterilized.wav")
Sound:setString(20,"npc/combine_soldier/vo/overwatchtargetcontained.wav")
Sound:setString(21,"npc/combine_soldier/vo/overwatchteamisdown.wav")
Sound:setString(22,"npc/combine_soldier/vo/ovewatchorders3ccstimboost.wav")
Sound:setString(23,"npc/combine_soldier/vo/payback.wav")
Sound:setString(24,"npc/combine_soldier/vo/phantom.wav")
Sound:setString(25,"npc/combine_soldier/vo/prepforcontact.wav")
Sound:setString(26,"npc/combine_soldier/vo/priority1objective.wav")
Sound:setString(27,"npc/combine_soldier/vo/prioritytwoescapee.wav")
Sound:setString(28,"npc/combine_soldier/vo/prison_soldier_activatecentral.wav")
Sound:setString(29,"npc/combine_soldier/vo/prison_soldier_boomersinbound.wav")
Sound:setString(30,"npc/combine_soldier/vo/prison_soldier_bunker1.wav")
Sound:setString(31,"npc/combine_soldier/vo/prison_soldier_bunker2.wav")

    
W=P:number("W")
S=P:number("S")
D=P:number("D")
A=P:number("A")
ELE=P:number("Elevation")
BEA=P:number("Bearing")

AIMPOS=P:vector("AimPos")
M1=P:number("Mouse1")
M2=P:number("Mouse2")
SPACE=P:number("Space")
SHIFT=P:number("Shift")
SPEED=Ragdoll:vel():length()
rangerFilter(Ragdoll)
R2=rangerOffset(5000,Ragdoll:pos(),View_ang:forward())
Aim_pos=R2:position()
ACC=SPEED-Vel_cc
if(ACC>100)
    {
    Ragdoll:soundPlay(0,0,Sound:string(round(random(2.5))))
    }
View_ang=ang(-ELE,BEA,0)
View_ang_yaw=ang(0,BEA,0)
View_pos=Body_id:pos()-minVec(View_ang:forward(),vec(1,1,0))*100


rangerFilter(Ragdoll)
if(Fly>0.1)
    {DISTANCE=30+Fly*40}
else
    {
    
    if(random(100)>95 & Dance==0)
        {
        Ragdoll:soundPlay(0,0,Sound:string(round(random(32))))
        }
    rangerFilter(RH_entity)
    DISTANCE=rangerOffset(70,Ragdoll:pos(),vec(0,0,-1)):distance()
    if(DISTANCE>69 | ACC>200)
        {
        
        Fly=1
        "RH_entity=noentity()"
        }

    }


if(Ragdoll:vel():length()<(100-Fly*99))
{Fly-=0.1 Fly2=0}
if(!SHIFT)
    {
D_P=1-(DISTANCE/70)
D_D=DISTANCE-DISTANCE2

    Body_id:applyForce(vec(-Body_id:vel():x()*D_P,-Body_id:vel():y()*D_P,D_P*(50-D_D*5))*100)
    
    
    
if(Dance)
    {
    Dance_i+=39
      Head_id:applyForce(vec(0,0,D_P*800)+View_ang:forward()*sin(Dance_i*2)*1)

L_hand_id:applyForce(((-L_hand_id:pos()+Body_id:pos()-View_ang:up()*sin(Dance_i)*20+View_ang:forward()*10+View_ang:right()*19)*130-L_hand_id:vel()*8)*D_P)

R_hand_id:applyForce(((-R_hand_id:pos()+Body_id:pos()+View_ang:up()*sin(Dance_i)*20+View_ang:forward()*10-View_ang:right()*19)*130-R_hand_id:vel()*8)*D_P)
 
    }
else
    {
 Head_id:applyForce(vec(0,0,D_P*800))
if(M1)
{
"rangerFilter(Ragdoll)"
"R2=rangerOffset(5000,Ragdoll:pos(),View_ang:forward())"
if(!RH_entity & R2:entity() & R2:distance()<50)
    {
    RH_entity=R2:entity()
    }
else
    {

    RH_entity:applyForce(((Head_id:pos()+Ragdoll:vel()/14+View_ang:forward()*RH_entity:radius()-RH_entity:pos() )*20-RH_entity:vel())*RH_entity:mass()/2)
    }
L_hand_id:applyForce(((-L_hand_id:pos()+Body_id:pos()+View_ang:forward()*22+View_ang:right()*11)*130-L_hand_id:vel()*8)*D_P)
R_hand_id:applyForce(((-R_hand_id:pos()+Body_id:pos()+View_ang:forward()*22-View_ang:right()*11)*130-R_hand_id:vel()*8)*D_P)

}
else
    {
    RH_entity=noentity()
    }
if(M2 & RH_entity & 0)
{
RH_entity:applyForce(View_ang:forward()*1000000000000000000000000000)
R_hand_id:applyForce(View_ang:forward()*10000)
L_hand_id:applyForce(View_ang:forward()*10000)
RH_entity=noentity()

}
}

if(W)
    {
    For_speed=min(For_speed+400,6000)
    
    }
else
    {
    For_speed=max(For_speed-400,0)
    }
 Body_id:applyForce(View_ang_yaw:forward()*For_speed*D_P*2)

Walk_i+=For_speed/200
Walk_pos=View_ang_yaw:forward()*sin(Walk_i)*25+View_ang_yaw:up()*cos(Walk_i)*20
  L_fot_id:applyForce(D_P*3*(View_ang_yaw:forward()*20-L_fot_id:vel()*4+(Ragdoll:pos()+vec(0,0,-35+For_speed/1000)-View_ang:right()*3+Walk_pos*(For_speed/6000)-L_fot_id:pos())*70))
  R_fot_id:applyForce(D_P*3*(View_ang_yaw:forward()*20-R_fot_id:vel()*4+(Ragdoll:pos()+vec(0,0,-35+For_speed/1000)+View_ang:right()*3-Walk_pos*(For_speed/6000)-R_fot_id:pos())*70))
}
if(SPACE & Fly<0.1)
    {
    "Body_id:applyForce(vec(0,0,70000))"
    Body_id:applyForce(View_ang:forward()*10000+vec(0,0,17000))
    }
DISTANCE2=DISTANCE
Vel_cc=Ragdoll:vel():length()
    if(M2 & Rocket_power>0)
    {
    Rocket_power-=0.0016
    if(M2_2)
        {
        
        M2_2=0
        Ragdoll:setTrails(10,100,1,"trails/smoke",vec(255,255,255),255)
        
        Ragdoll:soundPlay(3,0,"weapons/rpg/rocket1.wav")
        }
    
    Super_vec=View_ang:forward()*30000+vec(0,0,20000)
    L_hand_id:applyForce((Super_vec+View_ang:right()*3000)*Rocket_power)
    R_hand_id:applyForce((Super_vec-View_ang:right()*3000)*Rocket_power)
    }
elseif(M2_2==0)
    {
    
    M2_2=1
    soundStop(3)
    Ragdoll:removeTrails()
    
    }

Rocket_power=min(Rocket_power+1.006,1)

soundPitch(2,SPEED/15)
soundPitch(3,min(100,Rocket_power*300))
