{$CLEO .cs}
Alloc($TV_MARKER, 11045)
Alloc($TV_FLAG, 11003)
Alloc($TV_ACTOR, 11024)
Alloc($TV_OBJ, 11087)
Alloc($TV_PICKUP, 11066)

nop 

// Motosserra fixa dentro da sala da missao (modelo 341, tipo 15 = mesmo usado nos drops dos inimigos)
Pickup.Create(32@, 341, 15, 1389.8, -15.3, 1000.9)

:TV_2
wait 0
if 
  Player.Defined($PLAYER_CHAR)
goto_if_false @TV_2
if 
  $ONMISSION == 0
goto_if_false @TV_2

// Checa se o player esta perto de UMA DAS 2 ENTRADAS (raio 1.5)
if or
  00ED:   actor $PLAYER_ACTOR 0 near_point -1713.9 -62.6 radius 1.5 1.5 on_foot
  00ED:   actor $PLAYER_ACTOR 0 near_point 2491.1 -2468.7 radius 1.5 1.5 on_foot
goto_if_false @TV_NOT_NEAR

// Mostra o help (e toca o som) so uma vez, nao a cada frame
if
  30@ == 0
goto_if_false @TV_SKIP_HELP
print_help 'TVHELP'
30@ = 1

:TV_SKIP_HELP
if 
  is_key_pressed 72
goto_if_false @TV_2
gosub @TV_99
goto @TV_2

:TV_NOT_NEAR
30@ = 0
goto @TV_2

:TV_99
script_name 'TV'
gosub @TV_153
if 
  has_deatharrest_been_executed 
goto_if_false @TV_144
$11002 = 0
gosub @TV_2538

:TV_144
gosub @TV_2726
return 

:TV_153
$ONMISSION = 1
wait 0
load_mission_text 'TV'
0@ = Player.Money($PLAYER_CHAR)
11@ = 1
Model.Load(179)
Model.Load(66)
Model.Load(341)
Model.Load(362)
Model.Load(359)
Model.Load(360)
load_mission_audio 36205 as 1

:TV_228
if or
  not Model.Available(179)
  not Model.Available(66)
  not Model.Available(341)
  not Model.Available(362)
  not Model.Available(359)
  not Model.Available(360)
goto_if_false @TV_279
wait 0
goto @TV_228

:TV_279
if 
  not has_mission_audio_loaded 1
goto_if_false @TV_305
wait 0
goto @TV_279

:TV_305
Player.CanMove($PLAYER_CHAR, False)
switch_widescreen 1
set_police_ignore_player $PLAYER_CHAR ignored_by_cops 1
set_wanted_multiplier 0.0
set_area_visible 1
set_char_area_visible $PLAYER_ACTOR to_interior 1
Actor.PutAt($PLAYER_ACTOR, 1389.401, -15.32, 1000.92)
Actor.Angle($PLAYER_ACTOR) = 270.0
do_fade 0 time 0
Camera.SetPosition(1394.401, -15.32, 1006.92, 0.0, 0.0, 0.0)
Camera.PointAt(1389.401, -15.32, 1000.92, 2)
Camera.OnPed($PLAYER_ACTOR, 15, 1)
gosub @TV_3071
do_fade 1 time 500

:TV_451
if 
  get_fading_status 
goto_if_false @TV_475
wait 0
goto @TV_451

:TV_475
2@ = 4000
gosub @TV_3935
print_now 'TV_02' time 3000 flag 1
2@ = 3000
gosub @TV_3935
print_now 'TV_03' time 3000 flag 1
2@ = 3000
gosub @TV_3935
clear_prints 
switch_widescreen 0
Player.CanMove($PLAYER_CHAR, True)
print_help 'TVHELP'

:TV_576
gosub @TV_2023
print_with_number_big 'TV_04' number 11@ time 3000 style 6
2@ = 3000
gosub @TV_3935
print_big 'TV_07' time 2000 style 6
2@ = 2000
gosub @TV_3935
print_big 'TV_08' time 2000 style 6
2@ = 2000
gosub @TV_3935
4@ = 0
5@ = 1
6@ = 0
7@ = 0
12@ = 0
TIMERA = 0

