{$CLEO .cs}
{$USE CLEO+}
{$USE ini}
{$USE Audio}
{$USE newOpcodes}

0000: NOP

script_name "MtlQa"

// by ArtemQa146

const
    Speed_time = 0@
    Int_1 = 31@
    Int_2 = 30@
    Back_x = 29@
    back_y = 28@
    back_z = 27@
    angle_z = 26@
    money_ini = 25@
    check = 24@
    x1 = 23@
    x2 = 22@
    x3 = 21@
    x4 = 20@
    y1 = 19@
    y2 = 18@
    y3 = 17@
    y4 = 16@
    z1 = 15@
    z2 = 14@
    z3 = 13@
    z4 = 12@
    music = 11@
    mode = 10@
    door_1 = 9@
    door_2 = 8@
    check_bit = 7@
    ped_1 = 6@
    wash = 1
    sleep = 2
    whore = 3
end

0AF0: money_ini = read_int_from_ini_file "cleo\Motel.ini" section "Settings" key "Money"
0AF0: Speed_time = read_int_from_ini_file "cleo\Motel.ini" section "Settings" key "Speed time"
0AF0: mode = read_int_from_ini_file "cleo\Motel.ini" section "Settings" key "Advanced Mode"

0390: load_txd_dictionary "MTLQA"
038F: load_texture "MTLQA" as 1
0E3C: get_texture_from_sprite 1 store_to 1@
0391: release_textures

0AF2: x1 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "x1"
0AF2: y1 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "y1"
0AF2: z1 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "z1"
if and
    not x1 == 0
    not y1 == 0
then
    0E2A: add_cleo_blip 1@ position x1 y1 is_short 1 RGBA 255 255 255 255 store_to 2@
end

0AF2: x2 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "x2"
0AF2: y2 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "y2"
0AF2: z2 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "z2"
if and
    not x2 == 0
    not y2 == 0
then
    0E2A: add_cleo_blip 1@ position x2 y2 is_short 1 RGBA 255 255 255 255 store_to 2@
end

0AF2: x3 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "x3"
0AF2: y3 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "y3"
0AF2: z3 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "z3"
if and
    not x3 == 0
    not y3 == 0
then
    0E2A: add_cleo_blip 1@ position x3 y3 is_short 1 RGBA 255 255 255 255 store_to 2@
end

0AF2: x4 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "x4"
0AF2: y4 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "y4"
0AF2: z4 = read_float_from_ini_file "cleo\Motel.ini" section "New position" key "z4"
if and
    not x4 == 0
    not y4 == 0
then
    0E2A: add_cleo_blip 1@ position x4 y4 is_short 1 RGBA 255 255 255 255 store_to 2@
end

0E2A: add_cleo_blip 1@ position -779.1328 2745.2605 is_short 1 RGBA 255 255 255 255 store_to 2@
0E2A: add_cleo_blip 1@ position 2178.6897 -1770.5497 is_short 1 RGBA 255 255 255 255 store_to 2@
0E2A: add_cleo_blip 1@ position 88.6793 1182.0293 is_short 1 RGBA 255 255 255 255 store_to 2@
0E2A: add_cleo_blip 1@ position 2032.1741 2161.8232 is_short 1 RGBA 255 255 255 255 store_to 2@
0E2A: add_cleo_blip 1@ position -828.15 1438.7191 is_short 1 RGBA 255 255 255 255 store_to 2@
0E2A: add_cleo_blip 1@ position 2559.3589 1561.5369 is_short 1 RGBA 255 255 255 255 store_to 2@
0E2A: add_cleo_blip 1@ position 739.0193 -1430.8478 is_short 1 RGBA 255 255 255 255 store_to 2@

if $LS_FINAL_TOTAL_PASSED_MISSIONS >= 1
then 0E2A: add_cleo_blip 1@ position 2231.3777 -1159.7439 is_short 1 RGBA 255 255 255 255 store_to 2@
end

0AF0: 1@ = read_int_from_ini_file "cleo\Motel.ini" section "Settings" key "Disable the moon phase"
if
    1@ == 1
then
    0A8C: write_memory 0x713BF2 size 4 value 0x858B50 virtual_protect 0
end

