// by Junior_Djjr - MixMods.com.br

{$cleo}
{$USE ini}   
{$USE cleo+}
0000:

const
//Vars     
SPEED_ADD = 19@
SPEED = 20@
SPEED_W_DELTA = 31@
end

var
4@  : float
11@ : float
12@ : float
13@ : float
19@ : float
20@ : float
21@ : float
22@ : float
23@ : float
31@ : float
30@ : float
end


if 8AF2: not SPEED = get_float_from_ini_file "cleo\Simple Free Cam.ini" section "Config" key "InitialSpeed"
then SPEED = 0.3
end
SPEED *= 1.5
if 8AF2: not SPEED_ADD = get_float_from_ini_file "cleo\Simple Free Cam.ini" section "Config" key "AddSpeed"
then SPEED_ADD = 0.02
end
if 8AF0: not 17@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "ActivateKey1"
then 17@ = 75
end   
if 8AF0: not 18@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "ActivateKey2"
then 18@ = 77
end   
if 8AF0: not 14@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "FrontKey"
then 14@ = 73
end     
/*if 8AF0: not 15@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "LeftKey"
then 15@ = 74
end*/   
if 8AF0: not 16@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "BackKey"
then 16@ = 75
end   
if 8AF0: not 8@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "TeleportKey"
then 8@ = 36
end     

if 8AF0: not 9@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Save" key "SaveKey"
then 9@ = 36
end   

if 8AF0: not 32@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "SpeedUpKey"
then 32@ = 48
end
0AC6: 33@ = label @speedupkey offset
0A8C: write_memory 33@ size 4 value 32@ virtual_protect 0    

if 8AF0: not 32@ = get_int_from_ini_file "cleo\Simple Free Cam.ini" section "Keys" key "SpeedDownKey"
then 32@ = 80
end
0AC6: 33@ = label @speeddownkey offset
0A8C: write_memory 33@ size 4 value 32@ virtual_protect 0

gosub @ini_settings_can_reread


while true
    wait 0           
    if and
    is_key_pressed 17@
    is_key_pressed 18@
    jf continue
    
    gosub @ini_settings_can_reread
                  
    gosub @waitkeyrelease
    
    if 07DE:   model 1238 exists
    then
        10@ = 1238
    else
        if 07DE:   model 1000 exists
        then
            10@ = 1000
        else
            0ACD: show_text_highpriority "Error: Can't create dummy object. Model doesn't exist." time 10000
            continue
        end
    end
    
    model.Load(10@)
    038B: load_requested_models
    068D: get_camera_position_to 1@ 2@ 3@
    3@ += 1.0
    0E01: create_object_no_save 1238 at 1@ 2@ 3@ offset false ground false to 0@
    model.Destroy(10@)
    
    object.Angle(0@) = 0.0
    
    if 7@ == true
    then
        0826: enable_hud 0
        0581: enable_radar 0
    end
               
    0AB1: call_scm_func @InitMouseCam 4  10.0 0.0  -0.1 0.3
         
    
    while true
        wait 0
        if and  
        is_key_pressed 17@
        is_key_pressed 18@
        then
            break
        end
    
        SPEED_W_DELTA = 0.0
        007B: SPEED_W_DELTA += frame_delta_time * SPEED
                          
        if 03CA:   object 0@ exists
        then 
            object.CollisionDetection(0@,false)
            0750: set_object 0@ visibility false
        else
            break
        end
        
        if is_key_pressed 14@ //front
        then
            068D: get_camera_position_to 11@ 12@ 13@
            068E: get_camera_target_point_to 21@ 22@ 23@
            21@ -= 11@  
            22@ -= 12@
            23@ -= 13@
            21@ *= SPEED_W_DELTA  
            22@ *= SPEED_W_DELTA
            23@ *= SPEED_W_DELTA
            0400: store_coords_to 1@ 2@ 3@ from_object 0@ with_offset 21@ 22@ 23@
        end  
        if is_key_pressed 16@ //back
        then
            068D: get_camera_position_to 11@ 12@ 13@
            068E: get_camera_target_point_to 21@ 22@ 23@
            21@ -= 11@  
            22@ -= 12@
            23@ -= 13@
            21@ *= SPEED_W_DELTA  
            22@ *= SPEED_W_DELTA
            23@ *= SPEED_W_DELTA
            21@ *= -1.0     
            22@ *= -1.0
            23@ *= -1.0
            0400: store_coords_to 1@ 2@ 3@ from_object 0@ with_offset 21@ 22@ 23@
        end
        if 0AB1: call_scm_func @Mouse_UsedWheelUp 0 -> 32@
        then         
            0087: 11@ = SPEED_ADD
            if is_key_pressed 16
            then
                11@ *= 5.0
            end
            if 32@ == 1 //mouse
            then 007B: SPEED += frame_delta_time * 11@
            else
                0087: 33@ = 11@
                33@ /= 2.0
                007B: SPEED += frame_delta_time * 33@
            end
        end    
        if 0AB1: call_scm_func @Mouse_UsedWheelDown 0 -> 32@
        then                   
            0087: 11@ = SPEED_ADD   
            if is_key_pressed 16
            then
                11@ *= 5.0
            end
            if 32@ == 1 //mouse
            then 0081: SPEED -= frame_delta_time * 11@
            else
                0087: 33@ = 11@
                33@ /= 2.0
                0081: SPEED -= frame_delta_time * 33@
            end
            if SPEED < 11@
            then SPEED = 11@
            end
        end
        
        if 8@ > 0
        then
            if is_key_pressed 8@
            then                   
                01BB: store_object 0@ position_to 21@ 22@ 23@
                if is_key_pressed 16
                then
                    11@ = 23@
                    11@ += 0.5
                    02CE: 11@ = ground_z_at 21@ 22@ 11@
                    if not 11@ == 0.0
                    then
                        23@ = 11@
                    else
                        //try again
                        21@ += 0.01    
                        22@ += 0.01   
                        11@ = 23@    
                        11@ += 1.0
                        02CE: 11@ = ground_z_at 21@ 22@ 11@
                        if not 11@ == 0.0
                        then
                            23@ = 11@
                        end
                    end
                end
                00A1: put_actor $PLAYER_ACTOR at 21@ 22@ 23@
            end
        end   
         
        if 9@ > 0
        then
            if is_key_just_pressed 9@ //save
            then                   
                0AC6: 33@ = label @64Bytes offset
                068D: get_camera_position_to 21@ 22@ 23@
                0AD3: 33@ = string_format "%.3f %.3f %.3f" 21@ 22@ 23@
                0AF5: write_string 33@ to_ini_file "cleo\Simple Free Cam.ini" section "Save" key "SavedCoords"   
                
                0AC6: 33@ = label @64Bytes offset     
                068E: get_camera_target_point_to 21@ 22@ 23@
                0AD3: 33@ = string_format "%.3f %.3f %.3f" 21@ 22@ 23@
                0AF5: write_string 33@ to_ini_file "cleo\Simple Free Cam.ini" section "Save" key "SavedPointAt"
                
                0ACD: show_text_highpriority "Saved camera to 'cleo\Simple Free Cam.ini'" time 1500
            end
        end    
        
        0AB1: call_scm_func @MouseCamera 1 0@
        
        if 26@ == true //showinfos
        then
            gosub @ShowInfos
        end

        01BC: put_object 0@ at 1@ 2@ 3@      
    end
    
    gosub @waitkeyrelease
                
    if 7@ == true
    then
        0826: enable_hud 1
        0581: enable_radar 1
    end
    
    object.Destroy(0@) 
    camera.Restore() 
    27@ = 0
end