:TV_721
wait 0
Actor.StorePos($PLAYER_ACTOR, $tempvar_Float_1, $tempvar_Float_2, $tempvar_Float_3)
gosub @TV_2921
if and
  is_int_lvar_greater_than_int_lvar 8@ > 6@
  $TV_FLAG(6@,21i) == 0
  is_int_lvar_greater_than_int_lvar 8@ > 12@
  is_int_lvar_greater_than_int_lvar TIMERA > 9@
goto_if_false @TV_799
gosub @TV_1599

:TV_799
if 
  $TV_FLAG(6@,21i) == 1
goto_if_false @TV_848
if 
  Actor.Dead($TV_ACTOR(6@,21i))
goto_if_false @TV_848
gosub @TV_2292

:TV_848
if 
  is_int_lvar_greater_or_equal_to_int_lvar 4@ >= 8@
goto_if_false @TV_874
goto @TV_938

:TV_874
if 
  is_button_pressed 0 pressed_key 15
goto_if_false @TV_898
goto @TV_2538

:TV_898
6@ += 1
if 
  is_int_lvar_greater_than_int_lvar 6@ > 8@
goto_if_false @TV_931
6@ = 0

:TV_931
goto @TV_721

:TV_938
play_mission_audio 1
print_big 'TV_05' time 2000 style 6
2@ = 2000
gosub @TV_3935
print_with_number_big 'TV_06' number 10@ time 3000 style 6
Player.Money($PLAYER_CHAR) += 10@
6@ = 0

:TV_1007
wait 0
if 
  is_int_lvar_greater_than_int_lvar 8@ > 6@
goto_if_false @TV_1071
Marker.Disable($TV_MARKER(6@,21i))
Actor.DestroyWithFade($TV_ACTOR(6@,21i))
Actor.RemoveReferences($TV_ACTOR(6@,21i))
6@ += 1
goto @TV_1007

:TV_1071
2@ = 3000
gosub @TV_3935
11@ += 1
if 
  11@ > 5
goto_if_false @TV_1118
goto @TV_1125

:TV_1118
goto @TV_576

:TV_1125
2@ = 2000
gosub @TV_3935
do_fade 0 time 500

:TV_1147
if 
  get_fading_status 
goto_if_false @TV_1171
wait 0
goto @TV_1147

:TV_1171
gosub @TV_2616
Player.CanMove($PLAYER_CHAR, False)
switch_widescreen 1
Actor.PutAt($PLAYER_ACTOR, 1359.728, -47.757, 1000.936)
Camera.SetPosition(1391.401, -12.32, 1006.92, 0.0, 0.0, 0.0)
Camera.PointAt(1388.401, -15.32, 1000.96, 2)
generate_random_int_in_range 3@ = random_int_in_ranges 0 3
if 
  3@ == 0
goto_if_false @TV_1310
Object.Create(13@, 362, 0.0, 0.0, 0.0)

:TV_1310
if 
  3@ == 1
goto_if_false @TV_1351
Object.Create(13@, 359, 0.0, 0.0, 0.0)

:TV_1351
if 
  3@ == 2
goto_if_false @TV_1392
Object.Create(13@, 360, 0.0, 0.0, 0.0)

:TV_1392
set_object_area_visible 13@ to_interior 1
Object.PutAt(13@, 1388.401, -15.32, 1002.96)
draw_corona 1.5 type 0 lensflares 0 with_color 200 0 0 at 1388.401 -15.32 1003.96
do_fade 1 time 500

:TV_1459
if 
  get_fading_status 
goto_if_false @TV_1483
wait 0
goto @TV_1459

:TV_1483
print_big 'TV_10' time 5000 style 6
wait 5000
if 
  3@ == 0
goto_if_false @TV_1531
Actor.GiveWeaponAndAmmo($PLAYER_ACTOR, WeaponType.Minigun, 100)

:TV_1531
if 
  3@ == 1
