@name [TOX TEC] Sprops Coils
@inputs [Left_Wheel Right_Wheel Base]:wirelink 
@persist W1:entity W2:entity
if(changed(Base)&Base){
B=Base:entity()
}
if(first()|dupefinished()){
Scale=0.35
MATERIAL                        = "WTP/metal_2"#"debug/debugdrawflat"#"models/shiny"#"WTP/chrome_1"#"Phoenix_storms/fender_white"
Coil_Color                      = vec(100,20,20)
ShockTop_color                  = vec(50,50,50)
Shock_color                     = vec(50,50,50)
Spring_Distance_from_wheel      = -1
Spring_Distance_from_Base       = -3
Spring_hight                    = 3
SKIN                            = 2



### visual holos ##
# holo 10 = top part of left spring
# holo 11 = top part of right spring
# holo 12 = bottom part of left spring
# holo 13 = bottom part of right spring
    holoCreate(10)
    holoParent(10,B)
    holoScale(10,vec(1)*Scale)
    holoModel(10,"models/sprops/trans/misc/shock_3.mdl")
    holoBodygroup(10,0,4)
    holoSkin(10,SKIN)
    holoColor(10,ShockTop_color)
    holoCreate(11)
    holoParent(11,B)
    holoScale(11,vec(1)*Scale)
    holoModel(11,"models/sprops/trans/misc/shock_3.mdl")
    holoBodygroup(11,0,4)
    holoSkin(11,SKIN)
    holoColor(11,ShockTop_color)
    holoCreate(12)
    holoParent(12,B)
    holoScale(12,vec(1)*Scale)
    holoModel(12,"models/sprops/trans/misc/shock_2.mdl")
    holoBodygroup(12,0,3)
    holoSkin(12,1)
    holoColor(12,Shock_color)
    holoCreate(13)
    holoParent(13,B)
    holoScale(13,vec(1)*Scale)
    holoModel(13,"models/sprops/trans/misc/shock_2.mdl")
    holoBodygroup(13,0,3)
    holoSkin(13,1)
    holoColor(13,Shock_color)
    
    holoCreate(14)
    holoParent(14,B)
    holoScale(14,vec(0.5)*Scale)
    holoModel(14,"models/sprops/trans/misc/coil.mdl")
    holoBodygroup(14,0,2)
    holoMaterial(14,MATERIAL)
    holoColor(14,Coil_Color)
    
    holoCreate(15)
    holoParent(15,B)
    holoScale(15,vec(0.5)*Scale)
    holoModel(15,"models/sprops/trans/misc/coil.mdl")
    holoBodygroup(15,0,2)
    holoMaterial(15,MATERIAL)
    holoColor(15,Coil_Color)
}
if (W1|W2|B){
   interval(33)



if(changed(Left_Wheel)&Left_Wheel){ 
    W1=Left_Wheel:entity()
  
  W1_PosX = B:toLocal( W1:pos() ):x()
  
holoCreate(1)
holoPos(1,B:toWorld(vec(W1_PosX,Spring_Distance_from_Base,Spring_hight)))  
holoParent(1,B)
holoScale(1,vec(0.2))
holoAng(1,B:toWorld(ang(90,0,0)))
holoColor(1,vec4(0))
holoCreate(2)
holoPos(2,W1:toWorld(vec(0,0,Spring_Distance_from_wheel)))  
holoParent(2,W1)
holoScale(2,vec(0.2))
holoAng(2,B:toWorld(ang(0)))
holoColor(2,vec4(0))
}

if(changed(Right_Wheel)&Right_Wheel){ 
    W2=Right_Wheel:entity()
  
  W2_PosX = B:toLocal( W2:pos() ):x()
  
holoCreate(3)
holoPos(3,B:toWorld(vec(W2_PosX,-Spring_Distance_from_Base,Spring_hight)))  
holoParent(3,B)
holoScale(3,vec(0.2))
holoAng(3,B:toWorld(ang(90,0,0)))
holoColor(3,vec4(0))
holoCreate(4)
holoPos(4,W2:toWorld(vec(0,0,-Spring_Distance_from_wheel)))  
holoParent(4,W2)
holoScale(4,vec(0.2))
holoAng(4,B:toWorld(ang(0,0,0)))
holoColor(4,vec4(0))
}
if(first()|dupefinished()){
    holoPos(10,holoEntity(1):toWorld(vec(0)))
    holoPos(11,holoEntity(3):toWorld(vec(0)))
    
}
Ele1=holoEntity(1):elevation(holoEntity(2):pos())
Bear1=holoEntity(1):bearing(holoEntity(2):pos())
Ele2=holoEntity(3):elevation(holoEntity(4):pos())
Bear2=holoEntity(3):bearing(holoEntity(4):pos())
Length1=holoEntity(1):toLocal(holoEntity(2):pos()):length()/35.25
Length2=holoEntity(3):toLocal(holoEntity(4):pos()):length()/35.25
holoPos(14,holoEntity(10):toWorld(vec(0,0,0.5)))
holoPos(15,holoEntity(11):toWorld(vec(-0,0,0.5)))

holoPos(12,holoEntity(2):toWorld(vec(0)))
holoPos(13,holoEntity(4):toWorld(vec(0)))
holoAng(10,holoEntity(1):toWorld(ang(90-Ele1,-Bear1,0)))
holoAng(12,holoEntity(1):toWorld(ang(-90-Ele1,-Bear1,0)))
holoAng(11,holoEntity(3):toWorld(ang(90-Ele2,0-Bear2,0)))
holoAng(13,holoEntity(3):toWorld(ang(-90-Ele2,0-Bear2,0)))
holoAng(14,holoEntity(1):toWorld(ang(90-Ele1,0-Bear1,0)))
holoAng(15,holoEntity(3):toWorld(ang(90-Ele2,0-Bear2,0)))


holoScale(14,vec(0.13,0.13,0+Length1-0.11))
holoScale(15,vec(0.13,0.13,0+Length2-0.11))
}
if(first()|dupefinished()){
   holoCreate(16)
holoPos(16,holoEntity(10):toWorld(vec(0,0,2.2)*Scale))  
holoParent(16,holoEntity(10))
holoScale(16,vec(1)*Scale)
holoAng(16,holoEntity(10):toWorld(ang(180,0,0)))
holoColor(16,Shock_color)
holoModel(16,"models/bull/dynamicbutton_small.mdl")
holoCreate(17)
holoPos(17,holoEntity(11):toWorld(vec(0,0,2.2)*Scale))  
holoParent(17,holoEntity(11))
holoScale(17,vec(1)*Scale)
holoAng(17,holoEntity(11):toWorld(ang(180,0,0)))
holoColor(17,Shock_color)
holoModel(17,"models/bull/dynamicbutton_small.mdl")
}