while true
wait 0
    if
        player.Defined(0)
    then

        check = false
        1@ = 0.0
        2@ = 0.0
        3@ = 0.0
        
        if or
            Actor.Driving($PLAYER_ACTOR)
            0118:   actor $PLAYER_ACTOR dead
            0741:   actor $PLAYER_ACTOR busted
            010F:   player $PLAYER_CHAR wanted_level > 0
        then
            continue
        end
        
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -779.1328 2745.2605 45.6862 radius 15.0
        then
            1@ = -779.1328
            2@ = 2745.2605
            3@ = 45.6862
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2178.6897 -1770.5497 13.5445 radius 15.0
        then
            1@ = 2178.6897
            2@ = -1770.5497
            3@ = 13.5445
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 88.6793 1182.0293 18.6641 radius 15.0
        then
            1@ = 88.6793
            2@ = 1182.0293
            3@ = 18.6641
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2032.0337 2161.6648 10.8203 radius 15.0
        then
            1@ = 2032.0337
            2@ = 2161.6648
            3@ = 10.8203
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -828.15 1438.7191 13.7919 radius 15.0
        then
            1@ = -828.15
            2@ = 1438.7191
            3@ = 13.7919
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2559.3589 1561.5369 10.8203 radius 15.0
        then
            1@ = 2559.3589
            2@ = 1561.5369
            3@ = 10.8203
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 739.0193 -1430.8478 13.5235 radius 15.0
        then
            1@ = 739.0193
            2@ = -1430.8478
            3@ = 13.5235
        end
        
        if and
            $LS_FINAL_TOTAL_PASSED_MISSIONS >= 1
            not $ACTIVE_INTERIOR == 0
            0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2217.4377 -1146.4165 1025.7969 radius 15.0
        then
            1@ = 2217.4377
            2@ = -1146.4165
            3@ = 1025.7969
        end

        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos x1 y1 z1 radius 15.0
        then
            if and
                not x1 == 0
                not y1 == 0
            then
                0087: 1@ = x1 // (float)
                0087: 2@ = y1 // (float)
                0087: 3@ = z1 // (float)
            end
        end

        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos x2 y2 z2 radius 15.0
        then
            if and
                not x2 == 0
                not y2 == 0
            then
                0087: 1@ = x2 // (float)
                0087: 2@ = y2 // (float)
                0087: 3@ = z2 // (float)
            end
        end

        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos x3 y3 z3 radius 15.0
        then
            if and
                not x3 == 0
                not y3 == 0
            then
                0087: 1@ = x3 // (float)
                0087: 2@ = y3 // (float)
                0087: 3@ = z3 // (float)
            end
        end
        
        if 0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos x4 y4 z4 radius 15.0
        then
            if and
                not x4 == 0
                not y4 == 0
            then
                0087: 1@ = x4 // (float)
                0087: 2@ = y4 // (float)
                0087: 3@ = z4 // (float)
            end
        end
        
        //     
        if and
            not 1@ == 0.0
            not 2@ == 0.0
            not 3@ == 0.0
        then
            if
                00FF:   actor $PLAYER_ACTOR sphere 1 in_sphere 1@ 2@ 3@ radius 0.7 0.7 1.0 on_foot //    
            then
                if mode == 1
                then 0513: show_text_box_1number 'mtlqa2' number money_ini  // ~k~~VEHICLE_ENTER_EXIT~ Use Slot Machine $~1~
                else 0513: show_text_box_1number 'mtlqa0' number money_ini  // ~k~~VEHICLE_ENTER_EXIT~ Use Slot Machine $~1~
                end
                04C4: store_coords_to Back_x Back_y Back_z from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
                
                repeat
                wait 0
                if
                    player.Defined(0)
                then
                    if or
                        Actor.Driving($PLAYER_ACTOR)
                        0118:   actor $PLAYER_ACTOR dead
                        0741:   actor $PLAYER_ACTOR busted
                        010F:   player $PLAYER_CHAR wanted_level > 0
                    then
                        break
                    end
                    
                    //      
                    if and
                        010A:   player $PLAYER_CHAR money > money_ini
                        00E1:   player 0 pressed_key 15
                    then
                        check = true
                        break
                    else
                        //       
                        if and
                            810A:   not player $PLAYER_CHAR money > money_ini
                            00E1:   player 0 pressed_key 15
                        then
                            00BC: show_text_highpriority GXT 'mtlqa1' time 2000 flag 1
                        end
                    end
                else
                    break
                end
                until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos Back_x Back_y Back_z radius 1.5
                
                03E6: remove_text_box

            end
        end


        //  
        if
            check == true
        then
            if
                mode == 1
            then
                03BF: set_player $PLAYER_CHAR ignored_by_everyone 1
                0085: 1@ = money_ini // (int)
                1@ *= -1
                0109: player $PLAYER_CHAR money += 1@
                01B4: set_player $PLAYER_CHAR can_move 0
                06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 1


                016A: fade 0 time 1000 //  
                wait 1000

                model.Load(15029) //  
                model.Load(15025) //  
                model.Load(2987)
                038B: load_requested_models

                04C4: store_coords_to Back_x Back_y Back_z from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0 //   
                0172: angle_z = actor $PLAYER_ACTOR Z_angle
                0087: 3@ = Back_z // (float)
                3@ += 20.0
                0E01: create_object_no_save 15029 at Back_x Back_y 3@ offset 0 ground 0 to Int_1
                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.4 -0.1 0.0
                0E01: create_object_no_save 15025 at 1@ 2@ 3@ offset 0 ground 0 to Int_2
                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -1.7 0.5 -2.2
                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                0173: set_actor $PLAYER_ACTOR Z_angle_to 200.0
                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0
                0826: enable_hud 0
                0581: enable_radar 0

                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -5.6 1.5 -0.45
                0E01: create_object_no_save 2987 at 1@ 2@ 3@ offset 0 ground 0 to door_1
                0177: set_object door_1 Z_angle_to 90.0
                0382: set_object door_1 collision_detection 1
                0392: make_object door_1 moveable 0
                07F7: set_object Door_1 destructible 0
                08D2: object Door_1 scale_model 1.1
                
                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 1.3 1.6 -0.45
                0E01: create_object_no_save 2987 at 1@ 2@ 3@ offset 0 ground 0 to door_2
                0177: set_object door_2 Z_angle_to 270.0
                0382: set_object door_2 collision_detection 1
                0392: make_object door_2 moveable 0
                07F7: set_object Door_2 destructible 0
                08D2: object Door_2 scale_model 1.1

                model.Destroy(15029)
                model.Destroy(15025)
                model.Destroy(2987)
                
                02EB: restore_camera_with_jumpcut
                
                08C3: clear check_bit bit wash
                08C3: clear check_bit bit sleep
                08C3: clear check_bit bit whore
                
                wait 1000
                016A: fade 1 time 500 //  
                01B4: set_player $PLAYER_CHAR can_move 1
                
                repeat
                wait 0
                    if or
                        0118:   actor $PLAYER_ACTOR dead
                        0741:   actor $PLAYER_ACTOR busted
                    then
                        break
                    end

                    if and
                        03CA:   object Int_1 exists
                        03CA:   object Int_2 exists
                        03CA:   object door_1 exists
                        03CA:   object door_2 exists
                    then
                    
                    
                        // 
                        0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -3.5 -3.0 -1.0
                        if
                            0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 0.7
                        then
                            if
                                88B7:   not test check_bit bit sleep
                            then
                                if
                                    8A2A:   not text_box 'mtlqa3' displayed
                                then
                                    0512: show_permanent_text_box 'mtlqa3'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                                end
                            else
                                if
                                    8A2A:   not text_box 'mtlqa7' displayed
                                then
                                    0512: show_permanent_text_box 'mtlqa7'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                                end
                            end
                            
                            if and
                                88B7:   not test check_bit bit sleep
                                00E1:   player 0 pressed_key 15
                            then
                                03E6: remove_text_box
                                01B4: set_player $PLAYER_CHAR can_move 0
                                016A: fade 0 time 1000 //  
                                wait 1000
                                
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.0 0.0 0.0
                                01BC: put_object Int_2 at 1@ 2@ 3@
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -3.9 -3.1 -2.2
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 270.0
                                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0
                                
                                //  1
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.4 -1.3 -0.3
                                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -2.7 -3.5 -0.8
                                0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                0801: get_camera_zoom_factor_to 4@ // float

                                music = -1

                                0AF0: 1@ = read_int_from_ini_file "cleo\Motel.ini" section "Sound" key "Enable"
                                if
                                    1@ == 1
                                then
                                    0AAC: music = load_audio_stream "SoundQa\mtsleep.mp3"
                                end

                                repeat
                                wait 0
                                04ED: load_animation  "INT_HOUSE"
                                until 04EE:   animation "INT_HOUSE" loaded

                                016A: fade 1 time 500 //  
                                0812: AS_actor $PLAYER_ACTOR perform_animation "BED_In_R" IFP "INT_HOUSE" framedelta 1000.0 loopA 0 lockX 0 lockY 0 lockF 1 time -1  // versionB
                                wait 2500

                                016A: fade 0 time 1000 //  
                                wait 1000

                                if not music == -1
                                then
                                    0AF2: 1@ = read_float_from_ini_file "cleo\Motel.ini" section "Sound" key "Volume"
                                    0AAD: set_audio_stream music state 1
                                    0ABC: set_audio_stream music volume 1@
                                end

                                if
                                    $ACTIVE_INTERIOR == 0
                                then

                                    //  2 ()
                                    0922: set_camera_zoom_from 90.0 to 90.0 timelimit 20000 smooth_transition 2
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.0 0.0 10.0
                                    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 3.5 -10.0 14.0
                                    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                else

                                    //  2 ()
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.6 -1.5 -0.5
                                    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 2.7 3.5 -0.2
                                    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                end

                                wait 500
                                016A: fade 1 time 1000 //  

                                //  
                                timera = 0
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 90.0
                                0E40: get_current_hour 1@
                                1@ += 6

                                //   24    1,2  
                                if 1@ == 24
                                then 1@ = 0
                                end
                                if 1@ == 25
                                then 1@ = 1
                                end
                                if 1@ == 26
                                then 1@ = 2
                                end
                                if 1@ == 27
                                then 1@ = 3
                                end
                                if 1@ == 28
                                then 1@ = 4
                                end
                                if 1@ == 29
                                then 1@ = 5
                                end

                                //  
                                repeat
                                wait 0
                                    0EBB: pass_time Speed_time
                                    0E40: get_current_hour 2@
                                    if
                                        003B:   1@ == 2@  // (int)
                                    then
                                        break
                                    end
                                until timera > 30000 //   
                                wait 500

                                016A: fade 0 time 500 //  
                                wait 500

                                if not music == -1
                                then 0AAE: remove_audio_stream music
                                end

                                //  
                                0D39: 1@ = actor $PLAYER_ACTOR max_health
                                0223: set_actor $PLAYER_ACTOR health_to 1@

                                //  3
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.4 -1.3 -0.5
                                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -2.7 -3.5 -0.8
                                0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                0922: set_camera_zoom_from 90.0 to 4@ timelimit 500 smooth_transition 2

                                wait 500
                                016A: fade 1 time 500 //  
                                0812: AS_actor $PLAYER_ACTOR perform_animation "BED_Out_R" IFP "INT_HOUSE" framedelta 1000.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1  // versionB
                                wait 2500

                                016A: fade 0 time 1000 //  
                                wait 1000

                                //  
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.4 -0.1 0.0
                                01BC: put_object Int_2 at 1@ 2@ 3@
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -3.5 -3.0 -2.2
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 270.0
                                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0
                                02EB: restore_camera_with_jumpcut
                                04EF: release_animation "INT_HOUSE"
                                
                                08BD: set check_bit bit sleep
                                
                                wait 500
                                016A: fade 1 time 500 //  

                                01B4: set_player $PLAYER_CHAR can_move 1
                                continue
                            end
                        else
                            if or
                                0A2A:   text_box 'mtlqa3' displayed
                                0A2A:   text_box 'mtlqa7' displayed
                            then
                                03E6: remove_text_box
                            end
                        end
                        
                        
                        // 
                        0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 3.1 -3.6 -1.0
                        if
                            0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 0.7
                        then
                        
                            if
                                88B7:   not test check_bit bit wash
                            then
                                if
                                    8A2A:   not text_box 'mtlqa4' displayed
                                then
                                    0512: show_permanent_text_box 'mtlqa4'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                                end
                            else
                                if
                                    8A2A:   not text_box 'mtlqa6' displayed
                                then
                                    0512: show_permanent_text_box 'mtlqa6'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                                end
                            end
                            
                            if and
                                88B7:   not test check_bit bit wash
                                00E1:   player 0 pressed_key 15
                            then
                                03E6: remove_text_box
                                01B4: set_player $PLAYER_CHAR can_move 0
                                016A: fade 0 time 1000 //  
                                wait 1000
                                0793: save_player_clothes
                                087B: set_player $PLAYER_CHAR clothes_texture "player_torso" model "torso" body_part 0
                                087B: set_player $PLAYER_CHAR clothes_texture "player_legs" model "legs" body_part 2
                                070D: rebuild_player $PLAYER_CHAR
                                0382: set_object Int_2 collision_detection 0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 4.2 -4.0 -1.4
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                0575: set_actor $PLAYER_ACTOR pinned_position 1
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 355.0
                                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0

                                //  1
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 2.4 -4.7 -0.9
                                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 4.2 -3.5 -0.8
                                0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                
                                0AF0: 1@ = read_int_from_ini_file "cleo\Motel.ini" section "Sound" key "Enable"
                                if
                                    1@ == 1
                                then
                                    0AAC: music = load_audio_stream "SoundQa\mtsleep3.mp3"
                                end

                                if not music == -1
                                then
                                    0AF2: 1@ = read_float_from_ini_file "cleo\Motel.ini" section "Sound" key "Volume"
                                    0AAD: set_audio_stream music state 1
                                    0ABC: set_audio_stream music volume 1@
                                    0AC0: audio_stream music looped 1
                                end

                                repeat
                                wait 0
                                04ED: load_animation  "BEACH"
                                until 04EE:   animation "BEACH" loaded

                                016A: fade 1 time 500 //  
                                0812: AS_actor $PLAYER_ACTOR perform_animation "Lay_Bac_Loop" IFP "BEACH" framedelta 1000.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1  // versionB
                                wait 4000

                                016A: fade 0 time 1000 //  
                                wait 1000

                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 2.4 -1.5 -0.9
                                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 4.2 -4.0 -0.7
                                0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2

                                wait 500
                                016A: fade 1 time 1000 //  
                                
                                wait 3000

                                016A: fade 0 time 1000 //  
                                wait 1000
                                
                                if not music == -1
                                then 0AAE: remove_audio_stream music
                                end

                                08BD: set check_bit bit wash

                                //  
                                0575: set_actor $PLAYER_ACTOR pinned_position 0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 3.1 -3.6 -2.2
                                0382: set_object Int_2 collision_detection 1
                                06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 0
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 52.2197
                                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0
                                0382: set_object Int_2 collision_detection 1
                                02EB: restore_camera_with_jumpcut
                                04EF: release_animation "BEACH"
                                0794: restore_player_clothes
                                070D: rebuild_player $PLAYER_CHAR

                                wait 500
                                016A: fade 1 time 500 //  

                                01B4: set_player $PLAYER_CHAR can_move 1
                                continue
                            end
                        else
                            if or
                                0A2A:   text_box 'mtlqa4' displayed
                                0A2A:   text_box 'mtlqa6' displayed
                            then
                                03E6: remove_text_box
                            end
                        end
                        
                        
                        // 
                        0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.5 1.5 -1.0
                        if
                            0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 0.7
                        then

                            if
                                88B7:   not test check_bit bit whore
                            then
                                if
                                    8A2A:   not text_box 'mtlqa8' displayed
                                then
                                    0512: show_permanent_text_box 'mtlqa8'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                                end
                            else
                                if
                                    8A2A:   not text_box 'mtlqa9' displayed
                                then
                                    0512: show_permanent_text_box 'mtlqa9'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                                end
                            end
                            
                            if and
                                810A:   not player $PLAYER_CHAR money > 99
                                00E1:   player 0 pressed_key 15
                            then
                                00BC: show_text_highpriority GXT 'mtlqa1' time 2000 flag 1
                            end

                            if and
                                88B7:   not test check_bit bit whore
                                00E1:   player 0 pressed_key 15
                                010A:   player $PLAYER_CHAR money > 99
                            then
                                0085: 1@ = money_ini // (int)
                                1@ *= -1
                                0109: player $PLAYER_CHAR money += 1@
                                03E6: remove_text_box
                                01B4: set_player $PLAYER_CHAR can_move 0
                                016A: fade 0 time 1000 //  
                                model.Load(63)
                                038B: load_requested_models
                                wait 1000

                                repeat
                                wait 0
                                04ED: load_animation  "STRIP"
                                until 04EE:   animation "STRIP" loaded
                                
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.1 1.35 -2.2
                                009A: ped_1 = create_actor_pedtype 5 model 63 at 1@ 2@ 3@
                                0173: set_actor ped_1 Z_angle_to 140.8704
                                0E24: fix_char ped_1 ground 0 brightness 1 and_fade_in 0

                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -2.0 -1.5 -1.4
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 355.0
                                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0

                                //  1
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.2 0.5 -0.9
                                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.7 1.5 -0.2
                                0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                
                                model.Destroy(63)

                                music = -1

                                016A: fade 1 time 500 //  
                                0812: AS_actor ped_1 perform_animation "strip_E" IFP "STRIP" framedelta 1000.0 loopA 0 lockX 0 lockY 0 lockF 1 time -1  // versionB
                                wait 2500

                                016A: fade 0 time 1000 //  
                                wait 1000
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -3.5 -3.0 -2.2
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                if 056D:   actor ped_1 defined
                                then 009B: destroy_actor ped_1
                                end

                                music = -1

                                0AF0: 1@ = read_int_from_ini_file "cleo\Motel.ini" section "Sound" key "Enable"
                                if
                                    1@ == 1
                                then
                                    0AAC: music = load_audio_stream "SoundQa\mtsleep2.mp3"
                                end

                                if not music == -1
                                then
                                    0AF2: 1@ = read_float_from_ini_file "cleo\Motel.ini" section "Sound" key "Volume"
                                    0AAD: set_audio_stream music state 1
                                    0ABC: set_audio_stream music volume 1@
                                end
                                
                                0801: get_camera_zoom_factor_to 4@ // float

                                if
                                    $ACTIVE_INTERIOR == 0
                                then

                                    //  2 ()
                                    0922: set_camera_zoom_from 90.0 to 90.0 timelimit 20000 smooth_transition 2
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.0 0.0 10.0
                                    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 3.5 -10.0 14.0
                                    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                else

                                    //  2 ()
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.6 -1.5 -0.5
                                    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 2.7 3.5 -0.2
                                    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
                                end

                                wait 500
                                016A: fade 1 time 1000 //  

                                //  
                                timera = 0
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 90.0
                                0E40: get_current_hour 1@
                                1@ += 6

                                //   24    1,2  
                                if 1@ == 24
                                then 1@ = 0
                                end
                                if 1@ == 25
                                then 1@ = 1
                                end
                                if 1@ == 26
                                then 1@ = 2
                                end
                                if 1@ == 27
                                then 1@ = 3
                                end
                                if 1@ == 28
                                then 1@ = 4
                                end
                                if 1@ == 29
                                then 1@ = 5
                                end

                                //  
                                repeat
                                wait 0
                                    0EBB: pass_time Speed_time
                                    0E40: get_current_hour 2@
                                    if
                                        003B:   1@ == 2@  // (int)
                                    then
                                        break
                                    end
                                until timera > 30000 //   
                                wait 500

                                016A: fade 0 time 500 //  
                                wait 500

                                if not music == -1
                                then 0AAE: remove_audio_stream music
                                end

                                //  
                                0D39: 1@ = actor $PLAYER_ACTOR max_health
                                0223: set_actor $PLAYER_ACTOR health_to 1@

                                016A: fade 0 time 1000 //  
                                wait 1000
                                0922: set_camera_zoom_from 90.0 to 4@ timelimit 500 smooth_transition 2

                                //  
                                0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.4 1.5 -2.2
                                08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
                                0173: set_actor $PLAYER_ACTOR Z_angle_to 270.0
                                0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0
                                02EB: restore_camera_with_jumpcut
                                04EF: release_animation "STRIP"

                                08BD: set check_bit bit whore

                                wait 500
                                016A: fade 1 time 500 //  

                                01B4: set_player $PLAYER_CHAR can_move 1
                                continue
                            end
                        else
                            if or
                                0A2A:   text_box 'mtlqa8' displayed
                                0A2A:   text_box 'mtlqa9' displayed
                            then
                                03E6: remove_text_box
                            end
                        end

                        
                        
                        // 
                        0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -5.0 1.6 -1.0
                        if
                            0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 0.7
                        then
                            if
                                8A2A:   not text_box 'mtlqa5' displayed
                            then
                                0512: show_permanent_text_box 'mtlqa5'  // If your health reaches zero, you will pass out and you will be treated at the local medical center.
                            end
                            
                            if
                                00E1:   player 0 pressed_key 15
                            then
                                03E6: remove_text_box
                                01B4: set_player $PLAYER_CHAR can_move 0
                                016A: fade 0 time 1000 //  
                                wait 1000
                                
                                //  
                                06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 0
                                08C7: put_actor $PLAYER_ACTOR at Back_x Back_y Back_z dont_warp_gang
                                0173: set_actor $PLAYER_ACTOR Z_angle_to angle_z
                                0E24: fix_char $PLAYER_ACTOR ground 1 brightness 1 and_fade_in 0
                                0108: destroy_object Int_1
                                0108: destroy_object Int_2
                                0108: destroy_object door_1
                                0108: destroy_object door_2
                                02EB: restore_camera_with_jumpcut
                                0826: enable_hud 1
                                0581: enable_radar 1

                                wait 500
                                016A: fade 1 time 500 //  

                                01B4: set_player $PLAYER_CHAR can_move 1
                                03BF: set_player $PLAYER_CHAR ignored_by_everyone 0
                                break
                            end
                        else
                            if
                                0A2A:   text_box 'mtlqa5' displayed
                            then
                                03E6: remove_text_box
                            end
                        end
                        
                    else
                        break
                    end
                until not player.Defined(0)

                if 03CA:   object Int_1 exists
                then 0108: destroy_object Int_1
                end
                if 03CA:   object Int_2 exists
                then 0108: destroy_object Int_2
                end
                if 03CA:   object door_1 exists
                then 0108: destroy_object door_1
                end
                if 03CA:   object door_2 exists
                then 0108: destroy_object door_2
                end
                0826: enable_hud 1
                0581: enable_radar 1
                01B4: set_player $PLAYER_CHAR can_move 1
                03BF: set_player $PLAYER_CHAR ignored_by_everyone 0
                06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 0
                
                if or
                    0A2A:   text_box 'mtlqa3' displayed
                    0A2A:   text_box 'mtlqa4' displayed
                    0A2A:   text_box 'mtlqa5' displayed
                    0A2A:   text_box 'mtlqa6' displayed
                    0A2A:   text_box 'mtlqa7' displayed
                    0A2A:   text_box 'mtlqa8' displayed
                    0A2A:   text_box 'mtlqa9' displayed
                then
                    03E6: remove_text_box
                end
                
                repeat
                wait 0
                until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos Back_x Back_y Back_z radius 2.0
            else
                gosub @SLeep
            end
        end
    end