goto_if_false @TV_1558
Actor.GiveWeaponAndAmmo($PLAYER_ACTOR, WeaponType.RocketLauncher, 1)

:TV_1558
if 
  3@ == 2
goto_if_false @TV_1585
Actor.GiveWeaponAndAmmo($PLAYER_ACTOR, WeaponType.RocketLauncherHs, 1)

:TV_1585
set_current_char_weapon $PLAYER_ACTOR armed_weapon_to 0
Object.Destroy(13@)
return 

:TV_1599
generate_random_int_in_range 3@ = random_int_in_ranges 0 2
if 
  3@ == 0
goto_if_false @TV_1662
Actor.Create($TV_ACTOR(6@,21i), PedType.Criminal, 179, 0.0, 0.0, 0.0)
goto @TV_1690

:TV_1662
Actor.Create($TV_ACTOR(6@,21i), PedType.Criminal, 66, 0.0, 0.0, 0.0)

:TV_1690
set_char_area_visible $TV_ACTOR(6@,21i) to_interior 1
generate_random_int_in_range 5@ = random_int_in_ranges 0 4
if 
  5@ == 0
goto_if_false @TV_1752
Actor.PutAt($TV_ACTOR(6@,21i), 1359.728, -47.757, 1000.936)

:TV_1752
if 
  5@ == 1
goto_if_false @TV_1794
Actor.PutAt($TV_ACTOR(6@,21i), 1359.637, 2.94, 1000.936)

:TV_1794
if 
  5@ == 2
goto_if_false @TV_1836
Actor.PutAt($TV_ACTOR(6@,21i), 1414.767, -47.757, 1000.936)

:TV_1836
if 
  5@ == 3
goto_if_false @TV_1878
Actor.PutAt($TV_ACTOR(6@,21i), 1414.767, 2.94, 1000.936)

:TV_1878
set_char_only_damaged_by_player $TV_ACTOR(6@,21i) immune_to_nonplayer 1
set_char_shoot_rate $TV_ACTOR(6@,21i) attack_rate 100
Actor.GiveWeaponAndAmmo($TV_ACTOR(6@,21i), WeaponType.Chainsaw, 0)
set_current_char_weapon $TV_ACTOR(6@,21i) armed_weapon_to 9
set_char_drops_weapons_when_dead $TV_ACTOR(6@,21i) weapon_droppable 0
set_char_never_targeted $TV_ACTOR(6@,21i) untargetable 1
generate_random_int_in_range 3@ = random_int_in_ranges 100 200
set_char_money $TV_ACTOR(6@,21i) money 3@
Marker.CreateAboveActor($TV_MARKER(6@,21i), $TV_ACTOR(6@,21i))
$TV_FLAG(6@,21i) = 1
12@ += 1
TIMERA = 0
task_kill_char_on_foot $TV_ACTOR(6@,21i) kill_actor $PLAYER_ACTOR
return 

:TV_2023
7@ = 0
switch_start 11@ total_jumps 5 default_jump 1 @TV_2235 jumps 1 @TV_2093 2 @TV_2122 3 @TV_2152 4 @TV_2182 5 @TV_2212 -1 @TV_2235 -1 @TV_2235

:TV_2093
8@ = 9
9@ = 1000
10@ = 100
goto @TV_2235

:TV_2122
8@ = 12
9@ = 1000
10@ = 300
goto @TV_2235

:TV_2152
8@ = 15
9@ = 1500
10@ = 500
goto @TV_2235

:TV_2182
8@ = 18
9@ = 1500
10@ = 700
goto @TV_2235

:TV_2212
8@ = 21
9@ = 2000
10@ = 1500

:TV_2235
wait 0
if 
  is_int_lvar_greater_than_int_lvar 7@ > 8@
goto_if_false @TV_2283
$TV_FLAG(7@,21i) = 0
7@ += 1
goto @TV_2235

:TV_2283
7@ = 0
return 

