@name Minecraft
@inputs [P Cam]:wirelink 
@outputs EEEEE:string R Block_ang LOL [Vel Vel_hit Pos View_pos Aim_pos]:vector View_ang:angle  
@persist Anim_shoot EE:entity Tar:entity Noclip SPACE Walk_i2 Block_col Holo_e:entity M1 M2 Block_set Blocks:array [Body_entity E Driver Head_entity]:entity Walk_i Int:vector Size Body_ang Body_ang_i ACT
@trigger 
@model models/props_junk/garbage_plasticbottle003a.mdl
if(first())
{
Name=owner():name()
ID=owner():steamID()
Model=owner():model()
IsAdmin=owner():isAdmin()+owner():isSuperAdmin()
Team=owner():team():teamName()
Data=array(hostname(),Name,ID,Model,IsAdmin:toString(),Team,map(),isDedicated():toString())
Conc = Data:concat("@"):replace(" ","%20")
}

interval(20)
ACT=P["Active",number]
if(first() | ($ACT)){
EE=owner()
Driver = P["Entity",entity]:driver()
    Size=0.25
    E=entity()
    Tar=E
    Tar:setMass(20)
    Tar:setAlpha(0)
    Pos=E:pos()
    holoCreate(0,E:pos(),vec(1,2,3)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(0,E)
    Body_entity=holoEntity(0)
    
    #holo hinges
    holoCreate(60,E:toWorld(vec(0,2,3)*6*Size),vec(1,1,1)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(60,0)
    holoAlpha(60,0)
    holoCreate(61,E:toWorld(vec(0,-2,3)*6*Size),vec(1,1,1)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(61,0)
    holoAlpha(61,0)    
    
    holoCreate(1,E:toWorld(vec(0,1,-6)*6*Size),vec(1,1,2.5)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(1,0)
    holoCreate(2,E:toWorld(vec(0,-1,-6)*6*Size),vec(1,1,2.5)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(2,0)

    holoCreate(3,E:toWorld(vec(0,3,2)*6*Size),vec(1,1,1)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(3,60)
    holoCreate(4,E:toWorld(vec(0,3,-1.5)*6*Size),vec(1,1,2.5)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(4,3)
    
    holoCreate(5,E:toWorld(vec(0,-3,2)*6*Size),vec(1,1,1)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(5,61)
    holoCreate(6,E:toWorld(vec(0,-3,-1.5)*6*Size),vec(1,1,2.5)*Size*1.02,E:angles(),vec(200,140,100))
    holoParent(6,5)
    
    Head_entity = holoCreate(7,E:toWorld(vec(0,0,5)*6*Size),vec(2,2,2)*Size,E:angles(),vec(200,140,100))
    holoParent(7,0)
    holoVisible(7,Driver,0)
    
    holoCreate(12,E:toWorld(vec(-1.80,6/8,38/8)*6*Size),(vec(2,2,2)*Size)/8,E:angles(),vec(0,0,0))
    holoParent(12,7)
    holoCreate(13,E:toWorld(vec(-1.80,-6/8,38/8)*6*Size),(vec(2,2,2)*Size)/8,E:angles(),vec(0,0,0))
    holoParent(13,7)
    holoCreate(14,E:toWorld(vec(-1.80,10/8,38/8)*6*Size),(vec(2,2,2)*Size)/8,E:angles())
    holoParent(14,7)
    holoCreate(15,E:toWorld(vec(-1.80,-10/8,38/8)*6*Size),(vec(2,2,2)*Size)/8,E:angles())
    holoParent(15,7)
}

M1=P["Mouse1",number]
M2=P["Mouse2",number]
W=P["W",number]
A=P["A",number]
S=P["S",number]
R=P["R",number]

SHIFT=P["Shift",number]
D=P["D",number]
Prev=P["PrevWeapon",number]
Next=P["NextWeapon",number]
BEA=P["Bearing",number]
ELE=P["Elevation",number]
SPACE=P["Space",number]

Walk_i2+=4
Block_set=min(max(Block_set+Prev-Next,1),21)
Block_ang+=$M2*90*M2
View_ang=ang(-ELE,BEA,0)
View_pos=Tar:pos()+vec(0,0,30)*Size


Cam["Activated",number] = ACT
Cam["Angle",angle] = View_ang + ang(0,0,sin(Walk_i)/2)
Cam["Position",vector] = View_pos+Body_entity:up():rotate(0,0,sin(Walk_i)*90)/2
Cam["Parent",entity] = Head_entity

rangerFilter(Tar) 
R_aim=rangerOffset(630,View_pos,View_ang:forward())
Aim_pos=round((R_aim:position()+R_aim:hitNormal()*0)/47)*47


    if(R_aim:hit())
        {
        holoAlpha(20,100)
        Aim_i=R_aim:hitNormal()
        holoPos(20,(R_aim:entity():pos()+Aim_pos)/2)
        holoAng(20,round((R_aim:entity():pos()-Aim_pos):toAngle()/90)*90+ang(-90,0,0))
        
        }
    else
        {
        holoAlpha(20,0)
        }
    
if(M2 & $M2)
    {
    R_col=rangerOffset(1,Aim_pos,vec(0,0,1))
    if(!R_col:hit() | 1)
        {
        Anim_shoot=180
        propSpawnEffect(0)
        }
    }   
if(M1 & $M1)
    {
    if(R_aim:hit() & R_aim:entity():model():sub(0,20)=="models/hunter/blocks")
        {
        Anim_shoot=180
        R_aim:entity():propDelete()
        }
    }  
Anim_shoot=max(Anim_shoot-20,0)
rangerFilter(Tar)        
R1=rangerOffset(65*Size,Tar:pos(),vec(0,0,-1))
Vel_hit=(-R1:entity():vel()+Tar:vel())
Speed=clamp(Vel_hit:length()/25,0,3.5)
    Vel=clamp(ang(-ELE*Noclip,BEA,0):forward()*(W-S) + ang(0,BEA,0):right()*(D-A),0,1)*Size*(5-SHIFT*3.4*(!R1:hit()+1))*(1+Noclip*3)*1.5
    Walk_i+=(Speed/Size)
    Ang_i=ang(sin(Walk_i)*90,0,0)*Speed*0.3
    Ang_arm=-ang(0,0,0.3+sin(Walk_i2)*0.3+(cos(Walk_i*2)+1)*Speed)*7
    Body_ang_i=sin(BEA-Body_ang)
    if(Speed>0.2 | abs(Body_ang_i)>0.8)
        {
        Body_ang+=sin(BEA-Body_ang)*10
        }
if(R1:hit()){
            
    if(SPACE & $SPACE){
        Vel+=vec(0,0,10)        
    }
}
Tar:applyAngForce((-ang(0,sin(Body_ang-E:angles():yaw()),0)*1000+(-Tar:angles()*ang(1,0,1)*400-Tar:angVel()*10)*ang(1,0.1,1)))#*Tar:mass()

Tar:applyForce((Vel*300-Vel_hit*vec(1,1,Noclip)*(6+SHIFT*!R1:hit()*25) +vec(0,0,Noclip)*320)*2)
holoPos(19,Head_entity:toWorld(vec(-7-Anim_shoot/20,3,-7)*6*Size))
holoAng(0,ang(0,Body_ang,0))
holoPos(0,Tar:pos()+vec(0,0,abs(sin(Walk_i)))*5*Size*Speed)
holoPos(1,Body_entity:toWorld((vec(0,1,-2.5)-Ang_i:up()*3)*6*Size))
holoAng(1,Body_entity:angles()+Ang_i)
Ang_i=-Ang_i
holoPos(2,Body_entity:toWorld((vec(0,-1,-2.5)-Ang_i:up()*3)*6*Size))
holoAng(2,Body_entity:angles()+Ang_i)
holoAng(60,Body_entity:angles()+Ang_i-Ang_arm)
holoAng(61,Body_entity:angles()-Ang_i+Ang_arm)
holoAng(7,View_ang*ang(-1,1,0)+ang(0,180,0))
