This Snippet will get any actor that is near the specified part of the screen. This snippet is actually advanced and hard to understand by some users. But I will try to Pinpoint its use:
Snippet Application Example:
- A 2D Rectangle somewhere within the screen will bound the area of where desired actors will be fetched. the Drawing of Rectangle is from TopLeft to BottomRight
- Inside the 2D Rectangle, the user has an option to pin a "Base Coordinate". This Base Coordinate will be the "Center of Radius" for fetching nearby actors.
- The Base Coordinate(_nearscreencoordXY) shall be within the 2D Rectangle.
- It has a parameter to IGNORE a specific Actor that will not be processed during the actor fetching. The Actor fetching is all screen based(bounded within the screen), anything outside/not seenable will not be processed by this Snippet.
Code:
// 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@
Snippet Application Example:
Code:
00A0: store_actor $PLAYER_ACTOR position_to 29@ 30@ 31@
0AE1: 0@ = random_actor_near_point 29@ 30@ 31@ in_radius 1000.0 find_next 1 pass_deads 1
// get screen resolution using SCM built-in Function
0A8D: 30@ = read_memory 0xC17044 size 4 virtual_protect 0 // (int) full screen X
0A8D: 31@ = read_memory 0xC17048 size 4 virtual_protect 0 // (int) full screen Y
0093: 30@ = integer 30@ to_float
0093: 31@ = integer 31@ to_float
//
0087: 28@ = 30@
0087: 29@ = 31@
28@ /= 2.0
29@ /= 2.0
// get the player near the center of the whole screen.
0AB1: @getactoratscreen 7 _upperleftrectangleXY 0.0 0.0 _bottomrightrectangleXY 30@ 31@ _nearscreencoordXY 28@ 29@ _ignoreactor 0@ _storeactor 31@
//
// get the player near the center of the whole screen at the left side.
0AB1: @getactoratscreen 7 _upperleftrectangleXY 0.0 0.0 _bottomrightrectangleXY 28@ 31@ _nearscreencoordXY 28@ 29@ _ignoreactor 0@ _storeactor 31@
//
// get the player near the center of the whole screen at the right side.
0AB1: @getactoratscreen 7 _upperleftrectangleXY 28@ 0.0 _bottomrightrectangleXY 30@ 31@ _nearscreencoordXY 28@ 29@ _ignoreactor 0@ _storeactor 31@
//
// get the player near the center of the whole screen at the upper side.
0AB1: @getactoratscreen 7 _upperleftrectangleXY 0.0 0.0 _bottomrightrectangleXY 30@ 29@ _nearscreencoordXY 28@ 29@ _ignoreactor 0@ _storeactor 31@
//
// get the player near the center of the whole screen at the bottom side.
0AB1: @getactoratscreen 7 _upperleftrectangleXY 0.0 29@ _bottomrightrectangleXY 30@ 31@ _nearscreencoordXY 28@ 29@ _ignoreactor 0@ _storeactor 31@
//
Last edited: