CLEO Help Centered Crosshair of All Guns(like sniper)

CLEO related
Status
Not open for further replies.

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
270
Location
Pluto
Crosshair is the circle thing when you aim your weapon. You all might not notice:
  1. Most Crosshair of guns are found at 0.54ScreenWidthx0.46ScreenHeight
  2. Sniper Crosshair is centered at screen(0.5ScreenWidthx0.5ScreenHeight)

Does anybody know how to "put the Aim and Crosshair at Center of the screen" like sniper? I cannot find it anywhere. Snippets,Memory Pointer,Cleo demo will be much appreciated.

I need this because I am trying to create an Aimbot that does not have complex computation, I will be happy to share the code if I finished the code. The only thing missing on my aimbot is to make the air crosshair at center of the screen.
 

88resu

Active member
Joined
Oct 1, 2019
Messages
110
Reaction score
46
Location
Uganda
i think theres an offset for it, i did that before i can search later


/edit
Code:
crosshair Y float 0xB6EC10
crosshair X float 0xB6EC14

both values of 0.5 results in a retarded view. yes its the middle if u want that xD
 

Attachments

  • Download.png
    Download.png
    152.2 KB · Views: 57
Last edited:

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
270
Location
Pluto
i think theres an offset for it, i did that before i can search later


/edit
Code:
crosshair Y float 0xB6EC10
crosshair X float 0xB6EC14

both values of 0.5 results in a retarded view. yes its the middle if u want that xD

That is exactly what I was looking for! Thank you.


OK in return,here is my Basic Aimbot example, it is a Snapshot Aimbot:
  1. Toggle Key: CAPSLOCK + 1 key
  2. Just press fire+aim key and the crosshair will Instantly snap at the brain of an actor near the center of the screen.
Code:
{$CLEO}
0000: ajom's Basic Brain Snapshot(No Prediction System) - I call it "snapshot" because the crosshair "snap/instantly" moves at the brain of the actor

repeat
    wait 0
until 056D:   actor $PLAYER_ACTOR defined

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Initialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

const
    TARGET_ACTOR = 31@
    ISENABLED = 30@
    DATABASE = 29@

    KEY1 = 20 // CAPSLOCK
    KEY2 = 49 // 1 Key
end
ISENABLED = false

// save default settings to allocated memory
alloc DATABASE 8
0A8D: 1@ = read_memory 0xB6EC14 size 4 virtual_protect 0 // Crosshair X multiplier
0085: 0@ = DATABASE
0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0 // Save Crosshair X multiplier
0A8D: 1@ = read_memory 0xB6EC10 size 4 virtual_protect 0 // Crosshair Y multiplier
0@ += 4
0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0 // Save Crosshair Y multiplier
//

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Initialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Main Thread ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

