{

  use macro (Ctrl+J) "headsa"
  to insert a file header      
}

DEFINE OBJECTS 6
DEFINE OBJECT (noname)
DEFINE OBJECT PICKUPSAVE
DEFINE OBJECT DRUG_GREEN
DEFINE OBJECT BODYARMOUR
DEFINE OBJECT GEN_DOOREXT03
DEFINE OBJECT CLOTHESP

DEFINE MISSIONS 5
DEFINE MISSION 0 AT @INITIAL
DEFINE MISSION 1 AT @SF_MISSION_1
DEFINE MISSION 2 AT @SF_MISSION_2
DEFINE MISSION 3 AT @SF_MISSION_3
DEFINE MISSION 4 AT @LS_MISSION_1

DEFINE EXTERNAL_SCRIPTS 0 // Use -1 in order not to compile AAA script
DEFINE UNKNOWN_EMPTY_SEGMENT 0
DEFINE UNKNOWN_THREADS_MEMORY 0

{$VERSION 3.0.0000}

var
 $PLAYER_CHAR: Player
 $MARKER_CJ: Marker
 $marker_car: Marker
 $marker_dest: Marker
 $X_WPICK: array 20 of Float
 $Y_WPICK: array 20 of Float
 $Z_WPICK: array 20 of Float
 $I_WPICK: array 20 of Int
 $D_WPICK: array 20 of Int
 $L_WPICK: array 20 of Int
 $MAX_WPICK: Int
 $PICKUP_NUM: Int
 $PICKUP_I: Int
 $PICKUP_II: Int
 $MODEL_PICKUP: Model
 $WID_PICKUP: Int
 $P_WPICK: array 20 of Pickup
 $X_APICK: array 20 of Float
 $Y_APICK: array 20 of Float
 $Z_APICK: array 20 of Float
 $D_APICK: array 20 of Int
 $MAX_APICK: Int
 $P_APICK: array 10 of Pickup
 $SAVE_PICKUPS: array 20 of Pickup
 $SAVE_PICKUPS_X: array 20 of Float
 $SAVE_PICKUPS_Y: array 20 of Float
 $SAVE_PICKUPS_Z: array 20 of Float
 $SAVE_MARKERS: array 20 of Marker
 $SAVE_POINTS_X: array 20 of Float
 $SAVE_POINTS_Y: array 20 of Float
 $SAVE_POINTS_Z: array 20 of Float
 $SAVE_POINTS_A: array 20 of Float
 $BUS_TARGETS_X: array 20 of Float
 $BUS_TARGETS_Y: array 20 of Float
 $BUS_TARGETS_Z: array 20 of Float
 $BUS_TARGETS_A: array 20 of Float
 $BUSES: array 20 of Car
 $BUS_MARKERS: array 20 of Marker
 $BUS_DRIVERS: array 20 of Actor
end // var 
03A4: name_thread 'MAIN' 
01F0: set_max_wanted_level_to 6 
0111: toggle_wasted_busted_check 0 
00C0: set_current_time_hours_to 8 minutes_to 0 
04E4: unknown_refresh_game_renderer_at -1767.60 862.37 
03CB: set_rendering_origin_at -1767.60 862.37 24.88 
0053: $PLAYER_CHAR = create_player #NULL at -1767.60 862.37 24.88
01F5: $PLAYER_ACTOR = create_player_actor $PLAYER_CHAR 
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 
0373: set_camera_directly_behind_player 
01B6: set_weather 0 
0001: wait 0 ms 
087B: set_player $PLAYER_CHAR clothes_texture "PLAYER_FACE" model "HEAD" body_part 1 
087B: set_player $PLAYER_CHAR clothes_texture "JEANSDENIM" model "JEANS" body_part 2 
087B: set_player $PLAYER_CHAR clothes_texture "SNEAKERBINCBLK" model "SNEAKER" body_part 3 
087B: set_player $PLAYER_CHAR clothes_texture "VEST" model "VEST" body_part 0 
070D: rebuild_player $PLAYER_CHAR 
01B4: toggle_player $PLAYER_CHAR can_move 1 
016A: fade 1 time 0 
04BB: select_interior 0
030D: set_max_progress 4 
0629: change_integer_stat 181 to 4 
016C: restart_if_wasted_at 2027.77 -1420.52 15.99 angle 137.0 town_number 0 
016D: restart_if_busted_at 1550.68 -1675.49 14.51 angle 90.0 town_number 0 
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here 
0004: $DEFAULT_WAIT_TIME = 250
03E6: remove_text_box
Actor.Angle($PLAYER_ACTOR) = 180
//054C: use_GXT_table 'MPACK'
start_mission 0
wait 0 ms
// put your create_thread commands here
// RE-ENABLE THESE!
create_thread @SF_MISSION_CHECK
create_thread @LS_MISSION_CHECK
create_thread @SAVEGAME
create_thread @CROSSLOC_BUS
//0213: $My_Save = create_pickup #PICKUPSAVE type 15 at -2026.7897 156.7931 29.0391
//0570: $Marker_Save = create_asset_radar_marker_with_icon 35 at -2026.7897 156.7931 29.0391

:MAIN_LOOP
0001: wait $DEFAULT_WAIT_TIME ms
00BF: $TIME_HOURS = current_time_hours, $TIME_MINS = current_time_minutes
{if
0214:   pickup $My_Save picked_up
jf @MAIN_SAVE_END
03D8: show_save_screen
:MY_SAVE_CHECK
wait 0 ms
if
83D9:   not save_done
jf @MAIN_SAVE_END
jump @MY_SAVE_CHECK
:MAIN_SAVE_END}

jump @MAIN_LOOP 
end_thread

:SUB_FADE_500MS
0169: set_fade_color_RGB 0 0 0 
fade 0 500 

repeat
    wait 0
until not fading

return 

:SUB_FADE_500MS_AND_RESTORE_CONTROLS
0169: set_fade_color_RGB 0 0 0 
fade 0 500 

repeat
    wait 0
    00BE: text_clear_all 
    03E6: remove_text_box 
until not fading

if 
   Player.Defined($PLAYER_CHAR)
then
fade 0 0 
Camera.Restore_WithJumpCut
0687: clear_actor $PLAYER_ACTOR task 
fade 0 0 
end

return

:SUB_GET_NEARBY_WEAPON
wait 0
0209: $PICKUP_II = random_int_in_ranges 0 $MAX_WPICK
$PICKUP_NUM = $L_WPICK[$PICKUP_II]
03DC: $MARKER_PICKUP = create_marker_above_pickup $P_WPICK[$PICKUP_NUM]
Marker.SetColor($MARKER_PICKUP, 1)
0781: get_weapon_with_ID $I_WPICK[$PICKUP_NUM] model_to $MODEL_PICKUP 
$WID_PICKUP = $I_WPICK[$PICKUP_NUM]
return

// put your mods (threads) here
:SAVEGAME
thread "P_SAVE"
$TOTAL_AVAILABLE_SAVE_PICKUPS = 0
$SAVE_PICKUPS_EXIST = 0

$SAVE_PICKUPS_X[0] = -2027.7611
$SAVE_PICKUPS_Y[0] = 414.4381
$SAVE_PICKUPS_Z[0] = 35.1719

$SAVE_POINTS_X[0] = -2024.1561
$SAVE_POINTS_Y[0] = 414.4381
$SAVE_POINTS_Z[0] = 35.1719
$SAVE_POINTS_A[0] = 270.0

0570: $SAVE_MARKERS[0] = create_asset_radar_marker_with_icon 35 at $SAVE_PICKUPS_X[0] $SAVE_PICKUPS_Y[0] 0.0