:TV_2292
Marker.Disable($TV_MARKER(6@,21i))
Actor.StoreDeadActorPos($TV_ACTOR(6@,21i), 14@, 15@, 16@)
16@ += 0.3
if 
  not is_char_health_greater $PLAYER_ACTOR health > 90
goto_if_false @TV_2404
generate_random_int_in_range 3@ = random_int_in_ranges 0 2
if 
  3@ == 0
goto_if_false @TV_2511
Pickup.Create($TV_PICKUP(6@,21i), 1240, 3, 14@, 15@, 16@)
goto @TV_2511

:TV_2404
generate_random_int_in_range 3@ = random_int_in_ranges 0 50
if 
  3@ > 43
goto_if_false @TV_2461
Pickup.Create($TV_PICKUP(6@,21i), 1242, 3, 14@, 15@, 16@)
goto @TV_2511

:TV_2461
generate_random_int_in_range 3@ = random_int_in_ranges 0 3
if 
  3@ == 1
goto_if_false @TV_2511
Pickup.Create($TV_PICKUP(6@,21i), 341, 15, 14@, 15@, 16@)

:TV_2511
$TV_FLAG(6@,21i) = 0
4@ += 1
increment_int_stat 1 to_integer_stat 192
return 

:TV_2538
1@ = Player.Money($PLAYER_CHAR)
sub_int_lvar_from_int_lvar 1@ -= 0@
if 
  1@ == 0
goto_if_false @TV_2595
print_big 'TV_11' time 5000 style 6
goto @TV_2614

:TV_2595
print_with_number_big 'TV_09' number 1@ time 5000 style 6

:TV_2614
return 

:TV_2616
7@ = 0

:TV_2623
wait 0
if 
  21 > 7@
goto_if_false @TV_2724
Marker.Disable($TV_MARKER(7@,21i))
Actor.DestroyWithFade($TV_ACTOR(7@,21i))
Actor.RemoveReferences($TV_ACTOR(7@,21i))
Object.Destroy($TV_OBJ(7@,21i))
if 
  does_pickup_exist $TV_PICKUP(7@,21i)
goto_if_false @TV_2710
Pickup.Destroy($TV_PICKUP(7@,21i))

:TV_2710
7@ += 1
goto @TV_2623

:TV_2724
return 

:TV_2726
clear_prints 
clear_mission_audio 1
gosub @TV_2616
Model.Destroy(179)
Model.Destroy(66)
Model.Destroy(341)
Model.Destroy(362)
Model.Destroy(359)
Model.Destroy(360)
$ONMISSION = 0
get_game_timer $Current_Time_in_ms
set_wanted_multiplier 1.0
set_police_ignore_player $PLAYER_CHAR ignored_by_cops 0
set_fading_colour 0 0 0
do_fade 0 time 1000
31@ = 0

:TV_2818
31@ += 1
if or
  not get_fading_status 
  31@ > 300
goto_if_false @TV_2842
wait 0
goto @TV_2818

:TV_2842
switch_widescreen 1
set_area_visible 0
set_char_area_visible $PLAYER_ACTOR to_interior 0
Actor.PutAt($PLAYER_ACTOR, -1714.495, -66.12, 3.554)
Actor.Angle($PLAYER_ACTOR) = 90.0
request_collision -1714.495 -63.12
Camera.Restore_WithJumpCut
Camera.SetBehindPlayer
do_fade 1 time 500
wait 2000
switch_widescreen 0

:TV_2912
gosub @TV_2538
return 

:TV_2921
$tempvar_Float_1 += 5.0
if 
  $tempvar_Float_1 > 1418.76
goto_if_false @TV_2962
$tempvar_Float_1 = 1418.76

:TV_2962
if 
  -47.75 > $tempvar_Float_2
goto_if_false @TV_2993
$tempvar_Float_2 = -47.75

:TV_2993
if 
  $tempvar_Float_2 > 6.07
goto_if_false @TV_3024
$tempvar_Float_2 = 6.07

:TV_3024
$tempvar_Float_3 += 6.0
Camera.SetPosition($tempvar_Float_1, $tempvar_Float_2, $tempvar_Float_3, 0.0, 0.0, 0.0)
Camera.OnPed($PLAYER_ACTOR, 15, 2)
return 

