{$CLEO .cs}
0000: NOP 
thread 'OWdeg' 

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

0D42: load_txd "owdegBAN" from "cleo\\OWimg\\owdegBAN.txd"
wait 1000

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

:DEGRADE_33
wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #BANDITO)
else_jump @DEGRADE_33 

03C0: 0@ = actor $PLAYER_ACTOR car
03E5: show_text_box 'OW_0003' // Tire Degrade OFF
wait 3000

1@ = 0 // left front tire
2@ = 0 // right front tire
3@ = 0 // left rear tire
4@ = 0 // right rear tire

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

:standby
wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #BANDITO)
else_jump @DEGRADE_553

wait 0
if
00E1:   player 0 pressed_key 6 // Hand Breake
else_jump @standby

03E5: show_text_box 'OW_0004' // Tire Degrade ON
wait 3000
0D44: 11@ = find_texture "ovbr800" in_dictionary "owdegBAN"
wait 100

20@ = 0
:DEGRADE_35
0D7E: draw_sprite_with_texture 11@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
20@ += 1
wait 1
// 008A: $pippo = 20@ // (int)
// 04F7: status_text $pippo type 0 line 1 GXT 'OW_0001'
if
20@ == 75 // 3 sec
else_jump @DEGRADE_35

//==================================

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

wait 0
if
00E1:   player 0 pressed_key 6 // Hand Breake
else_jump @DEGRADE_400
jump @DEGRADE_553

//------

:DEGRADE_400
0050: gosub @CALCULATOR

wait 0
if or
1@ > 13
2@ > 13
3@ > 50
4@ > 50
else_jump @DEGRADE_40

//********************************************************

// O N E - T I R E

03E5: show_text_box 'OW_0005' // 1 tire damage
wait 3000
0D44: 11@ = find_texture "ovbr801" in_dictionary "owdegBAN"
wait 100
0D44: 12@ = find_texture "ovbr802" in_dictionary "owdegBAN"
wait 100
0D44: 13@ = find_texture "ovbr803" in_dictionary "owdegBAN"
wait 100
0D44: 14@ = find_texture "ovbr804" in_dictionary "owdegBAN"
wait 100

20@ = 0
:ONE_TIRE_1

wait 0
if
1@ > 13
else_jump @ONE_TIRE_1a
0D7E: draw_sprite_with_texture 11@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @ONE_TIRE_2

:ONE_TIRE_1a
wait 0
if
2@ > 13
else_jump @ONE_TIRE_1b
0D7E: draw_sprite_with_texture 12@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @ONE_TIRE_2

:ONE_TIRE_1b
wait 0
if
3@ > 50
else_jump @ONE_TIRE_1c
0D7E: draw_sprite_with_texture 13@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @ONE_TIRE_2

:ONE_TIRE_1c
0D7E: draw_sprite_with_texture 14@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0

:ONE_TIRE_2
20@ += 1
wait 1
if
20@ == 35 // 3 sec
else_jump @ONE_TIRE_1
wait 10000

//********************************************************

:DEGRADE_42

wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #BANDITO)
else_jump @DEGRADE_553

wait 0
if
00E1:   player 0 pressed_key 6 // Hand Breake
else_jump @DEGRADE_42x
jump @DEGRADE_553

:DEGRADE_42x
02E3: 5@ = car 0@ speed
0092: 6@ = float 5@ to_integer
wait 0
if
0019:   6@ > 45
else_jump @DEGRADE_420
04BA: set_car 0@ speed_to 55.0

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

:DEGRADE_420
0050: gosub @CALCULATOR

wait 0
if and
1@ > 13
2@ > 13
else_jump @DEGRADE_42a
jump @TWO_TIRE

:DEGRADE_42a
wait 0
if and
1@ > 13
3@ > 50
else_jump @DEGRADE_42b
jump @TWO_TIRE

:DEGRADE_42b
wait 0
if and
1@ > 13
4@ > 50
else_jump @DEGRADE_42c
jump @TWO_TIRE

:DEGRADE_42c
wait 0
if and
2@ > 13
3@ > 50
else_jump @DEGRADE_42d
jump @TWO_TIRE

:DEGRADE_42d
wait 0
if and
3@ > 50
4@ > 50
else_jump @DEGRADE_42

//********************************************************

// T W O - T I R E

:TWO_TIRE

