{$VERSION 3.1.0020}

03A4: name_thread 'MAIN'
var              
 $PLAYER_CHAR: Player 
end // var
01F0: set_max_wanted_level_to 6 
0111: toggle_wasted_busted_check 0 
00C0: set_current_time 15 0 
04E4: unknown_refresh_game_renderer_at 824.0641 -1794.8955 
Camera.SetAtPos(2488.562, -1666.865, 12.8757)
$PLAYER_CHAR = Player.Create(#NULL, 2488.562, -1666.865, 12.8757)
$PLAYER_ACTOR = Actor.EmulateFromPlayer($PLAYER_CHAR)
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group
Camera.SetBehindPlayer
set_weather 0          
wait 0 ms                                
$PLAYER_CHAR.SetClothes("GARAGELEG", "GARAGETR", Special)                                      
$PLAYER_CHAR.Build
$PLAYER_CHAR.CanMove = True
fade 1 (out) 0 ms                     
select_interior 0
0629: change_stat 181 (islands unlocked) to 4
016C: restart_if_wasted_at 2027.77 -1420.52 15.99 angle 137.0 town_number 0 
016C: restart_if_wasted_at 1180.85 -1325.57 12.58 angle 271.4 town_number 0 
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here ($ONMISSION)
03E6: remove_text_box
0330: toggle_player $PLAYER_CHAR infinite_run 1

create_thread @GravityMan

end_thread

:GravityMan
thread 'GRAVITY'
gosub @ChangeGXTEntries
0@ = 304482
1@ = 304481
create_thread @MemoryProofRead address 0x863984 size 4 VirtualProtect 1
wait 0
0089: 2@ = $MEMORY_PROOF_READ // default value
gosub @UpdateGravityStatus
03C4: set_status_text $MEMORY_PROOF_READ type 0 GXT 'FED_DFL'   
while true
    wait 250
    if
        &0(0@,1i) == 0xFF // Num -
    then
        3@ = -0.001
    else if
            &0(0@,1i) == 0xFF0000 // Num +
        then
            3@ = 0.001
        else if
                &0(1@,1i) == 0xFF0000 // Num *
            then                
                create_thread @MemoryProofWrite address 0x863984 size 4 value 2@ VirtualProtect 1
                0088: $MEMORY_PROOF_READ = 2@
                gosub @UpdateGravityStatus
            end
            Continue    
        end    
    end
    create_thread @MemoryProofRead address 0x863984 size 4 VirtualProtect 1
    wait 0
    005F: $MEMORY_PROOF_READ += 3@    
    create_thread @MemoryProofWrite address 0x863984 size 4 value $MEMORY_PROOF_READ VirtualProtect 1
    gosub @UpdateGravityStatus
    wait 600
end // while

:UpdateGravityStatus
$MEMORY_PROOF_READ *= 100000.0
0092: $MEMORY_PROOF_READ = float $MEMORY_PROOF_READ to_integer   
return


{ ----------------------------------------------------------------- 
  Memory Access Thread

  to write a value with the specified length to the memory address  use
  create_thread @MemoryProofWrite address X:DWord size X:BYTE value X:DWORD VirtualProtect X:BOOL
  
  to read a value with the specified length by the memory address  use
  create_thread @MemoryProofRead address X:DWord size X:BYTE VirtualProtect X:BOOL
  The read value will be stored to the variable $MEMORY_PROOF_READ

  The possible Size values: 1 (byte), 2 (word), 4 (dword)
  The VirtualProtect parameter is optional
----------------------------------------------------------------- }

:MemoryProofWrite
4@ = @MemoryWrite
3@ == 1
jf @_____novp

:_____mpvp
5@ = -429863
&0(5@,1i) =  0xA49960
&0(5@,1i) += @_____vpsv
0052: gap 0 virtual_protect_at_address 0@ size 1@ newprotect 4 gap 0 0
0572: run_VPSV 1
gosub 4@
0052: gap 0 virtual_protect_at_address 0@ size 1@ newprotect -1 gap 0 0
0572: run_VPSV 1
&0(5@,1i) = 0
end_thread

:MemoryProofRead
4@ = @MemoryRead
2@ == 0
jf @_____mpvp

:_____novp
gosub 4@
end_thread

:MemoryWrite
4@ = -429864
&0(4@,1i) =  0xA49960
&0(4@,1i) += @_____mwss
0052: gap 0 target_address 0@ size 1@ value 2@ gap 0 0
0A3D: run_MWSS 1
&0(4@,1i) = 0
return

:MemoryRead
4@ = -429864
&0(4@,1i) =  0xA49960
&0(4@,1i) += @_____mrmm
02EC: run_MRMM 1 read_address 0@ size 1@
hex
3D0A008D0100000000 {store_to} 02 $MEMORY_PROOF_READ
end
&0(4@,1i) = 0
return

:_____vpsv
hex
68 F4 3C A4 00 83 3D 84 3C A4 00 FF
75 08 FF 35 F4 3C A4 00 EB 06 FF 35 
84 3C A4 00 FF 35 80 3C A4 00 FF 35 
7C 3C A4 00 FF 15 2C 80 85 00 C3
end

:_____mwss
hex
8B 15 7C 3C A4 00 8B 05 84 3C A4 00
8B 0D 80 3C A4 00 83 F9 01 75 03 88 
02 C3 83 F9 02 75 04 66 89 02 C3 89 
02 C3
end

:_____mrmm
hex
31 C0 BA 78 3C A4 00 89 02 8B 0D 80 
3C A4 00 8B 05 7C 3C A4 00 83 F9 01 
75 05 8A 00 88 02 C3 83 F9 02 75 07 
66 8B 00 66 89 02 C3 8B 00 89 02 C3              
end

{ ---------end of memory access thread----------------------------- }

// ----------------------------------------------------------------------
//          change GXT Entries
// ----------------------------------------------------------------------  
:ChangeGXTEntries  
  0@ = -429863
  &0(0@,1i) = 0xA49965
  &0(0@,1i) += @_____cgps
  02EC: 1 @__gxtentry @__newgxt
  // -------------------------------  
  :_____cgps
  hex 
   72 05 00 51 00 8B 05 7C 3C A4 00
   05 63 99 A4 00 50 B9 40 B3 C1 00 
   B8 50 00 6A 00 FF D0 8B 15 80 3C 
   A4 00 81 C2 64 99 A4 00 52 50 B8 
   60 86 71 00 FF D0 83 C4 08 C3  
  end
  :__newgxt
  0900: "GRAVITY:"
  :__gxtentry  
  0900: 'FED_DFL'                                                           
// -------------------------------