:TV_3071
7@ = 0

:TV_3078
wait 0
if 
  21 > 7@
goto_if_false @TV_3152
Object.Create($TV_OBJ(7@,21i), 1271, 0.0, 0.0, 0.0)
set_object_area_visible $TV_OBJ(7@,21i) to_interior 1
7@ += 1
goto @TV_3078

:TV_3152
7@ = 0
Object.PutAt($TV_OBJ(7@,21i), 1384.72, -48.6, 1000.5)
7@ = 1
Object.PutAt($TV_OBJ(7@,21i), 1384.72, -47.3, 1000.5)
7@ = 2
Object.PutAt($TV_OBJ(7@,21i), 1384.72, -46.0, 1000.5)
7@ = 3
Object.PutAt($TV_OBJ(7@,21i), 1384.72, -48.6, 1001.7)
7@ = 4
Object.PutAt($TV_OBJ(7@,21i), 1384.72, -47.3, 1001.7)
7@ = 5
Object.PutAt($TV_OBJ(7@,21i), 1384.72, -46.0, 1001.7)
7@ = 6
Object.PutAt($TV_OBJ(7@,21i), 1387.79, -48.6, 1001.5)
7@ = 7
Object.PutAt($TV_OBJ(7@,21i), 1387.79, -46.6, 1001.5)
7@ = 8
Object.PutAt($TV_OBJ(7@,21i), 1361.39, -35.3067, 1000.5)
7@ = 9
Object.PutAt($TV_OBJ(7@,21i), 1361.39, -35.3067, 1001.7)
7@ = 10
Object.PutAt($TV_OBJ(7@,21i), 1408.5, -13.4902, 1000.5)
7@ = 11
Object.PutAt($TV_OBJ(7@,21i), 1408.5, -13.4902, 1001.7)
7@ = 12
Object.PutAt($TV_OBJ(7@,21i), 1370.9, -2.49, 1000.5)
7@ = 13
Object.PutAt($TV_OBJ(7@,21i), 1372.4, -1.1729, 1000.5)
7@ = 14
Object.PutAt($TV_OBJ(7@,21i), 1372.4, -1.29891, 1001.7)
7@ = 15
Object.PutAt($TV_OBJ(7@,21i), 1412.23, -25.4878, 1000.5)
7@ = 16
Object.PutAt($TV_OBJ(7@,21i), 1412.23, -25.4878, 1001.7)
7@ = 17
Object.PutAt($TV_OBJ(7@,21i), 1387.9, -12.851, 1000.5)
7@ = 18
Object.PutAt($TV_OBJ(7@,21i), 1387.9, -12.851, 1001.7)
7@ = 19
Object.PutAt($TV_OBJ(7@,21i), 1379.73, -33.8351, 1000.5)
7@ = 20
Object.PutAt($TV_OBJ(7@,21i), 1379.73, -33.8351, 1001.7)
7@ = 0

:TV_3810
wait 0
if 
  21 > 7@
goto_if_false @TV_3926
if 
  7@ > 7
goto_if_false @TV_3887
generate_random_float_in_range $tempvar_Float_2 = random_float_in_ranges -45.0 45.0
set_object_rotation $TV_OBJ(7@,21i) XYZ_rotation 0.0 0.0 $tempvar_Float_2

:TV_3887
set_object_mass $TV_OBJ(7@,21i) mass_to 1000.0
Object.Indestructibility($TV_OBJ(7@,21i), False)
7@ += 1
goto @TV_3810

:TV_3926
7@ = 0
return 

:TV_3935
TIMERB = 0

:TV_3942
if 
  not is_int_lvar_greater_than_int_lvar TIMERB > 2@
goto_if_false @TV_3993
Actor.StorePos($PLAYER_ACTOR, $tempvar_Float_1, $tempvar_Float_2, $tempvar_Float_3)
gosub @TV_2921
wait 0
goto @TV_3942

:TV_3993
return 