while true
    wait 0 // loop anti hang
    
    if and
        0AB0:   key_pressed KEY1
        0AB0:   key_pressed KEY2
    then
        0B12: ISENABLED = ISENABLED XOR 1
        if ISENABLED == true
        then
            0A8C: write_memory 0xB6EC14 size 4 value 0.5 virtual_protect 0 // Crosshair X multiplier
            0A8C: write_memory 0xB6EC10 size 4 value 0.5 virtual_protect 0 // Crosshair Y multiplier
        else // reset default crosshair settings
            0085: 0@ = DATABASE
            0A8D: 1@ = read_memory 0@ size 4 virtual_protect 0 // default settings: Crosshair X multiplier
            0A8C: write_memory 0xB6EC14 size 4 value 1@ virtual_protect 0 // Crosshair X multiplier
            0@ += 4
            0A8D: 1@ = read_memory 0@ size 4 virtual_protect 0 // default settings: Crosshair Y multiplier
            0A8C: write_memory 0xB6EC10 size 4 value 1@ virtual_protect 0 // Crosshair Y multiplier
        end
        0AD1: show_formatted_text_highpriority "~g~Brain Snapshot: ~y~%d" time 2000 ISENABLED
        while 0AB0:   key_pressed KEY2 // anti key spam
            wait 0
        end
    end

    if ISENABLED == true
    then
        
        if // or
            // 00E1:   player $PLAYER_CHAR pressed_key 6 // aim weapon
            00E1:   player $PLAYER_CHAR pressed_key 17 // fire weapon
        then
            
            // screen resolution
            0A8D: 0@ = read_memory 0xC17044 size 4 virtual_protect 0 // Screen Width
            0A8D: 1@ = read_memory 0xC17048 size 4 virtual_protect 0 // Screen Height
            008F: 0@ = integer 0@ to_float
            008F: 1@ = integer 1@ to_float
            // screen half resolution
            0087: 2@ = 0@
            0087: 3@ = 1@
            2@ /= 2.0
            3@ /= 2.0
            //
    
            if 0AB1: @getactoratscreen 7 _withinupperleftrectangleXY 0.0 0.0 _andbottomrightrectangleXY 0@ 1@ _nearscreencoordXY 2@ 3@ _ignoreactor -1 _storeactor TARGET_ACTOR
            then
                0A96: 0@ = actor TARGET_ACTOR struct
                while 00E1:   player $PLAYER_CHAR pressed_key 6 // aim weapon
                    if and
                        056D:   actor TARGET_ACTOR defined
                        00E1:   player $PLAYER_CHAR pressed_key 17 // fire weapon
                    then
                        0AA6: call_method 0x5E4280 struct 0@ num_params 3 pop 0 bIncludeAnim 1 iBoneID 6 vPosition 1@v // store Actor Brain XYZ Position to 1@ 2@ 3@
                        0AB1: @camatpos 5 _XYZ 1@ 2@ 3@ _withCamOffsetAngleX 0.0 _andCamOffsetAngleZ 0.0
                        wait 0 // loop anti hang
                    else break
                    end
                end
            end
    
        end
        
    end

end

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Main Thread ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SubRoutines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of SubRoutines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// 0AB1: @getactoratscreen 7 _withinupperleftrectangleXY 0.0 0.0 _andbottomrightrectangleXY 2.0 2.0 _nearscreencoordXY 1.0 1.0 _ignoreactor -1 _storeactor 29@ // all coords are float!
:getactoratscreen

0085: 29@ = 6@ // ignored actor
28@ = 65535.0 // very high screen coord

0A8D: 27@ = read_memory 0xB74490 size 4 virtual_protect 0
27@ += 4
0A8D: 27@ = read_memory 27@ size 4 virtual_protect 0
for 26@ = 0x0 to 0x8B00 step 0x100
    0A8D: 25@ = read_memory 27@ size 1 virtual_protect 0
    27@++
    if and
        25@ >= 0x00
        25@ < 0x80
    then
        005A: 25@ += 26@ // got the ped
  
        if or
            856D: NOT actor 25@ defined // REMOTE ACTOR IS NOT DEFINED
            003C: $PLAYER_ACTOR == 25@ // OUR ACTOR == REMOTE ACTOR
            003C: 6@ == 25@ // IGNORED ACTOR == REMOTE ACTOR
        then continue
        end
  
        if 82CB: not actor 25@ bounding_sphere_visible
        then continue
        end
  
        //
        // < SOME PARAMETERS HERE FOR GETTING YOUR DESIRED TARGETS >
        //
  
        00A0: store_actor 25@ position_to 21@ 22@ 23@
        0B55: convert_3D_coords 21@ 22@ 23@ to_screen 14@ 15@
        0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 21@ 22@ 23@ _to2Dcoord_XY 22@ 23@
        0AD1: show_formatted_text_highpriority "SNIPPET: %fx%f~n~SAMPFUNCS: %dx%d" time 2000 22@ 23@ 14@ 15@
        if and // if bounded within the rectangle
            0035:   22@ >= 0@  // leftmost boundary
            0035:   2@ >= 22@  // rightmost boundary
            0035:   23@ >= 1@  // uppermost boundary
            0035:   3@ >= 23@  // bottommost boundary
        then
            0509: 21@ = distance_between_XY 22@ 23@ and_XY 4@ 5@
            if 0025:   28@ > 21@  // (float)
            then
                0087: 28@ = 21@ // store nearer distance
                0085: 29@ = 25@ // store nearer actor
            end
        end
    end
end
if or
    856D: not actor 29@ defined
    003C: 29@ == 6@ // was the ignored actor
then 059A:  return_false
else 0485:  return_true
end
ret 1 29@

