You are on page 1of 16

{$CLEO .

cs}

const
Key_1 = 0xA4 // Left Alt
Key_2 = 0x31 // 1
Key_Aim = 0x02 // Right mouse button
Key_Misc_1 = 0x31 // 1 - Previous bone
Key_Misc_2 = 0x32 // 2 - Next bone
Key_Misc_3 = 0xA0 // Left Shift - Change Aim Mode
Key_Misc_4 = 0x51 // Q - Change to left nearest actor
Key_Misc_5 = 0x45 // E - Change to right nearest actor
end

03A4: name_thread 'Aimbot'


0006: 30@ = 0 // 0 - Normal, 1 - Aim Wheels
0006: 31@ = 8 // Bone ID - 8: BONE_HEAD
0006: 32@ = 600

:Start
0001: wait 0 ms
00D6: if
0050: gosub @KeyCheck
004D: jump_if_false @Start
0ACD: show_text_highpriority "~r~[~w~~h~Aimbot~r~] ~w~~h~:: Activated" time
3000
0A9F: $popf = current_thread_pointer
0008: $popf += 0x10 // CScriptThread.m_iBaseAddress
0A8D: $popf = read_memory $popf size 4 virtual_protect 0
000C: $popf -= @popFloat

:Search
0001: wait 0 ms
if
0AB0: key_pressed Key_Aim
then
0050: gosub @Find_Target
00D6: if
056D: actor $ACTOR_TARGET defined
004D: jump_if_false @Search
0A96: 28@ = actor $ACTOR_TARGET struct
0085: 29@ = 31@ // (int)
goto @Main
end
00D6: if
0050: gosub @KeyCheck
004D: jump_if_false @Search
0002: jump @Stop

:Main
0001: wait 0 ms
00D6: if and
056D: actor $ACTOR_TARGET defined
8118: not actor $ACTOR_TARGET dead
0AB0: key_pressed Key_Aim
004D: jump_if_false @Aim_Lock_Off
if
0449: actor $ACTOR_TARGET in_a_car
then
if
0039: 30@ == 1
then
03C0: 0@ = actor $ACTOR_TARGET car
0A97: 1@ = car 0@ struct
000A: 1@ += 0x590 // [byte] The class of transport
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
if or
0039: 1@ == 0 // CAutomobile
0039: 1@ == 9 // CBike
then
if or
8496: not tire 0 on_car 0@ deflated
8496: not tire 1 on_car 0@ deflated
8496: not tire 2 on_car 0@ deflated
8496: not tire 3 on_car 0@ deflated
then
goto @Main_Wheel
end
end
end

if
8039: not 31@ == 8
then
0006: 31@ = 8
end
else
if
803B: not 31@ == 29@ // (int)
then
0085: 31@ = 29@ // (int)
end
end

0AA6: call_method 0x5E4280 struct 28@ num_params 3 pop 0 bIncludeAnim 1 iBoneID


31@ vPosition 0@v // CPed__getBonePosition
0AB1: call_scm_func @AimAtPosition 3 coords_XYZ 0@ 1@ 2@
0050: gosub @KeyMiscCheck
0002: jump @Main

:Main_Wheel
0001: wait 0 ms
00D6: if and
056D: actor $ACTOR_TARGET defined
8118: not actor $ACTOR_TARGET dead
0AB0: key_pressed Key_Aim
004D: jump_if_false @Aim_Lock_Off
00D6: if and
0039: 30@ == 1
0449: actor $ACTOR_TARGET in_a_car
004D: jump_if_false @Main
03C0: 0@ = actor $ACTOR_TARGET car
00D6: if or
8496: not tire 0 on_car 0@ deflated
8496: not tire 1 on_car 0@ deflated
8496: not tire 2 on_car 0@ deflated
8496: not tire 3 on_car 0@ deflated
004D: jump_if_false @Main
0050: gosub @GetNearestWheel
0407: store_coords_to 0@ 1@ 2@ from_car 0@ with_offset $X_OFFS $Y_OFFS $Z_OFFS
0AB1: call_scm_func @AimAtPosition 3 coords_XYZ 0@ 1@ 2@
0050: gosub @KeyMiscCheck
0002: jump @Main_Wheel