end

:SLeep
03BF: set_player $PLAYER_CHAR ignored_by_everyone 1
0085: 1@ = money_ini // (int)
1@ *= -1
0109: player $PLAYER_CHAR money += 1@
01B4: set_player $PLAYER_CHAR can_move 0
06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 1


016A: fade 0 time 1000 //  
wait 1000

model.Load(15029) //  
model.Load(15025) //  
038B: load_requested_models

04C4: store_coords_to Back_x Back_y Back_z from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0 //   
0172: angle_z = actor $PLAYER_ACTOR Z_angle

0087: 3@ = Back_z // (float)
3@ += 20.0
0E01: create_object_no_save 15029 at Back_x Back_y 3@ offset 0 ground 0 to Int_1
0E01: create_object_no_save 15025 at Back_x Back_y 3@ offset 0 ground 0 to Int_2
0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -3.9 -3.1 -2.2
08C7: put_actor $PLAYER_ACTOR at 1@ 2@ 3@ dont_warp_gang
0173: set_actor $PLAYER_ACTOR Z_angle_to 270.0
0E24: fix_char $PLAYER_ACTOR ground 0 brightness 1 and_fade_in 0
0826: enable_hud 0
0581: enable_radar 0

model.Destroy(15029)
model.Destroy(15025)