:getScreenXYFrom3DCoords
{
Parameters: 0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 0@ 1@ 2@ _toscreencoord_XY 3@ 4@
   Passed:     0@ - position X     1@ - position Y     2@ - position Z
   Result:     3@ - screen X     4@ - screen Y
Example:   0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 2488.562 -1666.865 12.8757 _toscreencoord_XY 1@ 2@
}
0AA5: call 0x70CE30 num_params 6 pop 6 bFarClip 0 bNearClip 0 pMultY 6@v pMultX 5@v pScreen 3@v pCoords 0@v // ConvertGlobalXYToScreenXY

0A8D: 11@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859520 size 4 virtual_protect 0 // screen X scale
006B: 11@ *= 12@
0073: 3@ /= 11@

0A8D: 11@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859524 size 4 virtual_protect 0 // screen Y scale
006B: 11@ *= 12@
0073: 4@ /= 11@

0AB2: ret 2 3@ 4@

// 0AB1: @camatpos 5 _XYZ 0@ 1@ 2@ _withCamOffsetAngleX 3@ _andCamOffsetAngleZ 4@
:camatpos
    // ~~~~~~~~~~anti auto-vehicle cam movement
if and
    TIMERA>=400
    Actor.Driving($PLAYER_ACTOR)
then
    0A8C: write_memory 0xB70118 size 4 value 50.0 virtual_protect 0 // reset camera stabalizer timer, credit to Parazitas
    TIMERA = 0
end
    // ~~~~~~~~~~

068D: get_camera_position_to 31@ 30@ 29@

    // ~~~~~~~~~~Camera Z-Angle from our camera towards the target
0087: 28@ = 1@  // y2
0063: 28@ -= 30@  // y1
0087: 27@ = 0@  // x2
0063: 27@ -= 31@  // x1
if and
    27@ == 0.0
    28@ == 0.0
then 28@ = 0.0
else
    0AA5: atan2 | 0x4207C0 2 2 | _X 27@ _Y 28@
    0AE9: pop_float 28@ // store result from above operation
end
28@ += 3.1415926535897981710616733832795 // Camera Angle Leads 180 degrees respect to Z world coordinats
005B: 28@ += 4@  // use the defined camz offset to move the camera leftwards or rightwards
    // ~~~~~~~~~~

    // ~~~~~~~~~~Camera X-Angle from our camera towards the target
0087: 27@ = 2@ // z2
0063: 27@ -= 29@  // z1
0509: 26@ = distance_between_XY 31@ 30@ and_XY 0@ 1@ // adjacent side
if and
    26@ == 0.0
    27@ == 0.0
then 27@ = 0.0
else
    0AA5: atan2 | 0x4207C0 2 2 | _X 26@ _Y 27@
    0AE9: pop_float 27@ // store result from above operation
end
005B: 27@ += 3@  // use the defined camx offset to move the camera downwards or upwards
    // ~~~~~~~~~~

0A25: set_camera_on_players_X_angle 27@ Z_angle 28@
ret 0

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Now I am facing a New problem, it is about Wesser's getScreenXYFrom3DCoords, I produces innacurate result. I compared it with SAMPFUNCS Opcode 0B55 and it seems the SAMPFUNCS shows the right screen value while getScreenXYFrom3DCoords produces bad results:
Code:
// 25@ is any actor at the screen
00A0: store_actor 25@ position_to 21@ 22@ 23@
0B55: convert_3D_coords 21@ 22@ 23@ to_screen 14@ 15@
0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 21@ 22@ 23@ _to2Dcoord_XY 22@ 23@
0AD1: show_formatted_text_highpriority "SNIPPET: %fx%f~n~SAMPFUNCS: %dx%d" time 2000 22@ 23@ 14@ 15@

As you can see on the picture the SAMPFUNCS have the right values. The getScreenXYFrom3DCoords snippet fails to have the same value. Anybody knows the sourcecode of SAMPFUNCS Opcode 0B55?
 

Attachments

  • 23.png
    23.png
    456.6 KB · Views: 62
  • Untitled.png
    Untitled.png
    751 KB · Views: 61
Last edited:

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Even if I convert SAMPFUNCS into float, the Odd difference between their return values are still high. Any workarounds?
PHP:
{$CLEO .cs}

0000:

wait 8500

while true
wait 0

if 0256:   player $PLAYER_CHAR defined
then
    0AB1: @ClosestPeds 0
end

end

:ClosestPeds
0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0
29@ += 0x4
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
for 30@ = 0 to 35584 step 0x100
    0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0
    000A: 29@ += 0x1
    if and
        0029: 31@ >= 0x00
        001B: 0x80 > 31@                     
    then
        005A: 31@ += 30@
        if and
        056D:   actor 31@ defined
        803B:   31@ == $PLAYER_ACTOR // not my ped
        then
            00A0: store_actor 31@ position_to 28@ 27@ 26@
            0B55: convert_3D_coords 28@ 27@ 26@ to_screen 25@ 24@
            0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 28@ 27@ 26@ _to2Dcoord_XY 23@ 22@
            0B60: convert_game_screen_coords 23@ 22@ to_window_screen_coords 21@ 20@
            0AD1: show_formatted_text_highpriority "SNIPPET: %dx%d~n~SAMPFUNCS: %dx%d" time 2000 21@ 20@ 25@ 24@
        end
    end
end
0AB2: ret 0

:getScreenXYFrom3DCoords
{
Parameters: 0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 0@ 1@ 2@ _toscreencoord_XY 3@ 4@
   Passed:     0@ - position X     1@ - position Y     2@ - position Z
   Result:     3@ - screen X     4@ - screen Y
Example:   0AB1: @getScreenXYFrom3DCoords 3 _from3Dcoord_XYZ 2488.562 -1666.865 12.8757 _toscreencoord_XY 1@ 2@
}
0AA5: call 0x70CE30 num_params 6 pop 6 bFarClip 0 bNearClip 0 pMultY 6@v pMultX 5@v pScreen 3@v pCoords 0@v // ConvertGlobalXYToScreenXY

0A8D: 11@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859520 size 4 virtual_protect 0 // screen X scale
006B: 11@ *= 12@
0073: 3@ /= 11@

0A8D: 11@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859524 size 4 virtual_protect 0 // screen Y scale
006B: 11@ *= 12@
0073: 4@ /= 11@

0AB2: ret 2 3@ 4@



Nobody made yet without SAMPFUNCS this snippet and that is annoying...
0B60: convert_game_screen_coords 23@ 22@ to_window_screen_coords 21@ 20@
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
270
Location
Pluto
Nobody made yet without SAMPFUNCS this snippet and that is annoying...
0B60: convert_game_screen_coords 23@ 22@ to_window_screen_coords 21@ 20@

After Conducting some Experiments, I realized some things:
Code:
// Snippet to convert World 3D Coordinates into 2D Screen Relative to the Window. This is what I exactly need and works like Opcode 0B55 but in floating point format
0AA5: call 0x70CE30 num_params 6 pop 6 bFarClip 0 bNearClip 0 pMultY 6@v pMultX 5@v pScreen 3@v pCoords 0@v // Convert GlobalXYZ To WindowScreenXY

// Snippet to convert World 3D Coordinates into 2D Screen Relative to the Game.
:WorldXYZtoGameScreenXY
{
Parameters: 0AB1: @WorldXYZtoGameScreenXY 3 _from3Dcoord_XYZ 0@ 1@ 2@ _toscreencoord_XY 3@ 4@
   Passed:     0@ - position X     1@ - position Y     2@ - position Z
   Result:     3@ - screen X     4@ - screen Y
Example:   0AB1: @WorldXYZtoGameScreenXY 3 _from3Dcoord_XYZ 2488.562 -1666.865 12.8757 _toscreencoord_XY 1@ 2@
}
0AA5: call 0x70CE30 num_params 6 pop 6 bFarClip 0 bNearClip 0 pMultY 6@v pMultX 5@v pScreen 3@v pCoords 0@v // Convert WorldXYZ To WindowScreenXY

0A8D: 11@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859520 size 4 virtual_protect 0 // screen X scale
006B: 11@ *= 12@
0073: 3@ /= 11@

0A8D: 11@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859524 size 4 virtual_protect 0 // screen Y scale
006B: 11@ *= 12@
0073: 4@ /= 11@

0AB2: ret 2 3@ 4@
So Wesser's snippet returns screen coord relative to the game. What I need is SCM Function 0x70CE30.


Problem Solved, here is the Final version of the Snapshot Aimbot:
Code:
{$CLEO}
0000: ajom's Basic Brain Snapshot(No Prediction System) - I call it "snapshot" because the crosshair "snap/instantly" moves at the brain of the actor