03E5: show_text_box 'OW_0006' // 2 tire damage
wait 3000
0D44: 11@ = find_texture "ovbr805" in_dictionary "owdegBAN"
wait 100
0D44: 12@ = find_texture "ovbr806" in_dictionary "owdegBAN"
wait 100
0D44: 13@ = find_texture "ovbr807" in_dictionary "owdegBAN"
wait 100
0D44: 14@ = find_texture "ovbr808" in_dictionary "owdegBAN"
wait 100
0D44: 15@ = find_texture "ovbr809" in_dictionary "owdegBAN"
wait 100
0D44: 16@ = find_texture "ovbr810" in_dictionary "owdegBAN"
wait 100

20@ = 0
:TWO_TIRE_1

wait 0
if and
1@ > 13
2@ > 13
else_jump @TWO_TIRE_1a
0D7E: draw_sprite_with_texture 11@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @TWO_TIRE_2

:TWO_TIRE_1a
wait 0
if and
1@ > 13
3@ > 50
else_jump @TWO_TIRE_1b
0D7E: draw_sprite_with_texture 12@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @TWO_TIRE_2

:TWO_TIRE_1b
wait 0
if and
1@ > 13
4@ > 50
else_jump @TWO_TIRE_1c
0D7E: draw_sprite_with_texture 13@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @TWO_TIRE_2

:TWO_TIRE_1c
wait 0
if and
2@ > 13
3@ > 50
else_jump @TWO_TIRE_1d
0D7E: draw_sprite_with_texture 14@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @TWO_TIRE_2

:TWO_TIRE_1d
wait 0
if and
2@ > 13
4@ > 50
else_jump @TWO_TIRE_1e
0D7E: draw_sprite_with_texture 15@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @TWO_TIRE_2

:TWO_TIRE_1e
0D7E: draw_sprite_with_texture 16@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0

:TWO_TIRE_2
20@ += 1
wait 1
if
20@ == 30 // 3 sec
else_jump @TWO_TIRE_1
wait 10000

//********************************************************

:DEGRADE_43

wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #BANDITO)
else_jump @DEGRADE_553

wait 0
if
00E1:   player 0 pressed_key 6 // Hand Breake
else_jump @DEGRADE_43x
jump @DEGRADE_553

:DEGRADE_43x
02E3: 5@ = car 0@ speed
0092: 6@ = float 5@ to_integer
wait 0
if
0019:   6@ > 30
else_jump @DEGRADE_430
04BA: set_car 0@ speed_to 40.0

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

:DEGRADE_430
0050: gosub @CALCULATOR

wait 0
if and
1@ > 13
2@ > 13
3@ > 50
else_jump @DEGRADE_43a
jump @THREE_TIRE

:DEGRADE_43a
wait 0
if and
1@ > 13
2@ > 13
4@ > 50
else_jump @DEGRADE_43b
jump @THREE_TIRE

:DEGRADE_43b
wait 0
if and
1@ > 13
3@ > 50
4@ > 50
else_jump @DEGRADE_43d
jump @THREE_TIRE

:DEGRADE_43d
wait 0
if and
2@ > 13
3@ > 50
4@ > 50
else_jump @DEGRADE_43

//********************************************************

// T H R E E - T I R E

:THREE_TIRE

03E5: show_text_box 'OW_0007' // 3 tire damage
wait 3000
0D44: 11@ = find_texture "ovbr811" in_dictionary "owdegBAN"
wait 100
0D44: 12@ = find_texture "ovbr812" in_dictionary "owdegBAN"
wait 100
0D44: 13@ = find_texture "ovbr813" in_dictionary "owdegBAN"
wait 100
0D44: 14@ = find_texture "ovbr814" in_dictionary "owdegBAN"
wait 100

20@ = 0
:THREE_TIRE_1

wait 0
if
1@ > 13
else_jump @THREE_TIRE_1a
0D7E: draw_sprite_with_texture 14@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @THREE_TIRE_2 

:THREE_TIRE_1a
wait 0
if
2@ > 13
else_jump @THREE_TIRE_1b
0D7E: draw_sprite_with_texture 13@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @THREE_TIRE_2

:THREE_TIRE_1b
wait 0
if
3@ > 50
else_jump @THREE_TIRE_1c
0D7E: draw_sprite_with_texture 12@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
jump @THREE_TIRE_2

:THREE_TIRE_1c
0D7E: draw_sprite_with_texture 11@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0

