@persist [PlayerTarget Prop E Base Pivot]:entity
@persist [C1 C2 C3 C4 C5]:vector
@persist [Anim SmAnim Hold NumBlades I J Time Deploy Fire M1 M2 Reload Use Spinner]
@persist [Stab Dist]:array

#Thanks to The Sandvich Maker for this
function void holoStyle(Index,Position:vector,Scale:vector,Angle:angle,Colour:vector,Model:string)
{
    holoPos(Index,Position)
    holoScale(Index,Scale)
    holoAng(Index,Angle)
    holoColor(Index,Colour)
    holoModel(Index,Model)    
}

runOnTick(1)

if(first())
{
    NumBlades = 8  #How many swords to spawn. Any number >=1 will work, but you will hit the default holograms limit at 9 or so
    #If you're crazy you can use "wire_expression2_unlimited 1" in singleplayer and spawn up to 34, but it WILL lag the shit out of you!
    
    entity():setAlpha(0)
    PlayerTarget = owner()
    C1 = vec(80,80,80) # Dark grey
    C2 = vec(255,213,109) # Gold
    C3 = vec(140,140,140) #Light grey
    C4 = vec(40,40,40) #Darker grey
    C5 = vec(160,255,170) #Green
 
    for(I=1,NumBlades)
    {
        Stab[I,number] = 0    
    }
    
    Pivot = holoCreate(5000) holoScale(5000,vec()) holoParent(5000,entity()) 
    Base = holoCreate(5001,Pivot:toWorld(vec(0,0,0)),vec(0.1,0.1,0.1),Pivot:toWorld(ang(0,0,0)),C5,"models/hunter/tubes/tube1x1x8.mdl") holoParent(5001,0) 
    holoAlpha(5001,0) holoMaterial(5001,"models/alyx/emptool_glow")
    holoPos(5000,owner():pos()+vec(0,0,55))
    holoAng(5000,owner():angles())
    holoParent(5000,owner())
    rangerDefaultZero(0)
    print("Puppeteer: Spawning " + NumBlades * 29 + " holograms, please wait...")
}

#Spawn a whole lot of holograms
while(holoCanCreate()&J<=NumBlades*29)
{
    holoCreate(J) holoScale(J,vec())
    J++
}