repeat
    wait 0
until 056D:   actor $PLAYER_ACTOR defined

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Initialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

const
    TARGET_ACTOR = 31@
    ISENABLED = 30@
    DATABASE = 29@

    KEY1 = 20 // CAPSLOCK
    KEY2 = 49 // 1 Key
end
ISENABLED = false

// save default settings to allocated memory
alloc DATABASE 8
0A8D: 1@ = read_memory 0xB6EC14 size 4 virtual_protect 0 // Crosshair X multiplier
0085: 0@ = DATABASE
0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0 // Save Crosshair X multiplier
0A8D: 1@ = read_memory 0xB6EC10 size 4 virtual_protect 0 // Crosshair Y multiplier
0@ += 4
0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0 // Save Crosshair Y multiplier
//

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Initialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Main Thread ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

while true
    wait 0 // loop anti hang
    
    if and
        0AB0:   key_pressed KEY1
        0AB0:   key_pressed KEY2
    then
        0B12: ISENABLED = ISENABLED XOR 1
        if ISENABLED == true
        then
            0A8C: write_memory 0xB6EC14 size 4 value 0.5 virtual_protect 0 // Crosshair X multiplier
            0A8C: write_memory 0xB6EC10 size 4 value 0.5 virtual_protect 0 // Crosshair Y multiplier
        else // reset default crosshair settings
            0085: 0@ = DATABASE
            0A8D: 1@ = read_memory 0@ size 4 virtual_protect 0 // default settings: Crosshair X multiplier
            0A8C: write_memory 0xB6EC14 size 4 value 1@ virtual_protect 0 // Crosshair X multiplier
            0@ += 4
            0A8D: 1@ = read_memory 0@ size 4 virtual_protect 0 // default settings: Crosshair Y multiplier
            0A8C: write_memory 0xB6EC10 size 4 value 1@ virtual_protect 0 // Crosshair Y multiplier
        end
        0AD1: show_formatted_text_highpriority "~g~Brain Snapshot: ~y~%d" time 2000 ISENABLED
        while 0AB0:   key_pressed KEY2 // anti key spam
            wait 0
        end
    end

    if ISENABLED == true
    then
        
        if // or
            // 00E1:   player $PLAYER_CHAR pressed_key 6 // aim weapon
            00E1:   player $PLAYER_CHAR pressed_key 17 // fire weapon
        then
            
            // screen resolution
            0A8D: 0@ = read_memory 0xC17044 size 4 virtual_protect 0 // Screen Width
            0A8D: 1@ = read_memory 0xC17048 size 4 virtual_protect 0 // Screen Height
            008F: 0@ = integer 0@ to_float
            008F: 1@ = integer 1@ to_float
            // screen half resolution
            0087: 2@ = 0@
            0087: 3@ = 1@
            2@ /= 2.0
            3@ /= 2.0
            //
    
            if 0AB1: @getactoratscreen 7 _withinupperleftrectangleXY 0.0 0.0 _andbottomrightrectangleXY 0@ 1@ _nearscreencoordXY 2@ 3@ _ignoreactor -1 _storeactor TARGET_ACTOR
            then
                0A96: 0@ = actor TARGET_ACTOR struct
                while 00E1:   player $PLAYER_CHAR pressed_key 6 // aim weapon
                    if and
                        056D:   actor TARGET_ACTOR defined
                        00E1:   player $PLAYER_CHAR pressed_key 17 // fire weapon
                    then
                        0AA6: call_method 0x5E4280 struct 0@ num_params 3 pop 0 bIncludeAnim 1 iBoneID 6 vPosition 1@v // store Actor Brain XYZ Position to 1@ 2@ 3@
                        0AB1: @camatpos 5 _XYZ 1@ 2@ 3@ _withCamOffsetAngleX 0.0 _andCamOffsetAngleZ 0.0
                        wait 0 // loop anti hang
                    else break
                    end
                end
            end
    
        end
        
    end

end

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Main Thread ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SubRoutines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of SubRoutines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// 0AB1: @getactoratscreen 7 _withinupperleftrectangleXY 0.0 0.0 _andbottomrightrectangleXY 2.0 2.0 _nearscreencoordXY 1.0 1.0 _ignoreactor -1 _storeactor 29@ // all coords are float!
:getactoratscreen