//  1
0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.4 -1.3 -0.3
015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -2.7 -3.5 -0.8
0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
0801: get_camera_zoom_factor_to 4@ // float

music = -1

0AF0: 1@ = read_int_from_ini_file "cleo\Motel.ini" section "Sound" key "Enable"
if
    1@ == 1
then
    0AAC: music = load_audio_stream "SoundQa\mtsleep.mp3"
end

repeat
wait 0
04ED: load_animation  "INT_HOUSE"
until 04EE:   animation "INT_HOUSE" loaded

016A: fade 1 time 500 //  
0812: AS_actor $PLAYER_ACTOR perform_animation "BED_In_R" IFP "INT_HOUSE" framedelta 1000.0 loopA 0 lockX 0 lockY 0 lockF 1 time -1  // versionB
wait 2500

016A: fade 0 time 1000 //  
wait 1000

if not music == -1
then
    0AF2: 1@ = read_float_from_ini_file "cleo\Motel.ini" section "Sound" key "Volume"
    0AAD: set_audio_stream music state 1
    0ABC: set_audio_stream music volume 1@
end

if
    $ACTIVE_INTERIOR == 0
then

    //  2 ()
    0922: set_camera_zoom_from 90.0 to 90.0 timelimit 20000 smooth_transition 2
    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 0.0 0.0 10.0
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 3.5 -10.0 14.0
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
else

    //  2 ()
    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.6 -1.5 -0.5
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset 2.7 3.5 -0.2
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
end