repeat
    wait 0
    
    if 
        not Player.Defined($PLAYER_CHAR)
    then
        continue
    end

    if
        $SAVE_PICKUPS_EXIST == 0
    then    
        Pickup.Destroy($SAVE_PICKUPS[0])
        
        if
            $ONMISSION == 0
        then
            $SAVE_PICKUPS[0] = Pickup.Create(#PICKUPSAVE, 3, $SAVE_PICKUPS_X[0], $SAVE_PICKUPS_Y[0], $SAVE_PICKUPS_Z[0])
            
            $SAVE_PICKUPS_EXIST = 1
        end
    end
    
    for 2@ = 0 to $TOTAL_AVAILABLE_SAVE_PICKUPS
        wait 0
    
        if
            $SAVE_PICKUPS[2@].Picked_up()
        then
            $BUSES_CREATED = 0
            for 9@ = 0 to $MAX_BUSES
                $BUSES[9@].Destroy()
            end

            03D8: show_save_screen
            $SAVE_PICKUPS[2@].Destroy()
            // clean up buses, sometimes it hacks around and crashes
//            0459: end_thread_named "CROSSLOC_BUS" 
                                    
            repeat
                wait 0
            until 03D9: save_done
            
            $SAVE_PICKUPS[2@].Create(#PICKUPSAVE, 3, $SAVE_PICKUPS_X[2@], $SAVE_PICKUPS_Y[2@], $SAVE_PICKUPS_Z[2@])
            0395: clear_area 1 at $SAVE_POINTS_X[2@] $SAVE_POINTS_Y[2@] $SAVE_POINTS_Z[2@] radius 1.0
            Actor.Angle($PLAYER_ACTOR) = $SAVE_POINTS_A[2@] 
            Actor.PutAt($PLAYER_ACTOR, $SAVE_POINTS_X[2@], $SAVE_POINTS_Y[2@], $SAVE_POINTS_Z[2@])
            wait 0
//            create_thread @CROSSLOC_BUS
            $SAVE_PICKUPS_EXIST = 0
        end
    end                                                      
until false

end_thread

:SF_MISSION_CHECK
thread "CHECKER_SF"

for 25@ = 1 to 3
    $MARKER_CJ = Marker.CreateIconAndSphere(15, $X_BPB_MRK, $Y_BPB_MRK, $Z_BPB_MRK)
    wait 500
    Marker.Disable($MARKER_CJ)
    wait 500
end

$MARKER_CJ = Marker.CreateIconAndSphere(15, $X_BPB_MRK, $Y_BPB_MRK, $Z_BPB_MRK)

repeat
    wait 0 ms
    if and
        Player.Defined($PLAYER_CHAR)
        $ONMISSION == 0
    then
        if and
            00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere $X_BPB_MRK $Y_BPB_MRK $Z_BPB_MRK radius 1.0 1.0 2.0 on_foot  
            Player.Controllable($PLAYER_CHAR)
        then
            $ONMISSION = 1
            $SAVE_PICKUPS_EXIST = 0
            00BA: show_text_styled GXT 'SF_1' time 1000 style 2
            start_mission 1
            $SAVE_PICKUPS_EXIST = 1
        end
    end   
until $SF_MISSIONS_PASSED == 1

Marker.Disable($MARKER_CJ)

wait 3000

for 25@ = 1 to 3
    $marker_car = Marker.CreateIconAndSphere(55, -2124.5042, 149.8957, 0.0)
    wait 500
    Marker.Disable($marker_car)
    wait 500
end

$marker_car = Marker.CreateIconAndSphere(55, -2124.5042, 149.8957, 0.0)

// re-add this
//0570: $marker_car = create_asset_radar_marker_with_icon 55 at -2124.5042 149.8957 35.2505
//018B: set_marker $marker_car radar_mode 2 
// check: mission 2, car stuff
repeat
    wait 0 ms
    if and
        Player.Defined($PLAYER_CHAR)
        $ONMISSION == 0
    then
        if and
            Actor.Driving($PLAYER_ACTOR)
            Actor.DrivingVehicleType($PLAYER_ACTOR, #COMET)
 //           80FE:   actor $PLAYER_ACTOR sphere 0 in_sphere -2124.5052 149.8967 35.2505 radius 1.0 1.0 1.0
            0100: actor $PLAYER_ACTOR in_sphere -2124.5052 149.8967 35.2505 radius 2.0 2.0 2.0 sphere 0 in_car  
            Player.Controllable($PLAYER_CHAR)
            $SF_DRUG_RUNNER == 0
        then
            $ONMISSION = 1
            00BA: show_text_styled GXT 'SF_2' time 1000 style 2
            start_mission 2
        end
    end   
until $SF_MISSIONS_PASSED == 2

Marker.Disable($marker_car)
wait 2000
for 25@ = 1 to 3
    $MARKER_PPCS = Marker.CreateIconAndSphere(29, $X_PPCS_MRK, $Y_PPCS_MRK, $Z_PPCS_MRK)
    wait 500
    Marker.Disable($MARKER_PPCS)
    wait 500
end

$MARKER_PPCS = Marker.CreateIconAndSphere(29, $X_PPCS_MRK, $Y_PPCS_MRK, $Z_PPCS_MRK)

repeat
    wait 0 ms
    if and
        Player.Defined($PLAYER_CHAR)
        $ONMISSION == 0
    then
        if and
            00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere $X_PPCS_MRK $Y_PPCS_MRK $Z_PPCS_MRK radius 0.50 0.50 1.0 on_foot  
            Player.Controllable($PLAYER_CHAR)
        then
            $SAVE_PICKUPS_EXIST = 0
            $ONMISSION = 1
            00BA: show_text_styled GXT 'SF_3' time 1000 style 2
            start_mission 3
            $SAVE_PICKUPS_EXIST = 1
        end
    end   
until $SF_MISSIONS_PASSED == 3

Marker.Disable($MARKER_PPCS)

end_thread

:CROSSLOC_BUS
thread "CROSSLOC_BUS"
// DON'T USE THIS. I REPEAT: DON'T USE THIS! It crashes BAD.

{
$BUSES_CREATED = 0
$MAX_BUSES = 1

#COACH.Load()
#WMYBU.Load()

repeat
    wait 0 ms
    
    if and
        #WMYBU.Available()
        #COACH.Available()
    then
        break
    end
until false

repeat
    wait 0
    
    2@ = 0

    if
        $BUSES_CREATED == 2
    then
        $BUS_DRIVERS[0].DestroyInstantly()
        $BUSES[0].Destroy()
        $BUS_DRIVERS[1].DestroyInstantly()
        $BUSES[1].Destroy()
        
        $BUSES_CREATED = 0
    end
    
    if
        $BUSES_CREATED == 0
    then
        $BUS_MARKERS[0].Disable()
        $BUS_MARKERS[1].Disable()    
        $BUSES[0].Create(#COACH, -1724.2766, 663.4058, 24.8906)
        $BUS_MARKERS[0].CreateIconAndSphere(51, -1724.2766, 663.4058, 0.0)
        0129: $BUS_DRIVERS[0] = create_actor_pedtype 23 model #WMYBU in_car $BUSES[0] driverseat
        
        $BUS_TARGETS_X[0] = 2404.929
        $BUS_TARGETS_Y[0] = -1661.4479
        $BUS_TARGETS_Z[0] = 13.3828
        $BUS_TARGETS_A[0] = 270.0

        $BUSES[1].Create(#COACH, 2389.5718, -1654.8003, 13.3828)
        Car.Angle($BUSES[1]) = 90.0
        $BUS_MARKERS[1].CreateIconAndSphere(51, 2389.5718, -1654.8003, 0.0)
        0129: $BUS_DRIVERS[1] = create_actor_pedtype 23 model #WMYBU in_car $BUSES[1] driverseat
        
        $BUS_TARGETS_X[1] = -1990.4694
        $BUS_TARGETS_Y[1] = 152.3127
        $BUS_TARGETS_Z[1] = 27.5391
        $BUS_TARGETS_A[1] = 0.0

        $BUSES_CREATED = 1 
    end
    
    
    for 2@ = 0 to $MAX_BUSES
        wait 0
    
        if and
            Player.Defined($PLAYER_CHAR)
            Player.Controllable($PLAYER_CHAR)
            $ONMISSION == 0
            $BUSES_CREATED == 1
        then
            if and
                0203: actor $PLAYER_ACTOR near_car $BUSES[2@] radius 20.0 20.0 flag 0 on_foot
                00E1: player 0 pressed_key 15 
            then
                09B9: show_entered_car_name 0 
                $ONMISSION = 1 
                Player.CanMove($PLAYER_CHAR) = False
                05CA: AS_actor $PLAYER_ACTOR enter_car $BUSES[2@] passenger_seat 1 5000 ms 
                
                repeat
                    wait 0
                until Actor.InCar($PLAYER_ACTOR, $BUSES[2@])
                wait 0 
                
                041E: set_radio_station 11 
                00BE: text_clear_all 
                //Marker.Disable($BUS_MARKERS[2@])
                0221: set_player $PLAYER_CHAR trapped_in_car 1 
                00BA: show_text_styled GXT 'SKIP' time 1000 style 2  // Later that day...
                0169: set_fade_color_RGB 0 0 0 
                fade 0 1000 
                wait 1000 
                04E4: unknown_refresh_game_renderer_at $BUS_TARGETS_X[2@] $BUS_TARGETS_Y[2@] 
                Camera.SetAtPos($BUS_TARGETS_X[2@], $BUS_TARGETS_Y[2@], $BUS_TARGETS_Z[2@])
                0395: clear_area 1 at $BUS_TARGETS_X[2@] $BUS_TARGETS_Y[2@] $BUS_TARGETS_Z[2@] radius 4.0 
                Camera.SetPosition($BUS_TARGETS_X[2@], $BUS_TARGETS_Y[2@], $BUS_TARGETS_Z[2@], 0.0, 0.0, 0.0)
                Car.PutAt($BUSES[2@], $BUS_TARGETS_X[2@], $BUS_TARGETS_Y[2@], $BUS_TARGETS_Z[2@])
                Car.Angle($BUSES[2@]) = $BUS_TARGETS_A[2@]
                Camera.SetBehindPlayer
                Camera.Restore_WithJumpCut
                wait 1000 
                0221: set_player $PLAYER_CHAR trapped_in_car 0 
                Player.CanMove($PLAYER_CHAR) = True
                $30 = 0 
                fade 1 1000 
                wait 1000 
                05CD: AS_actor $PLAYER_ACTOR exit_car $BUSES[2@] 
                
                while Actor.InCar($PLAYER_ACTOR, $BUSES[2@])
                    wait 0 
                end 
                
                09B9: show_entered_car_name 1 
                $ONMISSION = 0
                
                039E: set_actor $BUS_DRIVERS[2@] locked 0 while_in_car 
                05D2: AS_actor $BUS_DRIVERS[2@] run_to_and_hijack_car $BUSES[2@] max_search_radius 20.0 traffic_behavior 0
                
                Car.RemoveReferences($BUSES[2@])
                Actor.RemoveReferences($BUS_DRIVERS[2@]) 
                
                while 02CA: car $BUSES[2@] bounding_sphere_visible
                    wait 0
                end
                
                $BUSES_CREATED = 2 
            end
        end
    end
until false
}
// DO use this taxi code.
0662: NOP "The previous code crashed, was something with buses"

$BUS_TARGETS_X[1] = 2404.929
$BUS_TARGETS_Y[1] = -1661.4479
$BUS_TARGETS_Z[1] = 13.3828
$BUS_TARGETS_A[1] = 270.0

$BUS_TARGETS_X[2] = -1990.4694
$BUS_TARGETS_Y[2] = 152.3127
$BUS_TARGETS_Z[2] = 27.5391
$BUS_TARGETS_A[2] = 0.0

repeat
    wait 0

    if and
        Player.Defined($PLAYER_CHAR)
        00E1: player 0 pressed_key 15
        $ONMISSION == 0
        Player.Controllable($PLAYER_CHAR) 
    then
        wait 200
        
        if
            00E1: player 0 pressed_key 15 // the player needs to have the key pressed a while.
        then
            04C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 5.0 5.0 2.0
            04C4: store_coords_to 3@ 4@ 5@ from_actor $PLAYER_ACTOR with_offset -5.0 -5.0 -2.0
            04C4: store_coords_to 6@ 8@ 9@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 -0.5
            
            053E: 7@ = get_random_car_with_model #TAXI in_rectangle_cornerA 0@ 1@ cornerB 3@ 4@
            if
                Car.Wrecked(7@)
            then
                053E: 7@ = get_random_car_with_model #CABBIE in_rectangle_cornerA 0@ 1@ cornerB 3@ 4@

//                0394: play_music 2

                if
                    Car.Wrecked(7@)
                then
//                    0394: play_music 1
                
                    continue
                    //jump @MAIN_LOOP
                end            
            end
            
            046C: 17@ = car 7@ driver
            if 
                Actor.Dead(17@)
            then
                continue
            end
            
            Actor.PutAt($PLAYER_ACTOR, 6@, 8@, 9@)
            
            // okay, we have a car, with (<del>hopefully</del> surely) a driver in it. NEXT!
            09B9: show_entered_car_name 0 
            $ONMISSION = 1 
            Player.CanMove($PLAYER_CHAR) = False
            05CA: AS_actor $PLAYER_ACTOR enter_car 7@ passenger_seat 1 5000 ms 
            
            repeat
                wait 0
            until Actor.InCar($PLAYER_ACTOR, 7@)
            wait 0 
            
            08D4: 12@ = create_panel_with_title 'TAXI' position 29.0 45.0 width 160.0 columns 2 interactive 1 background 1 alignment 0
            08DB: set_panel 12@ column 0 header 'TAXI' data 'GROVEST' 'SFFIN' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
            08DB: set_panel 12@ column 1 header 'COST' data 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
            08D9: set_panel 12@ row 0 enable 1
            08D9: set_panel 12@ row 1 enable 1
            08EE: set_panel 12@ column 1 row 0 text_1number 'DOLLAR' 30  // $~1~
            08EE: set_panel 12@ column 1 row 1 text_1number 'DOLLAR' 30  // $~1~
                                          
            15@ = 0
            
            repeat
                wait 0 ms
                if
                    00E1: key_pressed 0 15
                then
                    break
                end
                
                if
                    00E1: key_pressed 0 16
                then
                    08D7: 25@ = panel 12@ active_row
                    if
                        25@ == 0
                    then
                        15@ = 1
                    end
                    
                    if
                        25@ == 1
                    then
                        15@ = 2
                    end
                    
                    break
                end
            until false

            08DA: remove_panel 12@
            
            if
                15@ == 0
            then
                $ONMISSION = 0
                Player.CanMove($PLAYER_CHAR) = True
                09B9: show_entered_car_name 1
                05CD: AS_actor $PLAYER_ACTOR exit_car 7@
                continue
            end
            
            041E: set_radio_station 11 
            00BE: text_clear_all 
            //Marker.Disable($BUS_MARKERS[2@])
            0221: set_player $PLAYER_CHAR trapped_in_car 1 
            00BA: show_text_styled GXT 'SKIP' time 1000 style 2  // Later that day...
            0169: set_fade_color_RGB 0 0 0 
            fade 0 1000 
            wait 1000 
            04E4: unknown_refresh_game_renderer_at $BUS_TARGETS_X[15@] $BUS_TARGETS_Y[15@] 
            Camera.SetAtPos($BUS_TARGETS_X[15@], $BUS_TARGETS_Y[15@], $BUS_TARGETS_Z[15@])
            0395: clear_area 1 at $BUS_TARGETS_X[15@] $BUS_TARGETS_Y[15@] $BUS_TARGETS_Z[15@] radius 4.0 
            Camera.SetPosition($BUS_TARGETS_X[15@], $BUS_TARGETS_Y[15@], $BUS_TARGETS_Z[15@], 0.0, 0.0, 0.0)
            Car.PutAt(7@, $BUS_TARGETS_X[15@], $BUS_TARGETS_Y[15@], $BUS_TARGETS_Z[15@])
            Car.Angle(7@) = $BUS_TARGETS_A[15@]
            Camera.SetBehindPlayer
            Camera.Restore_WithJumpCut
            wait 1000 
            0221: set_player $PLAYER_CHAR trapped_in_car 0 
            Player.CanMove($PLAYER_CHAR) = True

            fade 1 1000 
            wait 1000 
            05CD: AS_actor $PLAYER_ACTOR exit_car 7@ 
            
            while Actor.InCar($PLAYER_ACTOR, 7@)
                wait 0 
            end 
            
            09B9: show_entered_car_name 1 
            $ONMISSION = 0
            
//            Car.SetDriverBehaviour(7@, 1)
            046C: 17@ = car 7@ driver
            039E: set_actor 17@ locked 0 while_in_car 
            05D2: AS_actor 17@ run_to_and_hijack_car 7@ max_search_radius 20.0 traffic_behavior 0
            Car.RemoveReferences(7@)
            Actor.RemoveReferences(17@)
        end
    end
until false
end_thread

:LS_MISSION_CHECK
thread "CHECKER_LS"

repeat
    wait 0 ms
until $SF_MISSIONS_PASSED == 1

repeat
    wait 0 ms
until $ONMISSION == 0

for 25@ = 1 to 3
    $MARKER_SWEET = Marker.CreateIconAndSphere(38, $X_SWEET_HOUSE, $Y_SWEET_HOUSE, $Z_SWEET_HOUSE)
    wait 500
    Marker.Disable($MARKER_SWEET)
    wait 500
end

$MARKER_SWEET = Marker.CreateIconAndSphere(38, $X_SWEET_HOUSE, $Y_SWEET_HOUSE, $Z_SWEET_HOUSE)

repeat
    wait 0 ms
    if and
        Player.Defined($PLAYER_CHAR)
        $ONMISSION == 0
    then
        if and
            00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere $X_SWEET_HOUSE $Y_SWEET_HOUSE $Z_SWEET_HOUSE radius 1.2 1.2 2.0 on_foot  
            Player.Controllable($PLAYER_CHAR)
        then
            $ONMISSION = 1
            $SAVE_PICKUPS_EXIST = 0
            00BA: show_text_styled GXT 'LS_1' time 1000 style 2
            start_mission 4
            $SAVE_PICKUPS_EXIST = 1
        end
    end   
until $LS_MISSIONS_PASSED == 1

Marker.Disable($MARKER_SWEET)

end_thread

//-------------Mission 0---------------
:INITIAL
var
    3@: Int
    20@: Int
    12@: Int
    5@: Model
end
$SF_MISSIONS_PASSED = 0
$LS_MISSIONS_PASSED = 0
$SF_DRUG_RUNNER = 0
$ONMISSION = 0

//07FB: set_interior 'GF1' access 1  // Denise's - not working?
// ^ found it, it does not have a EnEx defined... stupid rockstar
//07FB: set_interior 'LACRAK' access 1  // Crack Den
//09E6: set_burglary_houses_accessible 1
// ^ REMOVE AFTER TESTING!

$GIRLDOOR0 = Object.Init(#GEN_DOOREXT03, 2401.75, -1714.477, 13.125)
Object.RemoveFromMissionCleanupList($GIRLDOOR0)
Object.Indestructibility($GIRLDOOR0) = False
Object.SetImmunities($GIRLDOOR0, 1, 1, 1, 1, 1)

$X_BPB_MRK = -1757.7087 
$Y_BPB_MRK = 862.8126 
$Z_BPB_MRK = 24.8828

$X_DRUGLAB = -2141.2966
$Y_DRUGLAB = -135.5773
$Z_DRUGLAB = 36.1033

$X_PPCS_MRK = -1967.3381 
$Y_PPCS_MRK = 162.2868
$Z_PPCS_MRK = 27.6875

$X_SWEET_HOUSE = 2515.07 
$Y_SWEET_HOUSE = -1673.98 
$Z_SWEET_HOUSE = 12.71 

// sf mission 2 cars
014B: $SFM2_CAR = init_parked_car_generator #COMET color -1 -1 1 alarm 0 door_lock 0 0 10000 at -2124.5042 149.8957 35.2505 angle 90.0
014C: set_parked_car_generator $SFM2_CAR cars_to_generate_to 101 
0A17: set_parked_car_generator $SFM2_CAR to_player_owned 1

// san fierro pickups

$X_WPICK[0] = -2810.3113
$Y_WPICK[0] = 393.6072
$Z_WPICK[0] = 4.5
//$I_WPICK[0] = #MICRO_UZI
$I_WPICK[0] = 28

$X_WPICK[1] = -2132.3347
$Y_WPICK[1] = 351.5589
$Z_WPICK[1] = 35.1719
//$I_WPICK[1] = #SILENCED
$I_WPICK[1] = 23

$X_WPICK[2] = -2215.7615
$Y_WPICK[2] = 636.7358
$Z_WPICK[2] = 49.4565
//$I_WPICK[2] = #DESERT_EAGLE
$I_WPICK[2] = 24

$X_WPICK[3] = -1659.3597
$Y_WPICK[3] = 1209.6027
$Z_WPICK[3] = 32.9092
//$I_WPICK[3] = #SHOTGSPA
$I_WPICK[3] = 27

$X_WPICK[4] = -2207.5781
$Y_WPICK[4] = -21.237
$Z_WPICK[4] = 35.3203
//$I_WPICK[4] = #MOLOTOV
$I_WPICK[4] = 18

$X_WPICK[5] = -2306.1111
$Y_WPICK[5] = 92.6443
$Z_WPICK[5] = 35.3516
//$I_WPICK[5] = #BAT
$I_WPICK[5] = 5

$X_WPICK[6] = -2467.5327
$Y_WPICK[6] = 404.3851
$Z_WPICK[6] = 27.7736
//$I_WPICK[6] = #MP5LNG
$I_WPICK[6] = 29

$X_WPICK[7] = -2854.0237
$Y_WPICK[7] = 709.9567
$Z_WPICK[7] = 26.749
//$I_WPICK[7] = #AK47
$I_WPICK[7] = 30

$X_WPICK[8] = -2706.8552
$Y_WPICK[8] = 865.8928
$Z_WPICK[8] = 70.7031
//$I_WPICK[8] = #GRENADE
$I_WPICK[8] = 16

$X_WPICK[9] = -1746.3324
$Y_WPICK[9] = 156.5632
$Z_WPICK[9] = 3.5547
//$I_WPICK[9] = #M4
$I_WPICK[9] = 31

$S_WPICK = 10
$MAX_WPICK = 7

20@ = 0

for 30@ = 0 to 20
    wait 0
    $D_WPICK[30@] = 0
end

repeat
    wait 0
    0209: 12@ = random_int_in_ranges 0 $S_WPICK
    if
        $D_WPICK[12@] == 0
    then
        wait 0
        0781: read_model_from_weapon $I_WPICK[12@] save_to 5@ 
        
        5@.Load();
        repeat
            wait 0
        until 5@.Available()
        032B: $P_WPICK[20@] = create_weapon_pickup 5@ group 15 ammo 120 at $X_WPICK[12@] $Y_WPICK[12@] $Z_WPICK[12@]
//        03DC: 25@ = create_marker_above_pickup $P_WPICK[20@]
//        Marker.SetColor(25@, 0)         
        $D_WPICK[12@] = 1
        $L_WPICK[20@] = 12@
        20@ += 1
    end
until 20@ >= $MAX_WPICK

//03E5: show_text_box 'SFHLP3'

$X_APICK[0] = -1799.656
$Y_APICK[0] = 749.973
$Z_APICK[0] = 24.8906

{
$X_APICK[1] = -1951.6006
$Y_APICK[1] = 1375.9113
$Z_APICK[1] = 7.1841
}

$X_APICK[1] = -1796.656
$Y_APICK[1] = 749.973
$Z_APICK[1] = 24.8906

$X_APICK[2] = -1794.656
$Y_APICK[2] = 749.973
$Z_APICK[2] = 24.8906

$S_APICK = 3
$MAX_APICK = 2

3@ = 0

for 30@ = 0 to 39
    wait 0
    $D_APICK[30@] = 0
end

repeat
    wait 0
    0209: 12@ = random_int_in_ranges 0 $S_APICK
    if
        $D_APICK[12@] == 0
    then
        wait 0
        #BODYARMOUR.Load()
        repeat
            wait 0
        until #BODYARMOUR.Available()
        $P_APICK[3@].Create(#BODYARMOUR, 15, $X_APICK[12@], $Y_APICK[12@], $Z_APICK[12@])
//        03DC: 25@ = create_marker_above_pickup $P_APICK[20@]
//        Marker.SetColor(25@, 1)         
        $D_APICK[12@] = 1
        3@ += 1
    end
until 3@ >= $MAX_APICK

//gosub @SUB_GET_NEARBY_WEAPON

// 0629: change_integer_stat 225 to 999 

end_thread
// put your missions here

// mission 1: welcome
:SF_MISSION_1
thread 'MISSION 1'
gosub @SF_MISSION1_MAIN
if wasted_or_busted
then   
    gosub @SF_MISSION1_FAIL
end
gosub @SF_MISSION1_CLEANUP
end_thread

:SF_MISSION1_MAIN
// TODO: add text
//054C: use_GXT_table 'MPACK'  
Model.Load(#BULLET)
Model.Load(#CELLPHONE)
038B: load_requested_models

:SF_MISSION1_LOAD
wait 0 ms
if and                           
    Model.Available(#BULLET)
    Model.Available(#CELLPHONE)
jf @SF_MISSION1_LOAD

0729: AS_actor $PLAYER_ACTOR hold_cellphone 1
wait 1000 ms
00BC: show_text_highpriority GXT 'SFTXT2' time 3000 flag 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SFTXT4' time 3000 flag 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SFTXT3' time 3000 flag 1
wait 3000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 0

$car = Car.Create(#BULLET, -1689.3564, 1052.9912, 17.5859)
Car.Angle($car) = 90

$marker_car = Marker.CreateAboveCar($car)
//Marker.SetColor($marker_car, 3)
0165: set_marker $marker_car color_to 1

00BC: show_text_highpriority GXT 'SFTXT1' time 5000 flag 1

repeat
    wait 0 ms
    
    if Car.Wrecked($car)
    then 
        jump @SF_MISSION1_FAIL_CAR
    end
until Actor.InCar($PLAYER_ACTOR, $car)

Car.SetImmunities($car, 0, 0, 0, 1, 0)

Marker.Disable($marker_car)
//01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~
//$marker_dest = Marker.CreateIconWithoutSphere(0, $X_DRUGLAB, $Y_DRUGLAB, $Z_DRUGLAB)
02A8: $marker_dest = create_marker 0 at $X_DRUGLAB $Y_DRUGLAB $Z_DRUGLAB
0165: set_marker $marker_dest color_to 4
Marker.SetIconSize($marker_dest, 3)
//03BC: $sphere_dest = create_sphere_at $X_DRUGLAB $Y_DRUGLAB $Z_DRUGLAB radius 5.0
//Marker.SetColor()
//10@ = Marker.CreateIconAndSphere(0, $X_BPB_MRK, $Y_BPB_MRK, $Z_BPB_MRK)
00BC: show_text_highpriority GXT 'SFTXT5' time 5000 flag 1
repeat
    wait 0 ms
    
    if Car.Wrecked($car)
    then 
        jump @SF_MISSION1_FAIL_CAR
    end
    
{    if
        not Actor.InCar($PLAYER_ACTOR, $car)
    then
        $marker_car = Marker.CreateAboveCar($car)
    end
    
    if
        Actor.InCar($PLAYER_ACTOR, $car)
    then
        Marker.Disable($marker_car)
    end}
until 01AD: car $car sphere 1 near_point $X_DRUGLAB $Y_DRUGLAB radius 5.0 5.0

Marker.Disable($marker_dest)

Player.ClearWantedLevel($PLAYER_CHAR)

//05CD: AS_actor $PLAYER_ACTOR exit_car $car
//wait 2000 ms
//Car.DoorStatus($car, 2)

//wait 2000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SFTXT6' time 3000 flag 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SFTXT7' time 3000 flag 1
wait 3000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 0

gosub @SUB_GET_NEARBY_WEAPON

{repeat
    wait 0
until 00FF: actor $PLAYER_ACTOR sphere 1 in_sphere $X_WPICK[$PICKUP_NUM] $Y_WPICK[$PICKUP_NUM] $Z_WPICK[$PICKUP_NUM] radius 3.0 3.0 3.0 on_foot

repeat
    wait 0
until Pickup.Picked_up($P_WPICK[$PICKUP_NUM])}

03E5: show_text_box 'SFHLP2'

//wait 2000

//00BC: show_text_highpriority GXT 'SFTXT8' time 5000 flag 1

02A8: 20@ = create_marker 0 at -2027.7611 414.4381 35.1719
0165: set_marker 20@ color_to 4
Marker.SetIconSize(20@, 3)

repeat
    wait 0
until 00FE: actor $PLAYER_ACTOR sphere 0 in_sphere -2027.7611 414.4381 35.1719 radius 30.0 30.0 30.0 
 
:SF_MISSION1_PASSED
0394: play_music 1
$SF_MISSIONS_PASSED += 1
0318: set_latest_mission_passed 'SF_1'
01E3: show_text_1number_styled GXT 'M_PASS' number 100 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~
Player.Money($PLAYER_CHAR) += 100
030C: progress_made += 1
Player.WantedLevel($PLAYER_CHAR) = 0
return

:SF_MISSION1_CLEANUP
$ONMISSION = 0
#BULLET.Destroy()
Marker.Disable($marker_car)
Marker.Disable($marker_dest)
Marker.Disable($sphere_dest)
Marker.Disable(20@)
Marker.Disable($MARKER_PICKUP)
Car.RemoveReferences($car)
if
    $SF_MISSIONS_PASSED == 1
then
    wait 5000 ms
    03E5: show_text_box 'SFHLP1'
end
//Car.Health($car) = 0.0
return

:SF_MISSION1_FAIL_CAR
00BC: show_text_highpriority GXT 'SFTXT9' time 5000 flag 1
jump @SF_MISSION1_FAIL

:SF_MISSION1_FAIL
//00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
Car.Health($car) = 0.0 
return 

// ---------------------------------------------------------------
// mission 2: welcome
:SF_MISSION_2
thread 'MISSION 2'
gosub @SF_MISSION2_MAIN
if wasted_or_busted
then   
    gosub @SF_MISSION2_FAIL
end
gosub @SF_MISSION2_CLEANUP
end_thread

:SF_MISSION2_MAIN
// TODO: add text
//054C: use_GXT_table 'MPACK'
$package = Pickup.Create(#DRUG_GREEN, 3, -2764.6487, 375.6251, 6.3418)  
//Model.Load(#)
Model.Load(#BULLET)
Model.Load(#SFR2)
Model.Load(#TEC9)
#CELLPHONE.Load()
038B: load_requested_models

:SF_MISSION2_LOAD
wait 0 ms
if and                           
    Model.Available(#SFR2)
    Model.Available(#BULLET)
    Model.Available(#TEC9)
    #CELLPHONE.Available()
jf @SF_MISSION2_LOAD

0729: AS_actor $PLAYER_ACTOR hold_cellphone 1
wait 1000 ms
00BC: show_text_highpriority GXT 'SF2TXT1' time 3000 flag 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SF2TXT2' time 3000 flag 1
wait 3000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 0

03DC: $marker_pack = create_marker_above_pickup $package
//Marker.SetColor($marker_car, 3)
0165: set_marker $marker_pack color_to 1
Marker.SetIconSize($marker_pack, 3)

20@ = Car.Create(#BULLET, -2260.5552, 391.5856, 34.179)
0129: 21@ = create_actor_pedtype 24 model #SFR2 in_car 20@
017B: set_actor 21@ weapon 32 ammo_to 200000

01C8: 22@ = create_actor_pedtype 24 model #SFR2 in_car 20@ passenger_seat 0
//22@ = Actor.Create(Mission1, #SFR2, -2708.1655, 450.322, 24.1797)
01B2: give_actor 22@ weapon 32 ammo 200000
01B9: set_actor 22@ armed_weapon_to 32
//0464: put_actor 22@ into_turret_on_car 20@ at_car_offset 0.4242 -0.0679 0 position 2 shooting_angle_limit 0.0 with_weapon 32
0713: actor 22@ driveby_actor $PLAYER_ACTOR car -1 point 0.0 0.0 0.0 radius 5000.0 8 1 firing_rate 60
//05E2: AS_actor 22@ kill_actor $PLAYER_ACTOR

Car.ImmuneToNonPlayer(20@) = true
Car.SetMaxSpeed(20@, 500.0)
Car.DoorStatus(20@, 2)

repeat
    wait 0 ms
until Pickup.Picked_up($package)
Pickup.Destroy($package)
Marker.Disable($marker_pack)

00BC: show_text_highpriority GXT 'SF2TXT4' time 5000 flag 1

repeat
    wait 0 ms
until Actor.Driving($PLAYER_ACTOR)

//$enemy_car1 = Car.Create(#BULLET, -2722.3032, 418.024, 4.1431)
$enemy_car1 = Car.Create(#BULLET, -2708.3865, 296.6691, 4.2218)
0129: $enemy1_driver = create_actor_pedtype 24 model #SFR2 in_car $enemy_car1
017B: set_actor $enemy1_driver weapon 32 ammo_to 200000

//$enemy1_shooter = Actor.Create(Mission1, #SFR2, -2708.1655, 450.322, 24.1797)
01C8: $enemy1_shooter = create_actor_pedtype 24 model #SFR2 in_car $enemy_car1 passenger_seat 0
01B2: give_actor $enemy1_shooter weapon 32 ammo 200000
01B9: set_actor $enemy1_shooter armed_weapon_to 32
//0464: put_actor $enemy1_shooter into_turret_on_car $enemy_car1 at_car_offset 0.4242 -0.0679 0 position 2 shooting_angle_limit 0.0 with_weapon 32
0713: actor $enemy1_shooter driveby_actor $PLAYER_ACTOR car -1 point 0.0 0.0 0.0 radius 5000.0 8 1 firing_rate 60
//05E2: AS_actor $enemy1_shooter kill_actor $PLAYER_ACTOR

Car.SetDriverBehaviour($enemy_car1, 3) // was: 3 (killplayer, followroad), but the enemy was too safety-crazed... he even stopped for traffic lights!
Car.ImmuneToNonPlayer($enemy_car1) = true
Car.SetMaxSpeed($enemy_car1, 500.0)
Car.DoorStatus($enemy_car1, 2)

//00A7: car $enemy_car1 drive_to 
//01EC: make_car $enemy_car1 very_heavy 1 
 
02A8: $marker_dest = create_marker 0 at $X_DRUGLAB $Y_DRUGLAB $Z_DRUGLAB
0165: set_marker $marker_dest color_to 4
Marker.SetIconSize($marker_dest, 3)

00BC: show_text_highpriority GXT 'SF2TXT3' time 5000 flag 1

$marker_enemy = Marker.CreateAboveCar($enemy_car1)

01EB: set_traffic_density_multiplier_to 0.3

repeat
    wait 0 ms
    
    if
        Car.Wrecked($enemy_car1)
    then
        Marker.Disable($marker_enemy)
    end
    
    if and 
        0100: actor $PLAYER_ACTOR in_sphere $X_DRUGLAB $Y_DRUGLAB $Z_DRUGLAB radius 450.0 450.0 450.0 sphere 0 in_car
        40@ == 0
        not Car.Wrecked(20@)
    then
        // make some text
        02A3: enable_widescreen 1
        Player.CanMove($PLAYER_CHAR) = False
        Camera.SetPosition(-2237.8169, 380.7336, 46.1224, 0.0, 0.0, 0.0)
        Camera.PointAt(-2260.5552, 391.5856, 34.179, 2)
        // set car
        Car.SetDriverBehaviour(20@, 3)
        23@ = Marker.CreateAboveCar(20@)
        00BC: show_text_highpriority GXT 'SF2TXT5' time 5000 flag 1
        wait 5000 ms
        02A3: enable_widescreen 0
        Player.CanMove($PLAYER_CHAR) = True
        Camera.Restore_WithJumpCut()
        40@ = 1
    end
    
    if
        Car.Wrecked(20@)
    then
        Marker.Disable(23@)
    end
until 0100: actor $PLAYER_ACTOR in_sphere $X_DRUGLAB $Y_DRUGLAB $Z_DRUGLAB radius 5.0 5.0 5.0 sphere 1 in_car
 
:SF_MISSION2_PASSED
0394: play_music 1
$SF_MISSIONS_PASSED += 1
$SF_DRUG_RUNNER = 1
0318: set_latest_mission_passed 'SF_2'
01E3: show_text_1number_styled GXT 'M_PASS' number 500 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~
030C: progress_made += 1
Player.Money($PLAYER_CHAR) += 500
Player.WantedLevel($PLAYER_CHAR) = 0
return

:SF_MISSION2_CLEANUP
$ONMISSION = 0
Car.Health($enemy_car1) = 0.0
Car.Health(20@) = 0.0
Marker.Disable($marker_enemy)
Marker.Disable(23@)
Marker.Disable($marker_dest)
01EB: set_traffic_density_multiplier_to 1.0
return

:SF_MISSION2_FAIL
//00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
return 

// ---------------------------------------------------------------
// mission 3: all the pizzas
:SF_MISSION_3
thread 'MISSION 3'
gosub @SF_MISSION3_MAIN
if wasted_or_busted
then   
    gosub @SF_MISSION3_FAIL
end
gosub @SF_MISSION3_CLEANUP
end_thread

:SF_MISSION3_MAIN
#DESERT_EAGLE.Load()
#WMYPIZZ.Load()
#WMYBU.Load()
#COLT45.Load()
#CELLPHONE.Load()
#PREMIER.Load()
038B: load_requested_models

:SF_MISSION3_LOAD
wait 0 ms
if and                           
    #CELLPHONE.Available()
    #DESERT_EAGLE.Available()
    #WMYPIZZ.Available()
    #WMYBU.Available()
    #COLT45.Available()
    #PREMIER.Available()
jf @SF_MISSION3_LOAD

0729: AS_actor $PLAYER_ACTOR hold_cellphone 1
wait 1000 ms
00BC: show_text_highpriority GXT 'SF3TX01' time 3000 flag 1
02A8: 11@ = create_marker 0 at -1807.1318 944.1807 24.8906
Marker.SetIconSize(11@, 3)
Marker.SetColor(11@, 0)
wait 3000 ms
00BC: show_text_highpriority GXT 'SF3TX02' time 3000 flag 1
032B: 10@ = create_weapon_pickup #DESERT_EAGLE group 3 ammo 120 at -1963.1986 162.2506 27.6875
03DC: 12@ = create_marker_above_pickup 10@
Marker.SetColor(12@, 1)
wait 3000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 0

//gosub @SUB_GET_NEARBY_WEAPON

{repeat
    wait 0
until 00FF: actor $PLAYER_ACTOR sphere 1 in_sphere $X_WPICK[$PICKUP_NUM] $Y_WPICK[$PICKUP_NUM] $Z_WPICK[$PICKUP_NUM] radius 5.0 5.0 5.0 on_foot}

00BC: show_text_highpriority GXT 'SF3TX03' time 5000 flag 1

//Marker.Disable($MARKER_PICKUP)

{
$MODEL_PICKUP.Load()

repeat
    wait 0
until $MODEL_PICKUP.Available()
}

repeat
    wait 0 ms
    
    if
        Pickup.Picked_up(10@)
    then
        Marker.Disable(12@)
    end
until 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere -1807.1318 944.1807 24.8906 radius 2.0 2.0 2.0 on_foot

Marker.Disable(12@)

00BC: show_text_highpriority GXT 'SF3TX04' time 5000 flag 1

// go inside!
repeat
    wait 0 ms
until 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere 374.036 -124.7741 1001.4922 radius 50.0 50.0 10.0 on_foot

Marker.Disable(11@)

060A: create_decision_maker_type 2 store_to 140@

0615: define_AS_pack_begin 40@
//0850: AS_actor -1 follow_actor $PLAYER_ACTOR
05D9: AS_actor -1 run_to_actor $PLAYER_ACTOR timelimit 2000 stop_within_radius 3.0  
05E2: AS_actor -1 kill_actor $PLAYER_ACTOR
0616: define_AS_pack_end 40@
0643: set_AS_pack 40@ loop 1 

20@ = Actor.Create(Mission1, #WMYPIZZ, 368.5827, -115.8, 1001.4922)

Actor.WeaponAccuracy(20@) = 95.0
//01B2: give_actor 20@ weapon $WID_PICKUP ammo 120 // Load the weapon model before using this
//01B9: set_actor 20@ armed_weapon_to $WID_PICKUP
01B2: give_actor 20@ weapon 22 ammo 120 // Load the weapon model before using this
01B9: set_actor 20@ armed_weapon_to 22
0350: set_actor 20@ maintain_position_when_attacked 1
0618: assign_actor 20@ to_AS_pack 40@

21@ = Actor.Create(Mission1, #WMYPIZZ, 372.7157, -114.0977, 1001.4922)

Actor.WeaponAccuracy(21@) = 95.0
01B2: give_actor 21@ weapon 22 ammo 120 // Load the weapon model before using this
01B9: set_actor 21@ armed_weapon_to 22
//01B2: give_actor 21@ weapon $WID_PICKUP ammo 120 // Load the weapon model before using this
//01B9: set_actor 21@ armed_weapon_to $WID_PICKUP
0350: set_actor 21@ maintain_position_when_attacked 1
//0618: assign_actor 21@ to_AS_pack 40@

22@ = Actor.Create(Mission1, #WMYPIZZ, 377.4144, -132.0208, 1001.4922)

01B2: give_actor 22@ weapon 22 ammo 120 // Load the weapon model before using this
01B9: set_actor 22@ armed_weapon_to 22
0350: set_actor 22@ maintain_position_when_attacked 1 
//05DD: AS_actor 22@ flee_from_actor $PLAYER_ACTOR from_origin_radius 100.0 timelimit 10000

05E2: AS_actor 20@ kill_actor $PLAYER_ACTOR
05E2: AS_actor 21@ kill_actor $PLAYER_ACTOR
05E2: AS_actor 22@ kill_actor $PLAYER_ACTOR
060B: set_actor 20@ decision_maker_to 140@ 
060B: set_actor 21@ decision_maker_to 140@ 
060B: set_actor 22@ decision_maker_to 140@ 
077A: set_actor 20@ acquaintance 3 to_actors_pedtype 0 // see ped.dat
077A: set_actor 21@ acquaintance 3 to_actors_pedtype 0 // see ped.dat 
077A: set_actor 22@ acquaintance 3 to_actors_pedtype 0 // see ped.dat 


00BC: show_text_highpriority GXT 'SF3TX05' time 5000 flag 1

// these don't work in interiors
//25@ = Marker.CreateAboveActor(20@)
//26@ = Marker.CreateAboveActor(21@)
//27@ = Marker.CreateAboveActor(22@)

repeat
    wait 0 ms
    
    {if
        Actor.Dead(20@)
    then
        Marker.Disable(25@)
    end
    
    if
        Actor.Dead(21@)
    then
        Marker.Disable(26@)
    end
    
    if
        Actor.Dead(22@)
    then
        Marker.Disable(27@)
    end}

    if
        00FF: actor $PLAYER_ACTOR sphere 0 in_sphere -1807.1318 944.1807 24.8906 radius 5.0 5.0 20.0 on_foot
    then
        jump @SF_MISSION3_FAIL_OUT
    end
    
    if and
        Actor.Dead(20@)
        Actor.Dead(21@)
        Actor.Dead(22@)
    then
        break
    end
until false

Player.ClearWantedLevel($PLAYER_CHAR)

wait 2000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 1
wait 1000 ms
00BC: show_text_highpriority GXT 'SF3TX06' time 3000 flag 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SF3TX07' time 3000 flag 1
wait 3000 ms
00BC: show_text_highpriority GXT 'SF3TX08' time 3000 flag 1
wait 3000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 0

wait 1000 ms

00BC: show_text_highpriority GXT 'SF3TX12' time 5000 flag 1

5@ = Car.Create(#PREMIER, -1978.6158, 465.1574, 28.8908)
Car.Angle(5@) = 0.0
Car.DoorStatus(5@) = 2
Car.SetMaxSpeed(5@, 500.0)
0129: 6@ = create_actor_pedtype 24 model #WMYBU in_car 5@

repeat
    wait 0
until 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere -1807.1318 944.1807 24.8906 radius 5.0 5.0 20.0 on_foot

02A8: 3@ = create_marker 0 at -1979.1404 544.1484 35.0098
Marker.SetColor(3@, 0)
Marker.SetIconSize(3@, 3)

repeat
    wait 0
until 0100: actor $PLAYER_ACTOR in_sphere -1979.1404 544.1484 35.0098 radius 25.0 25.0 25.0 sphere 0 in_car

Marker.Disable(3@)

02A3: enable_widescreen 1
Player.CanMove($PLAYER_CHAR) = False
Camera.SetPosition(-1972.7919, 542.9792, 39.4272, 0.0, 0.0, 0.0)
Camera.PointAt(-1979.6716, 527.8436, 34.4233, 2)
// set car
Car.DriveTo(5@, -1807.1318, 944.1807, 24.8906)
4@ = Marker.CreateAboveCar(5@)
Marker.SetColor(4@, 0)
00BC: show_text_highpriority GXT 'SF3TX09' time 5000 flag 1
wait 5000 ms
02A3: enable_widescreen 0
Player.CanMove($PLAYER_CHAR) = True
Camera.Restore_WithJumpCut()

repeat
    wait 0
    
    if
        01AF: car 5@ sphere 0 in_sphere -1807.1318 944.1807 24.8906 radius 15.0 15.0 15.0
    then
        jump @SF_MISSION3_FAIL_ARRIVED
    end
    
    if
        Car.Wrecked(5@)
    then
        break
    end
    
    if
        Actor.Dead(6@)
    then
        break
    end 
until false

// campos: -1972.7919, 542.9792, 39.4272
// campoint: -1979.6716, 527.8436, 34.4233
 
:SF_MISSION3_PASSED
0394: play_music 1
$SF_MISSIONS_PASSED += 1
0318: set_latest_mission_passed 'SF_3'
01E3: show_text_1number_styled GXT 'M_PASS' number 500 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~
Player.Money($PLAYER_CHAR) += 500
030C: progress_made += 1
return                                                  
:SF_MISSION3_CLEANUP
$ONMISSION = 0
Marker.Disable(30@)
Marker.Disable(31@)
Marker.Disable(32@)
Marker.Disable(4@)
Marker.Disable(3@)
//Car.Health(5@) = 0.0

Actor.DestroyInstantly(6@)
Actor.DestroyInstantly(20@)
Actor.DestroyInstantly(21@)
Actor.DestroyInstantly(22@)

061B: remove_references_to_AS_pack 40@
return

:SF_MISSION3_FAIL_OUT
00BC: show_text_highpriority GXT 'SF3TX11' time 5000 flag 1
Player.WantedLevel($PLAYER_CHAR) = 2
jump @SF_MISSION3_FAIL

:SF_MISSION3_FAIL_ARRIVED
00BC: show_text_highpriority GXT 'SF3TX10' time 5000 flag 1
Player.WantedLevel($PLAYER_CHAR) = 2
jump @SF_MISSION3_FAIL

:SF_MISSION3_FAIL
//00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
return

:LS_MISSION_1
thread 'MISSION 1'
gosub @LS_MISSION1_MAIN
if wasted_or_busted
then   
    gosub @LS_MISSION1_FAIL
end
gosub @LS_MISSION1_CLEANUP
end_thread

:LS_MISSION1_MAIN
07FB: set_interior 'GF1' access 1  // Denise's
07FB: set_interior 'LACRAK' access 1  // Crack Den
// TODO: add text
//054C: use_GXT_table 'MPACK'
023C: load_special_actor 'SWEET' as 1 // models 290-299   
Model.Load(#GREENWOO)
Model.Load(#VOODOO)
Model.Load(#BALLAS1)
Model.Load(#BALLAS2)
Model.Load(#MICRO_UZI)
038B: load_requested_models

:LS_MISSION1_LOAD
wait 0 ms
if and                           
    Model.Available(#GREENWOO)
    Model.Available(#BALLAS1)
    Model.Available(#BALLAS2)
    Model.Available(#MICRO_UZI)
    Model.Available(#VOODOO)
    023D: special_actor 1 loaded
jf @LS_MISSION1_LOAD

2@ = Actor.Create(Mission1, #SPECIAL01, 2507.9402, -1672.1018, 13.3782)
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 
0631: put_actor 2@ in_group $PLAYER_GROUP
07CB: set_actor 2@ supporting_fire 0
3@ = Marker.CreateAboveActor(2@)
Marker.SetColor(3@, 1)

02A8: 4@ = create_marker 0 at 2401.5649 -1719.6389 13.6162
Marker.SetColor(4@, 2)
Marker.SetIconSize(4@, 3)

repeat
    wait 0
until 00FF: actor $PLAYER_ACTOR sphere 1 in_sphere 2401.5649 -1719.6389 13.6162 radius 2.0 2.0 2.0 on_foot

Marker.Disable(4@)

Player.CanMove($PLAYER_CHAR) = False
gosub @SUB_FADE_500MS
select_interior 1
04E4: unknown_refresh_game_renderer_at 246.0205 304.9978
Camera.SetAtPos(246.0205, 304.9978, 999.1484)
0860: link_actor $PLAYER_ACTOR to_interior 1
0860: link_actor 2@ to_interior 1
 
Actor.PutAt($PLAYER_ACTOR, 246.0205, 304.9978, 999.1484)
Camera.SetBehindPlayer
Camera.Restore_WithJumpCut

wait 1000
fade 1 500

Player.CanMove($PLAYER_CHAR) = True

5@ = Pickup.Create(#DRUG_GREEN, 3, 248.0676, 302.1555, 999.1484)

repeat
    wait 0
until Pickup.Picked_up(5@)

repeat
    wait 0
until 00FF: actor $PLAYER_ACTOR sphere 1 in_sphere 244.412 305.033 999.1484 radius 2.0 2.0 2.0 on_foot

Player.CanMove($PLAYER_CHAR) = False
gosub @SUB_FADE_500MS
select_interior 0
04E4: unknown_refresh_game_renderer_at 2401.5649 -1719.6389
Camera.SetAtPos(2401.5649, -1719.6389, 13.6162)
0860: link_actor $PLAYER_ACTOR to_interior 0
0860: link_actor 2@ to_interior 0
 
Actor.PutAt($PLAYER_ACTOR, 2401.5649, -1719.6389, 13.6162)
Camera.SetBehindPlayer
Camera.Restore_WithJumpCut

wait 1000
fade 1 500

Player.CanMove($PLAYER_CHAR) = True

6@ = Pickup.Create(#CLOTHESP, 3, 2239.8054, -1662.9869, 15.4766)
03DC: 7@ = create_marker_above_pickup 6@

repeat
    wait 0
until Pickup.Picked_up(6@)

Marker.Disable(7@)

gosub @SUB_FADE_500MS

087B: set_player $PLAYER_CHAR clothes_texture "CHINOSBLACK" model "CHINOS" body_part 2 
087B: set_player $PLAYER_CHAR clothes_texture "NECKDOLLAR" model "NECK" body_part 13 
087B: set_player $PLAYER_CHAR clothes_texture "TSHIRT2HORIZ" model "TSHIRT2" body_part 0 
$PLAYER_CHAR.Build()

wait 1000
fade 1 500

// code from SFM3

02A8: 11@ = create_marker 0 at 2168.3582 -1673.9459 15.0834
Marker.SetIconSize(11@, 3)
Marker.SetColor(11@, 0)

repeat
    wait 0 ms
until 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere 2168.3582 -1673.9459 15.0834 radius 2.0 2.0 2.0 on_foot

06C9: remove_actor 2@ from_group

// go inside!
repeat
    wait 0 ms
until 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere 318.6203 1118.7894 1083.8828 radius 70.0 70.0 30.0 on_foot

Marker.Disable(11@)

060A: create_decision_maker_type 2 store_to 140@

{0615: define_AS_pack_begin 40@
//0850: AS_actor -1 follow_actor $PLAYER_ACTOR
//05D9: AS_actor -1 run_to_actor $PLAYER_ACTOR timelimit 1000 stop_within_radius 3.0  
05E2: AS_actor -1 kill_actor $PLAYER_ACTOR
0616: define_AS_pack_end 40@
0643: set_AS_pack 40@ loop 1} 

20@ = Actor.Create(Mission1, #BALLAS1, 310.585, 1120.89, 1083.8828)

Actor.WeaponAccuracy(20@) = 95.0
01B2: give_actor 20@ weapon 28 ammo 240 // Load the weapon model before using this
01B9: set_actor 20@ armed_weapon_to 28
0350: set_actor 20@ maintain_position_when_attacked 1
0860: link_actor 20@ to_interior 5

21@ = Actor.Create(Mission1, #BALLAS2, 324.0353, 1129.0122, 1083.8828)

Actor.WeaponAccuracy(21@) = 95.0
01B2: give_actor 21@ weapon 28 ammo 240 // Load the weapon model before using this
01B9: set_actor 21@ armed_weapon_to 28
0350: set_actor 21@ maintain_position_when_attacked 1
0860: link_actor 21@ to_interior 5
060B: set_actor 21@ decision_maker_to 140@

// 314.5141, 1123.9297, 1083.8828
22@ = Actor.Create(Mission1, #BALLAS1, 323.4687, 1121.8982, 1083.8828)

Actor.WeaponAccuracy(22@) = 95.0
01B2: give_actor 22@ weapon 28 ammo 240 // Load the weapon model before using this
01B9: set_actor 22@ armed_weapon_to 28
0350: set_actor 22@ maintain_position_when_attacked 1
0860: link_actor 22@ to_interior 5
060B: set_actor 22@ decision_maker_to 140@

23@ = Actor.Create(Mission1, #BALLAS2, 314.5141, 1123.9297, 1083.8828)

Actor.WeaponAccuracy(23@) = 95.0
01B2: give_actor 23@ weapon 28 ammo 240 // Load the weapon model before using this
01B9: set_actor 23@ armed_weapon_to 28
0350: set_actor 23@ maintain_position_when_attacked 1
0860: link_actor 23@ to_interior 5
060B: set_actor 23@ decision_maker_to 140@

wait 1000
40@ = Pickup.Create(#DRUG_GREEN, 3, 318.9721, 1122.1222, 1083.8828)
wait 2000
07CD: AS_actor 22@ walk_to 318.9721 1122.1222 1083.8828 stop_with_angle 270.0 within_radius 0.3
wait 5000 
Pickup.Destroy(40@)
0A1D: AS_actor 22@ rotate_to_and_look_at_actor $PLAYER_ACTOR
wait 1000 

//0618: assign_actor 20@ to_AS_pack 40@
//0618: assign_actor 21@ to_AS_pack 40@
//0618: assign_actor 22@ to_AS_pack 40@
//0618: assign_actor 23@ to_AS_pack 40@
05E2: AS_actor 20@ kill_actor $PLAYER_ACTOR
05E2: AS_actor 21@ kill_actor $PLAYER_ACTOR
05E2: AS_actor 22@ kill_actor $PLAYER_ACTOR
05E2: AS_actor 23@ kill_actor $PLAYER_ACTOR
060B: set_actor 20@ decision_maker_to 140@ 
060B: set_actor 21@ decision_maker_to 140@ 
060B: set_actor 22@ decision_maker_to 140@ 
060B: set_actor 23@ decision_maker_to 140@ 
077A: set_actor 20@ acquaintance 3 to_actors_pedtype 0 // see ped.dat
077A: set_actor 21@ acquaintance 3 to_actors_pedtype 0 // see ped.dat 
077A: set_actor 22@ acquaintance 3 to_actors_pedtype 0 // see ped.dat 
077A: set_actor 23@ acquaintance 3 to_actors_pedtype 0 // see ped.dat 
// these don't work in interiors
25@ = Marker.CreateAboveActor(20@)
26@ = Marker.CreateAboveActor(21@)
27@ = Marker.CreateAboveActor(22@)
28@ = Marker.CreateAboveActor(23@)
08DC: create_interior_marker 25@ at 2167.835 -1672.923 radius 2.0
08DC: create_interior_marker 26@ at 2167.835 -1672.923 radius 2.0
08DC: create_interior_marker 27@ at 2167.835 -1672.923 radius 2.0
08DC: create_interior_marker 28@ at 2167.835 -1672.923 radius 2.0 

repeat
    wait 0 ms
    
    if
        Actor.Dead(20@)
    then
        Marker.Disable(25@)
    end
    
    if
        Actor.Dead(21@)
    then
        Marker.Disable(26@)
    end
    
    if
        Actor.Dead(22@)
    then
        Marker.Disable(27@)
    end

    if
        Actor.Dead(23@)
    then
        Marker.Disable(28@)
    end

    if
        00FF: actor $PLAYER_ACTOR sphere 0 in_sphere 2168.3582 -1673.9459 15.0834 radius 5.0 5.0 20.0 on_foot
    then
        jump @LS_MISSION1_FAIL
    end
    
    if and
        Actor.Dead(20@)
        Actor.Dead(21@)
        Actor.Dead(22@)
        Actor.Dead(23@)
    then
        break
    end
until false

repeat
    wait 0
until 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere 2168.3582 -1673.9459 15.0834 radius 5.0 5.0 20.0 on_foot

0631: put_actor 2@ in_group $PLAYER_GROUP
07CB: set_actor 2@ supporting_fire 1

$SWEET_CAR = Car.Create(#GREENWOO, 2183.2151, -1668.265, 14.6419)
70@ = Marker.CreateAboveCar($SWEET_CAR)

repeat
    wait 0
until Actor.InCar($PLAYER_ACTOR, $SWEET_CAR)

Marker.Disable(70@)

repeat
    wait 0
until Actor.InCar(2@, $SWEET_CAR)

Marker.Disable(3@)

65@ = Car.Create(#VOODOO, 2183.7507, -1691.7106, 13.6083)
52@ = Marker.CreateAboveCar(65@)
0129: 89@ = create_actor_pedtype 25 model #BALLAS2 in_car 65@ driverseat 
0446: set_actor 89@ immune_to_headshots 0 
01B2: give_actor 89@ weapon 28 ammo 99999 // Load the weapon model before using this 
01B9: set_actor 89@ armed_weapon_to 28 
Actor.WeaponAccuracy(89@) = 40
01C8: 90@ = create_actor_pedtype 25 model #BALLAS2 in_car 65@ passenger_seat 0 
0446: set_actor 90@ immune_to_headshots 0 
01B2: give_actor 90@ weapon 28 ammo 99999 // Load the weapon model before using this 
01B9: set_actor 90@ armed_weapon_to 28 
Actor.WeaponAccuracy(90@) = 40

0713: actor 90@ driveby_actor -1 car $SWEET_CAR point 0.0 0.0 0.0 radius 5000.0 8 1 firing_rate 60

0446: set_actor 2@ immune_to_headshots 1 
01B2: give_actor 2@ weapon 28 ammo 99999 // Load the weapon model before using this 
01B9: set_actor 2@ armed_weapon_to 28 
Actor.WeaponAccuracy(2@) = 80

0713: actor 2@ driveby_actor -1 car 65@ point 0.0 0.0 0.0 radius 5000.0 8 0 firing_rate 45

Car.SetDriverBehaviour(65@, 3)
Car.SetMaxSpeed(65@, 250.0)

98@ = Marker.CreateAboveCar(65@)

repeat
    wait 0
    
    if
        Car.Wrecked(65@)
    then
        break    
    end
    
    if or
        Actor.Dead(89@)
        Actor.Dead(90@)
    then
        break
    end
    
    if or
        Car.Wrecked($SWEET_CAR)
        Actor.Dead(2@)
    then
        jump @LS_MISSION1_FAIL
    end
until false

wait 500 ms
Marker.Disable(98@)
wait 500 ms

02A8: 99@ = create_marker 0 at $X_SWEET_HOUSE $Y_SWEET_HOUSE $Z_SWEET_HOUSE
Marker.SetIconSize(99@, 3)
Marker.SetColor(99@, 3)

repeat
    wait 0
    
    if or
        Car.Wrecked($SWEET_CAR)
        Actor.Dead(2@)
    then
        jump @LS_MISSION1_FAIL
    end
until 01AF: car $SWEET_CAR sphere 1 in_sphere $X_SWEET_HOUSE $Y_SWEET_HOUSE $Z_SWEET_HOUSE radius 3.0 3.0 2.0

Marker.Disable(99@)

:LS_MISSION1_PASSED
0394: play_music 1
$LS_MISSIONS_PASSED += 1
0318: set_latest_mission_passed 'LS_1'
01E3: show_text_1number_styled GXT 'M_PASS' number 1000 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~
Player.Money($PLAYER_CHAR) += 1000
030C: progress_made += 1
Player.WantedLevel($PLAYER_CHAR) = 0
return

:LS_MISSION1_CLEANUP
$ONMISSION = 0
Actor.RemoveReferences(20@)
Actor.RemoveReferences(21@)
Actor.RemoveReferences(22@)
Actor.RemoveReferences(23@)
Actor.RemoveReferences(2@)
Car.RemoveReferences(65@)
Marker.Disable(98@)
Marker.Disable(99@)
Marker.Disable(25@)
Marker.Disable(26@)
Marker.Disable(27@)
Marker.Disable(28@)
Marker.Disable(3@)
//Car.Health($car) = 0.0
return

:LS_MISSION1_FAIL
//00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
return 
       
//-------------External script 0---------------
// put your external scripts here
    