:Find_Target
0001: wait 0 ms
0AB1: call_scm_func @GetPlayerTargetedEntity 0 vehicle 0@ actor $ACTOR_TARGET
if
056E: car 0@ defined
then
03C0: 1@ = actor $PLAYER_ACTOR car
if
803B: not 1@ == 0@ // (int)
then
046C: $ACTOR_TARGET = car 0@ driver
if
856D: not actor $ACTOR_TARGET defined
then
01E9: 2@ = car 0@ num_passengers
if
0019: 2@ > 0
then
01EA: 3@ = car 0@ max_passengers
for 4@ = 0 to 3@
if
8431: not car 0@ passenger_seat_free 4@
then
0432: $ACTOR_TARGET = get_actor_handle_from_car 0@
passenger_seat 4@
Break
end
end
end
end
end
end
0051: return

:Aim_Lock_Off
0001: wait 0 ms
018C: play_sound 1058 at 0.0 0.0 0.0
0004: $ACTOR_TARGET = 0
0085: 31@ = 29@ // (int)
0001: wait 100 ms
0002: jump @Search

:Stop
0001: wait 0 ms
0ACD: show_text_highpriority "~r~[~w~~h~Aimbot~r~] ~w~~h~:: Deactivated" time
3000
0002: jump @Start

const
fDist = 300.0
end

:GetPlayerTargetedEntity
0A96: 0@ = actor $PLAYER_ACTOR struct
0A8D: 1@ = read_memory 0xB6F1A8 size 2 virtual_protect 0 //
TheCamera.m_aCams.m_wCamMode
0AA6: call_method 0x5E4280 struct 0@ num_params 3 pop 0 bIncludeAnim 1 iBoneID
25 vPosition 2@v // CPed__getBonePosition
000B: 4@ += 0.3
if or
0039: 1@ == 53
0039: 1@ == 55
then
0AA6: call_method 0x514970 struct 0xB6F028 num_params 6 pop 0 _targetOut
5@v _cameraOut 8@v _z 4@ _y 3@ _x 2@ _range fDist //
CCamera::Find3rdPersonCamTargetVector
else
068E: get_camera_target_point_to 5@ 6@ 7@
068D: get_camera_position_to 8@ 9@ 10@
0087: 11@ = 8@ // (float)
0087: 12@ = 9@ // (float)
0087: 13@ = 10@ // (float)

0063: 11@ -= 5@ // (float)


0063: 12@ -= 6@ // (float)
0063: 13@ -= 7@ // (float)

0087: 14@ = 11@ // (float)


0087: 15@ = 12@ // (float)
0087: 16@ = 13@ // (float)

0013: 11@ *= fDist


0013: 12@ *= fDist
0013: 13@ *= fDist

0087: 5@ = 8@ // (float)
0087: 6@ = 9@ // (float)
0087: 7@ = 10@ // (float)

0063: 5@ -= 11@ // (float)


0063: 6@ -= 12@ // (float)
0063: 7@ -= 13@ // (float)

0063: 8@ -= 14@ // (float)


0063: 9@ -= 15@ // (float)
0063: 10@ -= 16@ // (float)

end
0006: 1@ = 0 // entity = NULL
0AA7: call_function 0x56BA00 num_params 12 pop 12 0 0 0 0 _objects 1 _peds 1
_vehicles 1 _buildings 1 _pEntity 1@v _colPoint 8@v _end 5@v _start 2@v _result:
13@ // CWorld::ProcessLineOfSight
0006: 14@ = 0
0006: 15@ = 0
if
1@ <> 0
then
0A8E: 2@ = 1@ + 0x36
0A8D: 2@ = read_memory 2@ size 1 virtual_protect 0 // entity->m_nStatusType
0B10: 2@ = 2@ AND 7
if
2@ == 2 // ENTITY_TYPE_VEHICLE
then
0AEB: 14@ = car_struct 1@ handle
else if
2@ == 3 // ENTITY_TYPE_PED
then
if
803B: not 1@ == 0@ // (int)
then
0AEA: 15@ = actor_struct 1@ handle
end
end
end
end
0AB2: ret 2 14@ 15@