0085: 29@ = 6@ // ignored actor
28@ = 65535.0 // very high screen coord

0A8D: 27@ = read_memory 0xB74490 size 4 virtual_protect 0
27@ += 4
0A8D: 27@ = read_memory 27@ size 4 virtual_protect 0
for 26@ = 0x0 to 0x8B00 step 0x100
    0A8D: 25@ = read_memory 27@ size 1 virtual_protect 0
    27@++
    if and
        25@ >= 0x00
        25@ < 0x80
    then
        005A: 25@ += 26@ // got the ped
 
        if or
            856D: NOT actor 25@ defined // REMOTE ACTOR IS NOT DEFINED
            003C: $PLAYER_ACTOR == 25@ // OUR ACTOR == REMOTE ACTOR
            003C: 6@ == 25@ // IGNORED ACTOR == REMOTE ACTOR
        then continue
        end
 
        if 82CB: not actor 25@ bounding_sphere_visible
        then continue
        end
 
        //
        // < SOME PARAMETERS HERE FOR GETTING YOUR DESIRED TARGETS >
        //
 
        00A0: store_actor 25@ position_to 22@ 23@ 24@
        0AA5: call 0x70CE30 num_params 6 pop 6 bFarClip 0 bNearClip 0 pMultY 20@v pMultX 21@v pScreen 30@v pCoords 22@v // Convert GlobalXYZ To WindowScreenXY
        if and // if bounded within the rectangle
            0035:   30@ >= 0@  // leftmost boundary
            0035:   2@ >= 30@  // rightmost boundary
            0035:   31@ >= 1@  // uppermost boundary
            0035:   3@ >= 31@  // bottommost boundary
        then
            0509: 24@ = distance_between_XY 30@ 31@ and_XY 4@ 5@
            if 0025:   28@ > 24@  // (float)
            then
                0087: 28@ = 24@ // store nearer distance
                0085: 29@ = 25@ // store nearer actor
            end
        end
    end
end
if or
    856D: not actor 29@ defined
    003C: 29@ == 6@ // was the ignored actor
then 059A:  return_false
else 0485:  return_true
end
ret 1 29@

// 0AB1: @camatpos 5 _XYZ 0@ 1@ 2@ _withCamOffsetAngleX 3@ _andCamOffsetAngleZ 4@
:camatpos
    // ~~~~~~~~~~anti auto-vehicle cam movement
if and
    TIMERA>=400
    Actor.Driving($PLAYER_ACTOR)
then
    0A8C: write_memory 0xB70118 size 4 value 50.0 virtual_protect 0 // reset camera stabalizer timer, credit to Parazitas
    TIMERA = 0
end
    // ~~~~~~~~~~

068D: get_camera_position_to 31@ 30@ 29@

    // ~~~~~~~~~~Camera Z-Angle from our camera towards the target
0087: 28@ = 1@  // y2
0063: 28@ -= 30@  // y1
0087: 27@ = 0@  // x2
0063: 27@ -= 31@  // x1
if and
    27@ == 0.0
    28@ == 0.0
then 28@ = 0.0
else
    0AA5: atan2 | 0x4207C0 2 2 | _X 27@ _Y 28@
    0AE9: pop_float 28@ // store result from above operation
end
28@ += 3.1415926535897981710616733832795 // Camera Angle Leads 180 degrees respect to Z world coordinats
005B: 28@ += 4@  // use the defined camz offset to move the camera leftwards or rightwards
    // ~~~~~~~~~~

    // ~~~~~~~~~~Camera X-Angle from our camera towards the target
0087: 27@ = 2@ // z2
0063: 27@ -= 29@  // z1
0509: 26@ = distance_between_XY 31@ 30@ and_XY 0@ 1@ // adjacent side
if and
    26@ == 0.0
    27@ == 0.0
then 27@ = 0.0
else
    0AA5: atan2 | 0x4207C0 2 2 | _X 26@ _Y 27@
    0AE9: pop_float 27@ // store result from above operation
end
005B: 27@ += 3@  // use the defined camx offset to move the camera downwards or upwards
    // ~~~~~~~~~~

0A25: set_camera_on_players_X_angle 27@ Z_angle 28@
ret 0

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Status
Not open for further replies.
Top