// Automan Uber Allen (C) 2016
// !!! change 'PROTO' with your model !!!
{$CLEO .cs}
0000: NOP 
thread 'FLAPS' 

// component4 - Left Rear Door
// component5 - Right Rear Door

:flaps_13
wait 0 
if 
   Player.Defined($PLAYER_CHAR)
else_jump @flaps_13 

:flaps_33
wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #PROTO)
else_jump @flaps_33 
03C0: 0@ = actor $PLAYER_ACTOR car 

0698: set_car 0@ repair_componentB 4 
0698: set_car 0@ repair_componentB 5 
wait 0 
08A6: set_car 0@ componentA 4 rotation_to 0.5
08A6: set_car 0@ componentA 5 rotation_to 0.5

//-------------------------

:flaps64
wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #PROTO)
else_jump @flaps_553 

wait 0 
if
0AB0:  key_pressed 0x44 // 'D'
jf @flaps641
jump @turnright

:flaps641
wait 0 
if
0AB0:  key_pressed 0x41 // 'A'
jf @flaps642
jump @turnleft

:flaps642
wait 0 
if
0AB0:  key_pressed 0x27 // '->'
jf @flaps643
jump @turnright2

:flaps643
wait 0 
if
0AB0:  key_pressed 0x25 // '<-'
jf @flaps64
jump @turnleft2

//-------------------------

:turnright

// turn right: left down - rigth up
wait 0 
08A6: set_car 0@ componentA 4 rotation_to 0.45 
08A6: set_car 0@ componentA 5 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.4 
08A6: set_car 0@ componentA 5 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.35 
08A6: set_car 0@ componentA 5 rotation_to 0.65
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.3
08A6: set_car 0@ componentA 5 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.25 
08A6: set_car 0@ componentA 5 rotation_to 0.75
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.2
08A6: set_car 0@ componentA 5 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.15
08A6: set_car 0@ componentA 5 rotation_to 0.85
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.1
08A6: set_car 0@ componentA 5 rotation_to 0.9
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.05
08A6: set_car 0@ componentA 5 rotation_to 0.95
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.0
08A6: set_car 0@ componentA 5 rotation_to 1.0

while 0AB0:  key_pressed 0x44
wait 0 
end

// turn right: reset
wait 0 
08A6: set_car 0@ componentA 4 rotation_to 0.05
08A6: set_car 0@ componentA 5 rotation_to 0.95
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.1
08A6: set_car 0@ componentA 5 rotation_to 0.9
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.15
08A6: set_car 0@ componentA 5 rotation_to 0.85
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.2
08A6: set_car 0@ componentA 5 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.25 
08A6: set_car 0@ componentA 5 rotation_to 0.75
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.3
08A6: set_car 0@ componentA 5 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.35 
08A6: set_car 0@ componentA 5 rotation_to 0.65
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.4 
08A6: set_car 0@ componentA 5 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.45 
08A6: set_car 0@ componentA 5 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 5
08A6: set_car 0@ componentA 5 rotation_to 5

jump @flaps_33

//-------------------------

:turnleft

// turn left: left up - rigth down
wait 0 
08A6: set_car 0@ componentA 5 rotation_to 0.45 
08A6: set_car 0@ componentA 4 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.4 
08A6: set_car 0@ componentA 4 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.35 
08A6: set_car 0@ componentA 4 rotation_to 0.65
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.3
08A6: set_car 0@ componentA 4 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.25 
08A6: set_car 0@ componentA 4 rotation_to 0.75
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.2
08A6: set_car 0@ componentA 4 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.15
08A6: set_car 0@ componentA 4 rotation_to 0.85
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.1
08A6: set_car 0@ componentA 4 rotation_to 0.9
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.05
08A6: set_car 0@ componentA 4 rotation_to 0.95
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.0
08A6: set_car 0@ componentA 4 rotation_to 1.0

while 0AB0:  key_pressed 0x41
wait 0 
end

// turn left: reset
wait 0 
08A6: set_car 0@ componentA 5 rotation_to 0.05
08A6: set_car 0@ componentA 4 rotation_to 0.95
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.1
08A6: set_car 0@ componentA 4 rotation_to 0.9
wait 20
08A6: set_car 0@ componentA 5 rotation_to 0.15
08A6: set_car 0@ componentA 4 rotation_to 0.85
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.2
08A6: set_car 0@ componentA 4 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.25 
08A6: set_car 0@ componentA 4 rotation_to 0.75
wait 20
08A6: set_car 0@ componentA 5 rotation_to 0.3
08A6: set_car 0@ componentA 4 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.35 
08A6: set_car 0@ componentA 4 rotation_to 0.65
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.4 
08A6: set_car 0@ componentA 4 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.45 
08A6: set_car 0@ componentA 4 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 5.0
08A6: set_car 0@ componentA 4 rotation_to 5.0