#Style the holos
if(J>=NumBlades*29 & I <=NumBlades*29)
{
    #Blade base
    holoStyle(I , Pivot:toWorld(vec(0,0,10)),vec(),Pivot:toWorld(ang()),vec(),"cube") holoAlpha(I,5000)
    holoStyle(I+1 , Pivot:toWorld(vec(0,0,10)),vec(0.4,0.4,0.4),Pivot:toWorld(ang(0,0,90)),C2,"hq_torus_thick")  holoParent(I+1,I)
    holoStyle(I+2 , Pivot:toWorld(vec(0,0,10)),vec(0.3,0.3,0.1),Pivot:toWorld(ang(0,0,90)),C1,"hq_cylinder") holoParent(I+2,I) #Makeshift hinge
    
    #Standby symbols
    if(holoModelAny()){
        holoStyle(I+3 , Pivot:toWorld(vec(0,0,10)),vec(0.45,0.45,0.5),Pivot:toWorld(ang(0,0,90)),vec(255,255,255),"models/cheeze/buttons2/pwr_green.mdl") holoParent(I+3,I)
        holoStyle(I+4 , Pivot:toWorld(vec(0,0,10)),vec(0.45,0.45,0.5),Pivot:toWorld(ang(0,0,-90)),vec(255,255,255),"models/cheeze/buttons2/pwr_green.mdl") holoParent(I+4,I)
    }
    else
    {
        holoAlpha(I+3,0) 
        holoAlpha(I+4,0) 
    }
    
    #Handle
    holoStyle(I+5 , Pivot:toWorld(vec(2.8,0,10)),vec(0.11,0.07,0.15),Pivot:toWorld(ang(90,0,0)),C3,"hq_cylinder") holoParent(I+5,I+2)
    holoStyle(I+6 , Pivot:toWorld(vec(5.2,0,10)),vec(0.10,0.06,0.3),Pivot:toWorld(ang(90,0,0)),C1,"hq_cylinder") holoParent(I+6,I+2)
    holoStyle(I+7 , Pivot:toWorld(vec(7.5,0,10)),vec(0.11,0.07,0.14),Pivot:toWorld(ang(90,0,0)),C3,"hq_cylinder") holoParent(I+7,I+2)
    
    #Bridge
    holoStyle(I+8 , Pivot:toWorld(vec(-4,0,10)),vec(0.35,0.07,0.06),Pivot:toWorld(ang(0,0,0)),C4,"cube") holoParent(I+8,I)
    holoStyle(I+9 , Pivot:toWorld(vec(-10.4,0,9.75)),vec(1.4,0.04,0.13),Pivot:toWorld(ang(0,0,0)),C1,"cube") holoParent(I+9,I)
    holoStyle(I+10 , Pivot:toWorld(vec(-10,0,9)),vec(0.02,0.03,1.45),Pivot:toWorld(ang(90,0,0)),C3,"hq_cylinder") holoParent(I+10,I)
    
    #Blade parts
    holoStyle(I+11 , Pivot:toWorld(vec(0,0,15.4)),vec(2,0.9,0.02),Pivot:toWorld(ang(0,0,90)),C3,"hq_tube_thin") holoParent(I+11,I)
    holoClipEnabled(I+11,1,1) holoClipEnabled(I+11,2,1) holoClipEnabled(I+11,3,1)
    holoClip(I+11,1,vec(),vec(-1,0,0),0) holoClip(I+11,2,vec(-10,0,0),vec(1,0,0),0) holoClip(I+11,3,vec(0,0,0),vec(0,-1,0),0)

    holoStyle(I+12 , Pivot:toWorld(vec(-20,0,15.09)),vec(2,0.75,0.02),Pivot:toWorld(ang(0,0,90)),C3,"hq_tube_thin") holoParent(I+12,I)
    holoClipEnabled(I+12,1,1) holoClipEnabled(I+12,2,1) holoClipEnabled(I+12,3,1)
    holoClip(I+12,1,vec(1.35,0,0),vec(1,0,0),0) holoClip(I+12,2,vec(10,0,0),vec(-1,0,0),0) holoClip(I+12,3,vec(0,0,0),vec(0,-1,0),0)
    
    holoStyle(I+13 , Pivot:toWorld(vec(-1,0,13.5)),vec(2,0.7,0.04),Pivot:toWorld(ang(0,0,90)),C1,"hq_tube") holoParent(I+13,I)
    holoClipEnabled(I+13,1,1) holoClipEnabled(I+13,2,1) holoClipEnabled(I+13,3,1)
    holoClip(I+13,1,vec(3,0,0),vec(-1,0,0),0) holoClip(I+13,2,vec(-8.92,0,0),vec(1,0,0),0) holoClip(I+13,3,vec(0,0,0),vec(0,-1,0),0)

    holoStyle(I+14 , Pivot:toWorld(vec(-18.8,0,13.5)),vec(2,0.6,0.04),Pivot:toWorld(ang(0,0,90)),C1,"hq_tube") holoParent(I+14,I)
    holoClipEnabled(I+14,1,1) holoClipEnabled(I+14,2,1) holoClipEnabled(I+14,3,1)
    holoClip(I+14,1,vec(0,0,0),vec(1,0,0),0) holoClip(I+14,2,vec(8.92,0,0),vec(-1,0,0),0) holoClip(I+14,3,vec(0,0,0),vec(0,-1,0),0)
    
    #Green strip
    holoStyle(I+15 , Pivot:toWorld(vec(-12,0,10.1)),vec(1.13,0.05,0.03),Pivot:toWorld(ang(0,0,0)),C5,"cube") holoParent(I+15,I)
    
    #Patching a hole
    holoStyle(I+16 , Pivot:toWorld(vec(-10.5,0,10.5)),vec(0.25,0.04,0.2),Pivot:toWorld(ang(0,0,0)),C1,"cube") holoParent(I+16,I)
    
    #End cap
    holoStyle(I+17 , Pivot:toWorld(vec(-18.9,0,9.7)),vec(0.04,0.08,0.15),Pivot:toWorld(ang(0,0,0)),C4,"cube") holoParent(I+17,I)
    holoStyle(I+18 , Pivot:toWorld(vec(-18.9,0,10.93)),vec(0.08,0.04,0.05),Pivot:toWorld(ang(0,90,0)),C4,"prism") holoParent(I+18,I)
    
    #Section B
    holoStyle(I+19 , Pivot:toWorld(vec(-19.1,0,9.7)),vec(0.04,0.08,0.15),Pivot:toWorld(ang(0,0,0)),C4,"cube") holoParent(I+19,I) #Makeshift hinge again
    holoStyle(I+20 , Pivot:toWorld(vec(-19.1,0,10.9)),vec(0.08,0.04,0.05),Pivot:toWorld(ang(0,90,0)),C4,"prism") holoParent(I+20,I+19)
    
    #Blade parts again
    holoStyle(I+21 , Pivot:toWorld(vec(-15,0,15.4)),vec(2,0.9,0.02),Pivot:toWorld(ang(0,0,90)),C3,"hq_tube_thin") holoParent(I+21,I+19)
    holoClipEnabled(I+21,1,1) holoClipEnabled(I+21,2,1) holoClipEnabled(I+21,3,1)
    holoClip(I+21,1,vec(-4,0,0),vec(-1,0,0),0) holoClip(I+21,2,vec(-10,0,0),vec(1,0,0),0) holoClip(I+21,3,vec(0,0,0),vec(0,-1,0),0)
    
    holoStyle(I+22 , Pivot:toWorld(vec(-25.02,0,11.25)),vec(2,0.02,0.385),Pivot:toWorld(ang(0,0,0)),C3,"prism") holoParent(I+22,I+19)
    holoClipEnabled(I+22,1,1)
    holoClip(I+22,1,vec(),vec(-1,0,0),0)
    
    holoStyle(I+23 , Pivot:toWorld(vec(-15.5,0,12.92)),vec(2.15,0.54,0.04),Pivot:toWorld(ang(0,0,90)),C1,"hq_tube") holoParent(I+23,I+19)
    holoClipEnabled(I+23,1,1) holoClipEnabled(I+23,2,1) holoClipEnabled(I+23,3,1)
    holoClip(I+23,1,vec(-3.5,0,0),vec(-1,0,0),0) holoClip(I+23,2,vec(-9.5,0,0),vec(1,0,0),0) holoClip(I+23,3,vec(0,0,0),vec(0,-1,0),0)
    
    holoStyle(I+24 , Pivot:toWorld(vec(-24,0,-10)),vec(2.8,3.75,0.04),Pivot:toWorld(ang(0,0,90)),C1,"hq_cylinder") holoParent(I+24,I+19)
    holoClipEnabled(I+24,1,1) holoClipEnabled(I+24,2,1)
    holoClip(I+24,1,vec(-1,0,0),vec(-1,0,0),0) holoClip(I+24,2,vec(0,18.9,0),vec(0,1,0),0)
    
    holoStyle(I+25 , Pivot:toWorld(vec(-26,0,9.8)),vec(1.2,0.04,0.16),Pivot:toWorld(ang(0,0,0)),C1,"cube") holoParent(I+25,I+19)
    holoClipEnabled(I+25,1)
    holoClip(I+25,vec(-5.4,0,0),vec(1,0,-2),0)
    
    #Green strip
    holoStyle(I+26 , Pivot:toWorld(vec(-24.5,0,10.1)),vec(0.9,0.05,0.03),Pivot:toWorld(ang(0,0,0)),C5,"cube") holoParent(I+26,I+19)
    holoStyle(I+27 , Pivot:toWorld(vec(-20.5,0,10.2)),vec(0.2,0.06,0.08),Pivot:toWorld(ang(0,0,0)),C4,"cube") holoParent(I+27,I+19)
    holoStyle(I+28 , Pivot:toWorld(vec(-20.5,0,10.2)),vec(0.16,0.065,0.04),Pivot:toWorld(ang(0,0,0)),C2,"cube") holoParent(I+28,I+19)
    
    holoPos(I,entity():pos() + vec(0,I/10,0))
    rangerFilter(owner())
    rangerPersist(1)
    
    I+=29   
    #Thank you based sandvich
}

#If all holos have finished spawning/styling
if(I >= NumBlades*29)
{
    #WARNING: Spaghetti code ahead
    if(Deploy>=100){
    #Inputs
        if(owner():weapon():type() == "weapon_crowbar"|owner():weapon():type() == "laserpointer")
        {
            M1 = owner():keyAttack1()
            M2 = owner():keyAttack2()
