// 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 8 AF2: 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 8 AF2: not SPEED_ADD = get_float_from_ini_file "cleo\Simple Free Cam.ini"
section "Config"
key "AddSpeed"
then SPEED_ADD = 0.02
end
if 8 AF0: not 17 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Keys"
key "ActivateKey1"
then 17 @ = 75
end
if 8 AF0: not 18 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Keys"
key "ActivateKey2"
then 18 @ = 77
end
if 8 AF0: 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 8 AF0: not 16 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Keys"
key "BackKey"
then 16 @ = 75
end
if 8 AF0: not 8 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Keys"
key "TeleportKey"
then 8 @ = 36
end

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

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

if 8 AF0: not 32 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Keys"
key "SpeedDownKey"
then 32 @ = 80
end
0 AC6: 33 @ = label @speeddownkey offset
0 A8C: 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 07 DE: model 1238 exists
then
10 @ = 1238
else
if 07 DE: model 1000 exists
then
10 @ = 1000
else
  0 ACD: show_text_highpriority "Error: Can't create dummy object. Model doesn't exist."
time 10000
continue
end
end

model.Load(10 @)
038 B: load_requested_models
068 D: 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

0 AB1: 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
007 B: SPEED_W_DELTA += frame_delta_time * SPEED

if 03 CA: object 0 @ exists
then
object.CollisionDetection(0 @, false)
0750: set_object 0 @ visibility false
else
  break
end

if is_key_pressed 14 @ //front
then
068 D: get_camera_position_to 11 @ 12 @ 13 @
068 E: 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
068 D: get_camera_position_to 11 @ 12 @ 13 @
068 E: 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 0 AB1: 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 007 B: SPEED += frame_delta_time * 11 @
else
  0087: 33 @ = 11 @
33 @ /= 2.0
007 B: SPEED += frame_delta_time * 33 @
end
end
if 0 AB1: 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
01 BB: store_object 0 @ position_to 21 @ 22 @ 23 @
if is_key_pressed 16
then
11 @ = 23 @
11 @ += 0.5
02 CE: 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
02 CE: 11 @ = ground_z_at 21 @ 22 @ 11 @
if not 11 @ == 0.0
then
23 @ = 11 @
end
end
end
00 A1: put_actor $PLAYER_ACTOR at 21 @ 22 @ 23 @
end
end

if 9 @ > 0
then
if is_key_just_pressed 9 @ //save
then
0 AC6: 33 @ = label @64Bytes offset
068 D: get_camera_position_to 21 @ 22 @ 23 @
0 AD3: 33 @ = string_format "%.3f %.3f %.3f"
21 @ 22 @ 23 @
0 AF5: write_string 33 @ to_ini_file "cleo\Simple Free Cam.ini"
section "Save"
key "SavedCoords"

0 AC6: 33 @ = label @64Bytes offset
068 E: get_camera_target_point_to 21 @ 22 @ 23 @
0 AD3: 33 @ = string_format "%.3f %.3f %.3f"
21 @ 22 @ 23 @
0 AF5: write_string 33 @ to_ini_file "cleo\Simple Free Cam.ini"
section "Save"
key "SavedPointAt"

0 ACD: show_text_highpriority "Saved camera to 'cleo\Simple Free Cam.ini'"
time 1500
end
end

0 AB1: call_scm_func @MouseCamera 1 0 @

if 26 @ == true //showinfos
then
gosub @ShowInfos
end

01 BC: 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

  : waitkeyrelease
while true
wait 0
if and
not is_key_pressed 17 @
not is_key_pressed 18 @
then
break
end
end
return

: ini_settings_can_reread
if 8 AF0: not 26 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Config"
key "ShowInfos"
then 26 @ = true
end
if 8 AF0: not 7 @ = get_int_from_ini_file "cleo\Simple Free Cam.ini"
section "Config"
key "HideHud"
then 7 @ = 0
end
return

: CMD
hex
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end

  : InitMouseCam
0 AC6: 25 @ = label @MouseCamLastY offset
0 A8C: write_memory 25 @ size 4 value 0 @ vp 0
0 AC6: 25 @ = label @MouseCamLastZ offset
0 A8C: write_memory 25 @ size 4 value 1 @ vp 0
0 AC6: 25 @ = label @MouseCamspeed1 offset
0 A8C: write_memory 25 @ size 4 value 2 @ vp 0
0 AC6: 25 @ = label @MouseCamspeed2 offset
0 A8C: write_memory 25 @ size 4 value 3 @ vp 0
0 AB2: ret 0

  : MouseCamera
0085: 31 @ = 0 @ //object

0 AC6: 25 @ = label @MouseCamLastY offset
0 A8D: 0 @ = read_memory 25 @ size 4 vp 0
0 AC6: 25 @ = label @MouseCamLastZ offset
0 A8D: 1 @ = read_memory 25 @ size 4 vp 0

0 AC6: 25 @ = label @MouseCamspeed1 offset
0 A8D: 29 @ = read_memory 25 @ size 4 vp 0

0 AC6: 25 @ = label @MouseCamspeed2 offset
0 A8D: 28 @ = read_memory 25 @ size 4 vp 0

01 BB: store_object 31 @ position_to 20 @ 21 @ 22 @

if or
20 @ == 0.0
21 @ == 0.0
22 @ == 0.0
then
0 AB2: ret 0
end

0 A4A: store_joystick_X_offset_to 2 @ Y_offset_to 3 @

0E23: get_mouse_sensibility_to 4 @

006 B: 2 @ *= 4 @
2 @ *= 80.0