const
M_PI = 3.1415926535897932384626433832795
end

:AimAtPosition
// aim formula code taken & converted from m0d_sa
068D: get_camera_position_to 3@ 4@ 5@

0509: 11@ = distance_between_XY 0@ 1@ and_XY 3@ 4@

0063: 3@ -= 0@ // (float)
0063: 4@ -= 1@ // (float)
0063: 5@ -= 2@ // (float)

0A8D: 6@ = read_memory 0xB6F1A8 size 2 virtual_protect 0 //


TheCamera.m_aCams.m_wCamMode

if or
0039: 6@ == 53
0039: 6@ == 55
then // 3rd person mode

// multiplier
0A8D: 7@ = read_memory 0x8D5038 size 4 virtual_protect 0 // FOV
0007: 6@ = 0.5
006B: 7@ *= 6@ // (float)
02F6: 6@ = sine 7@ // (float)
02F7: 8@ = cosine 7@ // (float)
0073: 6@ /= 8@ // (float)

// fx
0A8D: 9@ = read_memory 0xB6EC10 size 4 virtual_protect 0 //
crosshairOffset.x
0007: 8@ = 0.5
0063: 8@ -= 9@ // (float)
000B: 8@ += 0.5
0063: 8@ -= 9@ // (float)

0A8D: 9@ = read_memory 0xC3EFA4 size 4 virtual_protect 0 //


screenAspectRatio
0007: 7@ = 1.0
0073: 7@ /= 9@ // (float)

006B: 8@ *= 7@ // (float)
006B: 8@ *= 6@ // (float)
0AA5: call 0x4207C0 num_params 2 pop 2 _x 8@ _y 1.0 // atan2
0AA7: call_function $popf num_params 0 pop 0 fValue 8@

0007: 7@ = M_PI
0063: 7@ -= 8@ // (float)

// fz
0A8D: 10@ = read_memory 0xB6EC14 size 4 virtual_protect 0 //
crosshairOffset.y
0087: 9@ = 10@ // (float)
0007: 8@ = 0.5
0063: 9@ -= 8@ // (float)
005B: 9@ += 10@ // (float)
0063: 9@ -= 8@ // (float)
006B: 9@ *= 6@ // (float)

0AA5: call 0x4207C0 num_params 2 pop 2 _x 9@ _y 1.0 // atan2


0AA7: call_function $popf num_params 0 pop 0 fValue 9@

0007: 8@ = M_PI
0063: 8@ -= 9@ // (float)
else
0007: 7@ = M_PI
0017: 7@ /= 2.0
0087: 8@ = 7@ // (float)
end

// x angle
0AA5: call 0x4207C0 num_params 2 pop 2 _x 5@ _y 11@ // atan2
0AA7: call_function $popf num_params 0 pop 0 fValue 9@

// z angle
0013: 3@ *= -1.0
0AA5: call 0x4207C0 num_params 2 pop 2 _x 3@ _y 4@ // atan2
0AA7: call_function $popf num_params 0 pop 0 fValue 10@

0007: 11@ = M_PI


0017: 11@ /= 2.0
0063: 10@ -= 11@ // (float)

0063: 9@ -= 7@ // (float)
0063: 10@ -= 8@ // (float)
0013: 10@ *= -1.0

0A25: set_camera_on_players_X_angle 9@ Z_angle 10@


0AB2: ret 0

:GetNearestWheel
0A97: 1@ = car 0@ struct
000A: 1@ += 0x590 // [byte] The class of transport
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
if
0039: 1@ == 0 // CAutomobile
then
0AB1: call_scm_func @GetCarWheelOffset 2 car 0@ componentId 5 store_to 10@
11@ 12@ // tire 0 - wheel_lf_dumm
0AB1: call_scm_func @GetCarWheelOffset 2 car 0@ componentId 7 store_to 13@
14@ 15@ // tire 1 - wheel_lb_dummy
0AB1: call_scm_func @GetCarWheelOffset 2 car 0@ componentId 2 store_to 16@
17@ 18@ // tire 2 - wheel_rf_dummy
0AB1: call_scm_func @GetCarWheelOffset 2 car 0@ componentId 4 store_to 19@
20@ 21@ // tire 3 - wheel_rb_dummy
0006: 2@ = 3
else
0AB1: call_scm_func @GetBikeWheelOffset 2 bike 0@ componentId 4 store_to
10@ 11@ 12@ // tire 0 - BIKE_WHEEL_FRONT
0AB1: call_scm_func @GetBikeWheelOffset 2 bike 0@ componentId 5 store_to
13@ 14@ 15@ // tire 1 - BIKE_WHEEL_REAR
0006: 2@ = 1
end

0005: $SEARCH_RADIUS = 1000000.0


00A0: store_actor $PLAYER_ACTOR position_to 4@ 5@ 6@
for 3@ = 0 to 2@
if
8496: not tire 3@ on_car 0@ deflated
then
0006: 7@ = 3
006A: 7@ *= 3@ // (int)
0006: 8@ = 1
0006: 9@ = 2
005A: 8@ += 7@ // (int)
005A: 9@ += 7@ // (int)
0407: store_coords_to 24@ 25@ 26@ from_car 0@ with_offset 10@(7@,12i)
10@(8@,12i) 10@(9@,12i)
050A: 1@ = distance_between_XYZ 24@ 25@ 26@ and_XYZ 4@ 5@ 6@
if
0026: $SEARCH_RADIUS > 1@ // (float)
then
0088: $SEARCH_RADIUS = 1@ // (float)
0088: $X_OFFS = 10@(7@,12i) // (float)
0088: $Y_OFFS = 10@(8@,12i) // (float)
0088: $Z_OFFS = 10@(9@,12i) // (float)
end
end
end
0051: return

:GetCarWheelOffset
{
Example:
0AB1: call_scm_func @GetCarWheelOffset 2 car 0@ componentId 1@ store_to 2@
3@ 4@
}
0006: 2@ = 4
006A: 2@ *= 1@ // (int)
0A97: 1@ = car 0@ struct
000A: 1@ += 0x648
005A: 1@ += 2@ // (int)
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
000A: 1@ += 0x40
0A8D: 2@ = read_memory 1@ size 4 virtual_protect 0 // x
000A: 1@ += 0x4
0A8D: 3@ = read_memory 1@ size 4 virtual_protect 0 // y
000A: 1@ += 0x4
0A8D: 4@ = read_memory 1@ size 4 virtual_protect 0 // z
0AB2: ret 3 2@ 3@ 4@
:GetBikeWheelOffset
{
Example:
0AB1: call_scm_func @GetBikeWheelPosition 2 bike 0@ componentId 1@ store_to
2@ 3@ 4@
}
0006: 2@ = 4
006A: 2@ *= 1@ // (int)
0A97: 1@ = car 0@ struct
000A: 1@ += 0x5A0
005A: 1@ += 2@ // (int)
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0

0085: 2@ = 1@ // (int)
000A: 2@ += 0x40
0A8D: 5@ = read_memory 2@ size 4 virtual_protect 0
000A: 2@ += 0x4
0A8D: 6@ = read_memory 2@ size 4 virtual_protect 0
000A: 2@ += 0x4
0A8D: 7@ = read_memory 2@ size 4 virtual_protect 0

000A: 1@ += 0x4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
000A: 1@ += 0x10

0AA5: call_method 0x7EDD60 num_params 3 pop 3 1@ 5@v 2@v


0AB2: ret 3 2@ 3@ 4@

:KeyCheck
if and
0019: 32@ > 600
0AB0: key_pressed Key_1
0AB0: key_pressed Key_2
then
0006: 32@ = 0
018C: play_sound 1057 at 0.0 0.0 0.0
0485: return_true
else
059A: return_false
end
0051: return

:KeyMiscCheck
if
0019: 32@ > 200
then
if
0AB0: key_pressed Key_Misc_1 // previous bone
then
if
0039: 29@ == 1
then
0006: 29@ = 54
else if
0039: 29@ == 21
then
0006: 29@ = 8
else if
0039: 29@ == 31
then
0006: 29@ = 26
else if
0039: 29@ == 41
then
0006: 29@ = 36
else if
0039: 29@ == 51
then
0006: 29@ = 44
else
000E: 29@ -= 1
end
end
end
end
end

0050: gosub @UpdateBone


0006: 32@ = 0
if
8449: not actor $ACTOR_TARGET in_a_car
then
0085: 31@ = 29@ // (int)
end
else if
0AB0: key_pressed Key_Misc_2 // next bone
then

if
0039: 29@ == 8
then
0006: 29@ = 21
else if
0039: 29@ == 26
then
0006: 29@ = 31
else if
0039: 29@ == 36
then
0006: 29@ = 41
else if
0039: 29@ == 44
then
0006: 29@ = 51
else if
0039: 29@ == 54
then
0006: 29@ = 1
else
000A: 29@ += 1
end
end
end
end
end

0050: gosub @UpdateBone


0006: 32@ = 0
if
8449: not actor $ACTOR_TARGET in_a_car
then
0085: 31@ = 29@ // (int)
end
else if
0AB0: key_pressed Key_Misc_3
then
0AC8: 22@ = allocate_memory_size 10
if
0039: 30@ == 1
then
0006: 30@ = 0
0AD3: 22@ = format "Normal"
else
0006: 30@ = 1
0AD3: 22@ = format "Wheel"
end
0006: 32@ = 0
0AD1: show_formatted_text_highpriority "~r~[~w~~h~Aimbot~r~] ~w~~h~::
%s aim mode." time 4000 22@
0AC9: free_allocated_memory 22@
else if or
0AB0: key_pressed Key_Misc_4
0AB0: key_pressed Key_Misc_5
then
if
0AB0: key_pressed Key_Misc_4
then
0004: $SEARCH_MODE = 0
else
0004: $SEARCH_MODE = 1
end
0005: $SEARCH_RADIUS = 320.0
0004: $ACTOR_TARGET_TMP = 0
0AB1: call_scm_func @LoopThroughPool 2 pool_ptr 0xB74490 gosub_loop
@ActorLoop
if
056D: actor $ACTOR_TARGET_TMP defined
then
0084: $ACTOR_TARGET = $ACTOR_TARGET_TMP // (int)
0A96: 28@ = actor $ACTOR_TARGET struct

0006: 32@ = 0
018C: play_sound 1057 at 0.0 0.0 0.0
end
end
end
end
end
end
0051: return

:UpdateBone
0AC8: 22@ = allocate_memory_size 25
if
0039: 29@ == 1
then
0AD3: 22@ = format "BONE_PELVIS1"
else if
0039: 29@ == 2
then
0AD3: 22@ = format "BONE_PELVIS"
else if
0039: 29@ == 3
then
0AD3: 22@ = format "BONE_SPINE1"
else if
0039: 29@ == 4
then
0AD3: 22@ = format "BONE_UPPERTORSO"
else if
0039: 29@ == 5
then
0AD3: 22@ = format "BONE_NECK"
else if
0039: 29@ == 6
then
0AD3: 22@ = format "BONE_HEAD2"
else if
0039: 29@ == 7
then
0AD3: 22@ = format "BONE_HEAD1"
else if
0039: 29@ == 8
then
0AD3: 22@ = format "BONE_HEAD"
else if
0039: 29@ == 21
then
0AD3: 22@ = format "BONE_RIGHTUPPERTORSO"
else if
0039: 29@ == 22
then
0AD3: 22@ = format "BONE_RIGHTSHOULDER"
else if
0039: 29@ == 23
then
0AD3: 22@ = format "BONE_RIGHTELBOW"
else if
0039: 29@ == 24
then
0AD3: 22@ = format "BONE_RIGHTWRIST"
else if
0039: 29@ == 25
then
0AD3: 22@ = format "BONE_RIGHTHAND"
else if
0039: 29@ == 26
then
0AD3: 22@ = format "BONE_RIGHTTHUMB"
else if
0039: 29@ == 31
then
0AD3: 22@ = format "BONE_LEFTUPPERTORSO"
else if
0039: 29@ == 32
then
0AD3: 22@ = format "BONE_LEFTSHOULDER"
else if
0039: 29@ == 33
then
0AD3: 22@ = format "BONE_LEFTELBOW"
else if
0039: 29@ == 34
then
0AD3: 22@ = format "BONE_LEFTWRIST"
else if
0039: 29@ == 35
then
0AD3: 22@ = format "BONE_LEFTHAND"
else if
0039: 29@ == 36
then
0AD3: 22@ = format "BONE_LEFTTHUMB"
else if
0039: 29@ == 41
then
0AD3: 22@ = format "BONE_LEFTHIP"
else if
0039: 29@ == 42
then
0AD3: 22@ = format "BONE_LEFTKNEE"
else if
0039: 29@ == 43
then
0AD3: 22@ = format "BONE_LEFTANKLE"
else if
0039: 29@ == 44
then
0AD3: 22@ = format "BONE_LEFTFOOT"
else if
0039: 29@ == 51
then
0AD3: 22@ = format "BONE_RIGHTHIP"
else if
0039: 29@ == 52
then
0AD3: 22@ = format "BONE_RIGHTKNEE"
else if
0039: 29@ == 53
then
0AD3: 22@ = format "BONE_RIGHTANKLE"
else if
0039: 29@ == 54
then
0AD3: 22@ = format "BONE_RIGHTFOOT"
else if
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
0AD1: show_formatted_text_highpriority "~r~[~w~~h~Aimbot~r~] ~w~~h~:: %d: %s"
time 4000 29@ 22@
0AC9: free_allocated_memory 22@
0051: return