:THREE_TIRE_2
20@ += 1
wait 1
if
20@ == 35 // 3 sec
else_jump @THREE_TIRE_1
wait 10000

//********************************************************

:DEGRADE_44

wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #BANDITO)
else_jump @DEGRADE_553

wait 0
if
00E1:   player 0 pressed_key 6 // Hand Breake
else_jump @DEGRADE_44a
jump @DEGRADE_553

:DEGRADE_44a
02E3: 5@ = car 0@ speed
0092: 6@ = float 5@ to_integer
wait 0
if
0019:   6@ > 15
else_jump @DEGRADE_440
04BA: set_car 0@ speed_to 25.0

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

:DEGRADE_440
0050: gosub @CALCULATOR

wait 0
if and
1@ > 13
2@ > 13
3@ > 50
4@ > 50
else_jump @DEGRADE_44

//********************************************************

// F O U R - T I R E

:FOUR_TIRE

03E5: show_text_box 'OW_0008' // all tire damage
wait 3000
0D44: 11@ = find_texture "ovbr815" in_dictionary "owdegBAN"
wait 100

20@ = 0
:FOUR_TIRE_1
0D7E: draw_sprite_with_texture 11@ at_cornerA 20.0 100.0 cornerB 370.0 460.0 color 255 255 255 255 angle 0.0
20@ += 1
wait 1
if
20@ == 75 // 3 sec
else_jump @FOUR_TIRE_1
wait 3500

//********************************************************

:DEGRADE_45

04BA: set_car 0@ speed_to 0.0
02D4: car 0@ turn_off_engine 

:DEGRADE_450
wait 0 
if 
   Actor.DrivingVehicleType($PLAYER_ACTOR, #BANDITO)
else_jump @DEGRADE_553 
jump @DEGRADE_450

//********************************************************

:DEGRADE_553
Car.RemoveReferences(0@)
jump @DEGRADE_33 

0A93: end_custom_thread 

//********************************************************

:CALCULATOR

02E3: 5@ = car 0@ speed
0092: 6@ = float 5@ to_integer
wait 0
if
6@ > 18
else_jump @CALC_END

wait 0
if
00E1:   player 0 pressed_key 16 // Accellerate
else_jump @CALC_1
jump @CALC_10

:CALC_1
wait 0
if
00E1:   player 0 pressed_key 14 // Breake
else_jump @CALC_END
jump @CALC_50

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

:CALC_10 // ACCELLERATE

//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

7@ = 0 //   0-|   1-\   2-/
wait 0
if
00E1:   player 0 pressed_key 0 // left-right
else_jump @STEER_END

0494: get_joystick 0 data_to $MOVE_AXIS_X $MOVE_AXIS_Y $SPECIAL_AXIS_X $SPECIAL_AXIS_Y
wait 0
if
$MOVE_AXIS_X == 0
else_jump @STEER_1

7@ = 1
jump @STEER_END

:STEER_1
7@ = 2

:STEER_END

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

wait 0
if
7@ == 0
else_jump @CALC_11
jump @CALC_20

:CALC_11
wait 0
if
7@ == 1
else_jump @CALC_30

3@ += 1
4@ += 3
jump @CALC_END

//-------

:CALC_30

3@ += 3
4@ += 1
jump @CALC_END

//-------

:CALC_20

3@ += 2
4@ += 2
jump @CALC_END

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

:CALC_50 // BREAKE

//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

7@ = 0 //   0-|   1-\   2-/
wait 0
if
00E1:   player 0 pressed_key 0 // left-right
else_jump @STEER2_END

0494: get_joystick 0 data_to $MOVE_AXIS_X $MOVE_AXIS_Y $SPECIAL_AXIS_X $SPECIAL_AXIS_Y
wait 0
if
$MOVE_AXIS_X == 0
else_jump @STEER2_1

7@ = 1
jump @STEER2_END

:STEER2_1
7@ = 2

:STEER2_END

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

wait 0
if
7@ == 0
else_jump @CALC_51
jump @CALC_60

:CALC_51
wait 0
if
7@ == 1
else_jump @CALC_70

1@ += 1
2@ += 3
jump @CALC_END

//-------

:CALC_70

1@ += 3
2@ += 1
jump @CALC_END

//-------

:CALC_60

1@ += 2
2@ += 2
jump @CALC_END

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

:CALC_END
0051: return