jump @flaps_33

//-------------------------

:turnright2

// turn right: left down - rigth up
wait 0 
08A6: set_car 0@ componentA 4 rotation_to 0.45 
08A6: set_car 0@ componentA 5 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.4 
08A6: set_car 0@ componentA 5 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.35 
08A6: set_car 0@ componentA 5 rotation_to 0.65
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.3
08A6: set_car 0@ componentA 5 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.25 
08A6: set_car 0@ componentA 5 rotation_to 0.75
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.2
08A6: set_car 0@ componentA 5 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.15
08A6: set_car 0@ componentA 5 rotation_to 0.85
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.1
08A6: set_car 0@ componentA 5 rotation_to 0.9
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.05
08A6: set_car 0@ componentA 5 rotation_to 0.95
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.0
08A6: set_car 0@ componentA 5 rotation_to 1.0

while 0AB0:  key_pressed 0x27
wait 0 
end

// turn right: reset
wait 0 
08A6: set_car 0@ componentA 4 rotation_to 0.05
08A6: set_car 0@ componentA 5 rotation_to 0.95
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.1
08A6: set_car 0@ componentA 5 rotation_to 0.9
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.15
08A6: set_car 0@ componentA 5 rotation_to 0.85
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.2
08A6: set_car 0@ componentA 5 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.25 
08A6: set_car 0@ componentA 5 rotation_to 0.75
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.3
08A6: set_car 0@ componentA 5 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.35 
08A6: set_car 0@ componentA 5 rotation_to 0.65
wait 20
08A6: set_car 0@ componentA 4 rotation_to 0.4 
08A6: set_car 0@ componentA 5 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 0.45 
08A6: set_car 0@ componentA 5 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 4 rotation_to 5
08A6: set_car 0@ componentA 5 rotation_to 5

jump @flaps_33

//-------------------------

:turnleft2

// turn left: left up - rigth down
wait 0 
08A6: set_car 0@ componentA 5 rotation_to 0.45 
08A6: set_car 0@ componentA 4 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.4 
08A6: set_car 0@ componentA 4 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.35 
08A6: set_car 0@ componentA 4 rotation_to 0.65
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.3
08A6: set_car 0@ componentA 4 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.25 
08A6: set_car 0@ componentA 4 rotation_to 0.75
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.2
08A6: set_car 0@ componentA 4 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.15
08A6: set_car 0@ componentA 4 rotation_to 0.85
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.1
08A6: set_car 0@ componentA 4 rotation_to 0.9
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.05
08A6: set_car 0@ componentA 4 rotation_to 0.95
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.0
08A6: set_car 0@ componentA 4 rotation_to 1.0

while 0AB0:  key_pressed 0x25
wait 0 
end

// turn left: reset
wait 0 
08A6: set_car 0@ componentA 5 rotation_to 0.05
08A6: set_car 0@ componentA 4 rotation_to 0.95
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.1
08A6: set_car 0@ componentA 4 rotation_to 0.9
wait 20
08A6: set_car 0@ componentA 5 rotation_to 0.15
08A6: set_car 0@ componentA 4 rotation_to 0.85
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.2
08A6: set_car 0@ componentA 4 rotation_to 0.8
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.25 
08A6: set_car 0@ componentA 4 rotation_to 0.75
wait 20
08A6: set_car 0@ componentA 5 rotation_to 0.3
08A6: set_car 0@ componentA 4 rotation_to 0.7
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.35 
08A6: set_car 0@ componentA 4 rotation_to 0.65
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.4 
08A6: set_car 0@ componentA 4 rotation_to 0.6
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 0.45 
08A6: set_car 0@ componentA 4 rotation_to 0.55
wait 20 
08A6: set_car 0@ componentA 5 rotation_to 5.0
08A6: set_car 0@ componentA 4 rotation_to 5.0

jump @flaps_33

//-------------------------

:flaps_553
Car.RemoveReferences(0@)
jump @flaps_33 
0A93: end_custom_thread