:LoopThroughPool
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // CPool
0@ += 0x4
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 0 // pByteMap
0@ += 0x4
0A8D: 3@ = read_memory 0@ size 4 virtual_protect 0 // nItems
3@ -= 1
for 4@ = 0 to 3@
0A8D: 0@ = read_memory 2@ size 1 virtual_protect 0
2@ += 0x1
if and
0@ > 0x0
0@ < 0x80
then
0085: 5@ = 4@
5@ *= 0x100
005A: 0@ += 5@
gosub 1@
end
end
0AB2: ret 0

:ActorLoop
if and
02CB: actor 0@ bounding_sphere_visible
87D6: not 0@ == $PLAYER_ACTOR // @ == $ (int)
8118: not actor 0@ dead
then
00A0: store_actor 0@ position_to 5@ 6@ 7@
068D: get_camera_position_to 8@ 9@ 10@
if
06BD: no_obstacles_between 5@ 6@ 7@ and 8@ 9@ 10@ solid 1 car 0 actor
0 object 0 particle 0
then
if
87D6: not 0@ == $ACTOR_TARGET // @ == $ (int)
then
if
0038: $SEARCH_MODE == 0
then
0007: 11@ = 0.0
0007: 12@ = 320.0
else
0007: 11@ = 320.0
0007: 12@ = 640.0
end
0AB1: call_scm_func @getScreenXYFrom3DCoords 3 coords_XYZ 5@ 6@ 7@
store_to 8@ 9@
if and
0035: 8@ >= 11@ // (float)
0035: 12@ >= 8@ // (float)
then
0509: 10@ = distance_between_XY 320.0 9@ and_XY 8@ 9@
if
0036: $SEARCH_RADIUS >= 10@ // (float)
then
0088: $SEARCH_RADIUS = 10@ // (float)
008A: $ACTOR_TARGET_TMP = 0@ // (int)
end
end
end
end
end
return

const
WIDTH = 640.0
HEIGHT = 448.0
HALF_WIDTH = 320.0
HALF_HEIGHT = 224.0
end

