[SNIPPET] Perfect crosshair pos

supahdupahnubah

Well-Known Member
Joined
Dec 31, 2015
Messages
673
Likes
1
Points
18
#1
Originally posted\made by this sweetie -> @0x688 http://ugbase.eu/Thread-Perfect-crosshair-pos?pid=98743
Output parameters are float
Usage : call @crosshair_coords 0 x_out [email protected] y_out [email protected]

[shcode=cpp]
:crosshair_coords
0A8D: [email protected] = read_memory 0xC9C040 size 4 virtual_protect 0 //x screen
0A8D: [email protected] = read_memory 0xC9C044 size 4 virtual_protect 0 //y screen
0A8D: [email protected] = read_memory 0xB6EC14 size 4 virtual_protect 0 
0A8D: [email protected] = read_memory 0xB6EC10 size 4 virtual_protect 0 
0093: [email protected] = integer [email protected] [email protected]
006F: [email protected] *= [email protected]
0093: [email protected] = integer [email protected] to_float
[email protected] *= 0.0015625
[email protected] *= 64.0
[email protected] *= 0.2                            
[email protected] *= 0.1
0063: [email protected] -= [email protected]  // (float)
///////
0093: [email protected] = integer [email protected] to_float
006F: [email protected] *= [email protected]
0093: [email protected] = integer [email protected] to_float
[email protected] *= 0.002232143
[email protected] *= 64.0
[email protected] *= 0.2                            
[email protected] *= 0.1
0063: [email protected] -= [email protected]  // (float)
ret 2 [email protected] [email protected]
[/shcode]
 

springfield

Well-Known Member
Staff member
Joined
Feb 18, 2005
Messages
2,931
Likes
6
Points
38
Website
www.ugbase.eu
#2
This should work too, but less code and gets right position for sniper also. I don't know why but the one you posted doesn't work for me using a simple script.

[shcode=cpp]
:get_xhair_pos
0A8D: [email protected] = readMem 0xC9C040 sz 4 vp 0 //x screen
0A8D: [email protected] = readMem 0xC9C044 sz 4 vp 0 //y screen
if 02D8: actor $PLAYER_ACTOR current_weapon == 34
then [email protected] *= 0.5
   [email protected] *= 0.5
else [email protected] *= 0.53
   [email protected] *= 0.4
end
ret 2 [email protected] [email protected]
[/shcode]

Script that doesn't work with first function.
[shcode=cpp]
while true
   wait 0
   call @crosshair_coords 0 [email protected] [email protected]
   0B69: render draw_box_pos [email protected] [email protected] size 5 5 color 0xFFC0FF01
end
[/shcode]
 
OP
OP
supahdupahnubah

supahdupahnubah

Well-Known Member
Joined
Dec 31, 2015
Messages
673
Likes
1
Points
18
#3
springfield said:
Script that doesn't work with first function.
[shcode=cpp]
while true
   wait 0
   call @crosshair_coords 0 [email protected] [email protected]
   0B69: render draw_box_pos [email protected] [email protected] size 5 5 color 0xFFC0FF01
end
[/shcode]
Guess it is because 0B69's input parameters are Integer, while this snippet returns float
So there's actually no benefits in calculating it with float to get better accuracy? To draw your txd crosshair for example
If not, then delete this thread please, thought it might be useful if someone asked to convert it
 

springfield

Well-Known Member
Staff member
Joined
Feb 18, 2005
Messages
2,931
Likes
6
Points
38
Website
www.ugbase.eu
#4
supahdupahnubah said:
Guess it is because 0B69's input parameters are Integer, while this snippet returns float
Yep, works fine when converting to int. Add that to the main post, i would've never though of that.
 

0x32789

Well-Known Member
Joined
May 26, 2014
Messages
766
Likes
1
Points
18
Location
teknickal suprot
#9
so, convertScreenXYto3DCoords will work with this? I mean if I use it for example, convert the screen XY to 3D Game coordinates, and check if the position is the position of a player, will it trigger?
it seems very useful
 

Zin

Well-Known Member
Joined
Aug 1, 2013
Messages
1,269
Likes
0
Points
36
Website
youtube.com
#16
springfield said:
This should work too, but less code and gets right position for sniper also. I don't know why but the one you posted doesn't work for me using a simple script.

[shcode=cpp]
:get_xhair_pos
0A8D: [email protected] = readMem 0xC9C040 sz 4 vp 0 //x screen
0A8D: [email protected] = readMem 0xC9C044 sz 4 vp 0 //y screen
if 02D8: actor $PLAYER_ACTOR current_weapon == 34
then [email protected] *= 0.5
   [email protected] *= 0.5
else [email protected] *= 0.53
   [email protected] *= 0.4
end
ret 2 [email protected] [email protected]
[/shcode]

Script that doesn't work with first function.
[shcode=cpp]
while true
   wait 0
   call @crosshair_coords 0 [email protected] [email protected]
   0B69: render draw_box_pos [email protected] [email protected] size 5 5 color 0xFFC0FF01
end
[/shcode]
I used it to draw a texture but the the texture just appears in the corner of the screen and not where the crosshair usually is.
 
Top