005 B: 1 @ += 2 @

006 B: 3 @ *= 4 @
3 @ *= -80.0

if 8 A4C: not mouse_not_inverted_vertically
then
3 @ *= -1.0
end

005 B: 0 @ += 3 @

if 1 @ > 360.0
then
1 @ -= 360.0
end
if 1 @ < -360.0
then
1 @ += 360.0
end

if 0 @ > 90.0
then 0 @ = 90.0
end
if 0 @ > 270.0
then 0 @ = 270.0
end
if 0 @ < -90.0
then 0 @ = -90.0
end
if 0 @ < -270.0
then 0 @ = -270.0
end

// Set camera position
{
  Camera XY
}
0656: get_angle 1 @ absolute_degrees_to 10 @
02 F6: 11 @ = sine 10 @
006 B: 11 @ *= 29 @ //distancia
005 B: 11 @ += 20 @
0087: 12 @ = 11 @
02 F7: 11 @ = cosine 10 @
006 B: 11 @ *= 29 @ //distancia
005 B: 11 @ += 21 @
0087: 13 @ = 11 @

{
  Camera Z
}
0656: get_angle 0 @ absolute_degrees_to 10 @
02 F6: 11 @ = sine 10 @
02 F7: 10 @ = cosine 10 @
0037: 11 @ /= 10 @
006 B: 11 @ *= 28 @ //distancia
0087: 14 @ = 11 @
005 B: 14 @ += 22 @

015 F: set_camera_position 12 @ 13 @ 14 @ rotation 0.0 0.0 0.0

0160: set_camera_point_at 20 @ 21 @ 22 @ mode 2

0 AC6: 3 @ = label @MouseCamLastY offset
0 A8C: write_memory 3 @ size 4 value 0 @ vp 0
0 AC6: 3 @ = label @MouseCamLastZ offset
0 A8C: write_memory 3 @ size 4 value 1 @ vp 0
0 AB2: ret 0

  : MouseCamLastY
hex
00 00 00 00
end
  : MouseCamLastZ
hex
00 00 00 00
end
  : MouseCamspeed1
hex
00 00 00 00
end
  : MouseCamspeed2
hex
00 00 00 00
end

  : ShowInfos
0 AC6: 33 @ = label @32Bytes offset
0 AD3: 33 @ = format "X: %.4f"
1 @
0 ADF: add_dynamic_GXT_entry "_ncinf1"
text 33 @
0 AD3: 33 @ = format "Y: %.4f"
2 @
0 ADF: add_dynamic_GXT_entry "_ncinf2"
text 33 @
0 AD3: 33 @ = format "Z: %.4f"
3 @
0 ADF: add_dynamic_GXT_entry "_ncinf3"
text 33 @

0 AD3: 33 @ = format "~y~Speed: %.2f"
SPEED
0 ADF: add_dynamic_GXT_entry "_ncinf4"
text 33 @

0 AD3: 33 @ = format "Simple Free Cam"
0 ADF: add_dynamic_GXT_entry "_ncinf0"
text 33 @

038 E: draw_box_position 535.0 220.0 size 80.0 60.0 RGBA 0 0 0 150
038 E: draw_box_position 535.0 182.5 size 100.0 15.0 RGBA 0 0 0 150

gosub @SetupTextHeader
033 E: set_draw_text_position 500.0 178.0 GXT "_ncinf0"

gosub @SetupTextInfo
033 E: set_draw_text_position 505.0 200.0 GXT "_ncinf1"
gosub @SetupTextInfo
033 E: set_draw_text_position 505.0 210.0 GXT "_ncinf2"
gosub @SetupTextInfo
033 E: set_draw_text_position 505.0 220.0 GXT "_ncinf3"
gosub @SetupTextInfo
033 E: set_draw_text_position 505.0 235.0 GXT "_ncinf4"

03 F0: enable_text_draw 1
return

: SetupTextHeader
0349: set_text_draw_font 2
081 C: draw_text_outline 1 RGBA 0 0 0 255
033 F: set_text_draw_letter_size 0.18 0.7
0343: set_text_draw_linewidth 640.0
0340: set_text_draw_RGBA 100 100 100 255
return

: SetupTextInfo
0349: set_text_draw_font 1
081 C: draw_text_outline 1 RGBA 0 0 0 255
033 F: set_text_draw_letter_size 0.25 0.82
0343: set_text_draw_linewidth 640.0
return

: 32 Bytes
hex
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end

  : 64 Bytes
hex
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end

  : Mouse_UsedWheelUp
if 0E10: is_mouse_wheel_up
then
0485: return_true
0 AB2: ret 1 1
end
0 AC6: 1 @ = label @speedupkey offset
0 A8D: 1 @ = read_memory 1 @ size 4 virtual_protect 0
if 1 @ > 0
then
if is_key_pressed 1 @
then
0485: return_true
0 AB2: ret 1 2
end
end
059 A: return_false
0 AB2: ret 1 0

  : Mouse_UsedWheelDown
if 0E11: is_mouse_wheel_down
then
0485: return_true
0 AB2: ret 1 1
end
0 AC6: 1 @ = label @speeddownkey offset
0 A8D: 1 @ = read_memory 1 @ size 4 virtual_protect 0
if 1 @ > 0
then
if is_key_pressed 1 @
then
0485: return_true
0 AB2: ret 1 2
end
end
059 A: return_false
0 AB2: ret 1 0

  : speedupkey
hex
00 00 00 00
end

  : speeddownkey
hex
00 00 00 00
end