wait 500
016A: fade 1 time 1000 //  

//  
timera = 0
0173: set_actor $PLAYER_ACTOR Z_angle_to 90.0
0E40: get_current_hour 1@
1@ += 6

//   24    1,2  
if 1@ == 24
then 1@ = 0
end
if 1@ == 25
then 1@ = 1
end
if 1@ == 26
then 1@ = 2
end
if 1@ == 27
then 1@ = 3
end
if 1@ == 28
then 1@ = 4
end
if 1@ == 29
then 1@ = 5
end

//  
repeat
wait 0
    0EBB: pass_time Speed_time
    0E40: get_current_hour 2@
    if
        003B:   1@ == 2@  // (int)
    then
        break
    end
until timera > 30000 //   
wait 500

016A: fade 0 time 500 //  
wait 500

if not music == -1
then 0AAE: remove_audio_stream music
end

//  
0D39: 1@ = actor $PLAYER_ACTOR max_health
0223: set_actor $PLAYER_ACTOR health_to 1@

//  3
0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -4.4 -1.3 -0.5
015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
0400: store_coords_to 1@ 2@ 3@ from_object Int_1 with_offset -2.7 -3.5 -0.8
0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
0922: set_camera_zoom_from 90.0 to 4@ timelimit 500 smooth_transition 2

wait 500
016A: fade 1 time 500 //  
0812: AS_actor $PLAYER_ACTOR perform_animation "BED_Out_R" IFP "INT_HOUSE" framedelta 1000.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1  // versionB
wait 2500

016A: fade 0 time 1000 //  
wait 1000

//  
06AB: set_actor $PLAYER_ACTOR all_weapons_hidden 0
08C7: put_actor $PLAYER_ACTOR at Back_x Back_y Back_z dont_warp_gang
0173: set_actor $PLAYER_ACTOR Z_angle_to angle_z
0E24: fix_char $PLAYER_ACTOR ground 1 brightness 1 and_fade_in 0
0108: destroy_object Int_1
0108: destroy_object Int_2
04EF: release_animation "INT_HOUSE"
02EB: restore_camera_with_jumpcut
0826: enable_hud 1
0581: enable_radar 1

wait 500
016A: fade 1 time 500 //  

01B4: set_player $PLAYER_CHAR can_move 1
03BF: set_player $PLAYER_CHAR ignored_by_everyone 0

repeat
wait 0
until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos Back_x Back_y Back_z radius 2.0
return