:getScreenXYFrom3DCoords
{
Parameters:
Passed:
0@ - position X
1@ - position Y
2@ - position Z
Result:
3@ - screen X
4@ - screen Y

Example:
0AB1: call_scm_func @getScreenXYFrom3DCoords 3 coords_XYZ 2488.562 -1666.865
12.8757 store_to 1@ 2@
}
0AB1: call_scm_func @getLocalVarOffset 1 var 0 store_to 12@
0AB1: call_scm_func @getLocalVarOffset 1 var 3 store_to 13@
0AB1: call_scm_func @getLocalVarOffset 1 var 6 store_to 14@
0AB1: call_scm_func @getLocalVarOffset 1 var 9 store_to 15@
0AA5: call 0x70CE30 num_params 6 pop 6 bNearClip 0 bFarClip 0 pMultY 15@ pMultX
14@ pScreen 13@ pCoords 12@
0AB1: call_scm_func @getFullScreenXY 2 coords_XY 3@ 4@ store_to 3@ 4@
0AB2: ret 2 3@ 4@

:get3DCoordsFromScreenXY
{
Parameters:
Passed:
0@ - screen X
1@ - screen Y
2@ - distance
Result:
14@ - position X
15@ - position Y
16@ - position Z

Example:
0AB1: call_scm_func @get3DCoordsFromScreenXY 3 coords_XY 320.0 224.0
distance 1.0 store_to 1@ 2@ 3@
}
0A8D: 3@ = read_memory 0x8D5038 size 4 virtual_protect 0 // field of view
3@ *= 0.5
02F6: 4@ = sine 3@
02F7: 5@ = cosine 3@
0073: 4@ /= 5@
6@ = 1.0
0@ /= HALF_WIDTH // half screen X
0063: 6@ -= 0@
006B: 6@ *= 4@
7@ = 1.0
1@ /= HALF_HEIGHT // half screen Y
0063: 7@ -= 1@
006B: 7@ *= 4@
0A8D: 8@ = read_memory 0xC3EFA4 size 4 virtual_protect 0 // screen aspect ratio
0073: 7@ /= 8@
006B: 6@ *= 2@
006B: 7@ *= 2@
0087: 9@ = 6@
0087: 10@ = 2@
0087: 11@ = 7@
0A8D: 12@ = read_memory 0xB6F03C size 4 virtual_protect 0 // camera matrix
0AB1: call_scm_func @getLocalVarOffset 1 var 9 store_to 13@
0AA5: call 0x59C790 num_params 3 pop 3 pOffsets 13@ pMatrix 12@ pResult 13@ //
CPlaceable__getMatrixAbsOffsets
12@ += 0x30
0A8D: 14@ = read_memory 12@ size 4 virtual_protect 0 // camera X position
12@ += 0x4
0A8D: 15@ = read_memory 12@ size 4 virtual_protect 0 // camera Y position
12@ += 0x4
0A8D: 16@ = read_memory 12@ size 4 virtual_protect 0 // camera Z position
005B: 14@ += 9@
005B: 15@ += 10@
005B: 16@ += 11@
0AB2: ret 3 14@ 15@ 16@

:getFullScreenXY
{
Parameters:
Passed:
0@ - full screen X
1@ - full screen Y
Result:
0@ - screen X
1@ - screen Y

Example:
0AB1: call_scm_func @getFullScreenXY 2 coords_XY 320.0 224.0 store_to 1@ 2@
}
2@ = WIDTH // screen X
0A8D: 4@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
0093: 4@ = integer 4@ to_float
0073: 2@ /= 4@
006B: 0@ *= 2@
3@ = HEIGHT // screen Y
0A8D: 5@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
0093: 5@ = integer 5@ to_float
0073: 3@ /= 5@
006B: 1@ *= 3@
0AB2: ret 2 0@ 1@

:getLocalVarOffset
{
Parameters:
Passed:
0@ - thread pointer (offset)
Result:
0@ - var pointer (offset)

Example:
0AB1: call_scm_func @getLocalVarOffset 1 var 0 store_to 1@
}
0A9F: 1@ = current_thread_pointer
0@ *= 0x4
0A8E: 2@ = 1@ + 0xDC // mission flag
if
2@ == 1
then
0@ += 0xA48960
else
005A: 0@ += 1@
0@ += 0x3C
end
0AB2: ret 1 0@

:popFloat
hex
83EC 04 // sub esp, 4
D95C24 00 // fstp [esp+4-4]
8B4424 00 // mov eax, [esp+4-4]
83C4 04 // add esp, 4
C3 // retn
end

You might also like